Commit 34a9d3e4 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Set an array of samplers as a single CS operation.

parent 7698b9e2
......@@ -124,7 +124,7 @@ enum wined3d_cs_op
WINED3D_CS_OP_SET_TEXTURE,
WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEWS,
WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW,
WINED3D_CS_OP_SET_SAMPLER,
WINED3D_CS_OP_SET_SAMPLERS,
WINED3D_CS_OP_SET_SHADER,
WINED3D_CS_OP_SET_BLEND_STATE,
WINED3D_CS_OP_SET_DEPTH_STENCIL_STATE,
......@@ -328,12 +328,13 @@ struct wined3d_cs_set_unordered_access_view
unsigned int initial_count;
};
struct wined3d_cs_set_sampler
struct wined3d_cs_set_samplers
{
enum wined3d_cs_op opcode;
enum wined3d_shader_type type;
UINT sampler_idx;
struct wined3d_sampler *sampler;
unsigned int start_idx;
unsigned int count;
struct wined3d_sampler *samplers[1];
};
struct wined3d_cs_set_shader
......@@ -604,7 +605,7 @@ static const char *debug_cs_op(enum wined3d_cs_op op)
WINED3D_TO_STR(WINED3D_CS_OP_SET_TEXTURE);
WINED3D_TO_STR(WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEWS);
WINED3D_TO_STR(WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW);
WINED3D_TO_STR(WINED3D_CS_OP_SET_SAMPLER);
WINED3D_TO_STR(WINED3D_CS_OP_SET_SAMPLERS);
WINED3D_TO_STR(WINED3D_CS_OP_SET_SHADER);
WINED3D_TO_STR(WINED3D_CS_OP_SET_BLEND_STATE);
WINED3D_TO_STR(WINED3D_CS_OP_SET_DEPTH_STENCIL_STATE);
......@@ -1736,27 +1737,32 @@ void wined3d_device_context_emit_set_unordered_access_view(struct wined3d_device
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
}
static void wined3d_cs_exec_set_sampler(struct wined3d_cs *cs, const void *data)
static void wined3d_cs_exec_set_samplers(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_set_sampler *op = data;
const struct wined3d_cs_set_samplers *op = data;
unsigned int i;
for (i = 0; i < op->count; ++i)
cs->state.sampler[op->type][op->start_idx + i] = op->samplers[i];
cs->state.sampler[op->type][op->sampler_idx] = op->sampler;
if (op->type != WINED3D_SHADER_TYPE_COMPUTE)
device_invalidate_state(cs->c.device, STATE_GRAPHICS_SHADER_RESOURCE_BINDING);
else
device_invalidate_state(cs->c.device, STATE_COMPUTE_SHADER_RESOURCE_BINDING);
}
void wined3d_device_context_emit_set_sampler(struct wined3d_device_context *context, enum wined3d_shader_type type,
unsigned int sampler_idx, struct wined3d_sampler *sampler)
void wined3d_device_context_emit_set_samplers(struct wined3d_device_context *context, enum wined3d_shader_type type,
unsigned int start_idx, unsigned int count, struct wined3d_sampler *const *samplers)
{
struct wined3d_cs_set_sampler *op;
struct wined3d_cs_set_samplers *op;
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
op->opcode = WINED3D_CS_OP_SET_SAMPLER;
op = wined3d_device_context_require_space(context, offsetof(struct wined3d_cs_set_samplers, samplers[count]),
WINED3D_CS_QUEUE_DEFAULT);
op->opcode = WINED3D_CS_OP_SET_SAMPLERS;
op->type = type;
op->sampler_idx = sampler_idx;
op->sampler = sampler;
op->start_idx = start_idx;
op->count = count;
memcpy(op->samplers, samplers, count * sizeof(*samplers));
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
}
......@@ -2912,7 +2918,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void
/* WINED3D_CS_OP_SET_TEXTURE */ wined3d_cs_exec_set_texture,
/* WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEWS */ wined3d_cs_exec_set_shader_resource_views,
/* WINED3D_CS_OP_SET_UNORDERED_ACCESS_VIEW */ wined3d_cs_exec_set_unordered_access_view,
/* WINED3D_CS_OP_SET_SAMPLER */ wined3d_cs_exec_set_sampler,
/* WINED3D_CS_OP_SET_SAMPLERS */ wined3d_cs_exec_set_samplers,
/* WINED3D_CS_OP_SET_SHADER */ wined3d_cs_exec_set_shader,
/* WINED3D_CS_OP_SET_BLEND_STATE */ wined3d_cs_exec_set_blend_state,
/* WINED3D_CS_OP_SET_DEPTH_STENCIL_STATE */ wined3d_cs_exec_set_depth_stencil_state,
......
......@@ -1697,10 +1697,7 @@ void CDECL wined3d_device_context_set_state(struct wined3d_device_context *conte
{
wined3d_device_context_emit_set_shader(context, i, state->shader[i]);
wined3d_device_context_emit_set_constant_buffers(context, i, 0, MAX_CONSTANT_BUFFERS, state->cb[i]);
for (j = 0; j < MAX_SAMPLER_OBJECTS; ++j)
{
wined3d_device_context_emit_set_sampler(context, i, j, state->sampler[i][j]);
}
wined3d_device_context_emit_set_samplers(context, i, 0, MAX_SAMPLER_OBJECTS, state->sampler[i]);
wined3d_device_context_emit_set_shader_resource_views(context, i, 0,
MAX_SHADER_RESOURCE_VIEWS, state->shader_resource_view[i]);
}
......@@ -2035,30 +2032,35 @@ void CDECL wined3d_device_context_set_shader_resource_views(struct wined3d_devic
}
}
void CDECL wined3d_device_context_set_sampler(struct wined3d_device_context *context,
enum wined3d_shader_type type, unsigned int idx, struct wined3d_sampler *sampler)
void CDECL wined3d_device_context_set_samplers(struct wined3d_device_context *context, enum wined3d_shader_type type,
unsigned int start_idx, unsigned int count, struct wined3d_sampler *const *samplers)
{
struct wined3d_state *state = context->state;
struct wined3d_sampler *prev;
unsigned int i;
TRACE("context %p, type %#x, idx %u, sampler %p.\n", context, type, idx, sampler);
TRACE("context %p, type %#x, start_idx %u, count %u, samplers %p.\n", context, type, start_idx, count, samplers);
if (idx >= MAX_SAMPLER_OBJECTS)
if (start_idx >= MAX_SAMPLER_OBJECTS || count > MAX_SAMPLER_OBJECTS - start_idx)
{
WARN("Invalid sampler index %u.\n", idx);
WARN("Invalid sampler index %u, count %u.\n", start_idx, count);
return;
}
prev = state->sampler[type][idx];
if (sampler == prev)
if (!memcmp(samplers, &state->sampler[type][start_idx], count * sizeof(*samplers)))
return;
if (sampler)
wined3d_sampler_incref(sampler);
state->sampler[type][idx] = sampler;
wined3d_device_context_emit_set_sampler(context, type, idx, sampler);
if (prev)
wined3d_sampler_decref(prev);
wined3d_device_context_emit_set_samplers(context, type, start_idx, count, samplers);
for (i = 0; i < count; ++i)
{
struct wined3d_sampler *prev = state->sampler[type][start_idx + i];
struct wined3d_sampler *sampler = samplers[i];
if (sampler)
wined3d_sampler_incref(sampler);
state->sampler[type][start_idx + i] = sampler;
if (prev)
wined3d_sampler_decref(prev);
}
}
void CDECL wined3d_device_context_set_unordered_access_view(struct wined3d_device_context *context,
......
......@@ -131,7 +131,7 @@
@ cdecl wined3d_device_context_set_primitive_type(ptr long long)
@ cdecl wined3d_device_context_set_rasterizer_state(ptr ptr)
@ cdecl wined3d_device_context_set_rendertarget_view(ptr long ptr long)
@ cdecl wined3d_device_context_set_sampler(ptr long long ptr)
@ cdecl wined3d_device_context_set_samplers(ptr long long long ptr)
@ cdecl wined3d_device_context_set_scissor_rects(ptr long ptr)
@ cdecl wined3d_device_context_set_shader(ptr long ptr)
@ cdecl wined3d_device_context_set_shader_resource_views(ptr long long long ptr)
......
......@@ -4835,8 +4835,8 @@ void wined3d_device_context_emit_set_render_state(struct wined3d_device_context
enum wined3d_render_state state, unsigned int value) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_set_rendertarget_view(struct wined3d_device_context *context, unsigned int view_idx,
struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_set_sampler(struct wined3d_device_context *context, enum wined3d_shader_type type,
unsigned int sampler_idx, struct wined3d_sampler *sampler) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_set_samplers(struct wined3d_device_context *context, enum wined3d_shader_type type,
unsigned int start_idx, unsigned int count, struct wined3d_sampler *const *samplers) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_set_sampler_state(struct wined3d_device_context *context, unsigned int sampler_idx,
enum wined3d_sampler_state state, unsigned int value) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_set_scissor_rects(struct wined3d_device_context *context,
......
......@@ -2513,8 +2513,8 @@ void __cdecl wined3d_device_context_set_rasterizer_state(struct wined3d_device_c
struct wined3d_rasterizer_state *rasterizer_state);
HRESULT __cdecl wined3d_device_context_set_rendertarget_view(struct wined3d_device_context *context,
unsigned int view_idx, struct wined3d_rendertarget_view *view, BOOL set_viewport);
void __cdecl wined3d_device_context_set_sampler(struct wined3d_device_context *context,
enum wined3d_shader_type type, unsigned int idx, struct wined3d_sampler *sampler);
void __cdecl wined3d_device_context_set_samplers(struct wined3d_device_context *context, enum wined3d_shader_type type,
unsigned int start_idx, unsigned int count, struct wined3d_sampler *const *samplers);
void __cdecl wined3d_device_context_set_scissor_rects(struct wined3d_device_context *context, unsigned int rect_count,
const RECT *rects);
void __cdecl wined3d_device_context_set_shader(struct wined3d_device_context *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