Specifically, tweak and make use of the already existing WINED3D_CS_OP_RESET_STATE.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d11/device.c | 40 +--------------------------------- dlls/wined3d/cs.c | 16 +++++++++++--- dlls/wined3d/device.c | 13 +++++++++-- dlls/wined3d/wined3d.spec | 1 + dlls/wined3d/wined3d_private.h | 2 +- include/wine/wined3d.h | 1 + 6 files changed, 28 insertions(+), 45 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 39144df3dc4..6f07bc92cdf 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -2591,49 +2591,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(); }
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 77d40801414..b55bfdab866 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -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) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 2c8ebba8844..08f986dd5e2 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -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) diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 901e9bee621..84412515c39 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -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) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index fadad706af4..af9beffc142 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -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; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 0be192b0f01..812c042cdd7 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -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);