wined3d: Acquire unordered access resources for compute dispatches.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Józef Kucia 2017-02-09 12:00:30 +01:00 committed by Alexandre Julliard
parent 6cc1335adc
commit 8962db2aa7
1 changed files with 53 additions and 33 deletions

View File

@ -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);
}