wined3d: Acquire resources through wined3d_device_context_ops.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-05-05 22:23:10 -05:00 committed by Alexandre Julliard
parent bd192cd2c6
commit 1ecc334df8
2 changed files with 49 additions and 32 deletions

View File

@ -480,6 +480,12 @@ static inline void wined3d_device_context_finish(struct wined3d_device_context *
context->ops->finish(context, queue_id);
}
static inline void wined3d_device_context_acquire_resource(struct wined3d_device_context *context,
struct wined3d_resource *resource)
{
context->ops->acquire_resource(context, resource);
}
static struct wined3d_cs *wined3d_cs_from_context(struct wined3d_device_context *context)
{
return CONTAINING_RECORD(context, struct wined3d_cs, c);
@ -765,15 +771,16 @@ void wined3d_device_context_emit_clear_rendertarget_view(struct wined3d_device_c
op->rect_count = 1;
op->rects[0] = *rect;
wined3d_resource_acquire(view->resource);
wined3d_device_context_acquire_resource(context, view->resource);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
if (flags & WINED3DCLEAR_SYNCHRONOUS)
wined3d_device_context_finish(context, WINED3D_CS_QUEUE_DEFAULT);
}
static void acquire_shader_resources(const struct wined3d_state *state, unsigned int shader_mask)
static void acquire_shader_resources(struct wined3d_device_context *context, unsigned int shader_mask)
{
const struct wined3d_state *state = context->state;
struct wined3d_shader_sampler_map_entry *entry;
struct wined3d_shader_resource_view *view;
struct wined3d_shader *shader;
@ -790,7 +797,7 @@ static void acquire_shader_resources(const struct wined3d_state *state, unsigned
for (j = 0; j < WINED3D_MAX_CBS; ++j)
{
if (state->cb[i][j])
wined3d_resource_acquire(&state->cb[i][j]->resource);
wined3d_device_context_acquire_resource(context, &state->cb[i][j]->resource);
}
for (j = 0; j < shader->reg_maps.sampler_map.count; ++j)
@ -800,7 +807,7 @@ static void acquire_shader_resources(const struct wined3d_state *state, unsigned
if (!(view = state->shader_resource_view[i][entry->resource_idx]))
continue;
wined3d_resource_acquire(view->resource);
wined3d_device_context_acquire_resource(context, view->resource);
}
}
}
@ -838,8 +845,8 @@ 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)
static void acquire_unordered_access_resources(struct wined3d_device_context *context,
const struct wined3d_shader *shader, struct wined3d_unordered_access_view * const *views)
{
unsigned int i;
@ -854,7 +861,7 @@ static void acquire_unordered_access_resources(const struct wined3d_shader *shad
if (!views[i])
continue;
wined3d_resource_acquire(views[i]->resource);
wined3d_device_context_acquire_resource(context, views[i]->resource);
}
}
@ -896,10 +903,12 @@ static void wined3d_cs_exec_dispatch(struct wined3d_cs *cs, const void *data)
state->unordered_access_view[WINED3D_PIPELINE_COMPUTE]);
}
static void acquire_compute_pipeline_resources(const struct wined3d_state *state)
static void acquire_compute_pipeline_resources(struct wined3d_device_context *context)
{
acquire_shader_resources(state, 1u << WINED3D_SHADER_TYPE_COMPUTE);
acquire_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_COMPUTE],
const struct wined3d_state *state = context->state;
acquire_shader_resources(context, 1u << WINED3D_SHADER_TYPE_COMPUTE);
acquire_unordered_access_resources(context, state->shader[WINED3D_SHADER_TYPE_COMPUTE],
state->unordered_access_view[WINED3D_PIPELINE_COMPUTE]);
}
@ -915,7 +924,7 @@ void CDECL wined3d_device_context_dispatch(struct wined3d_device_context *contex
op->parameters.u.direct.group_count_y = group_count_y;
op->parameters.u.direct.group_count_z = group_count_z;
acquire_compute_pipeline_resources(context->state);
acquire_compute_pipeline_resources(context);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
}
@ -931,8 +940,8 @@ void CDECL wined3d_device_context_dispatch_indirect(struct wined3d_device_contex
op->parameters.u.indirect.buffer = buffer;
op->parameters.u.indirect.offset = offset;
acquire_compute_pipeline_resources(context->state);
wined3d_resource_acquire(&buffer->resource);
acquire_compute_pipeline_resources(context);
wined3d_device_context_acquire_resource(context, &buffer->resource);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
}
@ -1024,37 +1033,38 @@ static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data)
state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
}
static void acquire_graphics_pipeline_resources(const struct wined3d_state *state,
static void acquire_graphics_pipeline_resources(struct wined3d_device_context *context,
BOOL indexed, const struct wined3d_d3d_info *d3d_info)
{
const struct wined3d_state *state = context->state;
unsigned int i;
if (indexed)
wined3d_resource_acquire(&state->index_buffer->resource);
wined3d_device_context_acquire_resource(context, &state->index_buffer->resource);
for (i = 0; i < ARRAY_SIZE(state->streams); ++i)
{
if (state->streams[i].buffer)
wined3d_resource_acquire(&state->streams[i].buffer->resource);
wined3d_device_context_acquire_resource(context, &state->streams[i].buffer->resource);
}
for (i = 0; i < ARRAY_SIZE(state->stream_output); ++i)
{
if (state->stream_output[i].buffer)
wined3d_resource_acquire(&state->stream_output[i].buffer->resource);
wined3d_device_context_acquire_resource(context, &state->stream_output[i].buffer->resource);
}
for (i = 0; i < ARRAY_SIZE(state->textures); ++i)
{
if (state->textures[i])
wined3d_resource_acquire(&state->textures[i]->resource);
wined3d_device_context_acquire_resource(context, &state->textures[i]->resource);
}
for (i = 0; i < d3d_info->limits.max_rt_count; ++i)
{
if (state->fb.render_targets[i])
wined3d_resource_acquire(state->fb.render_targets[i]->resource);
wined3d_device_context_acquire_resource(context, state->fb.render_targets[i]->resource);
}
if (state->fb.depth_stencil)
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],
wined3d_device_context_acquire_resource(context, state->fb.depth_stencil->resource);
acquire_shader_resources(context, ~(1u << WINED3D_SHADER_TYPE_COMPUTE));
acquire_unordered_access_resources(context, state->shader[WINED3D_SHADER_TYPE_PIXEL],
state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]);
}
@ -1064,7 +1074,6 @@ void wined3d_device_context_emit_draw(struct wined3d_device_context *context,
bool indexed)
{
const struct wined3d_d3d_info *d3d_info = &context->device->adapter->d3d_info;
const struct wined3d_state *state = context->state;
struct wined3d_cs_draw *op;
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
@ -1079,7 +1088,7 @@ void wined3d_device_context_emit_draw(struct wined3d_device_context *context,
op->parameters.u.direct.instance_count = instance_count;
op->parameters.indexed = indexed;
acquire_graphics_pipeline_resources(state, indexed, d3d_info);
acquire_graphics_pipeline_resources(context, indexed, d3d_info);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
}
@ -1100,8 +1109,8 @@ void CDECL wined3d_device_context_draw_indirect(struct wined3d_device_context *c
op->parameters.u.indirect.offset = offset;
op->parameters.indexed = indexed;
acquire_graphics_pipeline_resources(state, indexed, d3d_info);
wined3d_resource_acquire(&buffer->resource);
acquire_graphics_pipeline_resources(context, indexed, d3d_info);
wined3d_device_context_acquire_resource(context, &buffer->resource);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
}
@ -2461,9 +2470,9 @@ void wined3d_device_context_emit_blt_sub_resource(struct wined3d_device_context
memset(&op->fx, 0, sizeof(op->fx));
op->filter = filter;
wined3d_resource_acquire(dst_resource);
wined3d_device_context_acquire_resource(context, dst_resource);
if (src_resource)
wined3d_resource_acquire(src_resource);
wined3d_device_context_acquire_resource(context, src_resource);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
if (flags & WINED3D_BLT_SYNCHRONOUS)
@ -2544,7 +2553,7 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte
op->data.slice_pitch = slice_pitch;
op->data.data = data;
wined3d_resource_acquire(resource);
wined3d_device_context_acquire_resource(context, resource);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_MAP);
/* The data pointer may go away, so we need to wait until it is read.
@ -2611,7 +2620,7 @@ void wined3d_device_context_emit_clear_uav_uint(struct wined3d_device_context *c
op->view = view;
op->clear_value = *clear_value;
wined3d_resource_acquire(view->resource);
wined3d_device_context_acquire_resource(context, view->resource);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
}
@ -2640,7 +2649,7 @@ void wined3d_device_context_emit_copy_uav_counter(struct wined3d_device_context
op->offset = offset;
op->view = uav;
wined3d_resource_acquire(&dst_buffer->resource);
wined3d_device_context_acquire_resource(context, &dst_buffer->resource);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
}
@ -2667,7 +2676,7 @@ void wined3d_device_context_emit_generate_mipmaps(struct wined3d_device_context
op->opcode = WINED3D_CS_OP_GENERATE_MIPMAPS;
op->view = view;
wined3d_resource_acquire(view->resource);
wined3d_device_context_acquire_resource(context, view->resource);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
}
@ -2683,6 +2692,11 @@ static void wined3d_cs_emit_stop(struct wined3d_cs *cs)
wined3d_cs_finish(cs, WINED3D_CS_QUEUE_DEFAULT);
}
static void wined3d_cs_acquire_resource(struct wined3d_device_context *context, struct wined3d_resource *resource)
{
wined3d_resource_acquire(resource);
}
static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) =
{
/* WINED3D_CS_OP_NOP */ wined3d_cs_exec_nop,
@ -2801,6 +2815,7 @@ static const struct wined3d_device_context_ops wined3d_cs_st_ops =
wined3d_cs_unmap,
wined3d_cs_issue_query,
wined3d_cs_flush,
wined3d_cs_acquire_resource,
};
static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs *cs, const struct wined3d_cs_queue *queue)
@ -2926,6 +2941,7 @@ static const struct wined3d_device_context_ops wined3d_cs_mt_ops =
wined3d_cs_unmap,
wined3d_cs_issue_query,
wined3d_cs_flush,
wined3d_cs_acquire_resource,
};
static void poll_queries(struct wined3d_cs *cs)

View File

@ -4697,6 +4697,7 @@ struct wined3d_device_context_ops
unsigned int sub_resource_idx);
void (*issue_query)(struct wined3d_device_context *context, struct wined3d_query *query, unsigned int flags);
void (*flush)(struct wined3d_device_context *context);
void (*acquire_resource)(struct wined3d_device_context *context, struct wined3d_resource *resource);
};
struct wined3d_device_context