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
break;
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
* 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
}
case WINED3DQUERYTYPE_EVENT:
/* 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));
GL_EXTCALL(glGenFencesNV(1, &((WineQueryEventData *)(object->extendedData))->fenceId));
checkGLcall("glGenFencesNV");
......
......@@ -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);
gl_info->supported[NV_VERTEX_PROGRAM] = TRUE;
} 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
......@@ -807,9 +809,19 @@ BOOL IWineD3DImpl_FillGLCaps(IWineD3D *iface, Display* display) {
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);
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++;
}
}
......
......@@ -65,9 +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");
if(This->type == WINED3DQUERYTYPE_EVENT) {
if(GL_SUPPORT(APPLE_FENCE)) {
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)) {
GL_EXTCALL(glDeleteQueriesARB(1, &((WineQueryOcclusionData *)(This->extendedData))->queryId));
checkGLcall("glDeleteQueriesARB");
......@@ -162,7 +167,10 @@ static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pDa
case WINED3DQUERYTYPE_EVENT:
{
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));
checkGLcall("glTestFenceNV");
} else {
......@@ -381,13 +389,17 @@ static HRESULT WINAPI IWineD3DQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIs
break;
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));
} else if(dwIssueFlags & WINED3DISSUE_BEGIN) {
/* Started implicitly at device creation */
ERR("Event query issued with START flag - what to do?\n");
checkGLcall("glSetFenceNV");
}
} 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);
typedef void (APIENTRY * PGLFNFINISHFENCENVPROC) (GLuint);
typedef GLboolean (APIENTRY * PGLFNISFENCENVPROC) (GLuint);
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 */
#ifndef GL_VERSION_2_0
......@@ -1509,6 +1522,8 @@ typedef enum _GL_SupportedExt {
ATI_TEXTURE_ENV_COMBINE3,
ATI_TEXTURE_MIRROR_ONCE,
EXT_VERTEX_SHADER,
/* APPLE */
APPLE_FENCE,
OPENGL_SUPPORTED_EXT_END
} GL_SupportedExt;
......@@ -1708,6 +1723,15 @@ typedef enum _GL_SupportedExt {
USE_GL_FUNC(PGLFNFINISHFENCENVPROC, glFinishFenceNV); \
USE_GL_FUNC(PGLFNISFENCENVPROC, glIsFenceNV); \
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 */
#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