=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: wined3d: Acquire unordered access resources for compute dispatches.

Alexandre Julliard julliard at winehq.org
Thu Feb 9 15:54:26 CST 2017


Module: wine
Branch: master
Commit: 8962db2aa76a0bf330dd5bd7f25f13e6fe9abb13
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=8962db2aa76a0bf330dd5bd7f25f13e6fe9abb13

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Thu Feb  9 12:00:30 2017 +0100

wined3d: Acquire unordered access resources for compute dispatches.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/cs.c | 86 ++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 53 insertions(+), 33 deletions(-)

diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index db94942..83bd60c 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -492,19 +492,63 @@ static void release_shader_resources(const struct wined3d_state *state, unsigned
     }
 }
 
+static void acquire_unordered_access_resources(const struct wined3d_shader *shader,
+        struct wined3d_unordered_access_view * const *views)
+{
+    unsigned int i;
+
+    if (!shader)
+        return;
+
+    for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
+    {
+        if (!shader->reg_maps.uav_resource_info[i].type)
+            continue;
+
+        if (!views[i])
+            continue;
+
+        wined3d_resource_acquire(views[i]->resource);
+    }
+}
+
+static void release_unordered_access_resources(const struct wined3d_shader *shader,
+        struct wined3d_unordered_access_view * const *views)
+{
+    unsigned int i;
+
+    if (!shader)
+        return;
+
+    for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
+    {
+        if (!shader->reg_maps.uav_resource_info[i].type)
+            continue;
+
+        if (!views[i])
+            continue;
+
+        wined3d_resource_release(views[i]->resource);
+    }
+}
+
 static void wined3d_cs_exec_dispatch(struct wined3d_cs *cs, const void *data)
 {
+    struct wined3d_state *state = &cs->device->state;
     const struct wined3d_cs_dispatch *op = data;
 
-    dispatch_compute(cs->device, &cs->device->state,
+    dispatch_compute(cs->device, state,
             op->group_count_x, op->group_count_y, op->group_count_z);
 
-    release_shader_resources(&cs->device->state, 1u << WINED3D_SHADER_TYPE_COMPUTE);
+    release_shader_resources(state, 1u << WINED3D_SHADER_TYPE_COMPUTE);
+    release_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_COMPUTE],
+            state->compute_unordered_access_view);
 }
 
 void wined3d_cs_emit_dispatch(struct wined3d_cs *cs,
         unsigned int group_count_x, unsigned int group_count_y, unsigned int group_count_z)
 {
+    const struct wined3d_state *state = &cs->device->state;
     struct wined3d_cs_dispatch *op;
 
     op = cs->ops->require_space(cs, sizeof(*op));
@@ -513,7 +557,9 @@ void wined3d_cs_emit_dispatch(struct wined3d_cs *cs,
     op->group_count_y = group_count_y;
     op->group_count_z = group_count_z;
 
-    acquire_shader_resources(&cs->device->state, 1u << WINED3D_SHADER_TYPE_COMPUTE);
+    acquire_shader_resources(state, 1u << WINED3D_SHADER_TYPE_COMPUTE);
+    acquire_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_COMPUTE],
+            state->compute_unordered_access_view);
 
     cs->ops->submit(cs);
 }
@@ -522,7 +568,6 @@ static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data)
 {
     struct wined3d_state *state = &cs->device->state;
     const struct wined3d_cs_draw *op = data;
-    struct wined3d_shader *shader;
     unsigned int i;
 
     if (!cs->device->adapter->gl_info.supported[ARB_DRAW_ELEMENTS_BASE_VERTEX]
@@ -555,27 +600,14 @@ static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data)
     if (state->fb->depth_stencil)
         wined3d_resource_release(state->fb->depth_stencil->resource);
     release_shader_resources(state, ~(1u << WINED3D_SHADER_TYPE_COMPUTE));
-    if ((shader = state->shader[WINED3D_SHADER_TYPE_PIXEL]))
-    {
-        struct wined3d_unordered_access_view *view;
-        for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
-        {
-            if (!shader->reg_maps.uav_resource_info[i].type)
-                continue;
-
-            if (!(view = state->unordered_access_view[i]))
-                continue;
-
-            wined3d_resource_release(view->resource);
-        }
-    }
+    release_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_PIXEL],
+            state->unordered_access_view);
 }
 
 void wined3d_cs_emit_draw(struct wined3d_cs *cs, int base_vertex_idx, unsigned int start_idx,
         unsigned int index_count, unsigned int start_instance, unsigned int instance_count, BOOL indexed)
 {
     const struct wined3d_state *state = &cs->device->state;
-    struct wined3d_shader *shader;
     struct wined3d_cs_draw *op;
     unsigned int i;
 
@@ -608,20 +640,8 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, int base_vertex_idx, unsigned i
     if (state->fb->depth_stencil)
         wined3d_resource_acquire(state->fb->depth_stencil->resource);
     acquire_shader_resources(state, ~(1u << WINED3D_SHADER_TYPE_COMPUTE));
-    if ((shader = state->shader[WINED3D_SHADER_TYPE_PIXEL]))
-    {
-        struct wined3d_unordered_access_view *view;
-        for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
-        {
-            if (!shader->reg_maps.uav_resource_info[i].type)
-                continue;
-
-            if (!(view = state->unordered_access_view[i]))
-                continue;
-
-            wined3d_resource_acquire(view->resource);
-        }
-    }
+    acquire_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_PIXEL],
+            state->unordered_access_view);
 
     cs->ops->submit(cs);
 }




More information about the wine-cvs mailing list