wined3d: Fake occlusion queries if the wrong context is active.

This commit is contained in:
Stefan Dösinger 2007-08-14 15:42:34 +02:00 committed by Alexandre Julliard
parent a99907d1d2
commit e184b09a66
3 changed files with 19 additions and 9 deletions

View File

@ -1140,6 +1140,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINE
TRACE("(%p) Allocating data for an occlusion query\n", This); TRACE("(%p) Allocating data for an occlusion query\n", This);
object->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineQueryOcclusionData)); object->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineQueryOcclusionData));
GL_EXTCALL(glGenQueriesARB(1, &((WineQueryOcclusionData *)(object->extendedData))->queryId)); GL_EXTCALL(glGenQueriesARB(1, &((WineQueryOcclusionData *)(object->extendedData))->queryId));
((WineQueryOcclusionData *)(object->extendedData))->ctx = This->activeContext;
break; break;
} }
case WINED3DQUERYTYPE_EVENT: case WINED3DQUERYTYPE_EVENT:

View File

@ -187,7 +187,9 @@ static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pDa
case WINED3DQUERYTYPE_OCCLUSION: case WINED3DQUERYTYPE_OCCLUSION:
{ {
DWORD* data = pData; DWORD* data = pData;
if (GL_SUPPORT(ARB_OCCLUSION_QUERY)) { if (GL_SUPPORT(ARB_OCCLUSION_QUERY) &&
((WineQueryOcclusionData *)This->extendedData)->ctx == This->wineD3DDevice->activeContext &&
This->wineD3DDevice->activeContext->tid == GetCurrentThreadId()) {
GLuint available; GLuint available;
GLuint samples; GLuint samples;
GLuint queryId = ((WineQueryOcclusionData *)This->extendedData)->queryId; GLuint queryId = ((WineQueryOcclusionData *)This->extendedData)->queryId;
@ -206,7 +208,7 @@ static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pDa
res = S_FALSE; res = S_FALSE;
} }
} else { } else {
FIXME("(%p) : Occlusion queries not supported. Returning 1.\n", This); WARN("(%p) : Occlusion queries not supported, or wrong context. Returning 1.\n", This);
*data = 1; *data = 1;
res = S_OK; res = S_OK;
} }
@ -380,6 +382,11 @@ static HRESULT WINAPI IWineD3DQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIs
switch (This->type) { switch (This->type) {
case WINED3DQUERYTYPE_OCCLUSION: case WINED3DQUERYTYPE_OCCLUSION:
if (GL_SUPPORT(ARB_OCCLUSION_QUERY)) { if (GL_SUPPORT(ARB_OCCLUSION_QUERY)) {
WineD3DContext *ctx = ((WineQueryOcclusionData *)This->extendedData)->ctx;
if(ctx != This->wineD3DDevice->activeContext || ctx->tid != GetCurrentThreadId()) {
WARN("Not the owning context, can't start query\n");
} else {
if (dwIssueFlags & WINED3DISSUE_BEGIN) { if (dwIssueFlags & WINED3DISSUE_BEGIN) {
GL_EXTCALL(glBeginQueryARB(GL_SAMPLES_PASSED_ARB, ((WineQueryOcclusionData *)This->extendedData)->queryId)); GL_EXTCALL(glBeginQueryARB(GL_SAMPLES_PASSED_ARB, ((WineQueryOcclusionData *)This->extendedData)->queryId));
checkGLcall("glBeginQuery()"); checkGLcall("glBeginQuery()");
@ -388,6 +395,7 @@ static HRESULT WINAPI IWineD3DQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIs
GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB)); GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
checkGLcall("glEndQuery()"); checkGLcall("glEndQuery()");
} }
}
} else { } else {
FIXME("(%p) : Occlusion queries not supported\n", This); FIXME("(%p) : Occlusion queries not supported\n", This);
} }

View File

@ -1460,6 +1460,7 @@ extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl;
/* Datastructures for IWineD3DQueryImpl.extendedData */ /* Datastructures for IWineD3DQueryImpl.extendedData */
typedef struct WineQueryOcclusionData { typedef struct WineQueryOcclusionData {
GLuint queryId; GLuint queryId;
WineD3DContext *ctx;
} WineQueryOcclusionData; } WineQueryOcclusionData;
typedef struct WineQueryEventData { typedef struct WineQueryEventData {