Commit 76b60b05 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Support event queries using GL_NV_fence.

parent be8e9e17
......@@ -1075,10 +1075,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINE
break;
case WINED3DQUERYTYPE_EVENT:
/* Half-Life 2 needs this query. It does not render the main menu correctly otherwise
* Pretend to support it, faking this query does not do much harm except potentially lowering performance
*/
FIXME("(%p) Event query: Unimplemented, but pretending to be supported\n", This);
if(!GL_SUPPORT(NV_FENCE)) {
/* Half-Life 2 needs this query. It does not render the main menu correctly otherwise
* Pretend to support it, faking this query does not do much harm except potentially lowering performance
*/
FIXME("(%p) Event query: Unimplemented, but pretending to be supported\n", This);
}
hr = WINED3D_OK;
break;
......@@ -1112,10 +1114,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINE
GL_EXTCALL(glGenQueriesARB(1, &((WineQueryOcclusionData *)(object->extendedData))->queryId));
break;
}
case WINED3DQUERYTYPE_EVENT:
/* TODO: GL_APPLE_fence */
if(GL_SUPPORT(NV_FENCE)) {
object->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineQueryEventData));
GL_EXTCALL(glGenFencesNV(1, &((WineQueryEventData *)(object->extendedData))->fenceId));
checkGLcall("glGenFencesNV");
}
break;
case WINED3DQUERYTYPE_VCACHE:
case WINED3DQUERYTYPE_RESOURCEMANAGER:
case WINED3DQUERYTYPE_VERTEXSTATS:
case WINED3DQUERYTYPE_EVENT:
case WINED3DQUERYTYPE_TIMESTAMP:
case WINED3DQUERYTYPE_TIMESTAMPDISJOINT:
case WINED3DQUERYTYPE_TIMESTAMPFREQ:
......
......@@ -65,6 +65,14 @@ static ULONG WINAPI IWineD3DQueryImpl_Release(IWineD3DQuery *iface) {
TRACE("(%p) : Releasing from %d\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
if(This->type == WINED3DQUERYTYPE_EVENT && GL_SUPPORT(NV_FENCE)) {
GL_EXTCALL(glDeleteFencesNV(1, &((WineQueryEventData *)(This->extendedData))->fenceId));
checkGLcall("glDeleteFencesNV");
} else if(This->type == WINED3DQUERYTYPE_OCCLUSION && GL_SUPPORT(ARB_OCCLUSION_QUERY)) {
GL_EXTCALL(glDeleteQueriesARB(1, &((WineQueryOcclusionData *)(This->extendedData))->queryId));
checkGLcall("glDeleteQueriesARB");
}
HeapFree(GetProcessHeap(), 0, This->extendedData);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -154,8 +162,13 @@ static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pDa
case WINED3DQUERYTYPE_EVENT:
{
BOOL* data = pData;
FIXME("(%p): Unimplemented query WINED3DQUERYTYPE_EVENT\n", This);
*data = TRUE; /*Don't know what this is supposed to be*/
if(GL_SUPPORT(NV_FENCE)) {
*data = GL_EXTCALL(glTestFenceNV(((WineQueryEventData *)This->extendedData)->fenceId));
checkGLcall("glTestFenceNV");
} else {
WARN("(%p): reporting GPU idle\n", This);
*data = TRUE;
}
}
break;
case WINED3DQUERYTYPE_OCCLUSION:
......@@ -367,6 +380,17 @@ static HRESULT WINAPI IWineD3DQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIs
}
break;
case WINED3DQUERYTYPE_EVENT: {
if (GL_SUPPORT(GL_NV_fence)) {
if (dwIssueFlags & WINED3DISSUE_END) {
GL_EXTCALL(glSetFenceNV(((WineQueryEventData *)This->extendedData)->fenceId, GL_ALL_COMPLETED_NV));
} else if(dwIssueFlags & WINED3DISSUE_BEGIN) {
/* Started implicitly at device creation */
ERR("Event query issued with START flag - what to do?\n");
}
}
}
default:
/* The fixme is printed when the app asks for the resulting data */
WARN("(%p) : Unhandled query type %#x\n", This, This->type);
......
......@@ -1339,6 +1339,9 @@ typedef struct WineQueryOcclusionData {
GLuint queryId;
} WineQueryOcclusionData;
typedef struct WineQueryEventData {
GLuint fenceId;
} WineQueryEventData;
/*****************************************************************************
* IWineD3DSwapChainImpl implementation structure (extends IUnknown)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment