st/nine: Move query9 pipe calls to nine_context
authorAxel Davy <axel.davy@ens.fr>
Thu, 27 Oct 2016 20:52:53 +0000 (22:52 +0200)
committerAxel Davy <axel.davy@ens.fr>
Tue, 20 Dec 2016 22:44:22 +0000 (23:44 +0100)
This will enable to use threading for them.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/nine_state.c
src/gallium/state_trackers/nine/nine_state.h
src/gallium/state_trackers/nine/query9.c

index a5fa55328ca9180e49871155c63964a4b078d377..9bad0da7d6651e0eef07f4e598850e4b5e89e34d 100644 (file)
@@ -2091,6 +2091,39 @@ nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf(struct NineDevice9 *devic
     device->pipe->draw_vbo(device->pipe, &info);
 }
 
+struct pipe_query *
+nine_context_create_query(struct NineDevice9 *device, unsigned query_type)
+{
+    return device->pipe->create_query(device->pipe, query_type, 0);
+}
+
+void
+nine_context_destroy_query(struct NineDevice9 *device, struct pipe_query *query)
+{
+    device->pipe->destroy_query(device->pipe, query);
+}
+
+void
+nine_context_begin_query(struct NineDevice9 *device, struct pipe_query *query)
+{
+    (void) device->pipe->begin_query(device->pipe, query);
+}
+
+void
+nine_context_end_query(struct NineDevice9 *device, struct pipe_query *query)
+{
+    (void) device->pipe->end_query(device->pipe, query);
+}
+
+boolean
+nine_context_get_query_result(struct NineDevice9 *device, struct pipe_query *query,
+                              boolean flush, boolean wait,
+                              union pipe_query_result *result)
+{
+    (void) flush;
+    return device->pipe->get_query_result(device->pipe, query, wait, result);
+}
+
 /* State defaults */
 
 static const DWORD nine_render_state_defaults[NINED3DRS_LAST + 1] =
index 9894f3898e08a7249d1971f17c659817ec219de3..2cf607c16bcb69c198d41ad00afa41403f899384 100644 (file)
@@ -486,6 +486,23 @@ nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf(struct NineDevice9 *devic
                                                        struct pipe_vertex_buffer *vbuf,
                                                        struct pipe_index_buffer *ibuf);
 
+struct pipe_query *
+nine_context_create_query(struct NineDevice9 *device, unsigned query_type);
+
+void
+nine_context_destroy_query(struct NineDevice9 *device, struct pipe_query *query);
+
+void
+nine_context_begin_query(struct NineDevice9 *device, struct pipe_query *query);
+
+void
+nine_context_end_query(struct NineDevice9 *device, struct pipe_query *query);
+
+boolean
+nine_context_get_query_result(struct NineDevice9 *device, struct pipe_query *query,
+                              boolean flush, boolean wait,
+                              union pipe_query_result *result);
+
 void nine_state_restore_non_cso(struct NineDevice9 *device);
 void nine_state_set_defaults(struct NineDevice9 *, const D3DCAPS9 *,
                              boolean is_reset);
index dd7f03d389e03cd457219542dea066704109272a..6bba4a785246f810ffdf11e75fcdc44066dffe36 100644 (file)
@@ -21,6 +21,7 @@
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
 #include "device9.h"
+#include "nine_state.h"
 #include "query9.h"
 #include "nine_helpers.h"
 #include "pipe/p_screen.h"
@@ -93,8 +94,8 @@ NineQuery9_ctor( struct NineQuery9 *This,
                  struct NineUnknownParams *pParams,
                  D3DQUERYTYPE Type )
 {
-    struct pipe_context *pipe = pParams->device->pipe;
-    const unsigned ptype = d3dquerytype_to_pipe_query(pParams->device->screen, Type);
+    struct NineDevice9 *device = pParams->device;
+    const unsigned ptype = d3dquerytype_to_pipe_query(device->screen, Type);
     HRESULT hr;
 
     DBG("This=%p pParams=%p Type=%d\n", This, pParams, Type);
@@ -109,7 +110,7 @@ NineQuery9_ctor( struct NineQuery9 *This,
     user_assert(ptype != ~0, D3DERR_INVALIDCALL);
 
     if (ptype < PIPE_QUERY_TYPES) {
-        This->pq = pipe->create_query(pipe, ptype, 0);
+        This->pq = nine_context_create_query(device, ptype);
         if (!This->pq)
             return E_OUTOFMEMORY;
     } else {
@@ -132,14 +133,14 @@ NineQuery9_ctor( struct NineQuery9 *This,
 void
 NineQuery9_dtor( struct NineQuery9 *This )
 {
-    struct pipe_context *pipe = This->base.device->pipe;
+    struct NineDevice9 *device = This->base.device;
 
     DBG("This=%p\n", This);
 
     if (This->pq) {
         if (This->state == NINE_QUERY_STATE_RUNNING)
-            pipe->end_query(pipe, This->pq);
-        pipe->destroy_query(pipe, This->pq);
+            nine_context_end_query(device, This->pq);
+        nine_context_destroy_query(device, This->pq);
     }
 
     NineUnknown_dtor(&This->base);
@@ -161,7 +162,7 @@ HRESULT NINE_WINAPI
 NineQuery9_Issue( struct NineQuery9 *This,
                   DWORD dwIssueFlags )
 {
-    struct pipe_context *pipe = This->base.device->pipe;
+    struct NineDevice9 *device = This->base.device;
 
     DBG("This=%p dwIssueFlags=%d\n", This, dwIssueFlags);
 
@@ -175,17 +176,16 @@ NineQuery9_Issue( struct NineQuery9 *This,
         return D3D_OK;
 
     if (dwIssueFlags == D3DISSUE_BEGIN) {
-        if (This->state == NINE_QUERY_STATE_RUNNING) {
-        pipe->end_query(pipe, This->pq);
-        }
-        pipe->begin_query(pipe, This->pq);
+        if (This->state == NINE_QUERY_STATE_RUNNING)
+            nine_context_end_query(device, This->pq);
+        nine_context_begin_query(device, This->pq);
         This->state = NINE_QUERY_STATE_RUNNING;
     } else {
         if (This->state != NINE_QUERY_STATE_RUNNING &&
             This->type != D3DQUERYTYPE_EVENT &&
             This->type != D3DQUERYTYPE_TIMESTAMP)
-            pipe->begin_query(pipe, This->pq);
-        pipe->end_query(pipe, This->pq);
+            nine_context_begin_query(device, This->pq);
+        nine_context_end_query(device, This->pq);
         This->state = NINE_QUERY_STATE_ENDED;
     }
     return D3D_OK;
@@ -205,7 +205,7 @@ NineQuery9_GetData( struct NineQuery9 *This,
                     DWORD dwSize,
                     DWORD dwGetDataFlags )
 {
-    struct pipe_context *pipe = This->base.device->pipe;
+    struct NineDevice9 *device = This->base.device;
     boolean ok, wait_query_result = FALSE;
     union pipe_query_result presult;
     union nine_query_result nresult;
@@ -240,7 +240,9 @@ NineQuery9_GetData( struct NineQuery9 *This,
     /* Note: We ignore dwGetDataFlags, because get_query_result will
      * flush automatically if needed */
 
-    ok = pipe->get_query_result(pipe, This->pq, wait_query_result, &presult);
+    ok = nine_context_get_query_result(device, This->pq,
+                                       !!(dwGetDataFlags & D3DGETDATA_FLUSH),
+                                       wait_query_result, &presult);
 
     if (!ok) return S_FALSE;