Commit 97d3ea26 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3d11: Implement ID3D11DeviceContext::ClearState() using a single CS op.

Specifically, tweak and make use of the already existing WINED3D_CS_OP_RESET_STATE. Signed-off-by: 's avatarZebediah Figura <z.figura12@gmail.com> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent eae83897
......@@ -2597,49 +2597,11 @@ static void STDMETHODCALLTYPE d3d11_device_context_CSGetConstantBuffers(ID3D11De
static void STDMETHODCALLTYPE d3d11_device_context_ClearState(ID3D11DeviceContext1 *iface)
{
struct d3d11_device_context *context = impl_from_ID3D11DeviceContext1(iface);
static const float blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f};
unsigned int i, j;
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
{
wined3d_device_context_set_shader(context->wined3d_context, i, NULL);
for (j = 0; j < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++j)
wined3d_device_context_set_constant_buffer(context->wined3d_context, i, j, NULL);
for (j = 0; j < D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++j)
wined3d_device_context_set_shader_resource_view(context->wined3d_context, i, j, NULL);
for (j = 0; j < D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; ++j)
wined3d_device_context_set_sampler(context->wined3d_context, i, j, NULL);
}
for (i = 0; i < D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; ++i)
{
wined3d_device_context_set_stream_source(context->wined3d_context, i, NULL, 0, 0);
}
wined3d_device_context_set_index_buffer(context->wined3d_context, NULL, WINED3DFMT_UNKNOWN, 0);
wined3d_device_context_set_vertex_declaration(context->wined3d_context, NULL);
wined3d_device_context_set_primitive_type(context->wined3d_context, WINED3D_PT_UNDEFINED, 0);
for (i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
{
wined3d_device_context_set_rendertarget_view(context->wined3d_context, i, NULL, FALSE);
}
wined3d_device_context_set_depth_stencil_view(context->wined3d_context, NULL);
for (i = 0; i < WINED3D_PIPELINE_COUNT; ++i)
{
for (j = 0; j < D3D11_PS_CS_UAV_REGISTER_COUNT; ++j)
wined3d_device_context_set_unordered_access_view(context->wined3d_context, i, j, NULL, ~0u);
}
ID3D11DeviceContext1_OMSetDepthStencilState(iface, NULL, 0);
ID3D11DeviceContext1_OMSetBlendState(iface, NULL, blend_factor, D3D11_DEFAULT_SAMPLE_MASK);
ID3D11DeviceContext1_RSSetViewports(iface, 0, NULL);
ID3D11DeviceContext1_RSSetScissorRects(iface, 0, NULL);
ID3D11DeviceContext1_RSSetState(iface, NULL);
for (i = 0; i < D3D11_SO_BUFFER_SLOT_COUNT; ++i)
{
wined3d_device_context_set_stream_output(context->wined3d_context, i, NULL, 0);
}
wined3d_device_context_set_predication(context->wined3d_context, NULL, FALSE);
wined3d_device_context_reset_state(context->wined3d_context);
wined3d_mutex_unlock();
}
......
......@@ -359,6 +359,7 @@ struct wined3d_cs_push_constants
struct wined3d_cs_reset_state
{
enum wined3d_cs_op opcode;
bool invalidate;
};
struct wined3d_cs_callback
......@@ -2143,18 +2144,27 @@ static void wined3d_cs_mt_push_constants(struct wined3d_device_context *context,
static void wined3d_cs_exec_reset_state(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_reset_state *op = data;
unsigned int state;
state_cleanup(&cs->state);
wined3d_state_reset(&cs->state, &cs->c.device->adapter->d3d_info);
if (op->invalidate)
{
for (state = 0; state <= STATE_HIGHEST; ++state)
device_invalidate_state(cs->c.device, state);
}
}
void wined3d_cs_emit_reset_state(struct wined3d_cs *cs)
void wined3d_device_context_emit_reset_state(struct wined3d_device_context *context, bool invalidate)
{
struct wined3d_cs_reset_state *op;
op = wined3d_device_context_require_space(&cs->c, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
op->opcode = WINED3D_CS_OP_RESET_STATE;
op->invalidate = invalidate;
wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_DEFAULT);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
}
static void wined3d_cs_exec_callback(struct wined3d_cs *cs, const void *data)
......
......@@ -1169,7 +1169,7 @@ void wined3d_device_uninit_3d(struct wined3d_device *device)
wined3d_texture_decref(texture);
}
wined3d_cs_emit_reset_state(device->cs);
wined3d_device_context_emit_reset_state(&device->cs->c, false);
state_cleanup(state);
wine_rb_clear(&device->samplers, device_free_sampler, NULL);
......@@ -1649,6 +1649,15 @@ void CDECL wined3d_device_context_get_scissor_rects(const struct wined3d_device_
*rect_count = state->scissor_rect_count;
}
void CDECL wined3d_device_context_reset_state(struct wined3d_device_context *context)
{
TRACE("context %p.\n", context);
state_cleanup(context->state);
wined3d_state_reset(context->state, &context->device->adapter->d3d_info);
wined3d_device_context_emit_reset_state(context, true);
}
void CDECL wined3d_device_context_set_state(struct wined3d_device_context *context, struct wined3d_state *state)
{
const struct wined3d_light_info *light;
......@@ -5417,7 +5426,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
if (reset_state)
{
TRACE("Resetting state.\n");
wined3d_cs_emit_reset_state(device->cs);
wined3d_device_context_emit_reset_state(&device->cs->c, false);
state_cleanup(state);
LIST_FOR_EACH_ENTRY_SAFE(resource, cursor, &device->resources, struct wined3d_resource, resource_list_entry)
......
......@@ -114,6 +114,7 @@
@ cdecl wined3d_device_context_get_viewports(ptr ptr ptr)
@ cdecl wined3d_device_context_issue_query(ptr ptr long)
@ cdecl wined3d_device_context_map(ptr ptr long ptr ptr long)
@ cdecl wined3d_device_context_reset_state(ptr)
@ cdecl wined3d_device_context_resolve_sub_resource(ptr ptr long ptr long long)
@ cdecl wined3d_device_context_set_blend_state(ptr ptr ptr long)
@ cdecl wined3d_device_context_set_constant_buffer(ptr long long ptr)
......
......@@ -4737,7 +4737,6 @@ void wined3d_device_context_emit_clear_uav_uint(struct wined3d_device_context *c
void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain, const RECT *src_rect,
const RECT *dst_rect, HWND dst_window_override, unsigned int swap_interval, DWORD flags) DECLSPEC_HIDDEN;
void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture *texture,
WORD flags, const struct wined3d_color_key *color_key) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs,
......@@ -4775,6 +4774,7 @@ void wined3d_device_context_emit_draw(struct wined3d_device_context *context,
bool indexed) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_generate_mipmaps(struct wined3d_device_context *context,
struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_reset_state(struct wined3d_device_context *context, bool invalidate) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_set_blend_state(struct wined3d_device_context *context,
struct wined3d_blend_state *state, const struct wined3d_color *blend_factor,
unsigned int sample_mask) DECLSPEC_HIDDEN;
......
......@@ -2480,6 +2480,7 @@ void __cdecl wined3d_device_context_issue_query(struct wined3d_device_context *c
HRESULT __cdecl wined3d_device_context_map(struct wined3d_device_context *context,
struct wined3d_resource *resource, unsigned int sub_resource_idx,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags);
void __cdecl wined3d_device_context_reset_state(struct wined3d_device_context *context);
void __cdecl wined3d_device_context_resolve_sub_resource(struct wined3d_device_context *context,
struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx,
struct wined3d_resource *src_resource, unsigned int src_sub_resource_idx, enum wined3d_format_id format_id);
......
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