wined3d: Introduce wined3d_device_set_unordered_access_view().
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>
This commit is contained in:
parent
7b770efe8c
commit
794d59259b
|
@ -3386,6 +3386,45 @@ static void context_bind_shader_resources(struct wined3d_context *context, const
|
|||
}
|
||||
}
|
||||
|
||||
static void context_bind_unordered_access_views(struct wined3d_context *context,
|
||||
const struct wined3d_state *state)
|
||||
{
|
||||
const struct wined3d_gl_info *gl_info = context->gl_info;
|
||||
struct wined3d_unordered_access_view *view;
|
||||
struct wined3d_texture *texture;
|
||||
struct wined3d_shader *shader;
|
||||
struct gl_texture *gl_texture;
|
||||
unsigned int i;
|
||||
|
||||
if (!(shader = state->shader[WINED3D_SHADER_TYPE_PIXEL]))
|
||||
return;
|
||||
|
||||
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]))
|
||||
{
|
||||
WARN("No unordered access view bound at index %u.\n", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (view->resource->type == WINED3D_RTYPE_BUFFER)
|
||||
{
|
||||
FIXME("Buffer unordered access views not implemented.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
texture = texture_from_resource(view->resource);
|
||||
wined3d_texture_load(texture, context, FALSE);
|
||||
gl_texture = wined3d_texture_get_gl_texture(texture, FALSE);
|
||||
GL_EXTCALL(glBindImageTexture(i, gl_texture->name, view->level_idx, GL_TRUE, 0, GL_READ_WRITE,
|
||||
view->format->glInternal));
|
||||
}
|
||||
checkGLcall("Bind unordered access views");
|
||||
}
|
||||
|
||||
/* Context activation is done by the caller. */
|
||||
BOOL context_apply_draw_state(struct wined3d_context *context,
|
||||
const struct wined3d_device *device, const struct wined3d_state *state)
|
||||
|
@ -3462,6 +3501,12 @@ BOOL context_apply_draw_state(struct wined3d_context *context,
|
|||
context->update_shader_resource_bindings = 0;
|
||||
}
|
||||
|
||||
if (context->update_unordered_access_view_bindings)
|
||||
{
|
||||
context_bind_unordered_access_views(context, state);
|
||||
context->update_unordered_access_view_bindings = 0;
|
||||
}
|
||||
|
||||
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
|
||||
{
|
||||
context_check_fbo_status(context, GL_FRAMEBUFFER);
|
||||
|
|
|
@ -42,6 +42,7 @@ enum wined3d_cs_op
|
|||
WINED3D_CS_OP_SET_CONSTANT_BUFFER,
|
||||
WINED3D_CS_OP_SET_TEXTURE,
|
||||
WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW,
|
||||
WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW,
|
||||
WINED3D_CS_OP_SET_SAMPLER,
|
||||
WINED3D_CS_OP_SET_SHADER,
|
||||
WINED3D_CS_OP_SET_RASTERIZER_STATE,
|
||||
|
@ -196,6 +197,13 @@ struct wined3d_cs_set_shader_resource_view
|
|||
struct wined3d_shader_resource_view *view;
|
||||
};
|
||||
|
||||
struct wined3d_cs_set_unordered_access_view
|
||||
{
|
||||
enum wined3d_cs_op opcode;
|
||||
unsigned int view_idx;
|
||||
struct wined3d_unordered_access_view *view;
|
||||
};
|
||||
|
||||
struct wined3d_cs_set_sampler
|
||||
{
|
||||
enum wined3d_cs_op opcode;
|
||||
|
@ -934,6 +942,35 @@ static void wined3d_cs_exec_set_shader_resource_view(struct wined3d_cs *cs, cons
|
|||
device_invalidate_state(cs->device, STATE_SHADER_RESOURCE_BINDING);
|
||||
}
|
||||
|
||||
void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, unsigned int view_idx,
|
||||
struct wined3d_unordered_access_view *view)
|
||||
{
|
||||
struct wined3d_cs_set_unordered_access_view *op;
|
||||
|
||||
op = cs->ops->require_space(cs, sizeof(*op));
|
||||
op->opcode = WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW;
|
||||
op->view_idx = view_idx;
|
||||
op->view = view;
|
||||
|
||||
cs->ops->submit(cs);
|
||||
}
|
||||
|
||||
static void wined3d_cs_exec_set_unordered_access_view(struct wined3d_cs *cs, const void *data)
|
||||
{
|
||||
const struct wined3d_cs_set_unordered_access_view *op = data;
|
||||
struct wined3d_unordered_access_view *prev;
|
||||
|
||||
prev = cs->state.unordered_access_view[op->view_idx];
|
||||
cs->state.unordered_access_view[op->view_idx] = op->view;
|
||||
|
||||
if (op->view)
|
||||
InterlockedIncrement(&op->view->resource->bind_count);
|
||||
if (prev)
|
||||
InterlockedDecrement(&prev->resource->bind_count);
|
||||
|
||||
device_invalidate_state(cs->device, STATE_UNORDERED_ACCESS_VIEW_BINDING);
|
||||
}
|
||||
|
||||
void wined3d_cs_emit_set_shader_resource_view(struct wined3d_cs *cs, enum wined3d_shader_type type,
|
||||
UINT view_idx, struct wined3d_shader_resource_view *view)
|
||||
{
|
||||
|
@ -1393,6 +1430,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void
|
|||
/* WINED3D_CS_OP_SET_CONSTANT_BUFFER */ wined3d_cs_exec_set_constant_buffer,
|
||||
/* WINED3D_CS_OP_SET_TEXTURE */ wined3d_cs_exec_set_texture,
|
||||
/* WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW */ wined3d_cs_exec_set_shader_resource_view,
|
||||
/* WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW */ wined3d_cs_exec_set_unordered_access_view,
|
||||
/* WINED3D_CS_OP_SET_SAMPLER */ wined3d_cs_exec_set_sampler,
|
||||
/* WINED3D_CS_OP_SET_SHADER */ wined3d_cs_exec_set_shader,
|
||||
/* WINED3D_CS_OP_SET_RASTERIZER_STATE */ wined3d_cs_exec_set_rasterizer_state,
|
||||
|
|
|
@ -2857,6 +2857,32 @@ struct wined3d_sampler * CDECL wined3d_device_get_gs_sampler(const struct wined3
|
|||
return device->state.sampler[WINED3D_SHADER_TYPE_GEOMETRY][idx];
|
||||
}
|
||||
|
||||
void CDECL wined3d_device_set_unordered_access_view(struct wined3d_device *device,
|
||||
unsigned int idx, struct wined3d_unordered_access_view *uav)
|
||||
{
|
||||
struct wined3d_unordered_access_view *prev;
|
||||
|
||||
TRACE("device %p, idx %u, uav %p.\n", device, idx, uav);
|
||||
|
||||
if (idx >= MAX_UNORDERED_ACCESS_VIEWS)
|
||||
{
|
||||
WARN("Invalid UAV index %u.\n", idx);
|
||||
return;
|
||||
}
|
||||
|
||||
prev = device->update_state->unordered_access_view[idx];
|
||||
if (uav == prev)
|
||||
return;
|
||||
|
||||
if (uav)
|
||||
wined3d_unordered_access_view_incref(uav);
|
||||
device->update_state->unordered_access_view[idx] = uav;
|
||||
if (!device->recording)
|
||||
wined3d_cs_emit_set_unordered_access_view(device->cs, idx, uav);
|
||||
if (prev)
|
||||
wined3d_unordered_access_view_decref(prev);
|
||||
}
|
||||
|
||||
/* Context activation is done by the caller. */
|
||||
#define copy_and_next(dest, src, size) memcpy(dest, src, size); dest += (size)
|
||||
static HRESULT process_vertices_strided(const struct wined3d_device *device, DWORD dwDestIndex, DWORD dwCount,
|
||||
|
|
|
@ -574,7 +574,7 @@ static void shader_glsl_load_samplers(const struct wined3d_gl_info *gl_info,
|
|||
GL_EXTCALL(glUniform1i(name_loc, mapped_unit));
|
||||
}
|
||||
}
|
||||
checkGLcall("glUniform1i");
|
||||
checkGLcall("Load sampler bindings");
|
||||
string_buffer_release(&priv->string_buffers, sampler_name);
|
||||
}
|
||||
|
||||
|
@ -598,6 +598,31 @@ static void shader_glsl_load_icb(const struct wined3d_gl_info *gl_info, struct s
|
|||
}
|
||||
}
|
||||
|
||||
/* Context activation is done by the caller. */
|
||||
static void shader_glsl_load_images(const struct wined3d_gl_info *gl_info, struct shader_glsl_priv *priv,
|
||||
GLuint program_id, const struct wined3d_shader_reg_maps *reg_maps)
|
||||
{
|
||||
struct wined3d_string_buffer *name = string_buffer_get(&priv->string_buffers);
|
||||
GLint location;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
|
||||
{
|
||||
if (!reg_maps->uav_resource_info[i].type)
|
||||
continue;
|
||||
|
||||
string_buffer_sprintf(name, "ps_image%u", i);
|
||||
location = GL_EXTCALL(glGetUniformLocation(program_id, name->buffer));
|
||||
if (location == -1)
|
||||
continue;
|
||||
|
||||
TRACE("Loading image %s on unit %u.\n", name->buffer, i);
|
||||
GL_EXTCALL(glUniform1i(location, i));
|
||||
}
|
||||
checkGLcall("Load image bindings");
|
||||
string_buffer_release(&priv->string_buffers, name);
|
||||
}
|
||||
|
||||
/* Context activation is done by the caller. */
|
||||
static inline void walk_constant_heap(const struct wined3d_gl_info *gl_info, const struct wined3d_vec4 *constants,
|
||||
const GLint *constant_locations, const struct constant_heap *heap, unsigned char *stack, DWORD version)
|
||||
|
@ -8077,6 +8102,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
|
|||
|
||||
shader_glsl_init_uniform_block_bindings(gl_info, priv, program_id, &pshader->reg_maps);
|
||||
shader_glsl_load_icb(gl_info, priv, program_id, &pshader->reg_maps);
|
||||
shader_glsl_load_images(gl_info, priv, program_id, &pshader->reg_maps);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -4964,6 +4964,18 @@ static void state_shader_resource_binding(struct wined3d_context *context,
|
|||
context->update_shader_resource_bindings = 1;
|
||||
}
|
||||
|
||||
static void state_uav_binding(struct wined3d_context *context,
|
||||
const struct wined3d_state *state, DWORD state_id)
|
||||
{
|
||||
TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id);
|
||||
context->update_unordered_access_view_bindings = 1;
|
||||
}
|
||||
|
||||
static void state_uav_warn(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
|
||||
{
|
||||
WARN("ARB_image_load_store is not supported by OpenGL implementation.\n");
|
||||
}
|
||||
|
||||
const struct StateEntryTemplate misc_state_template[] =
|
||||
{
|
||||
{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX), state_cb, }, ARB_UNIFORM_BUFFER_OBJECT },
|
||||
|
@ -4973,6 +4985,8 @@ const struct StateEntryTemplate misc_state_template[] =
|
|||
{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL), state_cb, }, ARB_UNIFORM_BUFFER_OBJECT },
|
||||
{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL), state_cb_warn, }, WINED3D_GL_EXT_NONE },
|
||||
{ STATE_SHADER_RESOURCE_BINDING, { STATE_SHADER_RESOURCE_BINDING, state_shader_resource_binding}, WINED3D_GL_EXT_NONE },
|
||||
{ STATE_UNORDERED_ACCESS_VIEW_BINDING, { STATE_UNORDERED_ACCESS_VIEW_BINDING, state_uav_binding }, ARB_SHADER_IMAGE_LOAD_STORE },
|
||||
{ STATE_UNORDERED_ACCESS_VIEW_BINDING, { STATE_UNORDERED_ACCESS_VIEW_BINDING, state_uav_warn }, WINED3D_GL_EXT_NONE },
|
||||
{ STATE_RENDER(WINED3D_RS_SRCBLEND), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE },
|
||||
{ STATE_RENDER(WINED3D_RS_DESTBLEND), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE },
|
||||
{ STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE), state_blend }, WINED3D_GL_EXT_NONE },
|
||||
|
|
|
@ -424,6 +424,7 @@ ULONG CDECL wined3d_stateblock_incref(struct wined3d_stateblock *stateblock)
|
|||
|
||||
void state_unbind_resources(struct wined3d_state *state)
|
||||
{
|
||||
struct wined3d_unordered_access_view *uav;
|
||||
struct wined3d_shader_resource_view *srv;
|
||||
struct wined3d_vertex_declaration *decl;
|
||||
struct wined3d_sampler *sampler;
|
||||
|
@ -506,6 +507,15 @@ void state_unbind_resources(struct wined3d_state *state)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
|
||||
{
|
||||
if ((uav = state->unordered_access_view[i]))
|
||||
{
|
||||
state->unordered_access_view[i] = NULL;
|
||||
wined3d_unordered_access_view_decref(uav);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void state_cleanup(struct wined3d_state *state)
|
||||
|
|
|
@ -4346,6 +4346,8 @@ const char *debug_d3dstate(DWORD state)
|
|||
return wine_dbg_sprintf("STATE_CONSTANT_BUFFER(%s)", debug_shader_type(state - STATE_CONSTANT_BUFFER(0)));
|
||||
if (STATE_IS_SHADER_RESOURCE_BINDING(state))
|
||||
return "STATE_SHADER_RESOURCE_BINDING";
|
||||
if (STATE_IS_UNORDERED_ACCESS_VIEW_BINDING(state))
|
||||
return "STATE_UNORDERED_ACCESS_VIEW_BINDING";
|
||||
if (STATE_IS_TRANSFORM(state))
|
||||
return wine_dbg_sprintf("STATE_TRANSFORM(%s)", debug_d3dtstype(state - STATE_TRANSFORM(0)));
|
||||
if (STATE_IS_STREAMSRC(state))
|
||||
|
|
|
@ -537,6 +537,14 @@ static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_acces
|
|||
|| !desc->u.texture.layer_count
|
||||
|| desc->u.texture.layer_count > depth_or_layer_count - desc->u.texture.layer_idx)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (desc->u.texture.layer_idx || desc->u.texture.layer_count != depth_or_layer_count)
|
||||
{
|
||||
FIXME("Unordered access view unsupported yet (layers %u-%u).\n",
|
||||
desc->u.texture.layer_idx, desc->u.texture.layer_count);
|
||||
}
|
||||
|
||||
view->level_idx = desc->u.texture.level_idx;
|
||||
}
|
||||
wined3d_resource_incref(view->resource = resource);
|
||||
|
||||
|
|
|
@ -145,6 +145,7 @@
|
|||
@ cdecl wined3d_device_set_texture(ptr long ptr)
|
||||
@ cdecl wined3d_device_set_texture_stage_state(ptr long long long)
|
||||
@ cdecl wined3d_device_set_transform(ptr long ptr)
|
||||
@ cdecl wined3d_device_set_unordered_access_view(ptr long ptr)
|
||||
@ cdecl wined3d_device_set_vertex_declaration(ptr ptr)
|
||||
@ cdecl wined3d_device_set_vertex_shader(ptr ptr)
|
||||
@ cdecl wined3d_device_set_viewport(ptr ptr)
|
||||
|
|
|
@ -1312,7 +1312,10 @@ DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
|
|||
#define STATE_SHADER_RESOURCE_BINDING (STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COUNT))
|
||||
#define STATE_IS_SHADER_RESOURCE_BINDING(a) ((a) == STATE_SHADER_RESOURCE_BINDING)
|
||||
|
||||
#define STATE_TRANSFORM(a) (STATE_SHADER_RESOURCE_BINDING + (a))
|
||||
#define STATE_UNORDERED_ACCESS_VIEW_BINDING (STATE_SHADER_RESOURCE_BINDING + 1)
|
||||
#define STATE_IS_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_UNORDERED_ACCESS_VIEW_BINDING)
|
||||
|
||||
#define STATE_TRANSFORM(a) (STATE_UNORDERED_ACCESS_VIEW_BINDING + (a))
|
||||
#define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)))
|
||||
|
||||
#define STATE_STREAMSRC (STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)) + 1)
|
||||
|
@ -1499,8 +1502,9 @@ struct wined3d_context
|
|||
DWORD hdc_is_private : 1;
|
||||
DWORD hdc_has_format : 1; /* only meaningful if hdc_is_private */
|
||||
DWORD update_shader_resource_bindings : 1;
|
||||
DWORD update_unordered_access_view_bindings : 1;
|
||||
DWORD destroy_delayed : 1;
|
||||
DWORD padding : 13;
|
||||
DWORD padding : 12;
|
||||
DWORD last_swizzle_map; /* MAX_ATTRIBS, 16 */
|
||||
DWORD shader_update_mask;
|
||||
DWORD constant_update_mask;
|
||||
|
@ -2402,6 +2406,7 @@ struct wined3d_state
|
|||
struct wined3d_buffer *cb[WINED3D_SHADER_TYPE_COUNT][MAX_CONSTANT_BUFFERS];
|
||||
struct wined3d_sampler *sampler[WINED3D_SHADER_TYPE_COUNT][MAX_SAMPLER_OBJECTS];
|
||||
struct wined3d_shader_resource_view *shader_resource_view[WINED3D_SHADER_TYPE_COUNT][MAX_SHADER_RESOURCE_VIEWS];
|
||||
struct wined3d_unordered_access_view *unordered_access_view[MAX_UNORDERED_ACCESS_VIEWS];
|
||||
|
||||
BOOL vs_consts_b[WINED3D_MAX_CONSTS_B];
|
||||
struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I];
|
||||
|
@ -3121,6 +3126,8 @@ void wined3d_cs_emit_set_texture_state(struct wined3d_cs *cs, UINT stage,
|
|||
enum wined3d_texture_stage_state state, DWORD value) DECLSPEC_HIDDEN;
|
||||
void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform_state state,
|
||||
const struct wined3d_matrix *matrix) DECLSPEC_HIDDEN;
|
||||
void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, unsigned int view_idx,
|
||||
struct wined3d_unordered_access_view *view) DECLSPEC_HIDDEN;
|
||||
void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs,
|
||||
struct wined3d_vertex_declaration *declaration) DECLSPEC_HIDDEN;
|
||||
void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_viewport *viewport) DECLSPEC_HIDDEN;
|
||||
|
@ -3255,6 +3262,8 @@ struct wined3d_unordered_access_view
|
|||
const struct wined3d_parent_ops *parent_ops;
|
||||
|
||||
const struct wined3d_format *format;
|
||||
|
||||
unsigned int level_idx;
|
||||
};
|
||||
|
||||
struct wined3d_swapchain_ops
|
||||
|
|
|
@ -2330,6 +2330,8 @@ void __cdecl wined3d_device_set_texture_stage_state(struct wined3d_device *devic
|
|||
UINT stage, enum wined3d_texture_stage_state state, DWORD value);
|
||||
void __cdecl wined3d_device_set_transform(struct wined3d_device *device,
|
||||
enum wined3d_transform_state state, const struct wined3d_matrix *matrix);
|
||||
void __cdecl wined3d_device_set_unordered_access_view(struct wined3d_device *device,
|
||||
unsigned int idx, struct wined3d_unordered_access_view *uav);
|
||||
void __cdecl wined3d_device_set_vertex_declaration(struct wined3d_device *device,
|
||||
struct wined3d_vertex_declaration *declaration);
|
||||
void __cdecl wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader);
|
||||
|
|
Loading…
Reference in New Issue