Paul Gofman : ddraw: Always activate the light when requested replacing some previous light.
Module: wine Branch: master Commit: 1eb6d8c58d469f46bcbcd31e27edc6850b975dc7 URL: https://source.winehq.org/git/wine.git/?a=commit;h=1eb6d8c58d469f46bcbcd31e2... Author: Paul Gofman <gofmanp(a)gmail.com> Date: Tue Jun 11 13:06:20 2019 +0300 ddraw: Always activate the light when requested replacing some previous light. Signed-off-by: Paul Gofman <gofmanp(a)gmail.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ddraw/light.c | 2 -- dlls/ddraw/viewport.c | 20 ++++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/dlls/ddraw/light.c b/dlls/ddraw/light.c index 22ebe20..9c624f1 100644 --- a/dlls/ddraw/light.c +++ b/dlls/ddraw/light.c @@ -62,8 +62,6 @@ void light_activate(struct d3d_light *light) if (light->light.dwFlags & D3DLIGHT_ACTIVE) { viewport_alloc_active_light_index(light); - if (!light->active_light_index) - return; light_update(light); IDirect3DDevice7_LightEnable(&device->IDirect3DDevice7_iface, light->active_light_index, TRUE); } diff --git a/dlls/ddraw/viewport.c b/dlls/ddraw/viewport.c index 07fd197..e94c4b8 100644 --- a/dlls/ddraw/viewport.c +++ b/dlls/ddraw/viewport.c @@ -135,9 +135,25 @@ void viewport_alloc_active_light_index(struct d3d_light *light) return; if (vp->active_lights_count >= DDRAW_MAX_ACTIVE_LIGHTS) - return; + { + struct d3d_light *l; + + LIST_FOR_EACH_ENTRY(l, &vp->light_list, struct d3d_light, entry) + { + if (l->active_light_index) + { + WARN("Too many active lights, viewport %p, light %p, deactivating %p.\n", vp, light, l); + light_deactivate(l); + /* Recycle active lights in a FIFO way. */ + list_remove(&light->entry); + list_add_tail(&vp->light_list, &light->entry); + break; + } + } + } map = vp->map_lights; + assert(vp->active_lights_count < DDRAW_MAX_ACTIVE_LIGHTS && map != ~0u); i = 0; while (map & 1) @@ -817,7 +833,7 @@ static HRESULT WINAPI d3d_viewport_AddLight(IDirect3DViewport3 *viewport, IDirec light_impl->active_viewport = vp; /* Add the light in the 'linked' chain */ - list_add_head(&vp->light_list, &light_impl->entry); + list_add_tail(&vp->light_list, &light_impl->entry); IDirect3DLight_AddRef(light); light_activate(light_impl);
participants (1)
-
Alexandre Julliard