VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/query.c@ 55393

Last change on this file since 55393 was 41950, checked in by vboxsync, 13 years ago

wined3d: remove debug assertion

  • Property svn:eol-style set to native
File size: 21.7 KB
Line 
1/*
2 * IWineD3DQuery implementation
3 *
4 * Copyright 2005 Oliver Stieber
5 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
6 * Copyright 2009 Henri Verbeet for CodeWeavers.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23/*
24 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
25 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
26 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
27 * a choice of LGPL license versions is made available with the language indicating
28 * that LGPLv2 or any later version may be used, or where a choice of which version
29 * of the LGPL is applied is otherwise unspecified.
30 */
31
32#include "config.h"
33#include "wined3d_private.h"
34
35WINE_DEFAULT_DEBUG_CHANNEL(d3d);
36#define GLINFO_LOCATION (*gl_info)
37
38BOOL wined3d_event_query_supported(const struct wined3d_gl_info *gl_info)
39{
40 return gl_info->supported[ARB_SYNC] || gl_info->supported[NV_FENCE] || gl_info->supported[APPLE_FENCE];
41}
42
43void wined3d_event_query_destroy(struct wined3d_event_query *query)
44{
45 if (query->context) context_free_event_query(query);
46 HeapFree(GetProcessHeap(), 0, query);
47}
48
49enum wined3d_event_query_result wined3d_event_query_test(struct wined3d_event_query *query, IWineD3DDeviceImpl *device)
50{
51 struct wined3d_context *context;
52 const struct wined3d_gl_info *gl_info;
53 enum wined3d_event_query_result ret;
54 BOOL fence_result;
55
56 TRACE("(%p) : device %p\n", query, device);
57
58 if (query->context == NULL)
59 {
60 TRACE("Query not started\n");
61 return WINED3D_EVENT_QUERY_NOT_STARTED;
62 }
63
64#if !defined(VBOX_WINE_WITH_SINGLE_CONTEXT) && !defined(VBOX_WINE_WITH_SINGLE_SWAPCHAIN_CONTEXT)
65 if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId())
66 {
67 WARN("Event query tested from wrong thread\n");
68 return WINED3D_EVENT_QUERY_WRONG_THREAD;
69 }
70#endif
71
72 context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
73 gl_info = context->gl_info;
74
75 ENTER_GL();
76
77 if (gl_info->supported[ARB_SYNC])
78 {
79 GLenum gl_ret = GL_EXTCALL(glClientWaitSync(query->object.sync, 0, 0));
80 checkGLcall("glClientWaitSync");
81
82 switch (gl_ret)
83 {
84 case GL_ALREADY_SIGNALED:
85 case GL_CONDITION_SATISFIED:
86 ret = WINED3D_EVENT_QUERY_OK;
87 break;
88
89 case GL_TIMEOUT_EXPIRED:
90 ret = WINED3D_EVENT_QUERY_WAITING;
91 break;
92
93 case GL_WAIT_FAILED:
94 default:
95 ERR("glClientWaitSync returned %#x.\n", gl_ret);
96 ret = WINED3D_EVENT_QUERY_ERROR;
97 }
98 }
99 else if (gl_info->supported[APPLE_FENCE])
100 {
101 fence_result = GL_EXTCALL(glTestFenceAPPLE(query->object.id));
102 checkGLcall("glTestFenceAPPLE");
103 if (fence_result) ret = WINED3D_EVENT_QUERY_OK;
104 else ret = WINED3D_EVENT_QUERY_WAITING;
105 }
106 else if (gl_info->supported[NV_FENCE])
107 {
108 fence_result = GL_EXTCALL(glTestFenceNV(query->object.id));
109 checkGLcall("glTestFenceNV");
110 if (fence_result) ret = WINED3D_EVENT_QUERY_OK;
111 else ret = WINED3D_EVENT_QUERY_WAITING;
112 }
113 else
114 {
115#ifdef VBOX_WITH_WDDM
116 /* doing Flush (rather than Finish) should be enough since we're serialized on the host in any way */
117 wglFlush();
118 ret = WINED3D_EVENT_QUERY_OK;
119#else
120 ERR("Event query created despite lack of GL support\n");
121 ret = WINED3D_EVENT_QUERY_ERROR;
122#endif
123 }
124
125 LEAVE_GL();
126
127 context_release(context);
128 return ret;
129}
130
131enum wined3d_event_query_result wined3d_event_query_finish(struct wined3d_event_query *query, IWineD3DDeviceImpl *device)
132{
133 struct wined3d_context *context;
134 const struct wined3d_gl_info *gl_info;
135 enum wined3d_event_query_result ret;
136
137 TRACE("(%p)\n", query);
138
139 if (!query->context)
140 {
141 TRACE("Query not started\n");
142 return WINED3D_EVENT_QUERY_NOT_STARTED;
143 }
144 gl_info = query->context->gl_info;
145
146 if (query->context->tid != GetCurrentThreadId() && !gl_info->supported[ARB_SYNC])
147 {
148 /* A glFinish does not reliably wait for draws in other contexts. The caller has
149 * to find its own way to cope with the thread switch
150 */
151#ifdef VBOX_WINE_WITH_SINGLE_CONTEXT
152 ERR("Event query finished from wrong thread\n");
153#else
154 WARN("Event query finished from wrong thread\n");
155#endif
156 return WINED3D_EVENT_QUERY_WRONG_THREAD;
157 }
158
159 context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
160
161 ENTER_GL();
162 if (gl_info->supported[ARB_SYNC])
163 {
164 GLenum gl_ret = GL_EXTCALL(glClientWaitSync(query->object.sync, 0, ~(GLuint64)0));
165 checkGLcall("glClientWaitSync");
166
167 switch (gl_ret)
168 {
169 case GL_ALREADY_SIGNALED:
170 case GL_CONDITION_SATISFIED:
171 ret = WINED3D_EVENT_QUERY_OK;
172 break;
173
174 /* We don't expect a timeout for a ~584 year wait */
175 default:
176 ERR("glClientWaitSync returned %#x.\n", gl_ret);
177 ret = WINED3D_EVENT_QUERY_ERROR;
178 }
179 }
180 else if (context->gl_info->supported[APPLE_FENCE])
181 {
182 GL_EXTCALL(glFinishFenceAPPLE(query->object.id));
183 checkGLcall("glFinishFenceAPPLE");
184 ret = WINED3D_EVENT_QUERY_OK;
185 }
186 else if (context->gl_info->supported[NV_FENCE])
187 {
188 GL_EXTCALL(glFinishFenceNV(query->object.id));
189 checkGLcall("glFinishFenceNV");
190 ret = WINED3D_EVENT_QUERY_OK;
191 }
192 else
193 {
194 ERR("Event query created without GL support\n");
195 ret = WINED3D_EVENT_QUERY_ERROR;
196 }
197 LEAVE_GL();
198
199 context_release(context);
200 return ret;
201}
202
203void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDeviceImpl *device)
204{
205 const struct wined3d_gl_info *gl_info;
206 struct wined3d_context *context;
207
208 if (query->context)
209 {
210 if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId())
211 {
212#ifdef VBOX_WINE_WITH_SINGLE_CONTEXT
213 ERR("unexpected\n");
214#endif
215 context_free_event_query(query);
216 context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
217 context_alloc_event_query(context, query);
218 }
219 else
220 {
221 context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
222 }
223 }
224 else
225 {
226 context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
227 context_alloc_event_query(context, query);
228 }
229
230 gl_info = context->gl_info;
231
232 ENTER_GL();
233
234 if (gl_info->supported[ARB_SYNC])
235 {
236 if (query->object.sync) GL_EXTCALL(glDeleteSync(query->object.sync));
237 checkGLcall("glDeleteSync");
238 query->object.sync = GL_EXTCALL(glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0));
239 checkGLcall("glFenceSync");
240 }
241 else if (gl_info->supported[APPLE_FENCE])
242 {
243 GL_EXTCALL(glSetFenceAPPLE(query->object.id));
244 checkGLcall("glSetFenceAPPLE");
245 }
246 else if (gl_info->supported[NV_FENCE])
247 {
248 GL_EXTCALL(glSetFenceNV(query->object.id, GL_ALL_COMPLETED_NV));
249 checkGLcall("glSetFenceNV");
250 }
251
252 LEAVE_GL();
253
254 context_release(context);
255}
256
257/*
258 * Occlusion Queries:
259 * http://www.gris.uni-tuebingen.de/~bartz/Publications/paper/hww98.pdf
260 * http://oss.sgi.com/projects/ogl-sample/registry/ARB/occlusion_query.txt
261 */
262
263/* *******************************************
264 IWineD3DQuery IUnknown parts follow
265 ******************************************* */
266static HRESULT WINAPI IWineD3DQueryImpl_QueryInterface(IWineD3DQuery *iface, REFIID riid, LPVOID *ppobj)
267{
268 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
269 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
270 if (IsEqualGUID(riid, &IID_IUnknown)
271 || IsEqualGUID(riid, &IID_IWineD3DBase)
272 || IsEqualGUID(riid, &IID_IWineD3DQuery)) {
273 IUnknown_AddRef(iface);
274 *ppobj = This;
275 return S_OK;
276 }
277 *ppobj = NULL;
278 return E_NOINTERFACE;
279}
280
281static ULONG WINAPI IWineD3DQueryImpl_AddRef(IWineD3DQuery *iface) {
282 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
283 TRACE("(%p) : AddRef increasing from %d\n", This, This->ref);
284 return InterlockedIncrement(&This->ref);
285}
286
287static ULONG WINAPI IWineD3DQueryImpl_Release(IWineD3DQuery *iface) {
288 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
289 ULONG ref;
290 TRACE("(%p) : Releasing from %d\n", This, This->ref);
291 ref = InterlockedDecrement(&This->ref);
292 if (ref == 0) {
293 /* Queries are specific to the GL context that created them. Not
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. */
297 if (This->type == WINED3DQUERYTYPE_EVENT)
298 {
299 struct wined3d_event_query *query = This->extendedData;
300 if (query) wined3d_event_query_destroy(query);
301 }
302 else if (This->type == WINED3DQUERYTYPE_OCCLUSION)
303 {
304 struct wined3d_occlusion_query *query = This->extendedData;
305
306 if (query->context) context_free_occlusion_query(query);
307 HeapFree(GetProcessHeap(), 0, This->extendedData);
308 }
309
310 HeapFree(GetProcessHeap(), 0, This);
311 }
312 return ref;
313}
314
315/* *******************************************
316 IWineD3DQuery IWineD3DQuery parts follow
317 ******************************************* */
318static HRESULT WINAPI IWineD3DQueryImpl_GetParent(IWineD3DQuery *iface, IUnknown **parent)
319{
320 TRACE("iface %p, parent %p.\n", iface, parent);
321
322 *parent = (IUnknown *)parent;
323 IUnknown_AddRef(*parent);
324
325 TRACE("Returning %p.\n", *parent);
326
327 return WINED3D_OK;
328}
329
330static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
331 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface;
332 struct wined3d_occlusion_query *query = This->extendedData;
333 IWineD3DDeviceImpl *device = This->device;
334 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
335 struct wined3d_context *context;
336 DWORD* data = pData;
337 GLuint available;
338 GLuint samples;
339 HRESULT res;
340
341 TRACE("(%p) : type D3DQUERY_OCCLUSION, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags);
342
343 if (!query->context) This->state = QUERY_CREATED;
344
345 if (This->state == QUERY_CREATED)
346 {
347 /* D3D allows GetData on a new query, OpenGL doesn't. So just invent the data ourselves */
348 TRACE("Query wasn't yet started, returning S_OK\n");
349 if(data) *data = 0;
350 return S_OK;
351 }
352
353 if (This->state == QUERY_BUILDING)
354 {
355 /* Msdn says this returns an error, but our tests show that S_FALSE is returned */
356 TRACE("Query is building, returning S_FALSE\n");
357 return S_FALSE;
358 }
359
360 if (!gl_info->supported[ARB_OCCLUSION_QUERY])
361 {
362 WARN("(%p) : Occlusion queries not supported. Returning 1.\n", This);
363 *data = 1;
364 return S_OK;
365 }
366
367 if (query->context->tid != GetCurrentThreadId())
368 {
369 FIXME("%p Wrong thread, returning 1.\n", This);
370 *data = 1;
371 return S_OK;
372 }
373
374 context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
375
376 ENTER_GL();
377
378 GL_EXTCALL(glGetQueryObjectuivARB(query->id, GL_QUERY_RESULT_AVAILABLE_ARB, &available));
379 checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT_AVAILABLE)");
380 TRACE("(%p) : available %d.\n", This, available);
381
382 if (available)
383 {
384 if (data)
385 {
386 GL_EXTCALL(glGetQueryObjectuivARB(query->id, GL_QUERY_RESULT_ARB, &samples));
387 checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT)");
388 TRACE("(%p) : Returning %d samples.\n", This, samples);
389 *data = samples;
390 }
391 res = S_OK;
392 }
393 else
394 {
395 res = S_FALSE;
396 }
397
398 LEAVE_GL();
399
400 context_release(context);
401
402 return res;
403}
404
405static HRESULT WINAPI IWineD3DEventQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
406 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface;
407 struct wined3d_event_query *query = This->extendedData;
408 BOOL *data = pData;
409 enum wined3d_event_query_result ret;
410
411 TRACE("(%p) : type D3DQUERY_EVENT, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags);
412
413 if (!pData || !dwSize) return S_OK;
414 if (!query)
415 {
416 WARN("(%p): Event query not supported by GL, reporting GPU idle\n", This);
417 *data = TRUE;
418 return S_OK;
419 }
420
421 ret = wined3d_event_query_test(query, This->device);
422 switch(ret)
423 {
424 case WINED3D_EVENT_QUERY_OK:
425 case WINED3D_EVENT_QUERY_NOT_STARTED:
426 *data = TRUE;
427 break;
428
429 case WINED3D_EVENT_QUERY_WAITING:
430 *data = FALSE;
431 break;
432
433 case WINED3D_EVENT_QUERY_WRONG_THREAD:
434 FIXME("(%p) Wrong thread, reporting GPU idle.\n", This);
435 *data = TRUE;
436 break;
437
438 case WINED3D_EVENT_QUERY_ERROR:
439 ERR("The GL event query failed, returning D3DERR_INVALIDCALL\n");
440 return WINED3DERR_INVALIDCALL;
441 }
442
443 return S_OK;
444}
445
446static DWORD WINAPI IWineD3DEventQueryImpl_GetDataSize(IWineD3DQuery* iface){
447 TRACE("(%p) : type D3DQUERY_EVENT\n", iface);
448
449 return sizeof(BOOL);
450}
451
452static DWORD WINAPI IWineD3DOcclusionQueryImpl_GetDataSize(IWineD3DQuery* iface){
453 TRACE("(%p) : type D3DQUERY_OCCLUSION\n", iface);
454
455 return sizeof(DWORD);
456}
457
458static WINED3DQUERYTYPE WINAPI IWineD3DQueryImpl_GetType(IWineD3DQuery* iface){
459 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
460 return This->type;
461}
462
463static HRESULT WINAPI IWineD3DEventQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIssueFlags) {
464 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
465
466 TRACE("(%p) : dwIssueFlags %#x, type D3DQUERY_EVENT\n", This, dwIssueFlags);
467 if (dwIssueFlags & WINED3DISSUE_END)
468 {
469 struct wined3d_event_query *query = This->extendedData;
470
471 /* Faked event query support */
472 if (!query) return WINED3D_OK;
473
474 wined3d_event_query_issue(query, This->device);
475 }
476 else if(dwIssueFlags & WINED3DISSUE_BEGIN)
477 {
478 /* Started implicitly at device creation */
479 ERR("Event query issued with START flag - what to do?\n");
480 }
481
482 if(dwIssueFlags & WINED3DISSUE_BEGIN) {
483 This->state = QUERY_BUILDING;
484 } else {
485 This->state = QUERY_SIGNALLED;
486 }
487
488 return WINED3D_OK;
489}
490
491static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIssueFlags) {
492 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
493 IWineD3DDeviceImpl *device = This->device;
494 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
495
496 if (gl_info->supported[ARB_OCCLUSION_QUERY])
497 {
498 struct wined3d_occlusion_query *query = This->extendedData;
499 struct wined3d_context *context;
500
501 /* This is allowed according to msdn and our tests. Reset the query and restart */
502 if (dwIssueFlags & WINED3DISSUE_BEGIN)
503 {
504 if (This->state == QUERY_BUILDING)
505 {
506 if (query->context->tid != GetCurrentThreadId())
507 {
508 FIXME("Wrong thread, can't restart query.\n");
509
510 context_free_occlusion_query(query);
511 context = context_acquire(This->device, NULL, CTXUSAGE_RESOURCELOAD);
512 context_alloc_occlusion_query(context, query);
513 }
514 else
515 {
516 context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
517
518 ENTER_GL();
519 GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
520 checkGLcall("glEndQuery()");
521 LEAVE_GL();
522 }
523 }
524 else
525 {
526 if (query->context) context_free_occlusion_query(query);
527 context = context_acquire(This->device, NULL, CTXUSAGE_RESOURCELOAD);
528 context_alloc_occlusion_query(context, query);
529 }
530
531 ENTER_GL();
532 GL_EXTCALL(glBeginQueryARB(GL_SAMPLES_PASSED_ARB, query->id));
533 checkGLcall("glBeginQuery()");
534 LEAVE_GL();
535
536 context_release(context);
537 }
538 if (dwIssueFlags & WINED3DISSUE_END) {
539 /* Msdn says _END on a non-building occlusion query returns an error, but
540 * our tests show that it returns OK. But OpenGL doesn't like it, so avoid
541 * generating an error
542 */
543 if (This->state == QUERY_BUILDING)
544 {
545 if (query->context->tid != GetCurrentThreadId())
546 {
547 FIXME("Wrong thread, can't end query.\n");
548 }
549 else
550 {
551 context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
552
553 ENTER_GL();
554 GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
555 checkGLcall("glEndQuery()");
556 LEAVE_GL();
557
558 context_release(context);
559 }
560 }
561 }
562 } else {
563 FIXME("(%p) : Occlusion queries not supported\n", This);
564 }
565
566 if(dwIssueFlags & WINED3DISSUE_BEGIN) {
567 This->state = QUERY_BUILDING;
568 } else {
569 This->state = QUERY_SIGNALLED;
570 }
571 return WINED3D_OK; /* can be WINED3DERR_INVALIDCALL. */
572}
573
574static const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl =
575{
576 /*** IUnknown methods ***/
577 IWineD3DQueryImpl_QueryInterface,
578 IWineD3DQueryImpl_AddRef,
579 IWineD3DQueryImpl_Release,
580 /*** IWineD3Dquery methods ***/
581 IWineD3DQueryImpl_GetParent,
582 IWineD3DEventQueryImpl_GetData,
583 IWineD3DEventQueryImpl_GetDataSize,
584 IWineD3DQueryImpl_GetType,
585 IWineD3DEventQueryImpl_Issue
586};
587
588static const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl =
589{
590 /*** IUnknown methods ***/
591 IWineD3DQueryImpl_QueryInterface,
592 IWineD3DQueryImpl_AddRef,
593 IWineD3DQueryImpl_Release,
594 /*** IWineD3Dquery methods ***/
595 IWineD3DQueryImpl_GetParent,
596 IWineD3DOcclusionQueryImpl_GetData,
597 IWineD3DOcclusionQueryImpl_GetDataSize,
598 IWineD3DQueryImpl_GetType,
599 IWineD3DOcclusionQueryImpl_Issue
600};
601
602HRESULT query_init(IWineD3DQueryImpl *query, IWineD3DDeviceImpl *device,
603 WINED3DQUERYTYPE type, IUnknown *parent)
604{
605 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
606
607 switch (type)
608 {
609 case WINED3DQUERYTYPE_OCCLUSION:
610 TRACE("Occlusion query.\n");
611 if (!gl_info->supported[ARB_OCCLUSION_QUERY])
612 {
613 WARN("Unsupported in local OpenGL implementation: ARB_OCCLUSION_QUERY.\n");
614 return WINED3DERR_NOTAVAILABLE;
615 }
616 query->lpVtbl = &IWineD3DOcclusionQuery_Vtbl;
617 query->extendedData = HeapAlloc(GetProcessHeap(), 0, sizeof(struct wined3d_occlusion_query));
618 if (!query->extendedData)
619 {
620 ERR("Failed to allocate occlusion query extended data.\n");
621 return E_OUTOFMEMORY;
622 }
623 ((struct wined3d_occlusion_query *)query->extendedData)->context = NULL;
624 break;
625
626 case WINED3DQUERYTYPE_EVENT:
627 TRACE("Event query.\n");
628 if (!wined3d_event_query_supported(gl_info))
629 {
630 /* Half-Life 2 needs this query. It does not render the main
631 * menu correctly otherwise. Pretend to support it, faking
632 * this query does not do much harm except potentially
633 * lowering performance. */
634 FIXME("Event query: Unimplemented, but pretending to be supported.\n");
635 }
636 query->lpVtbl = &IWineD3DEventQuery_Vtbl;
637 query->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct wined3d_event_query));
638 if (!query->extendedData)
639 {
640 ERR("Failed to allocate event query memory.\n");
641 return E_OUTOFMEMORY;
642 }
643 break;
644
645 case WINED3DQUERYTYPE_VCACHE:
646 case WINED3DQUERYTYPE_RESOURCEMANAGER:
647 case WINED3DQUERYTYPE_VERTEXSTATS:
648 case WINED3DQUERYTYPE_TIMESTAMP:
649 case WINED3DQUERYTYPE_TIMESTAMPDISJOINT:
650 case WINED3DQUERYTYPE_TIMESTAMPFREQ:
651 case WINED3DQUERYTYPE_PIPELINETIMINGS:
652 case WINED3DQUERYTYPE_INTERFACETIMINGS:
653 case WINED3DQUERYTYPE_VERTEXTIMINGS:
654 case WINED3DQUERYTYPE_PIXELTIMINGS:
655 case WINED3DQUERYTYPE_BANDWIDTHTIMINGS:
656 case WINED3DQUERYTYPE_CACHEUTILIZATION:
657 default:
658 FIXME("Unhandled query type %#x.\n", type);
659 return WINED3DERR_NOTAVAILABLE;
660 }
661
662 query->type = type;
663 query->state = QUERY_CREATED;
664 query->device = device;
665 query->parent = parent;
666 query->ref = 1;
667
668 return WINED3D_OK;
669}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette