Commit 908fb507 authored by Jan Sikorski's avatar Jan Sikorski Committed by Alexandre Julliard

wined3d: Acquire references to shaders in deferred contexts.

parent 6057507b
...@@ -73,6 +73,9 @@ struct wined3d_command_list ...@@ -73,6 +73,9 @@ struct wined3d_command_list
SIZE_T depth_stencil_state_count; SIZE_T depth_stencil_state_count;
struct wined3d_depth_stencil_state **depth_stencil_states; struct wined3d_depth_stencil_state **depth_stencil_states;
SIZE_T shader_count;
struct wined3d_shader **shaders;
}; };
static void wined3d_command_list_destroy_object(void *object) static void wined3d_command_list_destroy_object(void *object)
...@@ -122,6 +125,8 @@ ULONG CDECL wined3d_command_list_decref(struct wined3d_command_list *list) ...@@ -122,6 +125,8 @@ ULONG CDECL wined3d_command_list_decref(struct wined3d_command_list *list)
wined3d_rasterizer_state_decref(list->rasterizer_states[i]); wined3d_rasterizer_state_decref(list->rasterizer_states[i]);
for (i = 0; i < list->depth_stencil_state_count; ++i) for (i = 0; i < list->depth_stencil_state_count; ++i)
wined3d_depth_stencil_state_decref(list->depth_stencil_states[i]); wined3d_depth_stencil_state_decref(list->depth_stencil_states[i]);
for (i = 0; i < list->shader_count; ++i)
wined3d_shader_decref(list->shaders[i]);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_cs_destroy_object(device->cs, wined3d_command_list_destroy_object, list); wined3d_cs_destroy_object(device->cs, wined3d_command_list_destroy_object, list);
...@@ -622,6 +627,12 @@ static inline void wined3d_device_context_acquire_depth_stencil_state(struct win ...@@ -622,6 +627,12 @@ static inline void wined3d_device_context_acquire_depth_stencil_state(struct win
context->ops->acquire_depth_stencil_state(context, depth_stencil_state); context->ops->acquire_depth_stencil_state(context, depth_stencil_state);
} }
static inline void wined3d_device_context_acquire_shader(struct wined3d_device_context *context,
struct wined3d_shader *shader)
{
context->ops->acquire_shader(context, shader);
}
static struct wined3d_cs *wined3d_cs_from_context(struct wined3d_device_context *context) static struct wined3d_cs *wined3d_cs_from_context(struct wined3d_device_context *context)
{ {
return CONTAINING_RECORD(context, struct wined3d_cs, c); return CONTAINING_RECORD(context, struct wined3d_cs, c);
...@@ -1834,6 +1845,8 @@ void wined3d_device_context_emit_set_shader(struct wined3d_device_context *conte ...@@ -1834,6 +1845,8 @@ void wined3d_device_context_emit_set_shader(struct wined3d_device_context *conte
op->type = type; op->type = type;
op->shader = shader; op->shader = shader;
if (shader)
wined3d_device_context_acquire_shader(context, shader);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
} }
...@@ -3011,6 +3024,11 @@ static void wined3d_cs_acquire_depth_stencil_state(struct wined3d_device_context ...@@ -3011,6 +3024,11 @@ static void wined3d_cs_acquire_depth_stencil_state(struct wined3d_device_context
{ {
} }
static void wined3d_cs_acquire_shader(struct wined3d_device_context *context,
struct wined3d_shader *shader)
{
}
static void wined3d_cs_exec_execute_command_list(struct wined3d_cs *cs, const void *data); static void wined3d_cs_exec_execute_command_list(struct wined3d_cs *cs, const void *data);
static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) = static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) =
...@@ -3253,6 +3271,7 @@ static const struct wined3d_device_context_ops wined3d_cs_st_ops = ...@@ -3253,6 +3271,7 @@ static const struct wined3d_device_context_ops wined3d_cs_st_ops =
wined3d_cs_acquire_blend_state, wined3d_cs_acquire_blend_state,
wined3d_cs_acquire_rasterizer_state, wined3d_cs_acquire_rasterizer_state,
wined3d_cs_acquire_depth_stencil_state, wined3d_cs_acquire_depth_stencil_state,
wined3d_cs_acquire_shader,
}; };
static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs *cs, const struct wined3d_cs_queue *queue) static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs *cs, const struct wined3d_cs_queue *queue)
...@@ -3383,6 +3402,7 @@ static const struct wined3d_device_context_ops wined3d_cs_mt_ops = ...@@ -3383,6 +3402,7 @@ static const struct wined3d_device_context_ops wined3d_cs_mt_ops =
wined3d_cs_acquire_blend_state, wined3d_cs_acquire_blend_state,
wined3d_cs_acquire_rasterizer_state, wined3d_cs_acquire_rasterizer_state,
wined3d_cs_acquire_depth_stencil_state, wined3d_cs_acquire_depth_stencil_state,
wined3d_cs_acquire_shader,
}; };
static void poll_queries(struct wined3d_cs *cs) static void poll_queries(struct wined3d_cs *cs)
...@@ -3618,6 +3638,9 @@ struct wined3d_deferred_context ...@@ -3618,6 +3638,9 @@ struct wined3d_deferred_context
SIZE_T depth_stencil_state_count, depth_stencil_states_capacity; SIZE_T depth_stencil_state_count, depth_stencil_states_capacity;
struct wined3d_depth_stencil_state **depth_stencil_states; struct wined3d_depth_stencil_state **depth_stencil_states;
SIZE_T shader_count, shaders_capacity;
struct wined3d_shader **shaders;
}; };
static struct wined3d_deferred_context *wined3d_deferred_context_from_context(struct wined3d_device_context *context) static struct wined3d_deferred_context *wined3d_deferred_context_from_context(struct wined3d_device_context *context)
...@@ -3852,6 +3875,18 @@ static void wined3d_deferred_context_acquire_depth_stencil_state(struct wined3d_ ...@@ -3852,6 +3875,18 @@ static void wined3d_deferred_context_acquire_depth_stencil_state(struct wined3d_
wined3d_depth_stencil_state_incref(depth_stencil_state); wined3d_depth_stencil_state_incref(depth_stencil_state);
} }
static void wined3d_deferred_context_acquire_shader(struct wined3d_device_context *context,
struct wined3d_shader *shader)
{
struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context);
if (!wined3d_array_reserve((void **)&deferred->shaders, &deferred->shaders_capacity,
deferred->shader_count + 1, sizeof(*deferred->shaders)))
return;
deferred->shaders[deferred->shader_count++] = shader;
wined3d_shader_incref(shader);
}
static const struct wined3d_device_context_ops wined3d_deferred_context_ops = static const struct wined3d_device_context_ops wined3d_deferred_context_ops =
{ {
wined3d_deferred_context_require_space, wined3d_deferred_context_require_space,
...@@ -3867,6 +3902,7 @@ static const struct wined3d_device_context_ops wined3d_deferred_context_ops = ...@@ -3867,6 +3902,7 @@ static const struct wined3d_device_context_ops wined3d_deferred_context_ops =
wined3d_deferred_context_acquire_blend_state, wined3d_deferred_context_acquire_blend_state,
wined3d_deferred_context_acquire_rasterizer_state, wined3d_deferred_context_acquire_rasterizer_state,
wined3d_deferred_context_acquire_depth_stencil_state, wined3d_deferred_context_acquire_depth_stencil_state,
wined3d_deferred_context_acquire_shader,
}; };
HRESULT CDECL wined3d_deferred_context_create(struct wined3d_device *device, struct wined3d_device_context **context) HRESULT CDECL wined3d_deferred_context_create(struct wined3d_device *device, struct wined3d_device_context **context)
...@@ -3936,6 +3972,10 @@ void CDECL wined3d_deferred_context_destroy(struct wined3d_device_context *conte ...@@ -3936,6 +3972,10 @@ void CDECL wined3d_deferred_context_destroy(struct wined3d_device_context *conte
wined3d_depth_stencil_state_decref(deferred->depth_stencil_states[i]); wined3d_depth_stencil_state_decref(deferred->depth_stencil_states[i]);
heap_free(deferred->depth_stencil_states); heap_free(deferred->depth_stencil_states);
for (i = 0; i < deferred->shader_count; ++i)
wined3d_shader_decref(deferred->shaders[i]);
heap_free(deferred->shaders);
wined3d_state_destroy(deferred->c.state); wined3d_state_destroy(deferred->c.state);
heap_free(deferred->data); heap_free(deferred->data);
heap_free(deferred); heap_free(deferred);
...@@ -3958,6 +3998,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device ...@@ -3958,6 +3998,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
+ deferred->blend_state_count * sizeof(*object->blend_states) + deferred->blend_state_count * sizeof(*object->blend_states)
+ deferred->rasterizer_state_count * sizeof(*object->rasterizer_states) + deferred->rasterizer_state_count * sizeof(*object->rasterizer_states)
+ deferred->depth_stencil_state_count * sizeof(*object->depth_stencil_states) + deferred->depth_stencil_state_count * sizeof(*object->depth_stencil_states)
+ deferred->shader_count * sizeof(*object->shaders)
+ deferred->data_size); + deferred->data_size);
if (!memory) if (!memory)
...@@ -4017,6 +4058,12 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device ...@@ -4017,6 +4058,12 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
deferred->depth_stencil_state_count * sizeof(*object->depth_stencil_states)); deferred->depth_stencil_state_count * sizeof(*object->depth_stencil_states));
/* Transfer our references to the depth stencil states to the command list. */ /* Transfer our references to the depth stencil states to the command list. */
object->shaders = memory;
memory = &object->shaders[deferred->shader_count];
object->shader_count = deferred->shader_count;
memcpy(object->shaders, deferred->shaders, deferred->shader_count * sizeof(*object->shaders));
/* Transfer our references to the shaders to the command list. */
object->data = memory; object->data = memory;
object->data_size = deferred->data_size; object->data_size = deferred->data_size;
memcpy(object->data, deferred->data, deferred->data_size); memcpy(object->data, deferred->data, deferred->data_size);
...@@ -4029,6 +4076,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device ...@@ -4029,6 +4076,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
deferred->blend_state_count = 0; deferred->blend_state_count = 0;
deferred->rasterizer_state_count = 0; deferred->rasterizer_state_count = 0;
deferred->depth_stencil_state_count = 0; deferred->depth_stencil_state_count = 0;
deferred->shader_count = 0;
/* This is in fact recorded into a subsequent command list. */ /* This is in fact recorded into a subsequent command list. */
if (restore) if (restore)
......
...@@ -4852,6 +4852,7 @@ struct wined3d_device_context_ops ...@@ -4852,6 +4852,7 @@ struct wined3d_device_context_ops
struct wined3d_rasterizer_state *rasterizer_state); struct wined3d_rasterizer_state *rasterizer_state);
void (*acquire_depth_stencil_state)(struct wined3d_device_context *context, void (*acquire_depth_stencil_state)(struct wined3d_device_context *context,
struct wined3d_depth_stencil_state *depth_stencil_state); struct wined3d_depth_stencil_state *depth_stencil_state);
void (*acquire_shader)(struct wined3d_device_context *context, struct wined3d_shader *shader);
}; };
struct wined3d_device_context struct wined3d_device_context
......
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