wined3d: Acquire references to depth stencil states in deferred contexts.
Signed-off-by: Jan Sikorski <jsikorski@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
a313f6bc5c
commit
6057507be4
|
@ -70,6 +70,9 @@ struct wined3d_command_list
|
|||
|
||||
SIZE_T rasterizer_state_count;
|
||||
struct wined3d_rasterizer_state **rasterizer_states;
|
||||
|
||||
SIZE_T depth_stencil_state_count;
|
||||
struct wined3d_depth_stencil_state **depth_stencil_states;
|
||||
};
|
||||
|
||||
static void wined3d_command_list_destroy_object(void *object)
|
||||
|
@ -117,6 +120,8 @@ ULONG CDECL wined3d_command_list_decref(struct wined3d_command_list *list)
|
|||
wined3d_blend_state_decref(list->blend_states[i]);
|
||||
for (i = 0; i < list->rasterizer_state_count; ++i)
|
||||
wined3d_rasterizer_state_decref(list->rasterizer_states[i]);
|
||||
for (i = 0; i < list->depth_stencil_state_count; ++i)
|
||||
wined3d_depth_stencil_state_decref(list->depth_stencil_states[i]);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
wined3d_cs_destroy_object(device->cs, wined3d_command_list_destroy_object, list);
|
||||
|
@ -611,6 +616,12 @@ static inline void wined3d_device_context_acquire_rasterizer_state(struct wined3
|
|||
context->ops->acquire_rasterizer_state(context, rasterizer_state);
|
||||
}
|
||||
|
||||
static inline void wined3d_device_context_acquire_depth_stencil_state(struct wined3d_device_context *context,
|
||||
struct wined3d_depth_stencil_state *depth_stencil_state)
|
||||
{
|
||||
context->ops->acquire_depth_stencil_state(context, depth_stencil_state);
|
||||
}
|
||||
|
||||
static struct wined3d_cs *wined3d_cs_from_context(struct wined3d_device_context *context)
|
||||
{
|
||||
return CONTAINING_RECORD(context, struct wined3d_cs, c);
|
||||
|
@ -1882,6 +1893,8 @@ void wined3d_device_context_emit_set_depth_stencil_state(struct wined3d_device_c
|
|||
op->state = state;
|
||||
op->stencil_ref = stencil_ref;
|
||||
|
||||
if (state)
|
||||
wined3d_device_context_acquire_depth_stencil_state(context, state);
|
||||
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
|
||||
}
|
||||
|
||||
|
@ -2993,6 +3006,11 @@ static void wined3d_cs_acquire_rasterizer_state(struct wined3d_device_context *c
|
|||
{
|
||||
}
|
||||
|
||||
static void wined3d_cs_acquire_depth_stencil_state(struct wined3d_device_context *context,
|
||||
struct wined3d_depth_stencil_state *depth_stencil_state)
|
||||
{
|
||||
}
|
||||
|
||||
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) =
|
||||
|
@ -3234,6 +3252,7 @@ static const struct wined3d_device_context_ops wined3d_cs_st_ops =
|
|||
wined3d_cs_acquire_command_list,
|
||||
wined3d_cs_acquire_blend_state,
|
||||
wined3d_cs_acquire_rasterizer_state,
|
||||
wined3d_cs_acquire_depth_stencil_state,
|
||||
};
|
||||
|
||||
static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs *cs, const struct wined3d_cs_queue *queue)
|
||||
|
@ -3363,6 +3382,7 @@ static const struct wined3d_device_context_ops wined3d_cs_mt_ops =
|
|||
wined3d_cs_acquire_command_list,
|
||||
wined3d_cs_acquire_blend_state,
|
||||
wined3d_cs_acquire_rasterizer_state,
|
||||
wined3d_cs_acquire_depth_stencil_state,
|
||||
};
|
||||
|
||||
static void poll_queries(struct wined3d_cs *cs)
|
||||
|
@ -3595,6 +3615,9 @@ struct wined3d_deferred_context
|
|||
|
||||
SIZE_T rasterizer_state_count, rasterizer_states_capacity;
|
||||
struct wined3d_rasterizer_state **rasterizer_states;
|
||||
|
||||
SIZE_T depth_stencil_state_count, depth_stencil_states_capacity;
|
||||
struct wined3d_depth_stencil_state **depth_stencil_states;
|
||||
};
|
||||
|
||||
static struct wined3d_deferred_context *wined3d_deferred_context_from_context(struct wined3d_device_context *context)
|
||||
|
@ -3817,6 +3840,18 @@ static void wined3d_deferred_context_acquire_rasterizer_state(struct wined3d_dev
|
|||
wined3d_rasterizer_state_incref(rasterizer_state);
|
||||
}
|
||||
|
||||
static void wined3d_deferred_context_acquire_depth_stencil_state(struct wined3d_device_context *context,
|
||||
struct wined3d_depth_stencil_state *depth_stencil_state)
|
||||
{
|
||||
struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context);
|
||||
if (!wined3d_array_reserve((void **)&deferred->depth_stencil_states, &deferred->depth_stencil_states_capacity,
|
||||
deferred->depth_stencil_state_count + 1, sizeof(*deferred->depth_stencil_states)))
|
||||
return;
|
||||
|
||||
deferred->depth_stencil_states[deferred->depth_stencil_state_count++] = depth_stencil_state;
|
||||
wined3d_depth_stencil_state_incref(depth_stencil_state);
|
||||
}
|
||||
|
||||
static const struct wined3d_device_context_ops wined3d_deferred_context_ops =
|
||||
{
|
||||
wined3d_deferred_context_require_space,
|
||||
|
@ -3831,6 +3866,7 @@ static const struct wined3d_device_context_ops wined3d_deferred_context_ops =
|
|||
wined3d_deferred_context_acquire_command_list,
|
||||
wined3d_deferred_context_acquire_blend_state,
|
||||
wined3d_deferred_context_acquire_rasterizer_state,
|
||||
wined3d_deferred_context_acquire_depth_stencil_state,
|
||||
};
|
||||
|
||||
HRESULT CDECL wined3d_deferred_context_create(struct wined3d_device *device, struct wined3d_device_context **context)
|
||||
|
@ -3896,6 +3932,10 @@ void CDECL wined3d_deferred_context_destroy(struct wined3d_device_context *conte
|
|||
wined3d_rasterizer_state_decref(deferred->rasterizer_states[i]);
|
||||
heap_free(deferred->rasterizer_states);
|
||||
|
||||
for (i = 0; i < deferred->depth_stencil_state_count; ++i)
|
||||
wined3d_depth_stencil_state_decref(deferred->depth_stencil_states[i]);
|
||||
heap_free(deferred->depth_stencil_states);
|
||||
|
||||
wined3d_state_destroy(deferred->c.state);
|
||||
heap_free(deferred->data);
|
||||
heap_free(deferred);
|
||||
|
@ -3917,6 +3957,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
|
|||
+ deferred->query_count * sizeof(*object->queries)
|
||||
+ deferred->blend_state_count * sizeof(*object->blend_states)
|
||||
+ deferred->rasterizer_state_count * sizeof(*object->rasterizer_states)
|
||||
+ deferred->depth_stencil_state_count * sizeof(*object->depth_stencil_states)
|
||||
+ deferred->data_size);
|
||||
|
||||
if (!memory)
|
||||
|
@ -3969,6 +4010,13 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
|
|||
deferred->rasterizer_state_count * sizeof(*object->rasterizer_states));
|
||||
/* Transfer our references to the rasterizer states to the command list. */
|
||||
|
||||
object->depth_stencil_states = memory;
|
||||
memory = &object->depth_stencil_states[deferred->depth_stencil_state_count];
|
||||
object->depth_stencil_state_count = deferred->depth_stencil_state_count;
|
||||
memcpy(object->depth_stencil_states, deferred->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. */
|
||||
|
||||
object->data = memory;
|
||||
object->data_size = deferred->data_size;
|
||||
memcpy(object->data, deferred->data, deferred->data_size);
|
||||
|
@ -3980,6 +4028,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
|
|||
deferred->query_count = 0;
|
||||
deferred->blend_state_count = 0;
|
||||
deferred->rasterizer_state_count = 0;
|
||||
deferred->depth_stencil_state_count = 0;
|
||||
|
||||
/* This is in fact recorded into a subsequent command list. */
|
||||
if (restore)
|
||||
|
|
|
@ -4850,6 +4850,8 @@ struct wined3d_device_context_ops
|
|||
void (*acquire_blend_state)(struct wined3d_device_context *context, struct wined3d_blend_state *blend_state);
|
||||
void (*acquire_rasterizer_state)(struct wined3d_device_context *context,
|
||||
struct wined3d_rasterizer_state *rasterizer_state);
|
||||
void (*acquire_depth_stencil_state)(struct wined3d_device_context *context,
|
||||
struct wined3d_depth_stencil_state *depth_stencil_state);
|
||||
};
|
||||
|
||||
struct wined3d_device_context
|
||||
|
|
Loading…
Reference in New Issue