Implemented occlusion queries using either GL_ARB_occlusion_query or

GL_NV_occlusion_query.
This commit is contained in:
Oliver Stieber 2005-09-21 09:43:13 +00:00 committed by Alexandre Julliard
parent f7eb64ce97
commit 5ea96a851f
4 changed files with 93 additions and 3 deletions

View File

@ -991,7 +991,6 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINED3DQUER
case WINED3DQUERYTYPE_RESOURCEMANAGER: case WINED3DQUERYTYPE_RESOURCEMANAGER:
case WINED3DQUERYTYPE_VERTEXSTATS: case WINED3DQUERYTYPE_VERTEXSTATS:
case WINED3DQUERYTYPE_EVENT: case WINED3DQUERYTYPE_EVENT:
case WINED3DQUERYTYPE_OCCLUSION:
case WINED3DQUERYTYPE_TIMESTAMP: case WINED3DQUERYTYPE_TIMESTAMP:
case WINED3DQUERYTYPE_TIMESTAMPDISJOINT: case WINED3DQUERYTYPE_TIMESTAMPDISJOINT:
case WINED3DQUERYTYPE_TIMESTAMPFREQ: case WINED3DQUERYTYPE_TIMESTAMPFREQ:
@ -1001,6 +1000,10 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINED3DQUER
case WINED3DQUERYTYPE_PIXELTIMINGS: case WINED3DQUERYTYPE_PIXELTIMINGS:
case WINED3DQUERYTYPE_BANDWIDTHTIMINGS: case WINED3DQUERYTYPE_BANDWIDTHTIMINGS:
case WINED3DQUERYTYPE_CACHEUTILIZATION: case WINED3DQUERYTYPE_CACHEUTILIZATION:
break;
case WINED3DQUERYTYPE_OCCLUSION:
TRACE("(%p) occlusion query\n", This);
if (GL_SUPPORT(ARB_OCCLUSION_QUERY) || GL_SUPPORT(NV_OCCLUSION_QUERY))
hr = D3D_OK; hr = D3D_OK;
break; break;
default: default:
@ -1012,7 +1015,31 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINED3DQUER
D3DCREATEOBJECTINSTANCE(object, Query) D3DCREATEOBJECTINSTANCE(object, Query)
object->type = Type; object->type = Type;
/* 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)) {
TRACE("(%p) Allocating data for an occlusion query\n", This);
object->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineQueryOcclusionData));
break;
}
case D3DQUERYTYPE_VCACHE:
case D3DQUERYTYPE_RESOURCEMANAGER:
case D3DQUERYTYPE_VERTEXSTATS:
case D3DQUERYTYPE_EVENT:
case D3DQUERYTYPE_TIMESTAMP:
case D3DQUERYTYPE_TIMESTAMPDISJOINT:
case D3DQUERYTYPE_TIMESTAMPFREQ:
case D3DQUERYTYPE_PIPELINETIMINGS:
case D3DQUERYTYPE_INTERFACETIMINGS:
case D3DQUERYTYPE_VERTEXTIMINGS:
case D3DQUERYTYPE_PIXELTIMINGS:
case D3DQUERYTYPE_BANDWIDTHTIMINGS:
case D3DQUERYTYPE_CACHEUTILIZATION:
default:
object->extendedData = 0; object->extendedData = 0;
FIXME("(%p) Unhandled query type %d\n",This , Type);
}
TRACE("(%p) : Created Query %p\n", This, object); TRACE("(%p) : Created Query %p\n", This, object);
return D3D_OK; return D3D_OK;
} }

View File

@ -470,6 +470,9 @@ static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display)
} else if (strcmp(ThisExtn, "GL_ARB_vertex_buffer_object") == 0) { } else if (strcmp(ThisExtn, "GL_ARB_vertex_buffer_object") == 0) {
TRACE_(d3d_caps)(" FOUND: ARB Vertex Buffer support\n"); TRACE_(d3d_caps)(" FOUND: ARB Vertex Buffer support\n");
gl_info->supported[ARB_VERTEX_BUFFER_OBJECT] = TRUE; gl_info->supported[ARB_VERTEX_BUFFER_OBJECT] = TRUE;
} else if (strcmp(ThisExtn, "GL_ARB_occlusion_query") == 0) {
TRACE_(d3d_caps)(" FOUND: ARB Occlusion Query support\n");
gl_info->supported[ARB_OCCLUSION_QUERY] = TRUE;
/** /**
* EXT * EXT
*/ */
@ -545,6 +548,9 @@ static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display)
} else if (strcmp(ThisExtn, "GL_NV_texture_shader3") == 0) { } else if (strcmp(ThisExtn, "GL_NV_texture_shader3") == 0) {
TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Texture Shader (3) support\n"); TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Texture Shader (3) support\n");
gl_info->supported[NV_TEXTURE_SHADER3] = TRUE; gl_info->supported[NV_TEXTURE_SHADER3] = TRUE;
} else if (strcmp(ThisExtn, "GL_NV_occlusion_query") == 0) {
TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Occlusion Query (3) support\n");
gl_info->supported[NV_OCCLUSION_QUERY] = TRUE;
} else if (strstr(ThisExtn, "GL_NV_vertex_program")) { } else if (strstr(ThisExtn, "GL_NV_vertex_program")) {
gl_info->vs_nv_version = max(gl_info->vs_nv_version, (0 == strcmp(ThisExtn, "GL_NV_vertex_program1_1")) ? VS_VERSION_11 : VS_VERSION_10); gl_info->vs_nv_version = max(gl_info->vs_nv_version, (0 == strcmp(ThisExtn, "GL_NV_vertex_program1_1")) ? VS_VERSION_11 : VS_VERSION_10);
gl_info->vs_nv_version = max(gl_info->vs_nv_version, (0 == strcmp(ThisExtn, "GL_NV_vertex_program2")) ? VS_VERSION_20 : VS_VERSION_10); gl_info->vs_nv_version = max(gl_info->vs_nv_version, (0 == strcmp(ThisExtn, "GL_NV_vertex_program2")) ? VS_VERSION_20 : VS_VERSION_10);

View File

@ -971,6 +971,7 @@ typedef struct IWineD3DQueryImpl
/* IWineD3DQuery fields */ /* IWineD3DQuery fields */
D3DQUERYTYPE type; D3DQUERYTYPE type;
/* TODO: Think about using a IUnknown instead of a void* */
void *extendedData; void *extendedData;
@ -978,6 +979,12 @@ typedef struct IWineD3DQueryImpl
extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl; extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl;
/* Datastructures for IWineD3DQueryImpl.extendedData */
typedef struct WineQueryOcclusionData {
unsigned int queryId;
} WineQueryOcclusionData;
/***************************************************************************** /*****************************************************************************
* IWineD3DSwapChainImpl implementation structure (extends IUnknown) * IWineD3DSwapChainImpl implementation structure (extends IUnknown)
*/ */

View File

@ -666,6 +666,54 @@ typedef void (APIENTRY * PGLFNGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage,
#define GL_COORD_REPLACE_ARB 0x8862 #define GL_COORD_REPLACE_ARB 0x8862
#endif #endif
/* TODO: GL_NV_point_sprite */
/* Occlusion Queries */
typedef void (APIENTRY * PGLFNGENQUERIESARBPROC) (GLsizei n, GLuint *queries);
typedef void (APIENTRY * PGLFNDELETEQUERIESARBPROC) (GLsizei n, const GLuint *queries);
typedef GLboolean (APIENTRY * PGLFNISQUERYARBPROC) (GLuint query);
typedef void (APIENTRY * PGLFNBEGINQUERYARBPROC) (GLenum target, GLuint query);
typedef void (APIENTRY * PGLFNENDQUERYARBPROC) (GLenum target);
typedef void (APIENTRY * PGLFNGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params);
typedef void (APIENTRY * PGLFNGETQUERYOBJECTIVARBPROC) (GLuint query, GLenum pname, GLint *params);
typedef void (APIENTRY * PGLFNGETQUERYOBJECTUIVARBPROC) (GLuint query, GLenum pname, GLuint *params);
#ifndef GL_ARB_occlusion_query
#define GL_ARB_occlusion_query 1
#define GL_SAMPLES_PASSED_ARB 0x8914
#define GL_QUERY_COUNTER_BITS_ARB 0x8864
#define GL_CURRENT_QUERY_ARB 0x8865
#define GL_QUERY_RESULT_ARB 0x8866
#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867
#endif
typedef void (APIENTRY * PGLFNGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids);
typedef void (APIENTRY * PGLFNDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids);
typedef GLboolean (APIENTRY * PGLFNISOCCLUSIONQUERYNVPROC) (GLuint id);
typedef void (APIENTRY * PGLFNBEGINOCCLUSIONQUERYNVPROC) (GLuint id);
typedef void (APIENTRY * PGLFNENDOCCLUSIONQUERYNVPROC) (void);
typedef void (APIENTRY * PGLFNGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params);
typedef void (APIENTRY * PGLFNGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params);
/* GL_HP_occlusion_test isn't complete, but it's constants are used by GL_NV_occlusion_query */
#ifndef GL_HP_occlusion_test
#define GL_HP_occlusion_test 1
#define GL_OCCLUSION_TEST_HP 0x8165
#define GL_OCCLUSION_TEST_RESULT_HP 0x8165
#endif
#ifndef GL_NV_occlusion_query
#define GL_NV_occlusion_query 1
#define GL_PIXEL_COUNTER_BITS_NV 0x8864
#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865
#define GL_PIXEL_COUNT_NV 0x8866
#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867
#endif
/**************************************************** /****************************************************
* OpenGL Official Version * OpenGL Official Version
@ -762,6 +810,7 @@ typedef enum _GL_SupportedExt {
ARB_FRAGMENT_PROGRAM, ARB_FRAGMENT_PROGRAM,
ARB_MULTISAMPLE, ARB_MULTISAMPLE,
ARB_MULTITEXTURE, ARB_MULTITEXTURE,
ARB_OCCLUSION_QUERY,
ARB_POINT_PARAMETERS, ARB_POINT_PARAMETERS,
ARB_POINT_SPRITE, ARB_POINT_SPRITE,
ARB_TEXTURE_COMPRESSION, ARB_TEXTURE_COMPRESSION,
@ -792,6 +841,7 @@ typedef enum _GL_SupportedExt {
/* NVIDIA */ /* NVIDIA */
NV_FOG_DISTANCE, NV_FOG_DISTANCE,
NV_FRAGMENT_PROGRAM, NV_FRAGMENT_PROGRAM,
NV_OCCLUSION_QUERY,
NV_REGISTER_COMBINERS, NV_REGISTER_COMBINERS,
NV_REGISTER_COMBINERS2, NV_REGISTER_COMBINERS2,
NV_TEXGEN_REFLECTION, NV_TEXGEN_REFLECTION,