Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/wined3d/cs.c | 5 ++--- dlls/wined3d/device.c | 9 +++------ dlls/wined3d/stateblock.c | 8 +++++++- dlls/wined3d/wined3d_private.h | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 4ee3d97b7fc..66288014f30 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -2074,8 +2074,7 @@ static void wined3d_cs_exec_reset_state(struct wined3d_cs *cs, const void *data) struct wined3d_adapter *adapter = cs->device->adapter;
state_cleanup(&cs->state); - memset(&cs->state, 0, sizeof(cs->state)); - state_init(&cs->state, &adapter->d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT); + state_reset(&cs->state, &adapter->d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT); }
void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) @@ -2973,7 +2972,7 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) cs->device = device; cs->serialize_commands = TRACE_ON(d3d_sync) || wined3d_settings.cs_multithreaded & WINED3D_CSMT_SERIALIZE;
- state_init(&cs->state, d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT); + state_reset(&cs->state, d3d_info, WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT);
cs->data_size = WINED3D_INITIAL_CS_SIZE; if (!(cs->data = heap_alloc(cs->data_size))) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 865d7f83098..6a9eee152a3 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1265,8 +1265,7 @@ void wined3d_device_uninit_3d(struct wined3d_device *device) heap_free(device->swapchains); device->swapchains = NULL;
- memset(state, 0, sizeof(*state)); - state_init(state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); + state_reset(state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); }
/* Enables thread safety in the wined3d device and its resources. Called by DirectDraw @@ -5705,8 +5704,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
device->adapter->adapter_ops->adapter_uninit_3d(device);
- memset(state, 0, sizeof(*state)); - state_init(state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); + state_reset(state, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
device_init_swapchain_state(device, swapchain); if (wined3d_settings.logo) @@ -6020,8 +6018,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined hr = E_OUTOFMEMORY; goto err; } - memset(state, 0, sizeof(*state)); - state_init(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); + state_reset(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
device->state = state; device->max_frame_latency = 3; diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 46588fa4246..b23301a4758 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1854,7 +1854,7 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d state->streams[i].frequency = 1; }
-void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, DWORD flags) +static void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, DWORD flags) { unsigned int i;
@@ -1869,6 +1869,12 @@ void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_ state_init_default(state, d3d_info); }
+void state_reset(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, DWORD flags) +{ + memset(&state->flags, 0, sizeof(struct wined3d_state) - FIELD_OFFSET(struct wined3d_state, flags)); + state_init(state, d3d_info, flags); +} + static void stateblock_state_init_default(struct wined3d_stateblock_state *state, const struct wined3d_d3d_info *d3d_info) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 56d3ef8fea2..fe735c6e228 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4641,7 +4641,7 @@ HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD l const struct wined3d_light *params, struct wined3d_light_info **light_info) DECLSPEC_HIDDEN;
void state_cleanup(struct wined3d_state *state) DECLSPEC_HIDDEN; -void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, DWORD flags) DECLSPEC_HIDDEN; +void state_reset(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, DWORD flags) DECLSPEC_HIDDEN; void state_unbind_resources(struct wined3d_state *state) DECLSPEC_HIDDEN;
enum wined3d_cs_queue_id