WINED3D: Add real occlusion query support
H. Verbeet
hverbeet at gmail.com
Mon Jul 24 17:51:33 CDT 2006
The current code for occlusion queries always returns 1 fom the number
of samples that passed the test. This isn't particularly usefull,
other than to keep applications running. This patch adds support for
real occlusion queries by using the ARB_occlusion_query extension if
available. Two checks for NV_OCCLUSION_QUERY were removed, since they
weren't being used for anything.
-------------- next part --------------
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index cd166d2..323a2f5 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1390,7 +1390,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
switch(Type) {
case WINED3DQUERYTYPE_OCCLUSION:
TRACE("(%p) occlusion query\n", This);
- if (GL_SUPPORT(ARB_OCCLUSION_QUERY) || GL_SUPPORT(NV_OCCLUSION_QUERY))
+ if (GL_SUPPORT(ARB_OCCLUSION_QUERY))
hr = WINED3D_OK;
else
WARN("Unsupported in local OpenGL implementation: ARB_OCCLUSION_QUERY/NV_OCCLUSION_QUERY\n");
@@ -1419,9 +1419,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl
/* allocated the 'extended' data based on the type of query requested */
switch(Type){
case D3DQUERYTYPE_OCCLUSION:
- if(GL_SUPPORT(ARB_OCCLUSION_QUERY) || GL_SUPPORT(NV_OCCLUSION_QUERY)) {
+ if(GL_SUPPORT(ARB_OCCLUSION_QUERY)) {
TRACE("(%p) Allocating data for an occlusion query\n", This);
object->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineQueryOcclusionData));
+ GL_EXTCALL(glGenQueriesARB(1, &((WineQueryOcclusionData *)(object->extendedData))->queryId));
break;
}
case D3DQUERYTYPE_VCACHE:
diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index e01c8dc..026a23a 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -25,10 +25,15 @@ #include "config.h"
#include "wined3d_private.h"
/*
-http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/programmingguide/advancedtopics/Queries.asp
-*/
+ * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/programmingguide/advancedtopics/Queries.asp
+ *
+ * Occlusion Queries:
+ * http://www.gris.uni-tuebingen.de/~bartz/Publications/paper/hww98.pdf
+ * http://oss.sgi.com/projects/ogl-sample/registry/ARB/occlusion_query.txt
+ */
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
+#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->wineD3DDevice)->wineD3D))->gl_info
/* *******************************************
IWineD3DQuery IUnknown parts follow
@@ -89,6 +94,9 @@ static HRESULT WINAPI IWineD3DQueryImpl
static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags){
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
+
+ TRACE("(%p) : type %#x, pData %p, dwSize %#lx, dwGetDataFlags %#lx\n", This, This->type, pData, dwSize, dwGetDataFlags);
+
if(dwSize == 0){
/*you can use this method to poll the resource for the query status*/
/*We return success(S_OK) if we support a feature, and faikure(S_FALSE) if we don't, just return success and fluff it for now*/
@@ -148,12 +156,15 @@ static HRESULT WINAPI IWineD3DQueryImpl
case WINED3DQUERYTYPE_OCCLUSION:
{
DWORD* data = pData;
- *data = 1;
- /* TODO: opengl occlusion queries
- http://www.gris.uni-tuebingen.de/~bartz/Publications/paper/hww98.pdf
- http://oss.sgi.com/projects/ogl-sample/registry/ARB/occlusion_query.txt
- http://oss.sgi.com/projects/ogl-sample/registry/ARB/occlusion_query.txt
- */
+ if (GL_SUPPORT(ARB_OCCLUSION_QUERY)) {
+ GLint samples;
+ GL_EXTCALL(glGetQueryObjectivARB(((WineQueryOcclusionData *)This->extendedData)->queryId, GL_QUERY_RESULT_ARB, &samples));
+ TRACE("(%p) : Returning %d samples.\n", This, samples);
+ *data = samples;
+ } else {
+ FIXME("(%p) : Occlusion queries not supported. Returning 1.\n", This);
+ *data = 1;
+ }
}
break;
case WINED3DQUERYTYPE_TIMESTAMP:
@@ -263,11 +274,6 @@ static DWORD WINAPI IWineD3DQueryImpl_G
break;
case WINED3DQUERYTYPE_OCCLUSION:
dataSize = sizeof(DWORD);
- /*
- http://www.gris.uni-tuebingen.de/~bartz/Publications/paper/hww98.pdf
- http://oss.sgi.com/projects/ogl-sample/registry/ARB/occlusion_query.txt
- http://oss.sgi.com/projects/ogl-sample/registry/ARB/occlusion_query.txt
- */
break;
case WINED3DQUERYTYPE_TIMESTAMP:
dataSize = sizeof(UINT64);
@@ -312,7 +318,28 @@ static WINED3DQUERYTYPE WINAPI IWineD3D
static HRESULT WINAPI IWineD3DQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIssueFlags){
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
- FIXME("(%p) : stub\n", This);
+
+ TRACE("(%p) : dwIssueFlags %#lx, type %#x\n", This, dwIssueFlags, This->type);
+
+ switch (This->type) {
+ case WINED3DQUERYTYPE_OCCLUSION:
+ if (GL_SUPPORT(ARB_OCCLUSION_QUERY)) {
+ if (dwIssueFlags & D3DISSUE_BEGIN) {
+ GL_EXTCALL(glBeginQueryARB(GL_SAMPLES_PASSED_ARB, ((WineQueryOcclusionData *)This->extendedData)->queryId));
+ }
+ if (dwIssueFlags & D3DISSUE_END) {
+ GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
+ }
+ } else {
+ FIXME("(%p) : Occlusion queries not supported\n", This);
+ }
+ break;
+
+ default:
+ FIXME("(%p) : Unhandled query type %#x\n", This, This->type);
+ break;
+ }
+
return WINED3D_OK; /* can be WINED3DERR_INVALIDCALL. */
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 813919a..1017c77 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1160,7 +1160,7 @@ extern const IWineD3DQueryVtbl IWineD3DQ
/* Datastructures for IWineD3DQueryImpl.extendedData */
typedef struct WineQueryOcclusionData {
- unsigned int queryId;
+ GLuint queryId;
} WineQueryOcclusionData;
diff --git a/include/wine/wined3d_gl.h b/include/wine/wined3d_gl.h
index 7937626..a0b96d6 100644
--- a/include/wine/wined3d_gl.h
+++ b/include/wine/wined3d_gl.h
@@ -1417,6 +1417,12 @@ #define GL_EXT_FUNCS_GEN \
USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2FARBPROC, glMultiTexCoord2fARB); \
USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD3FARBPROC, glMultiTexCoord3fARB); \
USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4FARBPROC, glMultiTexCoord4fARB); \
+ /* GL_ARB_occlusion_query */ \
+ USE_GL_FUNC(PGLFNGENQUERIESARBPROC, glGenQueriesARB); \
+ USE_GL_FUNC(PGLFNDELETEQUERIESARBPROC, glDeleteQueriesARB); \
+ USE_GL_FUNC(PGLFNBEGINQUERYARBPROC, glBeginQueryARB); \
+ USE_GL_FUNC(PGLFNENDQUERYARBPROC, glEndQueryARB); \
+ USE_GL_FUNC(PGLFNGETQUERYOBJECTIVARBPROC, glGetQueryObjectivARB); \
/* GL_ARB_point_parameters */ \
USE_GL_FUNC(PGLFNGLPOINTPARAMETERFARBPROC, glPointParameterfARB); \
USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVARBPROC, glPointParameterfvARB); \
More information about the wine-patches
mailing list