[PATCH v3 1/4] wined3d: Store texture states in the wined3d_stateblock_state structure.

Zebediah Figura z.figura12 at gmail.com
Tue Feb 5 11:08:53 CST 2019


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/wined3d/device.c          |  9 ++++-----
 dlls/wined3d/stateblock.c      | 22 ++++++++++++++++------
 dlls/wined3d/wined3d_private.h |  2 ++
 3 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index dee99dcde2..8467acf361 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3431,7 +3431,6 @@ void CDECL wined3d_device_set_texture_stage_state(struct wined3d_device *device,
         UINT stage, enum wined3d_texture_stage_state state, DWORD value)
 {
     const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
-    DWORD old_value;
 
     TRACE("device %p, stage %u, state %s, value %#x.\n",
             device, stage, debug_d3dtexturestate(state), value);
@@ -3449,8 +3448,7 @@ void CDECL wined3d_device_set_texture_stage_state(struct wined3d_device *device,
         return;
     }
 
-    old_value = device->update_state->texture_states[stage][state];
-    device->update_state->texture_states[stage][state] = value;
+    device->update_stateblock_state->texture_states[stage][state] = value;
 
     if (device->recording)
     {
@@ -3459,13 +3457,14 @@ void CDECL wined3d_device_set_texture_stage_state(struct wined3d_device *device,
         return;
     }
 
-    /* Checked after the assignments to allow proper stateblock recording. */
-    if (old_value == value)
+    if (value == device->state.texture_states[stage][state])
     {
         TRACE("Application is setting the old value over, nothing to do.\n");
         return;
     }
 
+    device->state.texture_states[stage][state] = value;
+
     wined3d_cs_emit_set_texture_state(device->cs, stage, state, value);
 }
 
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 8117652192..61de76403e 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -925,12 +925,13 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
     for (i = 0; i < stateblock->num_contained_tss_states; ++i)
     {
         DWORD stage = stateblock->contained_tss_states[i].stage;
-        DWORD state = stateblock->contained_tss_states[i].state;
+        DWORD texture_state = stateblock->contained_tss_states[i].state;
 
-        TRACE("Updating texturestage state %u, %u to %#x (was %#x).\n", stage, state,
-                src_state->texture_states[stage][state], stateblock->state.texture_states[stage][state]);
+        TRACE("Updating texturestage state %u, %u to %#x (was %#x).\n", stage, texture_state,
+                state->texture_states[stage][texture_state],
+                stateblock->stateblock_state.texture_states[stage][texture_state]);
 
-        stateblock->state.texture_states[stage][state] = src_state->texture_states[stage][state];
+        stateblock->stateblock_state.texture_states[stage][texture_state] = state->texture_states[stage][texture_state];
     }
 
     /* Samplers */
@@ -1075,9 +1076,11 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
     for (i = 0; i < stateblock->num_contained_tss_states; ++i)
     {
         DWORD stage = stateblock->contained_tss_states[i].stage;
-        DWORD state = stateblock->contained_tss_states[i].state;
+        DWORD texture_state = stateblock->contained_tss_states[i].state;
 
-        wined3d_device_set_texture_stage_state(device, stage, state, stateblock->state.texture_states[stage][state]);
+        state->texture_states[stage][texture_state] = stateblock->stateblock_state.texture_states[stage][texture_state];
+        wined3d_device_set_texture_stage_state(device, stage, texture_state,
+                stateblock->stateblock_state.texture_states[stage][texture_state]);
     }
 
     /* Sampler states. */
@@ -1396,7 +1399,14 @@ void state_init(struct wined3d_state *state, struct wined3d_fb_state *fb,
 static void stateblock_state_init_default(struct wined3d_stateblock_state *state,
         const struct wined3d_d3d_info *d3d_info)
 {
+    unsigned int i;
+
     init_default_render_states(state->rs, d3d_info);
+
+    for (i = 0; i < MAX_TEXTURES; ++i)
+    {
+        init_default_texture_state(i, state->texture_states[i]);
+    }
 }
 
 void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 1e3ec28d6b..bfeb639ef3 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2981,6 +2981,8 @@ struct wined3d_stateblock_state
     BOOL ps_consts_b[WINED3D_MAX_CONSTS_B];
 
     DWORD rs[WINEHIGHEST_RENDER_STATE + 1];
+
+    DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
 };
 
 struct wined3d_device
-- 
2.20.1




More information about the wine-devel mailing list