Commit 45ee728d authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

wined3d: Only set changed.lights if wined3d_light_state_enable_light() changed state.

parent 3a59a4d1
......@@ -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));
......
......@@ -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,
......
......@@ -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;
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment