VirtualBox

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

Last change on this file since 20817 was 19678, checked in by vboxsync, 16 years ago

opengl: update wine to 1.1.21, add d3d9.dll to build list

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