Commit 95efeb7e authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Support GL_APPLE_fence for event queries.

parent 76b60b05
...@@ -1075,7 +1075,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINE ...@@ -1075,7 +1075,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINE
break; break;
case WINED3DQUERYTYPE_EVENT: case WINED3DQUERYTYPE_EVENT:
if(!GL_SUPPORT(NV_FENCE)) { if(!(GL_SUPPORT(NV_FENCE) || GL_SUPPORT(APPLE_FENCE) )) {
/* Half-Life 2 needs this query. It does not render the main menu correctly otherwise /* 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 * Pretend to support it, faking this query does not do much harm except potentially lowering performance
*/ */
...@@ -1116,7 +1116,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINE ...@@ -1116,7 +1116,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINE
} }
case WINED3DQUERYTYPE_EVENT: case WINED3DQUERYTYPE_EVENT:
/* TODO: GL_APPLE_fence */ /* TODO: GL_APPLE_fence */
if(GL_SUPPORT(NV_FENCE)) { if(GL_SUPPORT(APPLE_FENCE)) {
object->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineQueryEventData));
GL_EXTCALL(glGenFencesAPPLE(1, &((WineQueryEventData *)(object->extendedData))->fenceId));
checkGLcall("glGenFencesAPPLE");
} 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");
......
...@@ -788,7 +788,9 @@ BOOL IWineD3DImpl_FillGLCaps(IWineD3D *iface, Display* display) { ...@@ -788,7 +788,9 @@ BOOL IWineD3DImpl_FillGLCaps(IWineD3D *iface, Display* display) {
TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Vertex Shader support - version=%02x\n", gl_info->vs_nv_version); TRACE_(d3d_caps)(" FOUND: NVIDIA (NV) Vertex Shader support - version=%02x\n", gl_info->vs_nv_version);
gl_info->supported[NV_VERTEX_PROGRAM] = TRUE; gl_info->supported[NV_VERTEX_PROGRAM] = TRUE;
} else if (strstr(ThisExtn, "GL_NV_fence")) { } else if (strstr(ThisExtn, "GL_NV_fence")) {
gl_info->supported[NV_FENCE] = TRUE; if(!gl_info->supported[APPLE_FENCE]) {
gl_info->supported[NV_FENCE] = TRUE;
}
/** /**
* ATI * ATI
...@@ -807,9 +809,19 @@ BOOL IWineD3DImpl_FillGLCaps(IWineD3D *iface, Display* display) { ...@@ -807,9 +809,19 @@ BOOL IWineD3DImpl_FillGLCaps(IWineD3D *iface, Display* display) {
gl_info->vs_ati_version = VS_VERSION_11; gl_info->vs_ati_version = VS_VERSION_11;
TRACE_(d3d_caps)(" FOUND: ATI (EXT) Vertex Shader support - version=%02x\n", gl_info->vs_ati_version); TRACE_(d3d_caps)(" FOUND: ATI (EXT) Vertex Shader support - version=%02x\n", gl_info->vs_ati_version);
gl_info->supported[EXT_VERTEX_SHADER] = TRUE; gl_info->supported[EXT_VERTEX_SHADER] = TRUE;
/**
* Apple
*/
} else if (strstr(ThisExtn, "GL_APPLE_fence")) {
/* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
* The apple extension interacts with some other apple exts. Disable the NV
* extension if the apple one is support to prevent confusion in other parts
* of the code
*/
gl_info->supported[NV_FENCE] = FALSE;
gl_info->supported[APPLE_FENCE] = TRUE;
} }
if (*GL_Extensions == ' ') GL_Extensions++; if (*GL_Extensions == ' ') GL_Extensions++;
} }
} }
......
...@@ -65,9 +65,14 @@ static ULONG WINAPI IWineD3DQueryImpl_Release(IWineD3DQuery *iface) { ...@@ -65,9 +65,14 @@ static ULONG WINAPI IWineD3DQueryImpl_Release(IWineD3DQuery *iface) {
TRACE("(%p) : Releasing from %d\n", This, This->ref); TRACE("(%p) : Releasing from %d\n", This, This->ref);
ref = InterlockedDecrement(&This->ref); ref = InterlockedDecrement(&This->ref);
if (ref == 0) { if (ref == 0) {
if(This->type == WINED3DQUERYTYPE_EVENT && GL_SUPPORT(NV_FENCE)) { if(This->type == WINED3DQUERYTYPE_EVENT) {
GL_EXTCALL(glDeleteFencesNV(1, &((WineQueryEventData *)(This->extendedData))->fenceId)); if(GL_SUPPORT(APPLE_FENCE)) {
checkGLcall("glDeleteFencesNV"); GL_EXTCALL(glDeleteFencesAPPLE(1, &((WineQueryEventData *)(This->extendedData))->fenceId));
checkGLcall("glDeleteFencesAPPLE");
} else if(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)) { } else if(This->type == WINED3DQUERYTYPE_OCCLUSION && GL_SUPPORT(ARB_OCCLUSION_QUERY)) {
GL_EXTCALL(glDeleteQueriesARB(1, &((WineQueryOcclusionData *)(This->extendedData))->queryId)); GL_EXTCALL(glDeleteQueriesARB(1, &((WineQueryOcclusionData *)(This->extendedData))->queryId));
checkGLcall("glDeleteQueriesARB"); checkGLcall("glDeleteQueriesARB");
...@@ -162,7 +167,10 @@ static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pDa ...@@ -162,7 +167,10 @@ static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pDa
case WINED3DQUERYTYPE_EVENT: case WINED3DQUERYTYPE_EVENT:
{ {
BOOL* data = pData; BOOL* data = pData;
if(GL_SUPPORT(NV_FENCE)) { if(GL_SUPPORT(APPLE_FENCE)) {
*data = GL_EXTCALL(glTestFenceAPPLE(((WineQueryEventData *)This->extendedData)->fenceId));
checkGLcall("glTestFenceAPPLE");
} else if(GL_SUPPORT(NV_FENCE)) {
*data = GL_EXTCALL(glTestFenceNV(((WineQueryEventData *)This->extendedData)->fenceId)); *data = GL_EXTCALL(glTestFenceNV(((WineQueryEventData *)This->extendedData)->fenceId));
checkGLcall("glTestFenceNV"); checkGLcall("glTestFenceNV");
} else { } else {
...@@ -381,13 +389,17 @@ static HRESULT WINAPI IWineD3DQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIs ...@@ -381,13 +389,17 @@ static HRESULT WINAPI IWineD3DQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIs
break; break;
case WINED3DQUERYTYPE_EVENT: { case WINED3DQUERYTYPE_EVENT: {
if (GL_SUPPORT(GL_NV_fence)) { if (dwIssueFlags & WINED3DISSUE_END) {
if (dwIssueFlags & WINED3DISSUE_END) { if(GL_SUPPORT(APPLE_FENCE)) {
GL_EXTCALL(glSetFenceAPPLE(((WineQueryEventData *)This->extendedData)->fenceId));
checkGLcall("glSetFenceAPPLE");
} else if (GL_SUPPORT(NV_FENCE)) {
GL_EXTCALL(glSetFenceNV(((WineQueryEventData *)This->extendedData)->fenceId, GL_ALL_COMPLETED_NV)); GL_EXTCALL(glSetFenceNV(((WineQueryEventData *)This->extendedData)->fenceId, GL_ALL_COMPLETED_NV));
} else if(dwIssueFlags & WINED3DISSUE_BEGIN) { checkGLcall("glSetFenceNV");
/* Started implicitly at device creation */
ERR("Event query issued with START flag - what to do?\n");
} }
} else if(dwIssueFlags & WINED3DISSUE_BEGIN) {
/* Started implicitly at device creation */
ERR("Event query issued with START flag - what to do?\n");
} }
} }
......
...@@ -1146,6 +1146,19 @@ typedef GLboolean (APIENTRY * PGLFNTESTFENCENVPROC) (GLuint); ...@@ -1146,6 +1146,19 @@ typedef GLboolean (APIENTRY * PGLFNTESTFENCENVPROC) (GLuint);
typedef void (APIENTRY * PGLFNFINISHFENCENVPROC) (GLuint); typedef void (APIENTRY * PGLFNFINISHFENCENVPROC) (GLuint);
typedef GLboolean (APIENTRY * PGLFNISFENCENVPROC) (GLuint); typedef GLboolean (APIENTRY * PGLFNISFENCENVPROC) (GLuint);
typedef void (APIENTRY * PGLFNGETFENCEIVNVPROC) (GLuint, GLenum, GLint *); typedef void (APIENTRY * PGLFNGETFENCEIVNVPROC) (GLuint, GLenum, GLint *);
/* GL_APPLE_fence */
#ifndef GL_NV_fence
#define GL_DRAW_PIXELS_APPLE 0x8A0A
#define GL_FENCE_APPLE 0x84F3
#endif
typedef void (APIENTRY * PGLFNGENFENCESAPPLEPROC) (GLsizei, GLuint *);
typedef void (APIENTRY * PGLFNDELETEFENCESAPPLEPROC) (GLuint, const GLuint *);
typedef void (APIENTRY * PGLFNSETFENCEAPPLEPROC) (GLuint);
typedef GLboolean (APIENTRY * PGLFNTESTFENCEAPPLEPROC) (GLuint);
typedef void (APIENTRY * PGLFNFINISHFENCEAPPLEPROC) (GLuint);
typedef GLboolean (APIENTRY * PGLFNISFENCEAPPLEPROC) (GLuint);
typedef GLboolean (APIENTRY * PGLFNTESTOBJECTAPPLEPROC) (GLenum, GLuint);
typedef void (APIENTRY * PGLFNFINISHOBJECTAPPLEPROC) (GLenum, GLuint);
/* GL_VERSION_2_0 */ /* GL_VERSION_2_0 */
#ifndef GL_VERSION_2_0 #ifndef GL_VERSION_2_0
...@@ -1509,6 +1522,8 @@ typedef enum _GL_SupportedExt { ...@@ -1509,6 +1522,8 @@ typedef enum _GL_SupportedExt {
ATI_TEXTURE_ENV_COMBINE3, ATI_TEXTURE_ENV_COMBINE3,
ATI_TEXTURE_MIRROR_ONCE, ATI_TEXTURE_MIRROR_ONCE,
EXT_VERTEX_SHADER, EXT_VERTEX_SHADER,
/* APPLE */
APPLE_FENCE,
OPENGL_SUPPORTED_EXT_END OPENGL_SUPPORTED_EXT_END
} GL_SupportedExt; } GL_SupportedExt;
...@@ -1708,6 +1723,15 @@ typedef enum _GL_SupportedExt { ...@@ -1708,6 +1723,15 @@ typedef enum _GL_SupportedExt {
USE_GL_FUNC(PGLFNFINISHFENCENVPROC, glFinishFenceNV); \ USE_GL_FUNC(PGLFNFINISHFENCENVPROC, glFinishFenceNV); \
USE_GL_FUNC(PGLFNISFENCENVPROC, glIsFenceNV); \ USE_GL_FUNC(PGLFNISFENCENVPROC, glIsFenceNV); \
USE_GL_FUNC(PGLFNGETFENCEIVNVPROC, glGetFenceivNV); \ USE_GL_FUNC(PGLFNGETFENCEIVNVPROC, glGetFenceivNV); \
/* GL_APPLE_fence */ \
USE_GL_FUNC(PGLFNGENFENCESAPPLEPROC, glGenFencesAPPLE); \
USE_GL_FUNC(PGLFNDELETEFENCESAPPLEPROC, glDeleteFencesAPPLE); \
USE_GL_FUNC(PGLFNSETFENCEAPPLEPROC, glSetFenceAPPLE); \
USE_GL_FUNC(PGLFNTESTFENCEAPPLEPROC, glTestFenceAPPLE); \
USE_GL_FUNC(PGLFNFINISHFENCEAPPLEPROC, glFinishFenceAPPLE); \
USE_GL_FUNC(PGLFNISFENCEAPPLEPROC, glIsFenceAPPLE); \
USE_GL_FUNC(PGLFNTESTOBJECTAPPLEPROC, glTestObjectAPPLE); \
USE_GL_FUNC(PGLFNFINISHOBJECTAPPLEPROC, glFinishObjectAPPLE); \
/* OpenGL 2.0 functions */ /* OpenGL 2.0 functions */
#define GL2_FUNCS_GEN \ #define GL2_FUNCS_GEN \
......
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