wined3d: Merge WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW and WINED3D_CS_OP_SET_COMPUTE_UAV.

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:
Józef Kucia 2017-02-09 12:00:36 +01:00 committed by Alexandre Julliard
parent cb51abec90
commit 572aa0e0ea
7 changed files with 55 additions and 90 deletions

View File

@ -3563,7 +3563,8 @@ BOOL context_apply_draw_state(struct wined3d_context *context,
if (context->update_unordered_access_view_bindings)
{
context_bind_unordered_access_views(context,
state->shader[WINED3D_SHADER_TYPE_PIXEL], state->unordered_access_view);
state->shader[WINED3D_SHADER_TYPE_PIXEL],
state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
context->update_unordered_access_view_bindings = 0;
context->update_compute_unordered_access_view_bindings = 1;
}
@ -3606,7 +3607,8 @@ void context_apply_compute_state(struct wined3d_context *context,
if (context->update_compute_unordered_access_view_bindings)
{
context_bind_unordered_access_views(context,
state->shader[WINED3D_SHADER_TYPE_COMPUTE], state->compute_unordered_access_view);
state->shader[WINED3D_SHADER_TYPE_COMPUTE],
state->unordered_access_view[WINED3D_PIPELINE_COMPUTE]);
context->update_compute_unordered_access_view_bindings = 0;
context->update_unordered_access_view_bindings = 1;
}

View File

@ -44,7 +44,6 @@ enum wined3d_cs_op
WINED3D_CS_OP_SET_TEXTURE,
WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW,
WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW,
WINED3D_CS_OP_SET_COMPUTE_UAV,
WINED3D_CS_OP_SET_SAMPLER,
WINED3D_CS_OP_SET_SHADER,
WINED3D_CS_OP_SET_RASTERIZER_STATE,
@ -210,6 +209,7 @@ struct wined3d_cs_set_shader_resource_view
struct wined3d_cs_set_unordered_access_view
{
enum wined3d_cs_op opcode;
enum wined3d_pipeline pipeline;
unsigned int view_idx;
struct wined3d_unordered_access_view *view;
};
@ -542,7 +542,7 @@ static void wined3d_cs_exec_dispatch(struct wined3d_cs *cs, const void *data)
release_shader_resources(state, 1u << WINED3D_SHADER_TYPE_COMPUTE);
release_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_COMPUTE],
state->compute_unordered_access_view);
state->unordered_access_view[WINED3D_PIPELINE_COMPUTE]);
}
void wined3d_cs_emit_dispatch(struct wined3d_cs *cs,
@ -559,7 +559,7 @@ void wined3d_cs_emit_dispatch(struct wined3d_cs *cs,
acquire_shader_resources(state, 1u << WINED3D_SHADER_TYPE_COMPUTE);
acquire_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_COMPUTE],
state->compute_unordered_access_view);
state->unordered_access_view[WINED3D_PIPELINE_COMPUTE]);
cs->ops->submit(cs);
}
@ -601,7 +601,7 @@ static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data)
wined3d_resource_release(state->fb->depth_stencil->resource);
release_shader_resources(state, ~(1u << WINED3D_SHADER_TYPE_COMPUTE));
release_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_PIXEL],
state->unordered_access_view);
state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
}
void wined3d_cs_emit_draw(struct wined3d_cs *cs, int base_vertex_idx, unsigned int start_idx,
@ -641,7 +641,7 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, int base_vertex_idx, unsigned i
wined3d_resource_acquire(state->fb->depth_stencil->resource);
acquire_shader_resources(state, ~(1u << WINED3D_SHADER_TYPE_COMPUTE));
acquire_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_PIXEL],
state->unordered_access_view);
state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
cs->ops->submit(cs);
}
@ -1064,53 +1064,25 @@ static void wined3d_cs_exec_set_unordered_access_view(struct wined3d_cs *cs, con
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;
prev = cs->state.unordered_access_view[op->pipeline][op->view_idx];
cs->state.unordered_access_view[op->pipeline][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);
device_invalidate_state(cs->device, STATE_UNORDERED_ACCESS_VIEW_BINDING(op->pipeline));
}
void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, unsigned int view_idx,
struct wined3d_unordered_access_view *view)
void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined3d_pipeline pipeline,
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_compute_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.compute_unordered_access_view[op->view_idx];
cs->state.compute_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_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING);
}
void wined3d_cs_emit_set_compute_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_COMPUTE_UAV;
op->pipeline = pipeline;
op->view_idx = view_idx;
op->view = view;
@ -1565,7 +1537,6 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void
/* 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_COMPUTE_UAV */ wined3d_cs_exec_set_compute_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,

View File

@ -2826,56 +2826,44 @@ void CDECL wined3d_device_set_cs_cb(struct wined3d_device *device, unsigned int
wined3d_device_set_constant_buffer(device, WINED3D_SHADER_TYPE_COMPUTE, idx, buffer);
}
void CDECL wined3d_device_set_cs_uav(struct wined3d_device *device, unsigned int idx,
struct wined3d_unordered_access_view *uav)
static void wined3d_device_set_pipeline_unordered_access_view(struct wined3d_device *device,
enum wined3d_pipeline pipeline, 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->compute_unordered_access_view[idx];
prev = device->update_state->unordered_access_view[pipeline][idx];
if (uav == prev)
return;
if (uav)
wined3d_unordered_access_view_incref(uav);
device->update_state->compute_unordered_access_view[idx] = uav;
device->update_state->unordered_access_view[pipeline][idx] = uav;
if (!device->recording)
wined3d_cs_emit_set_compute_unordered_access_view(device->cs, idx, uav);
wined3d_cs_emit_set_unordered_access_view(device->cs, pipeline, idx, uav);
if (prev)
wined3d_unordered_access_view_decref(prev);
}
void CDECL wined3d_device_set_cs_uav(struct wined3d_device *device, unsigned int idx,
struct wined3d_unordered_access_view *uav)
{
TRACE("device %p, idx %u, uav %p.\n", device, idx, uav);
wined3d_device_set_pipeline_unordered_access_view(device, WINED3D_PIPELINE_COMPUTE, idx, uav);
}
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);
wined3d_device_set_pipeline_unordered_access_view(device, WINED3D_PIPELINE_GRAPHICS, idx, uav);
}
/* Context activation is done by the caller. */

View File

@ -5013,8 +5013,8 @@ const struct StateEntryTemplate misc_state_template[] =
{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE), state_cb, }, ARB_UNIFORM_BUFFER_OBJECT },
{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE), 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_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING, { STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING, state_uav_binding }, ARB_SHADER_IMAGE_LOAD_STORE },
{ STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING, { STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING, state_uav_warn }, WINED3D_GL_EXT_NONE },
{ STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING, { STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING, state_cs_uav_binding}, ARB_SHADER_IMAGE_LOAD_STORE },
{ STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING, { STATE_COMPUTE_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 },

View File

@ -508,17 +508,15 @@ void state_unbind_resources(struct wined3d_state *state)
}
}
for (i = 0; i < MAX_UNORDERED_ACCESS_VIEWS; ++i)
for (i = 0; i < WINED3D_PIPELINE_COUNT; ++i)
{
if ((uav = state->unordered_access_view[i]))
for (j = 0; j < MAX_UNORDERED_ACCESS_VIEWS; ++j)
{
state->unordered_access_view[i] = NULL;
if ((uav = state->unordered_access_view[i][j]))
{
state->unordered_access_view[i][j] = NULL;
wined3d_unordered_access_view_decref(uav);
}
if ((uav = state->compute_unordered_access_view[i]))
{
state->compute_unordered_access_view[i] = NULL;
wined3d_unordered_access_view_decref(uav);
}
}
}

View File

@ -4389,8 +4389,8 @@ const char *debug_d3dstate(DWORD state)
return "STATE_SHADER_RESOURCE_BINDING";
if (STATE_IS_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING(state))
return "STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING";
if (STATE_IS_UNORDERED_ACCESS_VIEW_BINDING(state))
return "STATE_UNORDERED_ACCESS_VIEW_BINDING";
if (STATE_IS_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING(state))
return "STATE_GRAPHICS_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))

View File

@ -1357,6 +1357,13 @@ DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
#define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
(((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
enum wined3d_pipeline
{
WINED3D_PIPELINE_GRAPHICS,
WINED3D_PIPELINE_COMPUTE,
WINED3D_PIPELINE_COUNT,
};
/* Routines and structures related to state management */
#define STATE_RENDER(a) (a)
@ -1383,10 +1390,10 @@ DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
#define STATE_SHADER_RESOURCE_BINDING (STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
#define STATE_IS_SHADER_RESOURCE_BINDING(a) ((a) == STATE_SHADER_RESOURCE_BINDING)
#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_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING (STATE_SHADER_RESOURCE_BINDING + 1)
#define STATE_IS_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING)
#define STATE_TRANSFORM(a) (STATE_UNORDERED_ACCESS_VIEW_BINDING + (a))
#define STATE_TRANSFORM(a) (STATE_GRAPHICS_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)
@ -1452,6 +1459,8 @@ DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
#define STATE_SHADER(a) ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_SHADER(a) : STATE_COMPUTE_SHADER)
#define STATE_CONSTANT_BUFFER(a) \
((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_CONSTANT_BUFFER(a) : STATE_COMPUTE_CONSTANT_BUFFER)
#define STATE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == WINED3D_PIPELINE_GRAPHICS ? \
STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING : STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
enum fogsource {
FOGSOURCE_FFP,
@ -2515,8 +2524,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];
struct wined3d_unordered_access_view *compute_unordered_access_view[MAX_UNORDERED_ACCESS_VIEWS];
struct wined3d_unordered_access_view *unordered_access_view[WINED3D_PIPELINE_COUNT][MAX_UNORDERED_ACCESS_VIEWS];
BOOL vs_consts_b[WINED3D_MAX_CONSTS_B];
struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I];
@ -3184,8 +3192,6 @@ void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx,
const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture *texture,
WORD flags, const struct wined3d_color_key *color_key) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_compute_unordered_access_view(struct wined3d_cs *cs, unsigned int view_idx,
struct wined3d_unordered_access_view *view) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_shader_type type,
UINT cb_idx, struct wined3d_buffer *buffer) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs,
@ -3221,8 +3227,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_unordered_access_view(struct wined3d_cs *cs, enum wined3d_pipeline pipeline,
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;