Module: wine Branch: master Commit: 45ee728dbb2f343f1e9f68e1c983c8eaf57e1680 URL: https://gitlab.winehq.org/wine/wine/-/commit/45ee728dbb2f343f1e9f68e1c983c8e...
Author: Paul Gofman pgofman@codeweavers.com Date: Tue May 16 20:17:32 2023 -0600
wined3d: Only set changed.lights if wined3d_light_state_enable_light() changed state.
---
dlls/wined3d/cs.c | 3 +-- dlls/wined3d/device.c | 4 ++-- dlls/wined3d/stateblock.c | 17 ++++++++++------- dlls/wined3d/wined3d_private.h | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index bca0b017c1f..f790e15cef0 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -2057,8 +2057,7 @@ static void wined3d_cs_exec_set_light_enable(struct wined3d_cs *cs, const void * }
prev_idx = light_info->glIndex; - wined3d_light_state_enable_light(&cs->state.light_state, &device->adapter->d3d_info, light_info, op->enable); - if (light_info->glIndex != prev_idx) + if (wined3d_light_state_enable_light(&cs->state.light_state, &device->adapter->d3d_info, light_info, op->enable)) { device_invalidate_state(device, STATE_LIGHT_TYPE); device_invalidate_state(device, STATE_ACTIVELIGHT(op->enable ? light_info->glIndex : prev_idx)); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index df186d9ffa2..775da5bac1f 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1695,8 +1695,8 @@ static void wined3d_device_set_light_enable(struct wined3d_device *device, UINT } }
- wined3d_light_state_enable_light(light_state, &device->adapter->d3d_info, light_info, enable); - wined3d_device_context_emit_set_light_enable(&device->cs->c, light_idx, enable); + if (wined3d_light_state_enable_light(light_state, &device->adapter->d3d_info, light_info, enable)) + wined3d_device_context_emit_set_light_enable(&device->cs->c, light_idx, enable); }
static HRESULT wined3d_device_set_clip_plane(struct wined3d_device *device, diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 16f58b726d0..7b953fce234 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -634,7 +634,7 @@ HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD l return WINED3D_OK; }
-void wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info, +bool wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info, struct wined3d_light_info *light_info, BOOL enable) { unsigned int light_count, i; @@ -644,18 +644,18 @@ void wined3d_light_state_enable_light(struct wined3d_light_state *state, const s if (light_info->glIndex == -1) { TRACE("Light already disabled, nothing to do.\n"); - return; + return false; }
state->lights[light_info->glIndex] = NULL; light_info->glIndex = -1; - return; + return true; }
if (light_info->glIndex != -1) { TRACE("Light already enabled, nothing to do.\n"); - return; + return false; }
/* Find a free light. */ @@ -667,7 +667,7 @@ void wined3d_light_state_enable_light(struct wined3d_light_state *state, const s
state->lights[i] = light_info; light_info->glIndex = i; - return; + return true; }
/* Our tests show that Windows returns D3D_OK in this situation, even with @@ -677,6 +677,7 @@ void wined3d_light_state_enable_light(struct wined3d_light_state *state, const s * * TODO: Test how this affects rendering. */ WARN("Too many concurrently active lights.\n"); + return false; }
static void wined3d_state_record_lights(struct wined3d_light_state *dst_state, @@ -1616,8 +1617,10 @@ HRESULT CDECL wined3d_stateblock_set_light_enable(struct wined3d_stateblock *sta if (FAILED(hr = wined3d_light_state_set_light(light_state, light_idx, &WINED3D_default_light, &light_info))) return hr; } - wined3d_light_state_enable_light(light_state, &stateblock->device->adapter->d3d_info, light_info, enable); - stateblock->changed.lights = 1; + + if (wined3d_light_state_enable_light(light_state, &stateblock->device->adapter->d3d_info, light_info, enable)) + stateblock->changed.lights = 1; + return S_OK; }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index d28a86f77c2..a5296530fb5 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -5049,7 +5049,7 @@ void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state, const struct wined3d_device *device, uint32_t flags) DECLSPEC_HIDDEN; void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state) DECLSPEC_HIDDEN;
-void wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info, +bool wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info, struct wined3d_light_info *light_info, BOOL enable) DECLSPEC_HIDDEN; struct wined3d_light_info *wined3d_light_state_get_light(const struct wined3d_light_state *state, unsigned int idx) DECLSPEC_HIDDEN;