Lines Matching defs:query

43 void wined3d_event_query_destroy(struct wined3d_event_query *query)
45 if (query->context) context_free_event_query(query);
46 HeapFree(GetProcessHeap(), 0, query);
49 enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_query *query, IWineD3DDeviceImpl *device)
56 TRACE("(%p) : device %p\n", query, device);
58 if (query->context == NULL)
65 if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId())
67 WARN("Event query tested from wrong thread\n");
72 context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
79 GLenum gl_ret = GL_EXTCALL(glClientWaitSync(query->object.sync, 0, 0));
101 fence_result = GL_EXTCALL(glTestFenceAPPLE(query->object.id));
108 fence_result = GL_EXTCALL(glTestFenceNV(query->object.id));
120 ERR("Event query created despite lack of GL support\n");
131 enum wined3d_event_query_result wined3d_event_query_finish(struct wined3d_event_query *query, IWineD3DDeviceImpl *device)
137 TRACE("(%p)\n", query);
139 if (!query->context)
144 gl_info = query->context->gl_info;
146 if (query->context->tid != GetCurrentThreadId() && !gl_info->supported[ARB_SYNC])
152 ERR("Event query finished from wrong thread\n");
154 WARN("Event query finished from wrong thread\n");
159 context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
164 GLenum gl_ret = GL_EXTCALL(glClientWaitSync(query->object.sync, 0, ~(GLuint64)0));
182 GL_EXTCALL(glFinishFenceAPPLE(query->object.id));
188 GL_EXTCALL(glFinishFenceNV(query->object.id));
194 ERR("Event query created without GL support\n");
203 void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDeviceImpl *device)
208 if (query->context)
210 if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId())
215 context_free_event_query(query);
217 context_alloc_event_query(context, query);
221 context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
227 context_alloc_event_query(context, query);
236 if (query->object.sync) GL_EXTCALL(glDeleteSync(query->object.sync));
238 query->object.sync = GL_EXTCALL(glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0));
243 GL_EXTCALL(glSetFenceAPPLE(query->object.id));
248 GL_EXTCALL(glSetFenceNV(query->object.id, GL_ALL_COMPLETED_NV));
294 * deleting the query will obviously leak it, but that's still better
295 * than potentially deleting a different query with the same id in this
296 * context, and (still) leaking the actual query. */
299 struct wined3d_event_query *query = This->extendedData;
300 if (query) wined3d_event_query_destroy(query);
304 struct wined3d_occlusion_query *query = This->extendedData;
306 if (query->context) context_free_occlusion_query(query);
332 struct wined3d_occlusion_query *query = This->extendedData;
343 if (!query->context) This->state = QUERY_CREATED;
347 /* D3D allows GetData on a new query, OpenGL doesn't. So just invent the data ourselves */
367 if (query->context->tid != GetCurrentThreadId())
374 context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
378 GL_EXTCALL(glGetQueryObjectuivARB(query->id, GL_QUERY_RESULT_AVAILABLE_ARB, &available));
386 GL_EXTCALL(glGetQueryObjectuivARB(query->id, GL_QUERY_RESULT_ARB, &samples));
407 struct wined3d_event_query *query = This->extendedData;
414 if (!query)
416 WARN("(%p): Event query not supported by GL, reporting GPU idle\n", This);
421 ret = wined3d_event_query_test(query, This->device);
439 ERR("The GL event query failed, returning D3DERR_INVALIDCALL\n");
469 struct wined3d_event_query *query = This->extendedData;
471 /* Faked event query support */
472 if (!query) return WINED3D_OK;
474 wined3d_event_query_issue(query, This->device);
479 ERR("Event query issued with START flag - what to do?\n");
498 struct wined3d_occlusion_query *query = This->extendedData;
501 /* This is allowed according to msdn and our tests. Reset the query and restart */
506 if (query->context->tid != GetCurrentThreadId())
508 FIXME("Wrong thread, can't restart query.\n");
510 context_free_occlusion_query(query);
512 context_alloc_occlusion_query(context, query);
516 context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
526 if (query->context) context_free_occlusion_query(query);
528 context_alloc_occlusion_query(context, query);
532 GL_EXTCALL(glBeginQueryARB(GL_SAMPLES_PASSED_ARB, query->id));
539 /* Msdn says _END on a non-building occlusion query returns an error, but
545 if (query->context->tid != GetCurrentThreadId())
547 FIXME("Wrong thread, can't end query.\n");
551 context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
602 HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device,
610 TRACE("Occlusion query.\n");
616 query->lpVtbl = &IWineD3DOcclusionQuery_Vtbl;
617 query->extendedData = HeapAlloc(GetProcessHeap(), 0, sizeof(struct wined3d_occlusion_query));
618 if (!query->extendedData)
620 ERR("Failed to allocate occlusion query extended data.\n");
623 ((struct wined3d_occlusion_query *)query->extendedData)->context = NULL;
627 TRACE("Event query.\n");
630 /* Half-Life 2 needs this query. It does not render the main
632 * this query does not do much harm except potentially
634 FIXME("Event query: Unimplemented, but pretending to be supported.\n");
636 query->lpVtbl = &IWineD3DEventQuery_Vtbl;
637 query->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct wined3d_event_query));
638 if (!query->extendedData)
640 ERR("Failed to allocate event query memory.\n");
658 FIXME("Unhandled query type %#x.\n", type);
662 query->type = type;
663 query->state = QUERY_CREATED;
664 query->device = device;
665 query->parent = parent;
666 query->ref = 1;