diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 660ba777efc..639e94a624b 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3904,14 +3904,17 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, wined3d_device_set_ps_consts_b(device, range.offset, range.size, &state->ps_consts_b[range.offset]); } - for (i = 0; i < ARRAY_SIZE(state->light_state->light_map); ++i) + if (changed->lights) { - const struct wined3d_light_info *light; - - LIST_FOR_EACH_ENTRY(light, &state->light_state->light_map[i], struct wined3d_light_info, entry) + for (i = 0; i < ARRAY_SIZE(state->light_state->light_map); ++i) { - wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms); - wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1); + const struct wined3d_light_info *light; + + LIST_FOR_EACH_ENTRY(light, &state->light_state->light_map[i], struct wined3d_light_info, entry) + { + wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms); + wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1); + } } } diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 69210e1fba2..c47a7323b14 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -209,6 +209,7 @@ static void stateblock_savedstates_set_all(struct wined3d_saved_states *states, states->vertexShader = 1; states->scissorRect = 1; states->blend_state = 1; + states->lights = 1; states->streamSource = 0xffff; states->streamFreq = 0xffff; @@ -262,6 +263,7 @@ static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *state states->vertexDecl = 1; states->vertexShader = 1; states->blend_state = 1; + states->lights = 1; for (i = 0; i < ARRAY_SIZE(vertex_states_render); ++i) { @@ -982,7 +984,8 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock, stateblock->stateblock_state.ps = state->ps; } - wined3d_state_record_lights(stateblock->stateblock_state.light_state, state->light_state); + if (stateblock->changed.lights) + wined3d_state_record_lights(stateblock->stateblock_state.light_state, state->light_state); if (stateblock->changed.blend_state && stateblock->stateblock_state.blend_state != state->blend_state) { @@ -1050,20 +1053,23 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock, wined3d_device_set_vs_consts_b(device, idx, 1, &stateblock->stateblock_state.vs_consts_b[idx]); } - for (i = 0; i < ARRAY_SIZE(stateblock->stateblock_state.light_state->light_map); ++i) + if (stateblock->changed.lights) { - const struct wined3d_light_info *light; - struct wined3d_light_info *new_light; - - LIST_FOR_EACH_ENTRY(light, &stateblock->stateblock_state.light_state->light_map[i], struct wined3d_light_info, entry) + for (i = 0; i < ARRAY_SIZE(stateblock->stateblock_state.light_state->light_map); ++i) { - if (SUCCEEDED(wined3d_light_state_set_light(state->light_state, light->OriginalIndex, - &light->OriginalParms, &new_light))) + const struct wined3d_light_info *light; + struct wined3d_light_info *new_light; + + LIST_FOR_EACH_ENTRY(light, &stateblock->stateblock_state.light_state->light_map[i], struct wined3d_light_info, entry) { - wined3d_light_state_enable_light(state->light_state, &device->adapter->d3d_info, new_light, light->glIndex != -1); + if (SUCCEEDED(wined3d_light_state_set_light(state->light_state, light->OriginalIndex, + &light->OriginalParms, &new_light))) + { + wined3d_light_state_enable_light(state->light_state, &device->adapter->d3d_info, new_light, light->glIndex != -1); + } + wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms); + wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1); } - wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms); - wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1); } } @@ -1708,6 +1714,7 @@ HRESULT CDECL wined3d_stateblock_set_stream_source_freq(struct wined3d_statebloc stateblock->changed.streamFreq |= 1u << stream_idx; return WINED3D_OK; } + HRESULT CDECL wined3d_stateblock_set_light(struct wined3d_stateblock *stateblock, UINT light_idx, const struct wined3d_light *light) { @@ -1744,6 +1751,7 @@ HRESULT CDECL wined3d_stateblock_set_light(struct wined3d_stateblock *stateblock return WINED3DERR_INVALIDCALL; } + stateblock->changed.lights = 1; return wined3d_light_state_set_light(stateblock->stateblock_state.light_state, light_idx, light, &object); } @@ -1761,6 +1769,7 @@ HRESULT CDECL wined3d_stateblock_set_light_enable(struct wined3d_stateblock *sta return hr; } 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 744e647008e..c658f5104c7 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3937,7 +3937,8 @@ struct wined3d_saved_states DWORD scissorRect : 1; DWORD store_stream_offset : 1; DWORD blend_state : 1; - DWORD padding : 3; + DWORD lights : 1; + DWORD padding : 2; }; struct StageState {