[PATCH 3/3] d3dx9: Use bitmask instead of BOOL array for light_updated.

Paul Gofman gofmanp at gmail.com
Thu Aug 31 08:08:31 CDT 2017


Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
 dlls/d3dx9_36/effect.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c
index 8095a0ee33..864f0e5a30 100644
--- a/dlls/d3dx9_36/effect.c
+++ b/dlls/d3dx9_36/effect.c
@@ -178,7 +178,7 @@ struct ID3DXEffectImpl
     DWORD begin_flags;
 
     D3DLIGHT9 current_light[8];
-    BOOL light_updated[8];
+    unsigned int light_updated;
     D3DMATERIAL9 current_material;
     BOOL material_updated;
 };
@@ -3067,7 +3067,7 @@ static HRESULT d3dx9_apply_state(struct ID3DXEffectImpl *effect, struct d3dx_pas
                     state_table[state->operation].op);
             d3dx9_set_light_parameter(state_table[state->operation].op,
                     &effect->current_light[state->index], param_value);
-            effect->light_updated[state->index] = TRUE;
+            effect->light_updated |= 1u << state->index;
             return D3D_OK;
         }
         case SC_MATERIAL:
@@ -3112,15 +3112,19 @@ static HRESULT d3dx9_apply_pass_states(struct ID3DXEffectImpl *effect, struct d3
             ret = hr;
         }
     }
-    for (i = 0; i < ARRAY_SIZE(effect->current_light); ++i)
+
+    if (effect->light_updated)
     {
-        if (effect->light_updated[i]
-                && FAILED(hr = SET_D3D_STATE(effect, SetLight, i, &effect->current_light[i])))
+        for (i = 0; i < ARRAY_SIZE(effect->current_light); ++i)
         {
-            WARN("Error setting light, hr %#x.\n", hr);
-            ret = hr;
+            if ((effect->light_updated & (1u << i))
+                    && FAILED(hr = SET_D3D_STATE(effect, SetLight, i, &effect->current_light[i])))
+            {
+                WARN("Error setting light, hr %#x.\n", hr);
+                ret = hr;
+            }
         }
-        effect->light_updated[i] = FALSE;
+        effect->light_updated = 0;
     }
 
     if (effect->material_updated
-- 
2.13.5




More information about the wine-patches mailing list