VirtualBox

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

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

crOpenGL: update to wine 1.1.26

  • Property svn:eol-style set to native
File size: 22.7 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 WineQueryEventData *query_data = (WineQueryEventData *)This->extendedData;
80
81 if (query_data->ctx->tid != GetCurrentThreadId())
82 {
83 FIXME("Query was created in a different thread, skipping deletion.\n");
84 }
85 else
86 {
87 ActivateContext(This->wineD3DDevice, query_data->ctx->surface, CTXUSAGE_RESOURCELOAD);
88
89 ENTER_GL();
90
91 if (GL_SUPPORT(APPLE_FENCE))
92 {
93 GL_EXTCALL(glDeleteFencesAPPLE(1, &query_data->fenceId));
94 checkGLcall("glDeleteFencesAPPLE");
95 }
96 else if (GL_SUPPORT(NV_FENCE))
97 {
98 GL_EXTCALL(glDeleteFencesNV(1, &query_data->fenceId));
99 checkGLcall("glDeleteFencesNV");
100 }
101
102 LEAVE_GL();
103 }
104 }
105 else if (This->type == WINED3DQUERYTYPE_OCCLUSION && GL_SUPPORT(ARB_OCCLUSION_QUERY))
106 {
107 WineQueryOcclusionData *query_data = (WineQueryOcclusionData *)This->extendedData;
108
109 if (query_data->ctx->tid != GetCurrentThreadId())
110 {
111 FIXME("Query was created in a different thread, skipping deletion.\n");
112 }
113 else
114 {
115 ActivateContext(This->wineD3DDevice, query_data->ctx->surface, CTXUSAGE_RESOURCELOAD);
116
117 ENTER_GL();
118
119 GL_EXTCALL(glDeleteQueriesARB(1, &query_data->queryId));
120 checkGLcall("glDeleteQueriesARB");
121
122 LEAVE_GL();
123 }
124 }
125
126 HeapFree(GetProcessHeap(), 0, This->extendedData);
127 HeapFree(GetProcessHeap(), 0, This);
128 }
129 return ref;
130}
131
132/* *******************************************
133 IWineD3DQuery IWineD3DQuery parts follow
134 ******************************************* */
135static HRESULT WINAPI IWineD3DQueryImpl_GetParent(IWineD3DQuery *iface, IUnknown** parent){
136 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
137
138 *parent= (IUnknown*) parent;
139 IUnknown_AddRef(*parent);
140 TRACE("(%p) : returning %p\n", This, *parent);
141 return WINED3D_OK;
142}
143
144static HRESULT WINAPI IWineD3DQueryImpl_GetDevice(IWineD3DQuery* iface, IWineD3DDevice **pDevice){
145 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
146 IWineD3DDevice_AddRef((IWineD3DDevice *)This->wineD3DDevice);
147 *pDevice = (IWineD3DDevice *)This->wineD3DDevice;
148 TRACE("(%p) returning %p\n", This, *pDevice);
149 return WINED3D_OK;
150}
151
152
153static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags){
154 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
155 HRESULT res = S_OK;
156
157 TRACE("(%p) : type %#x, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, This->type, pData, dwSize, dwGetDataFlags);
158
159 switch (This->type){
160
161 case WINED3DQUERYTYPE_VCACHE:
162 {
163
164 WINED3DDEVINFO_VCACHE *data = pData;
165 FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_VCACHE\n", This);
166 if(pData == NULL || dwSize == 0) break;
167 data->Pattern = WINEMAKEFOURCC('C','A','C','H');
168 data->OptMethod = 0; /*0 get longest strips, 1 optimize vertex cache*/
169 data->CacheSize = 0; /*cache size, only required if OptMethod == 1*/
170 data->MagicNumber = 0; /*only required if OptMethod == 1 (used internally)*/
171
172 }
173 break;
174 case WINED3DQUERYTYPE_RESOURCEMANAGER:
175 {
176 WINED3DDEVINFO_RESOURCEMANAGER *data = pData;
177 int i;
178 FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_RESOURCEMANAGER\n", This);
179 if(pData == NULL || dwSize == 0) break;
180 for(i = 0; i < WINED3DRTYPECOUNT; i++){
181 /*I'm setting the default values to 1 so as to reduce the risk of a div/0 in the caller*/
182 /* isTextureResident could be used to get some of this information */
183 data->stats[i].bThrashing = FALSE;
184 data->stats[i].ApproxBytesDownloaded = 1;
185 data->stats[i].NumEvicts = 1;
186 data->stats[i].NumVidCreates = 1;
187 data->stats[i].LastPri = 1;
188 data->stats[i].NumUsed = 1;
189 data->stats[i].NumUsedInVidMem = 1;
190 data->stats[i].WorkingSet = 1;
191 data->stats[i].WorkingSetBytes = 1;
192 data->stats[i].TotalManaged = 1;
193 data->stats[i].TotalBytes = 1;
194 }
195
196 }
197 break;
198 case WINED3DQUERYTYPE_VERTEXSTATS:
199 {
200 WINED3DDEVINFO_VERTEXSTATS *data = pData;
201 FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_VERTEXSTATS\n", This);
202 if(pData == NULL || dwSize == 0) break;
203 data->NumRenderedTriangles = 1;
204 data->NumExtraClippingTriangles = 1;
205
206 }
207 break;
208 case WINED3DQUERYTYPE_TIMESTAMP:
209 {
210 UINT64* data = pData;
211 FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_TIMESTAMP\n", This);
212 if(pData == NULL || dwSize == 0) break;
213 *data = 1; /*Don't know what this is supposed to be*/
214 }
215 break;
216 case WINED3DQUERYTYPE_TIMESTAMPDISJOINT:
217 {
218 BOOL* data = pData;
219 FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_TIMESTAMPDISJOINT\n", This);
220 if(pData == NULL || dwSize == 0) break;
221 *data = FALSE; /*Don't know what this is supposed to be*/
222 }
223 break;
224 case WINED3DQUERYTYPE_TIMESTAMPFREQ:
225 {
226 UINT64* data = pData;
227 FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_TIMESTAMPFREQ\n", This);
228 if(pData == NULL || dwSize == 0) break;
229 *data = 1; /*Don't know what this is supposed to be*/
230 }
231 break;
232 case WINED3DQUERYTYPE_PIPELINETIMINGS:
233 {
234 WINED3DDEVINFO_PIPELINETIMINGS *data = pData;
235 FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_PIPELINETIMINGS\n", This);
236 if(pData == NULL || dwSize == 0) break;
237
238 data->VertexProcessingTimePercent = 1.0f;
239 data->PixelProcessingTimePercent = 1.0f;
240 data->OtherGPUProcessingTimePercent = 97.0f;
241 data->GPUIdleTimePercent = 1.0f;
242 }
243 break;
244 case WINED3DQUERYTYPE_INTERFACETIMINGS:
245 {
246 WINED3DDEVINFO_INTERFACETIMINGS *data = pData;
247 FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_INTERFACETIMINGS\n", This);
248
249 if(pData == NULL || dwSize == 0) break;
250 data->WaitingForGPUToUseApplicationResourceTimePercent = 1.0f;
251 data->WaitingForGPUToAcceptMoreCommandsTimePercent = 1.0f;
252 data->WaitingForGPUToStayWithinLatencyTimePercent = 1.0f;
253 data->WaitingForGPUExclusiveResourceTimePercent = 1.0f;
254 data->WaitingForGPUOtherTimePercent = 96.0f;
255 }
256
257 break;
258 case WINED3DQUERYTYPE_VERTEXTIMINGS:
259 {
260 WINED3DDEVINFO_STAGETIMINGS *data = pData;
261 FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_VERTEXTIMINGS\n", This);
262
263 if(pData == NULL || dwSize == 0) break;
264 data->MemoryProcessingPercent = 50.0f;
265 data->ComputationProcessingPercent = 50.0f;
266
267 }
268 break;
269 case WINED3DQUERYTYPE_PIXELTIMINGS:
270 {
271 WINED3DDEVINFO_STAGETIMINGS *data = pData;
272 FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_PIXELTIMINGS\n", This);
273
274 if(pData == NULL || dwSize == 0) break;
275 data->MemoryProcessingPercent = 50.0f;
276 data->ComputationProcessingPercent = 50.0f;
277 }
278 break;
279 case WINED3DQUERYTYPE_BANDWIDTHTIMINGS:
280 {
281 WINED3DDEVINFO_BANDWIDTHTIMINGS *data = pData;
282 FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_BANDWIDTHTIMINGS\n", This);
283
284 if(pData == NULL || dwSize == 0) break;
285 data->MaxBandwidthUtilized = 1.0f;
286 data->FrontEndUploadMemoryUtilizedPercent = 1.0f;
287 data->VertexRateUtilizedPercent = 1.0f;
288 data->TriangleSetupRateUtilizedPercent = 1.0f;
289 data->FillRateUtilizedPercent = 97.0f;
290 }
291 break;
292 case WINED3DQUERYTYPE_CACHEUTILIZATION:
293 {
294 WINED3DDEVINFO_CACHEUTILIZATION *data = pData;
295 FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_CACHEUTILIZATION\n", This);
296
297 if(pData == NULL || dwSize == 0) break;
298 data->TextureCacheHitRate = 1.0f;
299 data->PostTransformVertexCacheHitRate = 1.0f;
300 }
301
302
303 break;
304 default:
305 FIXME("(%p) Unhandled query type %d\n",This , This->type);
306
307 };
308
309 /*dwGetDataFlags = 0 || D3DGETDATA_FLUSH
310 D3DGETDATA_FLUSH may return WINED3DERR_DEVICELOST if the device is lost
311 */
312 return res; /* S_OK if the query data is available*/
313}
314
315static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
316 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface;
317 WineQueryOcclusionData *query_data = (WineQueryOcclusionData *)This->extendedData;
318 DWORD* data = pData;
319 GLuint available;
320 GLuint samples;
321 HRESULT res;
322
323 TRACE("(%p) : type D3DQUERY_OCCLUSION, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags);
324
325 if (This->state == QUERY_CREATED)
326 {
327 /* D3D allows GetData on a new query, OpenGL doesn't. So just invent the data ourselves */
328 TRACE("Query wasn't yet started, returning S_OK\n");
329 if(data) *data = 0;
330 return S_OK;
331 }
332
333 if (This->state == QUERY_BUILDING)
334 {
335 /* Msdn says this returns an error, but our tests show that S_FALSE is returned */
336 TRACE("Query is building, returning S_FALSE\n");
337 return S_FALSE;
338 }
339
340 if (!GL_SUPPORT(ARB_OCCLUSION_QUERY))
341 {
342 WARN("(%p) : Occlusion queries not supported. Returning 1.\n", This);
343 *data = 1;
344 return S_OK;
345 }
346
347 if (query_data->ctx->tid != GetCurrentThreadId())
348 {
349 FIXME("%p Wrong thread, returning 1.\n", This);
350 *data = 1;
351 return S_OK;
352 }
353
354 ActivateContext(This->wineD3DDevice, query_data->ctx->surface, CTXUSAGE_RESOURCELOAD);
355
356 ENTER_GL();
357
358 GL_EXTCALL(glGetQueryObjectuivARB(query_data->queryId, GL_QUERY_RESULT_AVAILABLE_ARB, &available));
359 checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT_AVAILABLE)");
360 TRACE("(%p) : available %d.\n", This, available);
361
362 if (available)
363 {
364 if (data)
365 {
366 GL_EXTCALL(glGetQueryObjectuivARB(query_data->queryId, GL_QUERY_RESULT_ARB, &samples));
367 checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT)");
368 TRACE("(%p) : Returning %d samples.\n", This, samples);
369 *data = samples;
370 }
371 res = S_OK;
372 }
373 else
374 {
375 res = S_FALSE;
376 }
377
378 LEAVE_GL();
379
380 return res;
381}
382
383static HRESULT WINAPI IWineD3DEventQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
384 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface;
385 BOOL* data = pData;
386 WineQueryEventData *query_data = (WineQueryEventData *)This->extendedData;
387
388 TRACE("(%p) : type D3DQUERY_EVENT, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags);
389
390 if (!pData || !dwSize) return S_OK;
391
392 if (query_data->ctx->tid != GetCurrentThreadId())
393 {
394 /* See comment in IWineD3DQuery::Issue, event query codeblock */
395 FIXME("Wrong thread, reporting GPU idle.\n");
396 *data = TRUE;
397
398 return S_OK;
399 }
400
401 ActivateContext(This->wineD3DDevice, query_data->ctx->surface, CTXUSAGE_RESOURCELOAD);
402
403 ENTER_GL();
404
405 if (GL_SUPPORT(APPLE_FENCE))
406 {
407 *data = GL_EXTCALL(glTestFenceAPPLE(query_data->fenceId));
408 checkGLcall("glTestFenceAPPLE");
409 }
410 else if (GL_SUPPORT(NV_FENCE))
411 {
412 *data = GL_EXTCALL(glTestFenceNV(query_data->fenceId));
413 checkGLcall("glTestFenceNV");
414 }
415 else
416 {
417 WARN("(%p): reporting GPU idle\n", This);
418 *data = TRUE;
419 }
420
421 LEAVE_GL();
422
423 return S_OK;
424}
425
426static DWORD WINAPI IWineD3DQueryImpl_GetDataSize(IWineD3DQuery* iface){
427 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
428 int dataSize = 0;
429 TRACE("(%p) : type %#x\n", This, This->type);
430 switch(This->type){
431 case WINED3DQUERYTYPE_VCACHE:
432 dataSize = sizeof(WINED3DDEVINFO_VCACHE);
433 break;
434 case WINED3DQUERYTYPE_RESOURCEMANAGER:
435 dataSize = sizeof(WINED3DDEVINFO_RESOURCEMANAGER);
436 break;
437 case WINED3DQUERYTYPE_VERTEXSTATS:
438 dataSize = sizeof(WINED3DDEVINFO_VERTEXSTATS);
439 break;
440 case WINED3DQUERYTYPE_EVENT:
441 dataSize = sizeof(BOOL);
442 break;
443 case WINED3DQUERYTYPE_TIMESTAMP:
444 dataSize = sizeof(UINT64);
445 break;
446 case WINED3DQUERYTYPE_TIMESTAMPDISJOINT:
447 dataSize = sizeof(BOOL);
448 break;
449 case WINED3DQUERYTYPE_TIMESTAMPFREQ:
450 dataSize = sizeof(UINT64);
451 break;
452 case WINED3DQUERYTYPE_PIPELINETIMINGS:
453 dataSize = sizeof(WINED3DDEVINFO_PIPELINETIMINGS);
454 break;
455 case WINED3DQUERYTYPE_INTERFACETIMINGS:
456 dataSize = sizeof(WINED3DDEVINFO_INTERFACETIMINGS);
457 break;
458 case WINED3DQUERYTYPE_VERTEXTIMINGS:
459 dataSize = sizeof(WINED3DDEVINFO_STAGETIMINGS);
460 break;
461 case WINED3DQUERYTYPE_PIXELTIMINGS:
462 dataSize = sizeof(WINED3DDEVINFO_STAGETIMINGS);
463 break;
464 case WINED3DQUERYTYPE_BANDWIDTHTIMINGS:
465 dataSize = sizeof(WINED3DQUERYTYPE_BANDWIDTHTIMINGS);
466 break;
467 case WINED3DQUERYTYPE_CACHEUTILIZATION:
468 dataSize = sizeof(WINED3DDEVINFO_CACHEUTILIZATION);
469 break;
470 default:
471 FIXME("(%p) Unhandled query type %d\n",This , This->type);
472 dataSize = 0;
473 }
474 return dataSize;
475}
476
477static DWORD WINAPI IWineD3DEventQueryImpl_GetDataSize(IWineD3DQuery* iface){
478 TRACE("(%p) : type D3DQUERY_EVENT\n", iface);
479
480 return sizeof(BOOL);
481}
482
483static DWORD WINAPI IWineD3DOcclusionQueryImpl_GetDataSize(IWineD3DQuery* iface){
484 TRACE("(%p) : type D3DQUERY_OCCLUSION\n", iface);
485
486 return sizeof(DWORD);
487}
488
489static WINED3DQUERYTYPE WINAPI IWineD3DQueryImpl_GetType(IWineD3DQuery* iface){
490 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
491 return This->type;
492}
493
494
495static HRESULT WINAPI IWineD3DEventQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIssueFlags) {
496 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
497
498 TRACE("(%p) : dwIssueFlags %#x, type D3DQUERY_EVENT\n", This, dwIssueFlags);
499 if (dwIssueFlags & WINED3DISSUE_END)
500 {
501 WineQueryEventData *query_data = (WineQueryEventData *)This->extendedData;
502
503 if (query_data->ctx->tid != GetCurrentThreadId())
504 {
505 /* GL fences can be used only from the context that created them,
506 * so if a different context is active, don't bother setting the query. The penalty
507 * of a context switch is most likely higher than the gain of a correct query result
508 *
509 * If the query is used from a different thread, don't bother creating a multithread
510 * context - there's no point in doing that as the query would be unusable anyway
511 */
512 WARN("Query context not active\n");
513 }
514 else
515 {
516 ActivateContext(This->wineD3DDevice, query_data->ctx->surface, CTXUSAGE_RESOURCELOAD);
517
518 ENTER_GL();
519
520 if (GL_SUPPORT(APPLE_FENCE))
521 {
522 GL_EXTCALL(glSetFenceAPPLE(query_data->fenceId));
523 checkGLcall("glSetFenceAPPLE");
524 }
525 else if (GL_SUPPORT(NV_FENCE))
526 {
527 GL_EXTCALL(glSetFenceNV(query_data->fenceId, GL_ALL_COMPLETED_NV));
528 checkGLcall("glSetFenceNV");
529 }
530
531 LEAVE_GL();
532 }
533 } else if(dwIssueFlags & WINED3DISSUE_BEGIN) {
534 /* Started implicitly at device creation */
535 ERR("Event query issued with START flag - what to do?\n");
536 }
537
538 if(dwIssueFlags & WINED3DISSUE_BEGIN) {
539 This->state = QUERY_BUILDING;
540 } else {
541 This->state = QUERY_SIGNALLED;
542 }
543
544 return WINED3D_OK;
545}
546
547static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIssueFlags) {
548 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
549
550 if (GL_SUPPORT(ARB_OCCLUSION_QUERY))
551 {
552 WineQueryOcclusionData *query_data = (WineQueryOcclusionData *)This->extendedData;
553
554 if (query_data->ctx->tid != GetCurrentThreadId())
555 {
556 FIXME("Not the owning context, can't start query.\n");
557 }
558 else
559 {
560 ActivateContext(This->wineD3DDevice, query_data->ctx->surface, CTXUSAGE_RESOURCELOAD);
561
562 ENTER_GL();
563 /* This is allowed according to msdn and our tests. Reset the query and restart */
564 if (dwIssueFlags & WINED3DISSUE_BEGIN) {
565 if(This->state == QUERY_BUILDING) {
566 GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
567 checkGLcall("glEndQuery()");
568 }
569
570 GL_EXTCALL(glBeginQueryARB(GL_SAMPLES_PASSED_ARB, query_data->queryId));
571 checkGLcall("glBeginQuery()");
572 }
573 if (dwIssueFlags & WINED3DISSUE_END) {
574 /* Msdn says _END on a non-building occlusion query returns an error, but
575 * our tests show that it returns OK. But OpenGL doesn't like it, so avoid
576 * generating an error
577 */
578 if(This->state == QUERY_BUILDING) {
579 GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
580 checkGLcall("glEndQuery()");
581 }
582 }
583 LEAVE_GL();
584 }
585 } else {
586 FIXME("(%p) : Occlusion queries not supported\n", This);
587 }
588
589 if(dwIssueFlags & WINED3DISSUE_BEGIN) {
590 This->state = QUERY_BUILDING;
591 } else {
592 This->state = QUERY_SIGNALLED;
593 }
594 return WINED3D_OK; /* can be WINED3DERR_INVALIDCALL. */
595}
596
597static HRESULT WINAPI IWineD3DQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIssueFlags){
598 IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
599
600 TRACE("(%p) : dwIssueFlags %#x, type %#x\n", This, dwIssueFlags, This->type);
601
602 /* The fixme is printed when the app asks for the resulting data */
603 WARN("(%p) : Unhandled query type %#x\n", This, This->type);
604
605 if(dwIssueFlags & WINED3DISSUE_BEGIN) {
606 This->state = QUERY_BUILDING;
607 } else {
608 This->state = QUERY_SIGNALLED;
609 }
610
611 return WINED3D_OK; /* can be WINED3DERR_INVALIDCALL. */
612}
613
614
615/**********************************************************
616 * IWineD3DQuery VTbl follows
617 **********************************************************/
618
619const IWineD3DQueryVtbl IWineD3DQuery_Vtbl =
620{
621 /*** IUnknown methods ***/
622 IWineD3DQueryImpl_QueryInterface,
623 IWineD3DQueryImpl_AddRef,
624 IWineD3DQueryImpl_Release,
625 /*** IWineD3Dquery methods ***/
626 IWineD3DQueryImpl_GetParent,
627 IWineD3DQueryImpl_GetDevice,
628 IWineD3DQueryImpl_GetData,
629 IWineD3DQueryImpl_GetDataSize,
630 IWineD3DQueryImpl_GetType,
631 IWineD3DQueryImpl_Issue
632};
633
634const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl =
635{
636 /*** IUnknown methods ***/
637 IWineD3DQueryImpl_QueryInterface,
638 IWineD3DQueryImpl_AddRef,
639 IWineD3DQueryImpl_Release,
640 /*** IWineD3Dquery methods ***/
641 IWineD3DQueryImpl_GetParent,
642 IWineD3DQueryImpl_GetDevice,
643 IWineD3DEventQueryImpl_GetData,
644 IWineD3DEventQueryImpl_GetDataSize,
645 IWineD3DQueryImpl_GetType,
646 IWineD3DEventQueryImpl_Issue
647};
648
649const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl =
650{
651 /*** IUnknown methods ***/
652 IWineD3DQueryImpl_QueryInterface,
653 IWineD3DQueryImpl_AddRef,
654 IWineD3DQueryImpl_Release,
655 /*** IWineD3Dquery methods ***/
656 IWineD3DQueryImpl_GetParent,
657 IWineD3DQueryImpl_GetDevice,
658 IWineD3DOcclusionQueryImpl_GetData,
659 IWineD3DOcclusionQueryImpl_GetDataSize,
660 IWineD3DQueryImpl_GetType,
661 IWineD3DOcclusionQueryImpl_Issue
662};
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