Zebediah Figura : wined3d: Store blend factor in the wined3d_stateblock_state structure.

Alexandre Julliard julliard at winehq.org
Thu Feb 7 16:20:56 CST 2019


Module: wine
Branch: master
Commit: 44441feb3e9ae1cff5d9e0a66032b498e7ba6d36
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=44441feb3e9ae1cff5d9e0a66032b498e7ba6d36

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Wed Feb  6 19:38:27 2019 -0600

wined3d: Store blend factor in the wined3d_stateblock_state structure.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/device.c          |  9 ++++++---
 dlls/wined3d/stateblock.c      | 24 +++++++++++++-----------
 dlls/wined3d/wined3d_private.h |  1 +
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index c1d86ab..aec876f 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1991,13 +1991,17 @@ static void resolve_depth_buffer(struct wined3d_device *device)
 void CDECL wined3d_device_set_blend_state(struct wined3d_device *device,
         struct wined3d_blend_state *blend_state, const struct wined3d_color *blend_factor)
 {
-    struct wined3d_state *state = device->update_state;
+    struct wined3d_state *state = &device->state;
     struct wined3d_blend_state *prev;
 
     TRACE("device %p, blend_state %p, blend_factor %s.\n", device, blend_state, debug_color(blend_factor));
 
+    device->update_stateblock_state->blend_factor = *blend_factor;
     if (device->recording)
+    {
         device->recording->changed.blend_state = TRUE;
+        return;
+    }
 
     prev = state->blend_state;
     if (prev == blend_state && !memcmp(blend_factor, &state->blend_factor, sizeof(*blend_factor)))
@@ -2007,8 +2011,7 @@ void CDECL wined3d_device_set_blend_state(struct wined3d_device *device,
         wined3d_blend_state_incref(blend_state);
     state->blend_state = blend_state;
     state->blend_factor = *blend_factor;
-    if (!device->recording)
-        wined3d_cs_emit_set_blend_state(device->cs, blend_state, blend_factor);
+    wined3d_cs_emit_set_blend_state(device->cs, blend_state, blend_factor);
     if (prev)
         wined3d_blend_state_decref(prev);
 }
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index ebff906..fe307ae 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -859,18 +859,12 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
     }
 
     if (stateblock->changed.blend_state
-            && (src_state->blend_state != stateblock->state.blend_state
-            || memcmp(&src_state->blend_factor, &stateblock->state.blend_factor,
-                    sizeof(stateblock->state.blend_factor))))
+            && memcmp(&state->blend_factor, &stateblock->stateblock_state.blend_factor,
+                    sizeof(stateblock->stateblock_state.blend_factor)))
     {
-        TRACE("Updating blend state.\n");
+        TRACE("Updating blend factor.\n");
 
-        if (src_state->blend_state)
-                wined3d_blend_state_incref(src_state->blend_state);
-        if (stateblock->state.blend_state)
-                wined3d_blend_state_decref(stateblock->state.blend_state);
-        stateblock->state.blend_state = src_state->blend_state;
-        stateblock->state.blend_factor = src_state->blend_factor;
+        stateblock->stateblock_state.blend_factor = state->blend_factor;
     }
 
     map = stateblock->changed.streamSource;
@@ -1162,7 +1156,10 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
     }
 
     if (stateblock->changed.blend_state)
-        wined3d_device_set_blend_state(device, stateblock->state.blend_state, &stateblock->state.blend_factor);
+    {
+        state->blend_factor = stateblock->stateblock_state.blend_factor;
+        wined3d_device_set_blend_state(device, NULL, &stateblock->stateblock_state.blend_factor);
+    }
 
     map = stateblock->changed.streamSource;
     for (i = 0; map; map >>= 1, ++i)
@@ -1473,6 +1470,11 @@ static void stateblock_state_init_default(struct wined3d_stateblock_state *state
     }
 
     init_default_sampler_states(state->sampler_states);
+
+    state->blend_factor.r = 1.0f;
+    state->blend_factor.g = 1.0f;
+    state->blend_factor.b = 1.0f;
+    state->blend_factor.a = 1.0f;
 }
 
 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 11a0f69..13fdb1c 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2986,6 +2986,7 @@ struct wined3d_stateblock_state
     BOOL ps_consts_b[WINED3D_MAX_CONSTS_B];
 
     DWORD rs[WINEHIGHEST_RENDER_STATE + 1];
+    struct wined3d_color blend_factor;
 
     struct wined3d_texture *textures[MAX_COMBINED_SAMPLERS];
     DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];




More information about the wine-cvs mailing list