[PATCH 5/6] wined3d: Acquire unordered access resources for compute dispatches.
Józef Kucia
jkucia at codeweavers.com
Wed Feb 8 04:54:17 CST 2017
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/wined3d/cs.c | 80 ++++++++++++++++++++++++++++++++++---------------------
1 file changed, 50 insertions(+), 30 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index f2e10a8..03c286e 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,
op->group_count_x, op->group_count_y, op->group_count_z);
release_shader_resources(&cs->device->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));
@@ -514,6 +558,8 @@ void wined3d_cs_emit_dispatch(struct wined3d_cs *cs,
op->group_count_z = group_count_z;
acquire_shader_resources(&cs->device->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);
}
--
2.10.2
More information about the wine-patches
mailing list