Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/wined3d/cs.c | 48 ++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 1 + 2 files changed, 49 insertions(+)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index f161b63be3c..063e8bd0a04 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -64,6 +64,9 @@ struct wined3d_command_list
SIZE_T query_count; struct wined3d_deferred_query_issue *queries; + + SIZE_T blend_state_count; + struct wined3d_blend_state **blend_states; };
static void wined3d_command_list_destroy_object(void *object) @@ -107,6 +110,8 @@ ULONG CDECL wined3d_command_list_decref(struct wined3d_command_list *list) wined3d_resource_decref(list->uploads[i].resource); for (i = 0; i < list->query_count; ++i) wined3d_query_decref(list->queries[i].query); + for (i = 0; i < list->blend_state_count; ++i) + wined3d_blend_state_decref(list->blend_states[i]);
wined3d_mutex_lock(); wined3d_cs_destroy_object(device->cs, wined3d_command_list_destroy_object, list); @@ -589,6 +594,12 @@ static inline void wined3d_device_context_acquire_resource(struct wined3d_device context->ops->acquire_resource(context, resource); }
+static inline void wined3d_device_context_acquire_blend_state(struct wined3d_device_context *context, + struct wined3d_blend_state *blend_state) +{ + context->ops->acquire_blend_state(context, blend_state); +} + static struct wined3d_cs *wined3d_cs_from_context(struct wined3d_device_context *context) { return CONTAINING_RECORD(context, struct wined3d_cs, c); @@ -1831,6 +1842,8 @@ void wined3d_device_context_emit_set_blend_state(struct wined3d_device_context * op->factor = *blend_factor; op->sample_mask = sample_mask;
+ if (state) + wined3d_device_context_acquire_blend_state(context, state); wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); }
@@ -2957,6 +2970,11 @@ static void wined3d_cs_acquire_resource(struct wined3d_device_context *context, wined3d_resource_acquire(resource); }
+static void wined3d_cs_acquire_blend_state(struct wined3d_device_context *context, + struct wined3d_blend_state *blend_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) = @@ -3196,6 +3214,7 @@ static const struct wined3d_device_context_ops wined3d_cs_st_ops = wined3d_cs_flush, wined3d_cs_acquire_resource, wined3d_cs_acquire_command_list, + wined3d_cs_acquire_blend_state, };
static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs *cs, const struct wined3d_cs_queue *queue) @@ -3323,6 +3342,7 @@ static const struct wined3d_device_context_ops wined3d_cs_mt_ops = wined3d_cs_flush, wined3d_cs_acquire_resource, wined3d_cs_acquire_command_list, + wined3d_cs_acquire_blend_state, };
static void poll_queries(struct wined3d_cs *cs) @@ -3549,6 +3569,9 @@ struct wined3d_deferred_context
SIZE_T query_count, queries_capacity; struct wined3d_deferred_query_issue *queries; + + SIZE_T blend_state_count, blend_states_capacity; + struct wined3d_blend_state **blend_states; };
static struct wined3d_deferred_context *wined3d_deferred_context_from_context(struct wined3d_device_context *context) @@ -3747,6 +3770,18 @@ static void wined3d_deferred_context_acquire_command_list(struct wined3d_device_ wined3d_command_list_incref(deferred->command_lists[deferred->command_list_count++] = list); }
+static void wined3d_deferred_context_acquire_blend_state(struct wined3d_device_context *context, + struct wined3d_blend_state *blend_state) +{ + struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context); + if (!wined3d_array_reserve((void **)&deferred->blend_states, &deferred->blend_states_capacity, + deferred->blend_state_count + 1, sizeof(*deferred->blend_states))) + return; + + deferred->blend_states[deferred->blend_state_count++] = blend_state; + wined3d_blend_state_incref(blend_state); +} + static const struct wined3d_device_context_ops wined3d_deferred_context_ops = { wined3d_deferred_context_require_space, @@ -3759,6 +3794,7 @@ static const struct wined3d_device_context_ops wined3d_deferred_context_ops = wined3d_deferred_context_flush, wined3d_deferred_context_acquire_resource, wined3d_deferred_context_acquire_command_list, + wined3d_deferred_context_acquire_blend_state, };
HRESULT CDECL wined3d_deferred_context_create(struct wined3d_device *device, struct wined3d_device_context **context) @@ -3816,6 +3852,10 @@ void CDECL wined3d_deferred_context_destroy(struct wined3d_device_context *conte wined3d_query_decref(deferred->queries[i].query); heap_free(deferred->queries);
+ for (i = 0; i < deferred->blend_state_count; ++i) + wined3d_blend_state_decref(deferred->blend_states[i]); + heap_free(deferred->blend_states); + wined3d_state_destroy(deferred->c.state); heap_free(deferred->data); heap_free(deferred); @@ -3835,6 +3875,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device + deferred->upload_count * sizeof(*object->uploads) + deferred->command_list_count * sizeof(*object->command_lists) + deferred->query_count * sizeof(*object->queries) + + deferred->blend_state_count * sizeof(*object->blend_states) + deferred->data_size);
if (!memory) @@ -3874,6 +3915,12 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device memcpy(object->queries, deferred->queries, deferred->query_count * sizeof(*object->queries)); /* Transfer our references to the queries to the command list. */
+ object->blend_states = memory; + memory = &object->blend_states[deferred->blend_state_count]; + object->blend_state_count = deferred->blend_state_count; + memcpy(object->blend_states, deferred->blend_states, deferred->blend_state_count * sizeof(*object->blend_states)); + /* Transfer our references to the blend states to the command list. */ + object->data = memory; object->data_size = deferred->data_size; memcpy(object->data, deferred->data, deferred->data_size); @@ -3883,6 +3930,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device deferred->upload_count = 0; deferred->command_list_count = 0; deferred->query_count = 0; + deferred->blend_state_count = 0;
/* This is in fact recorded into a subsequent command list. */ if (restore) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 0c5f7dda228..3a4df301dcb 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4847,6 +4847,7 @@ struct wined3d_device_context_ops void (*flush)(struct wined3d_device_context *context); void (*acquire_resource)(struct wined3d_device_context *context, struct wined3d_resource *resource); void (*acquire_command_list)(struct wined3d_device_context *context, struct wined3d_command_list *list); + void (*acquire_blend_state)(struct wined3d_device_context *context, struct wined3d_blend_state *blend_state); };
struct wined3d_device_context
Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/wined3d/cs.c | 49 ++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 2 ++ 2 files changed, 51 insertions(+)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 063e8bd0a04..1c41194eff6 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -67,6 +67,9 @@ struct wined3d_command_list
SIZE_T blend_state_count; struct wined3d_blend_state **blend_states; + + SIZE_T rasterizer_state_count; + struct wined3d_rasterizer_state **rasterizer_states; };
static void wined3d_command_list_destroy_object(void *object) @@ -112,6 +115,8 @@ ULONG CDECL wined3d_command_list_decref(struct wined3d_command_list *list) wined3d_query_decref(list->queries[i].query); for (i = 0; i < list->blend_state_count; ++i) 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]);
wined3d_mutex_lock(); wined3d_cs_destroy_object(device->cs, wined3d_command_list_destroy_object, list); @@ -600,6 +605,12 @@ static inline void wined3d_device_context_acquire_blend_state(struct wined3d_dev context->ops->acquire_blend_state(context, blend_state); }
+static inline void wined3d_device_context_acquire_rasterizer_state(struct wined3d_device_context *context, + struct wined3d_rasterizer_state *rasterizer_state) +{ + context->ops->acquire_rasterizer_state(context, rasterizer_state); +} + static struct wined3d_cs *wined3d_cs_from_context(struct wined3d_device_context *context) { return CONTAINING_RECORD(context, struct wined3d_cs, c); @@ -1891,6 +1902,8 @@ void wined3d_device_context_emit_set_rasterizer_state(struct wined3d_device_cont op->opcode = WINED3D_CS_OP_SET_RASTERIZER_STATE; op->state = rasterizer_state;
+ if (rasterizer_state) + wined3d_device_context_acquire_rasterizer_state(context, rasterizer_state); wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); }
@@ -2975,6 +2988,11 @@ static void wined3d_cs_acquire_blend_state(struct wined3d_device_context *contex { }
+static void wined3d_cs_acquire_rasterizer_state(struct wined3d_device_context *context, + struct wined3d_rasterizer_state *rasterizer_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) = @@ -3215,6 +3233,7 @@ static const struct wined3d_device_context_ops wined3d_cs_st_ops = wined3d_cs_acquire_resource, wined3d_cs_acquire_command_list, wined3d_cs_acquire_blend_state, + wined3d_cs_acquire_rasterizer_state, };
static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs *cs, const struct wined3d_cs_queue *queue) @@ -3343,6 +3362,7 @@ static const struct wined3d_device_context_ops wined3d_cs_mt_ops = wined3d_cs_acquire_resource, wined3d_cs_acquire_command_list, wined3d_cs_acquire_blend_state, + wined3d_cs_acquire_rasterizer_state, };
static void poll_queries(struct wined3d_cs *cs) @@ -3572,6 +3592,9 @@ struct wined3d_deferred_context
SIZE_T blend_state_count, blend_states_capacity; struct wined3d_blend_state **blend_states; + + SIZE_T rasterizer_state_count, rasterizer_states_capacity; + struct wined3d_rasterizer_state **rasterizer_states; };
static struct wined3d_deferred_context *wined3d_deferred_context_from_context(struct wined3d_device_context *context) @@ -3782,6 +3805,18 @@ static void wined3d_deferred_context_acquire_blend_state(struct wined3d_device_c wined3d_blend_state_incref(blend_state); }
+static void wined3d_deferred_context_acquire_rasterizer_state(struct wined3d_device_context *context, + struct wined3d_rasterizer_state *rasterizer_state) +{ + struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context); + if (!wined3d_array_reserve((void **)&deferred->rasterizer_states, &deferred->rasterizer_states_capacity, + deferred->rasterizer_state_count + 1, sizeof(*deferred->rasterizer_states))) + return; + + deferred->rasterizer_states[deferred->rasterizer_state_count++] = rasterizer_state; + wined3d_rasterizer_state_incref(rasterizer_state); +} + static const struct wined3d_device_context_ops wined3d_deferred_context_ops = { wined3d_deferred_context_require_space, @@ -3795,6 +3830,7 @@ static const struct wined3d_device_context_ops wined3d_deferred_context_ops = wined3d_deferred_context_acquire_resource, wined3d_deferred_context_acquire_command_list, wined3d_deferred_context_acquire_blend_state, + wined3d_deferred_context_acquire_rasterizer_state, };
HRESULT CDECL wined3d_deferred_context_create(struct wined3d_device *device, struct wined3d_device_context **context) @@ -3856,6 +3892,10 @@ void CDECL wined3d_deferred_context_destroy(struct wined3d_device_context *conte wined3d_blend_state_decref(deferred->blend_states[i]); heap_free(deferred->blend_states);
+ for (i = 0; i < deferred->rasterizer_state_count; ++i) + wined3d_rasterizer_state_decref(deferred->rasterizer_states[i]); + heap_free(deferred->rasterizer_states); + wined3d_state_destroy(deferred->c.state); heap_free(deferred->data); heap_free(deferred); @@ -3876,6 +3916,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device + deferred->command_list_count * sizeof(*object->command_lists) + deferred->query_count * sizeof(*object->queries) + deferred->blend_state_count * sizeof(*object->blend_states) + + deferred->rasterizer_state_count * sizeof(*object->rasterizer_states) + deferred->data_size);
if (!memory) @@ -3921,6 +3962,13 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device memcpy(object->blend_states, deferred->blend_states, deferred->blend_state_count * sizeof(*object->blend_states)); /* Transfer our references to the blend states to the command list. */
+ object->rasterizer_states = memory; + memory = &object->rasterizer_states[deferred->rasterizer_state_count]; + object->rasterizer_state_count = deferred->rasterizer_state_count; + memcpy(object->rasterizer_states, deferred->rasterizer_states, + deferred->rasterizer_state_count * sizeof(*object->rasterizer_states)); + /* Transfer our references to the rasterizer states to the command list. */ + object->data = memory; object->data_size = deferred->data_size; memcpy(object->data, deferred->data, deferred->data_size); @@ -3931,6 +3979,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device deferred->command_list_count = 0; deferred->query_count = 0; deferred->blend_state_count = 0; + deferred->rasterizer_state_count = 0;
/* This is in fact recorded into a subsequent command list. */ if (restore) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 3a4df301dcb..ecdfe1006a3 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4848,6 +4848,8 @@ struct wined3d_device_context_ops void (*acquire_resource)(struct wined3d_device_context *context, struct wined3d_resource *resource); void (*acquire_command_list)(struct wined3d_device_context *context, struct wined3d_command_list *list); 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); };
struct wined3d_device_context
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/wined3d/cs.c | 49 ++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 2 ++ 2 files changed, 51 insertions(+)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 1c41194eff6..911b9a2b9c8 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -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) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index ecdfe1006a3..74c7932220b 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -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
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/wined3d/cs.c | 48 ++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 1 + 2 files changed, 49 insertions(+)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 911b9a2b9c8..2aa9f570d3e 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -73,6 +73,9 @@ struct wined3d_command_list
SIZE_T depth_stencil_state_count; 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) @@ -122,6 +125,8 @@ ULONG CDECL wined3d_command_list_decref(struct wined3d_command_list *list) 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]); + for (i = 0; i < list->shader_count; ++i) + wined3d_shader_decref(list->shaders[i]);
wined3d_mutex_lock(); 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 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) { return CONTAINING_RECORD(context, struct wined3d_cs, c); @@ -1834,6 +1845,8 @@ void wined3d_device_context_emit_set_shader(struct wined3d_device_context *conte op->type = type; op->shader = shader;
+ if (shader) + wined3d_device_context_acquire_shader(context, shader); 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 { }
+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 (* 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 = wined3d_cs_acquire_blend_state, wined3d_cs_acquire_rasterizer_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) @@ -3383,6 +3402,7 @@ static const struct wined3d_device_context_ops wined3d_cs_mt_ops = wined3d_cs_acquire_blend_state, wined3d_cs_acquire_rasterizer_state, wined3d_cs_acquire_depth_stencil_state, + wined3d_cs_acquire_shader, };
static void poll_queries(struct wined3d_cs *cs) @@ -3618,6 +3638,9 @@ struct wined3d_deferred_context
SIZE_T depth_stencil_state_count, depth_stencil_states_capacity; 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) @@ -3852,6 +3875,18 @@ static void wined3d_deferred_context_acquire_depth_stencil_state(struct wined3d_ 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 = { wined3d_deferred_context_require_space, @@ -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_rasterizer_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) @@ -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]); 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); heap_free(deferred->data); heap_free(deferred); @@ -3958,6 +3998,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device + 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->shader_count * sizeof(*object->shaders) + deferred->data_size);
if (!memory) @@ -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)); /* 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_size = 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 deferred->blend_state_count = 0; deferred->rasterizer_state_count = 0; deferred->depth_stencil_state_count = 0; + deferred->shader_count = 0;
/* This is in fact recorded into a subsequent command list. */ if (restore) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 74c7932220b..94f0f94b1d7 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4852,6 +4852,7 @@ struct wined3d_device_context_ops struct wined3d_rasterizer_state *rasterizer_state); 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); };
struct wined3d_device_context
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/wined3d/cs.c | 55 ++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 2 ++ 2 files changed, 57 insertions(+)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 2aa9f570d3e..caeb4edbc1a 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -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) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 94f0f94b1d7..7838d45425a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -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
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com