From 3b035e09854ba0099325c108e966d0d27234aca3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Tue, 26 Jan 2010 15:28:40 +0100
Subject: [PATCH 01/18] WineD3D: Remove the remains of the occlusion query faking code

query_init already rejects the creation of occlusion queries if the GL extension is not supported. All dx8+ cards support this by now with a driver that is up to
date(including the latest fglrx version that supports r500 cards and Mesa on r200 and intel cards)
---
 dlls/wined3d/query.c |  113 ++++++++++++++++++++++----------------------------
 1 files changed, 50 insertions(+), 63 deletions(-)

diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c
index 85d5311..3f1203a 100644
--- a/dlls/wined3d/query.c
+++ b/dlls/wined3d/query.c
@@ -131,13 +131,6 @@ static HRESULT  WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface,
         return S_FALSE;
     }
 
-    if (!gl_info->supported[ARB_OCCLUSION_QUERY])
-    {
-        WARN("(%p) : Occlusion queries not supported. Returning 1.\n", This);
-        *data = 1;
-        return S_OK;
-    }
-
     if (query->context->tid != GetCurrentThreadId())
     {
         FIXME("%p Wrong thread, returning 1.\n", This);
@@ -347,75 +340,69 @@ static HRESULT  WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface,  D
     IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface;
     IWineD3DDeviceImpl *device = This->device;
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+    struct wined3d_occlusion_query *query = This->extendedData;
+    struct wined3d_context *context;
 
-    if (gl_info->supported[ARB_OCCLUSION_QUERY])
+    /* This is allowed according to msdn and our tests. Reset the query and restart */
+    if (dwIssueFlags & WINED3DISSUE_BEGIN)
     {
-        struct wined3d_occlusion_query *query = This->extendedData;
-        struct wined3d_context *context;
-
-        /* This is allowed according to msdn and our tests. Reset the query and restart */
-        if (dwIssueFlags & WINED3DISSUE_BEGIN)
+        if (This->state == QUERY_BUILDING)
         {
-            if (This->state == QUERY_BUILDING)
+            if (query->context->tid != GetCurrentThreadId())
             {
-                if (query->context->tid != GetCurrentThreadId())
-                {
-                    FIXME("Wrong thread, can't restart query.\n");
-
-                    context_free_occlusion_query(query);
-                    context = context_acquire(This->device, NULL, CTXUSAGE_RESOURCELOAD);
-                    context_alloc_occlusion_query(context, query);
-                }
-                else
-                {
-                    context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
-
-                    ENTER_GL();
-                    GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
-                    checkGLcall("glEndQuery()");
-                    LEAVE_GL();
-                }
+                FIXME("Wrong thread, can't restart query.\n");
+
+                context_free_occlusion_query(query);
+                context = context_acquire(This->device, NULL, CTXUSAGE_RESOURCELOAD);
+                context_alloc_occlusion_query(context, query);
             }
             else
             {
-                if (query->context) context_free_occlusion_query(query);
-                context = context_acquire(This->device, NULL, CTXUSAGE_RESOURCELOAD);
-                context_alloc_occlusion_query(context, query);
+                context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
+
+                ENTER_GL();
+                GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
+                checkGLcall("glEndQuery()");
+                LEAVE_GL();
             }
+        }
+        else
+        {
+            if (query->context) context_free_occlusion_query(query);
+            context = context_acquire(This->device, NULL, CTXUSAGE_RESOURCELOAD);
+            context_alloc_occlusion_query(context, query);
+        }
 
-            ENTER_GL();
-            GL_EXTCALL(glBeginQueryARB(GL_SAMPLES_PASSED_ARB, query->id));
-            checkGLcall("glBeginQuery()");
-            LEAVE_GL();
+        ENTER_GL();
+        GL_EXTCALL(glBeginQueryARB(GL_SAMPLES_PASSED_ARB, query->id));
+        checkGLcall("glBeginQuery()");
+        LEAVE_GL();
 
-            context_release(context);
-        }
-        if (dwIssueFlags & WINED3DISSUE_END) {
-            /* Msdn says _END on a non-building occlusion query returns an error, but
-             * our tests show that it returns OK. But OpenGL doesn't like it, so avoid
-             * generating an error
-             */
-            if (This->state == QUERY_BUILDING)
+        context_release(context);
+    }
+    if (dwIssueFlags & WINED3DISSUE_END) {
+        /* Msdn says _END on a non-building occlusion query returns an error, but
+         * our tests show that it returns OK. But OpenGL doesn't like it, so avoid
+         * generating an error
+         */
+        if (This->state == QUERY_BUILDING)
+        {
+            if (query->context->tid != GetCurrentThreadId())
+            {
+                FIXME("Wrong thread, can't end query.\n");
+            }
+            else
             {
-                if (query->context->tid != GetCurrentThreadId())
-                {
-                    FIXME("Wrong thread, can't end query.\n");
-                }
-                else
-                {
-                    context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
-
-                    ENTER_GL();
-                    GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
-                    checkGLcall("glEndQuery()");
-                    LEAVE_GL();
-
-                    context_release(context);
-                }
+                context = context_acquire(This->device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
+
+                ENTER_GL();
+                GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
+                checkGLcall("glEndQuery()");
+                LEAVE_GL();
+
+                context_release(context);
             }
         }
-    } else {
-        FIXME("(%p) : Occlusion queries not supported\n", This);
     }
 
     if(dwIssueFlags & WINED3DISSUE_BEGIN) {
-- 
1.6.4.4

