Commit 0056ebf9 authored by Jan Sikorski's avatar Jan Sikorski Committed by Alexandre Julliard

wined3d: Acquire references to samplers in deferred contexts.

parent 908fb507
......@@ -76,6 +76,9 @@ struct wined3d_command_list
SIZE_T shader_count;
struct wined3d_shader **shaders;
SIZE_T sampler_count;
struct wined3d_sampler **samplers;
};
static void wined3d_command_list_destroy_object(void *object)
......@@ -127,6 +130,8 @@ ULONG CDECL wined3d_command_list_decref(struct wined3d_command_list *list)
wined3d_depth_stencil_state_decref(list->depth_stencil_states[i]);
for (i = 0; i < list->shader_count; ++i)
wined3d_shader_decref(list->shaders[i]);
for (i = 0; i < list->sampler_count; ++i)
wined3d_sampler_decref(list->samplers[i]);
wined3d_mutex_lock();
wined3d_cs_destroy_object(device->cs, wined3d_command_list_destroy_object, list);
......@@ -633,6 +638,12 @@ static inline void wined3d_device_context_acquire_shader(struct wined3d_device_c
context->ops->acquire_shader(context, shader);
}
static inline void wined3d_device_context_acquire_samplers(struct wined3d_device_context *context,
struct wined3d_sampler * const *samplers, unsigned int count)
{
context->ops->acquire_samplers(context, samplers, count);
}
static struct wined3d_cs *wined3d_cs_from_context(struct wined3d_device_context *context)
{
return CONTAINING_RECORD(context, struct wined3d_cs, c);
......@@ -1820,6 +1831,7 @@ void wined3d_device_context_emit_set_samplers(struct wined3d_device_context *con
op->count = count;
memcpy(op->samplers, samplers, count * sizeof(*samplers));
wined3d_device_context_acquire_samplers(context, samplers, count);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
}
......@@ -3029,6 +3041,11 @@ static void wined3d_cs_acquire_shader(struct wined3d_device_context *context,
{
}
static void wined3d_cs_acquire_samplers(struct wined3d_device_context *context,
struct wined3d_sampler * const *samplers, unsigned int count)
{
}
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) =
......@@ -3272,6 +3289,7 @@ static const struct wined3d_device_context_ops wined3d_cs_st_ops =
wined3d_cs_acquire_rasterizer_state,
wined3d_cs_acquire_depth_stencil_state,
wined3d_cs_acquire_shader,
wined3d_cs_acquire_samplers,
};
static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs *cs, const struct wined3d_cs_queue *queue)
......@@ -3403,6 +3421,7 @@ static const struct wined3d_device_context_ops wined3d_cs_mt_ops =
wined3d_cs_acquire_rasterizer_state,
wined3d_cs_acquire_depth_stencil_state,
wined3d_cs_acquire_shader,
wined3d_cs_acquire_samplers,
};
static void poll_queries(struct wined3d_cs *cs)
......@@ -3641,6 +3660,9 @@ struct wined3d_deferred_context
SIZE_T shader_count, shaders_capacity;
struct wined3d_shader **shaders;
SIZE_T sampler_count, samplers_capacity;
struct wined3d_sampler **samplers;
};
static struct wined3d_deferred_context *wined3d_deferred_context_from_context(struct wined3d_device_context *context)
......@@ -3887,6 +3909,26 @@ static void wined3d_deferred_context_acquire_shader(struct wined3d_device_contex
wined3d_shader_incref(shader);
}
static void wined3d_deferred_context_acquire_samplers(struct wined3d_device_context *context,
struct wined3d_sampler * const *samplers, unsigned int count)
{
struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context);
unsigned int i;
if (!wined3d_array_reserve((void **)&deferred->samplers, &deferred->samplers_capacity,
deferred->sampler_count + count, sizeof(*deferred->samplers)))
return;
for (i = 0; i < count; ++i)
{
if (samplers[i])
{
deferred->samplers[deferred->sampler_count++] = samplers[i];
wined3d_sampler_incref(samplers[i]);
}
}
}
static const struct wined3d_device_context_ops wined3d_deferred_context_ops =
{
wined3d_deferred_context_require_space,
......@@ -3903,6 +3945,7 @@ static const struct wined3d_device_context_ops wined3d_deferred_context_ops =
wined3d_deferred_context_acquire_rasterizer_state,
wined3d_deferred_context_acquire_depth_stencil_state,
wined3d_deferred_context_acquire_shader,
wined3d_deferred_context_acquire_samplers,
};
HRESULT CDECL wined3d_deferred_context_create(struct wined3d_device *device, struct wined3d_device_context **context)
......@@ -3976,6 +4019,10 @@ void CDECL wined3d_deferred_context_destroy(struct wined3d_device_context *conte
wined3d_shader_decref(deferred->shaders[i]);
heap_free(deferred->shaders);
for (i = 0; i < deferred->sampler_count; ++i)
wined3d_sampler_decref(deferred->samplers[i]);
heap_free(deferred->samplers);
wined3d_state_destroy(deferred->c.state);
heap_free(deferred->data);
heap_free(deferred);
......@@ -3999,6 +4046,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
+ deferred->rasterizer_state_count * sizeof(*object->rasterizer_states)
+ deferred->depth_stencil_state_count * sizeof(*object->depth_stencil_states)
+ deferred->shader_count * sizeof(*object->shaders)
+ deferred->sampler_count * sizeof(*object->samplers)
+ deferred->data_size);
if (!memory)
......@@ -4064,6 +4112,12 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
memcpy(object->shaders, deferred->shaders, deferred->shader_count * sizeof(*object->shaders));
/* Transfer our references to the shaders to the command list. */
object->samplers = memory;
memory = &object->samplers[deferred->sampler_count];
object->sampler_count = deferred->sampler_count;
memcpy(object->samplers, deferred->samplers, deferred->sampler_count * sizeof(*object->samplers));
/* Transfer our references to the samplers to the command list. */
object->data = memory;
object->data_size = deferred->data_size;
memcpy(object->data, deferred->data, deferred->data_size);
......@@ -4077,6 +4131,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
deferred->rasterizer_state_count = 0;
deferred->depth_stencil_state_count = 0;
deferred->shader_count = 0;
deferred->sampler_count = 0;
/* This is in fact recorded into a subsequent command list. */
if (restore)
......
......@@ -4853,6 +4853,8 @@ struct wined3d_device_context_ops
void (*acquire_depth_stencil_state)(struct wined3d_device_context *context,
struct wined3d_depth_stencil_state *depth_stencil_state);
void (*acquire_shader)(struct wined3d_device_context *context, struct wined3d_shader *shader);
void (*acquire_samplers)(struct wined3d_device_context *context, struct wined3d_sampler * const *samplers,
unsigned int count);
};
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