Commit fc3919c4 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Separate the "ops" member of struct wined3d_cs to a new wined3d_device_context structure.

parent cc82a51a
......@@ -4807,7 +4807,7 @@ static void wined3d_view_gl_destroy(struct wined3d_device *device,
wined3d_cs_destroy_object(device->cs, wined3d_view_gl_destroy_object, ctx);
if (ctx == &c)
device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
device->cs->c.ops->finish(&device->cs->c, WINED3D_CS_QUEUE_DEFAULT);
}
static void adapter_gl_destroy_rendertarget_view(struct wined3d_rendertarget_view *view)
......
......@@ -1394,7 +1394,7 @@ static void wined3d_view_vk_destroy(struct wined3d_device *device, VkBufferView
wined3d_cs_destroy_object(device->cs, wined3d_view_vk_destroy_object, ctx);
if (ctx == &c)
device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
device->cs->c.ops->finish(&device->cs->c, WINED3D_CS_QUEUE_DEFAULT);
}
static void adapter_vk_destroy_rendertarget_view(struct wined3d_rendertarget_view *view)
......
......@@ -458,12 +458,12 @@ struct wined3d_cs_stop
static inline void *wined3d_cs_require_space(struct wined3d_cs *cs,
size_t size, enum wined3d_cs_queue_id queue_id)
{
return cs->ops->require_space(cs, size, queue_id);
return cs->c.ops->require_space(&cs->c, size, queue_id);
}
static inline void wined3d_cs_submit(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
{
cs->ops->submit(cs, queue_id);
cs->c.ops->submit(&cs->c, queue_id);
}
static const char *debug_cs_op(enum wined3d_cs_op op)
......@@ -2023,9 +2023,15 @@ wined3d_cs_push_constant_info[] =
{FIELD_OFFSET(struct wined3d_state, ps_consts_b), sizeof(BOOL), WINED3D_SHADER_CONST_PS_B},
};
static void wined3d_cs_st_push_constants(struct wined3d_cs *cs, enum wined3d_push_constants p,
static struct wined3d_cs *wined3d_cs_from_context(struct wined3d_device_context *context)
{
return CONTAINING_RECORD(context, struct wined3d_cs, c);
}
static void wined3d_cs_st_push_constants(struct wined3d_device_context *context, enum wined3d_push_constants p,
unsigned int start_idx, unsigned int count, const void *constants)
{
struct wined3d_cs *cs = wined3d_cs_from_context(context);
struct wined3d_device *device = cs->device;
unsigned int context_count;
unsigned int i;
......@@ -2048,12 +2054,13 @@ static void wined3d_cs_exec_push_constants(struct wined3d_cs *cs, const void *da
{
const struct wined3d_cs_push_constants *op = data;
wined3d_cs_st_push_constants(cs, op->type, op->start_idx, op->count, op->constants);
wined3d_cs_st_push_constants(&cs->c, op->type, op->start_idx, op->count, op->constants);
}
static void wined3d_cs_mt_push_constants(struct wined3d_cs *cs, enum wined3d_push_constants p,
static void wined3d_cs_mt_push_constants(struct wined3d_device_context *context, enum wined3d_push_constants p,
unsigned int start_idx, unsigned int count, const void *constants)
{
struct wined3d_cs *cs = wined3d_cs_from_context(context);
struct wined3d_cs_push_constants *op;
size_t size;
......@@ -2669,8 +2676,11 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void
/* WINED3D_CS_OP_GENERATE_MIPMAPS */ wined3d_cs_exec_generate_mipmaps,
};
static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id)
static void *wined3d_cs_st_require_space(struct wined3d_device_context *context,
size_t size, enum wined3d_cs_queue_id queue_id)
{
struct wined3d_cs *cs = wined3d_cs_from_context(context);
if (size > (cs->data_size - cs->end))
{
size_t new_size;
......@@ -2694,8 +2704,9 @@ static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size, enu
return (BYTE *)cs->data + cs->start;
}
static void wined3d_cs_st_submit(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
static void wined3d_cs_st_submit(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
{
struct wined3d_cs *cs = wined3d_cs_from_context(context);
enum wined3d_cs_op opcode;
size_t start;
BYTE *data;
......@@ -2716,11 +2727,11 @@ static void wined3d_cs_st_submit(struct wined3d_cs *cs, enum wined3d_cs_queue_id
heap_free(data);
}
static void wined3d_cs_st_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
static void wined3d_cs_st_finish(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
{
}
static const struct wined3d_cs_ops wined3d_cs_st_ops =
static const struct wined3d_device_context_ops wined3d_cs_st_ops =
{
wined3d_cs_st_require_space,
wined3d_cs_st_submit,
......@@ -2747,10 +2758,12 @@ static void wined3d_cs_queue_submit(struct wined3d_cs_queue *queue, struct wined
SetEvent(cs->event);
}
static void wined3d_cs_mt_submit(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
static void wined3d_cs_mt_submit(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
{
struct wined3d_cs *cs = wined3d_cs_from_context(context);
if (cs->thread_id == GetCurrentThreadId())
return wined3d_cs_st_submit(cs, queue_id);
return wined3d_cs_st_submit(context, queue_id);
wined3d_cs_queue_submit(&cs->queue[queue_id], cs);
}
......@@ -2817,24 +2830,29 @@ static void *wined3d_cs_queue_require_space(struct wined3d_cs_queue *queue, size
return packet->data;
}
static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id)
static void *wined3d_cs_mt_require_space(struct wined3d_device_context *context,
size_t size, enum wined3d_cs_queue_id queue_id)
{
struct wined3d_cs *cs = wined3d_cs_from_context(context);
if (cs->thread_id == GetCurrentThreadId())
return wined3d_cs_st_require_space(cs, size, queue_id);
return wined3d_cs_st_require_space(context, size, queue_id);
return wined3d_cs_queue_require_space(&cs->queue[queue_id], size, cs);
}
static void wined3d_cs_mt_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
static void wined3d_cs_mt_finish(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id)
{
struct wined3d_cs *cs = wined3d_cs_from_context(context);
if (cs->thread_id == GetCurrentThreadId())
return wined3d_cs_st_finish(cs, queue_id);
return wined3d_cs_st_finish(context, queue_id);
while (cs->queue[queue_id].head != *(volatile LONG *)&cs->queue[queue_id].tail)
YieldProcessor();
}
static const struct wined3d_cs_ops wined3d_cs_mt_ops =
static const struct wined3d_device_context_ops wined3d_cs_mt_ops =
{
wined3d_cs_mt_require_space,
wined3d_cs_mt_submit,
......@@ -2969,7 +2987,7 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)
if (!(cs = heap_alloc_zero(sizeof(*cs))))
return NULL;
cs->ops = &wined3d_cs_st_ops;
cs->c.ops = &wined3d_cs_st_ops;
cs->device = device;
cs->serialize_commands = TRACE_ON(d3d_sync) || wined3d_settings.cs_multithreaded & WINED3D_CSMT_SERIALIZE;
......@@ -2982,7 +3000,7 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)
if (wined3d_settings.cs_multithreaded & WINED3D_CSMT_ENABLE
&& !RtlIsCriticalSectionLockedByThread(NtCurrentTeb()->Peb->LoaderLock))
{
cs->ops = &wined3d_cs_mt_ops;
cs->c.ops = &wined3d_cs_mt_ops;
if (!(cs->event = CreateEventW(NULL, FALSE, FALSE, NULL)))
{
......
......@@ -89,6 +89,7 @@ struct wined3d_adapter;
struct wined3d_buffer_vk;
struct wined3d_context;
struct wined3d_context_vk;
struct wined3d_device_context;
struct wined3d_gl_info;
struct wined3d_state;
struct wined3d_swapchain_gl;
......@@ -4671,18 +4672,24 @@ struct wined3d_cs_queue
BYTE data[WINED3D_CS_QUEUE_SIZE];
};
struct wined3d_cs_ops
struct wined3d_device_context_ops
{
void *(*require_space)(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id);
void (*submit)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id);
void (*finish)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id);
void (*push_constants)(struct wined3d_cs *cs, enum wined3d_push_constants p,
void *(*require_space)(struct wined3d_device_context *context, size_t size, enum wined3d_cs_queue_id queue_id);
void (*submit)(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id);
void (*finish)(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id);
void (*push_constants)(struct wined3d_device_context *context, enum wined3d_push_constants p,
unsigned int start_idx, unsigned int count, const void *constants);
};
struct wined3d_device_context
{
const struct wined3d_device_context_ops *ops;
};
struct wined3d_cs
{
const struct wined3d_cs_ops *ops;
struct wined3d_device_context c;
struct wined3d_device *device;
struct wined3d_state state;
HMODULE wined3d_module;
......@@ -4800,13 +4807,13 @@ HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resourc
static inline void wined3d_cs_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
{
cs->ops->finish(cs, queue_id);
cs->c.ops->finish(&cs->c, queue_id);
}
static inline void wined3d_cs_push_constants(struct wined3d_cs *cs, enum wined3d_push_constants p,
unsigned int start_idx, unsigned int count, const void *constants)
{
cs->ops->push_constants(cs, p, start_idx, count, constants);
cs->c.ops->push_constants(&cs->c, p, start_idx, count, constants);
}
static inline void wined3d_resource_wait_idle(struct wined3d_resource *resource)
......
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