VirtualBox

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

Last change on this file since 22652 was 22496, checked in by vboxsync, 15 years ago

crOpenGL: update wine to 1.1.27 and better fix for depthstencil surface refcounting

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