[PATCH] wined3d: Use wined3d_state_get_light() in wined3d_state_record_lights().

Zebediah Figura z.figura12 at gmail.com
Sun Dec 2 18:28:37 CST 2018


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/wined3d/stateblock.c | 52 +++++++++++++++++++----------------------------
 1 file changed, 21 insertions(+), 31 deletions(-)

diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index d7d936ea50..9c8c4e9859 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -674,6 +674,8 @@ void wined3d_state_enable_light(struct wined3d_state *state, const struct wined3
 
 static void wined3d_state_record_lights(struct wined3d_state *dst_state, const struct wined3d_state *src_state)
 {
+    const struct wined3d_light_info *src;
+    struct wined3d_light_info *dst;
     UINT i;
 
     /* Lights... For a recorded state block, we just had a chain of actions
@@ -681,48 +683,36 @@ static void wined3d_state_record_lights(struct wined3d_state *dst_state, const s
      * differ. */
     for (i = 0; i < LIGHTMAP_SIZE; ++i)
     {
-        struct list *e, *f;
-        LIST_FOR_EACH(e, &dst_state->light_map[i])
+        LIST_FOR_EACH_ENTRY(dst, &dst_state->light_map[i], struct wined3d_light_info, entry)
         {
-            BOOL updated = FALSE;
-            struct wined3d_light_info *src = LIST_ENTRY(e, struct wined3d_light_info, entry), *realLight;
-
-            /* Look up the light in the destination */
-            LIST_FOR_EACH(f, &src_state->light_map[i])
+            if ((src = wined3d_state_get_light(src_state, dst->OriginalIndex)))
             {
-                realLight = LIST_ENTRY(f, struct wined3d_light_info, entry);
-                if (realLight->OriginalIndex == src->OriginalIndex)
+                dst->OriginalParms = src->OriginalParms;
+
+                if (src->glIndex == -1 && dst->glIndex != -1)
                 {
-                    src->OriginalParms = realLight->OriginalParms;
-
-                    if (realLight->glIndex == -1 && src->glIndex != -1)
-                    {
-                        /* Light disabled */
-                        dst_state->lights[src->glIndex] = NULL;
-                    }
-                    else if (realLight->glIndex != -1 && src->glIndex == -1)
-                    {
-                        /* Light enabled */
-                        dst_state->lights[realLight->glIndex] = src;
-                    }
-                    src->glIndex = realLight->glIndex;
-                    updated = TRUE;
-                    break;
+                    /* Light disabled. */
+                    dst_state->lights[dst->glIndex] = NULL;
                 }
+                else if (src->glIndex != -1 && dst->glIndex == -1)
+                {
+                    /* Light enabled. */
+                    dst_state->lights[src->glIndex] = dst;
+                }
+                dst->glIndex = src->glIndex;
             }
-
-            if (!updated)
+            else
             {
                 /* This can happen if the light was originally created as a
                  * default light for SetLightEnable() while recording. */
                 WARN("Light %u in dst_state %p does not exist in src_state %p.\n",
-                        src->OriginalIndex, dst_state, src_state);
+                        dst->OriginalIndex, dst_state, src_state);
 
-                src->OriginalParms = WINED3D_default_light;
-                if (src->glIndex != -1)
+                dst->OriginalParms = WINED3D_default_light;
+                if (dst->glIndex != -1)
                 {
-                    dst_state->lights[src->glIndex] = NULL;
-                    src->glIndex = -1;
+                    dst_state->lights[dst->glIndex] = NULL;
+                    dst->glIndex = -1;
                 }
             }
         }
-- 
2.14.1




More information about the wine-devel mailing list