Commit cab9282d authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Load unordered access resources before binding shader resources.

Loading a texture might invalidate shader resource view bindings. Signed-off-by: 's avatarJózef Kucia <jkucia@codeweavers.com> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 873eace6
......@@ -3406,16 +3406,13 @@ static void context_bind_shader_resources(struct wined3d_context *context, const
}
}
static void context_bind_unordered_access_views(struct wined3d_context *context,
static void context_load_unordered_access_resources(struct wined3d_context *context,
const struct wined3d_shader *shader, struct wined3d_unordered_access_view * const *views)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_unordered_access_view *view;
struct wined3d_texture *texture = NULL;
struct wined3d_texture *texture;
struct wined3d_buffer *buffer;
GLuint texture_name;
unsigned int i;
GLint level;
context->uses_uavs = 0;
......@@ -3428,11 +3425,7 @@ static void context_bind_unordered_access_views(struct wined3d_context *context,
continue;
if (!(view = views[i]))
{
WARN("No unordered access view bound at index %u.\n", i);
GL_EXTCALL(glBindImageTexture(i, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R8));
continue;
}
if (view->resource->type == WINED3D_RTYPE_BUFFER)
{
......@@ -3448,14 +3441,41 @@ static void context_bind_unordered_access_views(struct wined3d_context *context,
}
context->uses_uavs = 1;
}
}
static void context_bind_unordered_access_views(struct wined3d_context *context,
const struct wined3d_shader *shader, struct wined3d_unordered_access_view * const *views)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_unordered_access_view *view;
GLuint texture_name;
unsigned int i;
GLint level;
if (!shader)
return;
for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
{
if (!shader->reg_maps.uav_resource_info[i].type)
continue;
if (!(view = views[i]))
{
WARN("No unordered access view bound at index %u.\n", i);
GL_EXTCALL(glBindImageTexture(i, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R8));
continue;
}
if (view->gl_view.name)
{
texture_name = view->gl_view.name;
level = 0;
}
else if (texture)
else if (view->resource->type != WINED3D_RTYPE_BUFFER)
{
struct wined3d_texture *texture = texture_from_resource(view->resource);
texture_name = wined3d_texture_get_gl_texture(texture, FALSE)->name;
level = view->desc.u.texture.level_idx;
}
......@@ -3496,6 +3516,8 @@ BOOL context_apply_draw_state(struct wined3d_context *context,
context_update_tex_unit_map(context, state);
context_preload_textures(context, state);
context_load_shader_resources(context, state, ~(1u << WINED3D_SHADER_TYPE_COMPUTE));
context_load_unordered_access_resources(context, state->shader[WINED3D_SHADER_TYPE_PIXEL],
state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
/* TODO: Right now the dependency on the vertex shader is necessary
* since context_stream_info_from_declaration depends on the reg_maps of
* the current VS but maybe it's possible to relax the coupling in some
......@@ -3579,6 +3601,8 @@ void context_apply_compute_state(struct wined3d_context *context,
unsigned int state_id, i, j;
context_load_shader_resources(context, state, 1u << WINED3D_SHADER_TYPE_COMPUTE);
context_load_unordered_access_resources(context, state->shader[WINED3D_SHADER_TYPE_COMPUTE],
state->unordered_access_view[WINED3D_PIPELINE_COMPUTE]);
for (i = 0, state_id = STATE_COMPUTE_OFFSET; i < ARRAY_SIZE(context->dirty_compute_states); ++i)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment