st/nine: Queries: Use gallium caps to get if queries are supported. (v2)
authorAxel Davy <axel.davy@ens.fr>
Mon, 24 Nov 2014 21:59:21 +0000 (22:59 +0100)
committerAxel Davy <axel.davy@ens.fr>
Wed, 3 Dec 2014 15:39:24 +0000 (16:39 +0100)
Some queries need the driver to advertise a cap to be supported.
For example r300 doesn't support them.

v2 (David): check also for PIPE_CAP_QUERY_PIPELINE_STATISTICS, fix wine
            tests on r300g

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/device9.c
src/gallium/state_trackers/nine/query9.c
src/gallium/state_trackers/nine/query9.h

index c16f7284799a445a07cbf4792f6a2b0d98762d61..e9599b853c021f939783257dc41722c00a5690cd 100644 (file)
@@ -3359,7 +3359,7 @@ NineDevice9_CreateQuery( struct NineDevice9 *This,
 
     DBG("This=%p Type=%d ppQuery=%p\n", This, Type, ppQuery);
 
-    hr = nine_is_query_supported(Type);
+    hr = nine_is_query_supported(This->screen, Type);
     if (!ppQuery || hr != D3D_OK)
         return hr;
 
index 5e301442dead3aa9d3364acbd03ccecaf65e2d7a..17c36e510fc1c6ba04ec7de9023eb4b27c9e6df8 100644 (file)
 #include "device9.h"
 #include "query9.h"
 #include "nine_helpers.h"
+#include "pipe/p_screen.h"
 #include "pipe/p_context.h"
 #include "util/u_math.h"
 #include "nine_dump.h"
 
 #define DBG_CHANNEL DBG_QUERY
 
-#define QUERY_TYPE_MAP_CASE(a, b) case D3DQUERYTYPE_##a: return PIPE_QUERY_##b
 static inline unsigned
-d3dquerytype_to_pipe_query(D3DQUERYTYPE type)
+d3dquerytype_to_pipe_query(struct pipe_screen *screen, D3DQUERYTYPE type)
 {
     switch (type) {
-    QUERY_TYPE_MAP_CASE(EVENT, GPU_FINISHED);
-    QUERY_TYPE_MAP_CASE(OCCLUSION, OCCLUSION_COUNTER);
-    QUERY_TYPE_MAP_CASE(TIMESTAMP, TIMESTAMP);
-    QUERY_TYPE_MAP_CASE(TIMESTAMPDISJOINT, TIMESTAMP_DISJOINT);
-    QUERY_TYPE_MAP_CASE(TIMESTAMPFREQ, TIMESTAMP_DISJOINT);
-    QUERY_TYPE_MAP_CASE(VERTEXSTATS, PIPELINE_STATISTICS);
-    case D3DQUERYTYPE_VCACHE:
-    case D3DQUERYTYPE_RESOURCEMANAGER:
-    case D3DQUERYTYPE_PIPELINETIMINGS:
-    case D3DQUERYTYPE_INTERFACETIMINGS:
-    case D3DQUERYTYPE_VERTEXTIMINGS:
-    case D3DQUERYTYPE_PIXELTIMINGS:
-    case D3DQUERYTYPE_BANDWIDTHTIMINGS:
-    case D3DQUERYTYPE_CACHEUTILIZATION:
-       return PIPE_QUERY_TYPES;
+    case D3DQUERYTYPE_EVENT:
+        return PIPE_QUERY_GPU_FINISHED;
+    case D3DQUERYTYPE_OCCLUSION:
+        return screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY) ?
+               PIPE_QUERY_OCCLUSION_COUNTER : PIPE_QUERY_TYPES;
+    case D3DQUERYTYPE_TIMESTAMP:
+        return screen->get_param(screen, PIPE_CAP_QUERY_TIMESTAMP) ?
+               PIPE_QUERY_TIMESTAMP : PIPE_QUERY_TYPES;
+    case D3DQUERYTYPE_TIMESTAMPDISJOINT:
+    case D3DQUERYTYPE_TIMESTAMPFREQ:
+        return screen->get_param(screen, PIPE_CAP_QUERY_TIMESTAMP) ?
+               PIPE_QUERY_TIMESTAMP_DISJOINT : PIPE_QUERY_TYPES;
+    case D3DQUERYTYPE_VERTEXSTATS:
+        return screen->get_param(screen,
+                                 PIPE_CAP_QUERY_PIPELINE_STATISTICS) ?
+               PIPE_QUERY_PIPELINE_STATISTICS : PIPE_QUERY_TYPES;
     default:
-        return ~0;
+        return PIPE_QUERY_TYPES; /* Query not supported */
     }
 }
 
@@ -73,9 +74,9 @@ nine_query_result_size(D3DQUERYTYPE type)
 }
 
 HRESULT
-nine_is_query_supported(D3DQUERYTYPE type)
+nine_is_query_supported(struct pipe_screen *screen, D3DQUERYTYPE type)
 {
-    const unsigned ptype = d3dquerytype_to_pipe_query(type);
+    const unsigned ptype = d3dquerytype_to_pipe_query(screen, type);
 
     user_assert(ptype != ~0, D3DERR_INVALIDCALL);
 
@@ -93,7 +94,7 @@ NineQuery9_ctor( struct NineQuery9 *This,
                  D3DQUERYTYPE Type )
 {
     struct pipe_context *pipe = pParams->device->pipe;
-    const unsigned ptype = d3dquerytype_to_pipe_query(Type);
+    const unsigned ptype = d3dquerytype_to_pipe_query(pParams->device->screen, Type);
     HRESULT hr;
 
     DBG("This=%p pParams=%p Type=%d\n", This, pParams, Type);
index abd43521862a21e1e5419a628a4976912621505c..ad1ca50f26d8d03be1507f3a63fab271544f6d9c 100644 (file)
@@ -48,7 +48,7 @@ NineQuery9( void *data )
 }
 
 HRESULT
-nine_is_query_supported(D3DQUERYTYPE);
+nine_is_query_supported(struct pipe_screen *screen, D3DQUERYTYPE);
 
 HRESULT
 NineQuery9_new( struct NineDevice9 *Device,