void wined3d_query_destroy(struct wined3d_query *query) { /* Queries are specific to the GL context that created them. Not * deleting the query will obviously leak it, but that's still better * than potentially deleting a different query with the same id in this * context, and (still) leaking the actual query. */ if (query->type == WINED3D_QUERY_TYPE_EVENT) { struct wined3d_event_query *event_query = query->extendedData; if (event_query) wined3d_event_query_destroy(event_query); } else if (query->type == WINED3D_QUERY_TYPE_OCCLUSION) { struct wined3d_occlusion_query *oq = query->extendedData; if (oq->context) context_free_occlusion_query(oq); HeapFree(GetProcessHeap(), 0, query->extendedData); } else if (query->type == WINED3D_QUERY_TYPE_TIMESTAMP) { struct wined3d_timestamp_query *tq = query->extendedData; if (tq->context) context_free_timestamp_query(tq); HeapFree(GetProcessHeap(), 0, query->extendedData); } HeapFree(GetProcessHeap(), 0, query); }
static void wined3d_query_destroy_object(void *object) { struct wined3d_query *query = object; #if defined(STAGING_CSMT) if (!list_empty(&query->poll_list_entry)) list_remove(&query->poll_list_entry); #endif /* STAGING_CSMT */ /* Queries are specific to the GL context that created them. Not * deleting the query will obviously leak it, but that's still better * than potentially deleting a different query with the same id in this * context, and (still) leaking the actual query. */ if (query->type == WINED3D_QUERY_TYPE_EVENT) { wined3d_event_query_destroy(wined3d_event_query_from_query(query)); } else if (query->type == WINED3D_QUERY_TYPE_OCCLUSION) { struct wined3d_occlusion_query *oq = wined3d_occlusion_query_from_query(query); if (oq->context) context_free_occlusion_query(oq); HeapFree(GetProcessHeap(), 0, oq); } else if (query->type == WINED3D_QUERY_TYPE_TIMESTAMP) { struct wined3d_timestamp_query *tq = wined3d_timestamp_query_from_query(query); if (tq->context) context_free_timestamp_query(tq); HeapFree(GetProcessHeap(), 0, tq); } else if (query->type == WINED3D_QUERY_TYPE_TIMESTAMP_DISJOINT || query->type == WINED3D_QUERY_TYPE_TIMESTAMP_FREQ) { HeapFree(GetProcessHeap(), 0, query); } else if (query->type == WINED3D_QUERY_TYPE_SO_STATISTICS) { HeapFree(GetProcessHeap(), 0, query); } else if (query->type == WINED3D_QUERY_TYPE_SO_OVERFLOW) { HeapFree(GetProcessHeap(), 0, query); } else { ERR("Query %p has invalid type %#x.\n", query, query->type); } }
ULONG CDECL wined3d_query_decref(struct wined3d_query *query) { ULONG refcount = InterlockedDecrement(&query->ref); TRACE("%p decreasing refcount to %u.\n", query, refcount); if (!refcount) { /* Queries are specific to the GL context that created them. Not * deleting the query will obviously leak it, but that's still better * than potentially deleting a different query with the same id in this * context, and (still) leaking the actual query. */ if (query->type == WINED3D_QUERY_TYPE_EVENT) { struct wined3d_event_query *event_query = query->extendedData; if (event_query) wined3d_event_query_destroy(event_query); } else if (query->type == WINED3D_QUERY_TYPE_OCCLUSION) { struct wined3d_occlusion_query *oq = query->extendedData; if (oq->context) context_free_occlusion_query(oq); HeapFree(GetProcessHeap(), 0, query->extendedData); } else if (query->type == WINED3D_QUERY_TYPE_TIMESTAMP) { struct wined3d_timestamp_query *tq = query->extendedData; if (tq->context) context_free_timestamp_query(tq); HeapFree(GetProcessHeap(), 0, query->extendedData); } HeapFree(GetProcessHeap(), 0, query); } return refcount; }
static HRESULT wined3d_timestamp_query_ops_issue(struct wined3d_query *query, DWORD flags) { struct wined3d_device *device = query->device; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; TRACE("query %p, flags %#x.\n", query, flags); if (gl_info->supported[ARB_TIMER_QUERY]) { struct wined3d_timestamp_query *tq = query->extendedData; struct wined3d_context *context; if (flags & WINED3DISSUE_BEGIN) { WARN("Ignoring WINED3DISSUE_BEGIN with a TIMESTAMP query.\n"); } if (flags & WINED3DISSUE_END) { if (tq->context) context_free_timestamp_query(tq); context = context_acquire(query->device, NULL); context_alloc_timestamp_query(context, tq); GL_EXTCALL(glQueryCounter(tq->id, GL_TIMESTAMP)); checkGLcall("glQueryCounter()"); context_release(context); } } else { ERR("Timestamp queries not supported.\n"); } if (flags & WINED3DISSUE_END) query->state = QUERY_SIGNALLED; return WINED3D_OK; }