wined3d: Deal with multithreading in event queries.
This commit is contained in:
parent
50c101135c
commit
a99907d1d2
|
@ -1143,15 +1143,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINE
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WINED3DQUERYTYPE_EVENT:
|
case WINED3DQUERYTYPE_EVENT:
|
||||||
/* TODO: GL_APPLE_fence */
|
|
||||||
if(GL_SUPPORT(APPLE_FENCE)) {
|
if(GL_SUPPORT(APPLE_FENCE)) {
|
||||||
object->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineQueryEventData));
|
object->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineQueryEventData));
|
||||||
GL_EXTCALL(glGenFencesAPPLE(1, &((WineQueryEventData *)(object->extendedData))->fenceId));
|
GL_EXTCALL(glGenFencesAPPLE(1, &((WineQueryEventData *)(object->extendedData))->fenceId));
|
||||||
checkGLcall("glGenFencesAPPLE");
|
checkGLcall("glGenFencesAPPLE");
|
||||||
|
((WineQueryEventData *)(object->extendedData))->ctx = This->activeContext;
|
||||||
} else if(GL_SUPPORT(NV_FENCE)) {
|
} else if(GL_SUPPORT(NV_FENCE)) {
|
||||||
object->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineQueryEventData));
|
object->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineQueryEventData));
|
||||||
GL_EXTCALL(glGenFencesNV(1, &((WineQueryEventData *)(object->extendedData))->fenceId));
|
GL_EXTCALL(glGenFencesNV(1, &((WineQueryEventData *)(object->extendedData))->fenceId));
|
||||||
checkGLcall("glGenFencesNV");
|
checkGLcall("glGenFencesNV");
|
||||||
|
((WineQueryEventData *)(object->extendedData))->ctx = This->activeContext;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,12 @@ static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pDa
|
||||||
case WINED3DQUERYTYPE_EVENT:
|
case WINED3DQUERYTYPE_EVENT:
|
||||||
{
|
{
|
||||||
BOOL* data = pData;
|
BOOL* data = pData;
|
||||||
if(GL_SUPPORT(APPLE_FENCE)) {
|
WineD3DContext *ctx = ((WineQueryEventData *)This->extendedData)->ctx;
|
||||||
|
if(ctx != This->wineD3DDevice->activeContext || ctx->tid != GetCurrentThreadId()) {
|
||||||
|
/* See comment in IWineD3DQuery::Issue, event query codeblock */
|
||||||
|
WARN("Query context not active, reporting GPU idle\n");
|
||||||
|
*data = TRUE;
|
||||||
|
} else if(GL_SUPPORT(APPLE_FENCE)) {
|
||||||
*data = GL_EXTCALL(glTestFenceAPPLE(((WineQueryEventData *)This->extendedData)->fenceId));
|
*data = GL_EXTCALL(glTestFenceAPPLE(((WineQueryEventData *)This->extendedData)->fenceId));
|
||||||
checkGLcall("glTestFenceAPPLE");
|
checkGLcall("glTestFenceAPPLE");
|
||||||
} else if(GL_SUPPORT(NV_FENCE)) {
|
} else if(GL_SUPPORT(NV_FENCE)) {
|
||||||
|
@ -390,7 +395,17 @@ static HRESULT WINAPI IWineD3DQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIs
|
||||||
|
|
||||||
case WINED3DQUERYTYPE_EVENT: {
|
case WINED3DQUERYTYPE_EVENT: {
|
||||||
if (dwIssueFlags & WINED3DISSUE_END) {
|
if (dwIssueFlags & WINED3DISSUE_END) {
|
||||||
if(GL_SUPPORT(APPLE_FENCE)) {
|
WineD3DContext *ctx = ((WineQueryEventData *)This->extendedData)->ctx;
|
||||||
|
if(ctx != This->wineD3DDevice->activeContext || ctx->tid != GetCurrentThreadId()) {
|
||||||
|
/* GL fences can be used only from the context that created them,
|
||||||
|
* so if a different context is active, don't bother setting the query. The penalty
|
||||||
|
* of a context switch is most likely higher than the gain of a correct query result
|
||||||
|
*
|
||||||
|
* If the query is used from a different thread, don't bother creating a multithread
|
||||||
|
* context - there's no point in doing that as the query would be unusable anyway
|
||||||
|
*/
|
||||||
|
WARN("Query context not active\n");
|
||||||
|
} else if(GL_SUPPORT(APPLE_FENCE)) {
|
||||||
GL_EXTCALL(glSetFenceAPPLE(((WineQueryEventData *)This->extendedData)->fenceId));
|
GL_EXTCALL(glSetFenceAPPLE(((WineQueryEventData *)This->extendedData)->fenceId));
|
||||||
checkGLcall("glSetFenceAPPLE");
|
checkGLcall("glSetFenceAPPLE");
|
||||||
} else if (GL_SUPPORT(NV_FENCE)) {
|
} else if (GL_SUPPORT(NV_FENCE)) {
|
||||||
|
|
|
@ -1464,6 +1464,7 @@ typedef struct WineQueryOcclusionData {
|
||||||
|
|
||||||
typedef struct WineQueryEventData {
|
typedef struct WineQueryEventData {
|
||||||
GLuint fenceId;
|
GLuint fenceId;
|
||||||
|
WineD3DContext *ctx;
|
||||||
} WineQueryEventData;
|
} WineQueryEventData;
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
|
Loading…
Reference in New Issue