ddraw: Do not limit inactive light count in viewport.
Signed-off-by: Paul Gofman <gofmanp@gmail.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
87a0edafbb
commit
d864cece53
|
@ -661,4 +661,7 @@ struct member_info
|
||||||
|
|
||||||
HRESULT hr_ddraw_from_wined3d(HRESULT hr) DECLSPEC_HIDDEN;
|
HRESULT hr_ddraw_from_wined3d(HRESULT hr) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
|
void viewport_alloc_active_light_index(struct d3d_light *light) DECLSPEC_HIDDEN;
|
||||||
|
void viewport_free_active_light_index(struct d3d_light *light) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -59,9 +59,14 @@ void light_activate(struct d3d_light *light)
|
||||||
return;
|
return;
|
||||||
device = light->active_viewport->active_device;
|
device = light->active_viewport->active_device;
|
||||||
|
|
||||||
light_update(light);
|
|
||||||
if (light->light.dwFlags & D3DLIGHT_ACTIVE)
|
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);
|
IDirect3DDevice7_LightEnable(&device->IDirect3DDevice7_iface, light->active_light_index, TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
@ -79,11 +84,17 @@ void light_deactivate(struct d3d_light *light)
|
||||||
|
|
||||||
if (!light->active_viewport || !light->active_viewport->active_device
|
if (!light->active_viewport || !light->active_viewport->active_device
|
||||||
|| light->active_viewport->active_device->current_viewport != light->active_viewport)
|
|| light->active_viewport->active_device->current_viewport != light->active_viewport)
|
||||||
|
{
|
||||||
|
assert(!light->active_light_index);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
device = light->active_viewport->active_device;
|
device = light->active_viewport->active_device;
|
||||||
if (light->light.dwFlags & D3DLIGHT_ACTIVE)
|
if (light->active_light_index)
|
||||||
|
{
|
||||||
IDirect3DDevice7_LightEnable(&device->IDirect3DDevice7_iface, light->active_light_index, FALSE);
|
IDirect3DDevice7_LightEnable(&device->IDirect3DDevice7_iface, light->active_light_index, FALSE);
|
||||||
|
viewport_free_active_light_index(light);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct d3d_light *impl_from_IDirect3DLight(IDirect3DLight *iface)
|
static inline struct d3d_light *impl_from_IDirect3DLight(IDirect3DLight *iface)
|
||||||
|
|
|
@ -122,7 +122,7 @@ void viewport_deactivate(struct d3d_viewport *viewport)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void viewport_alloc_active_light_index(struct d3d_light *light)
|
void viewport_alloc_active_light_index(struct d3d_light *light)
|
||||||
{
|
{
|
||||||
struct d3d_viewport *vp = light->active_viewport;
|
struct d3d_viewport *vp = light->active_viewport;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -150,6 +150,23 @@ static void viewport_alloc_active_light_index(struct d3d_light *light)
|
||||||
vp->map_lights |= 1u << i;
|
vp->map_lights |= 1u << i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void viewport_free_active_light_index(struct d3d_light *light)
|
||||||
|
{
|
||||||
|
struct d3d_viewport *vp = light->active_viewport;
|
||||||
|
|
||||||
|
TRACE("vp %p, light %p, index %u, active_lights_count %u, map_lights %#x.\n",
|
||||||
|
vp, light, light->active_light_index, vp->active_lights_count, vp->map_lights);
|
||||||
|
|
||||||
|
if (!light->active_light_index)
|
||||||
|
return;
|
||||||
|
|
||||||
|
assert(vp->map_lights & (1u << (light->active_light_index - 1)));
|
||||||
|
|
||||||
|
--vp->active_lights_count;
|
||||||
|
vp->map_lights &= ~(1u << (light->active_light_index - 1));
|
||||||
|
light->active_light_index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* _dump_D3DVIEWPORT, _dump_D3DVIEWPORT2
|
* _dump_D3DVIEWPORT, _dump_D3DVIEWPORT2
|
||||||
*
|
*
|
||||||
|
@ -798,19 +815,11 @@ static HRESULT WINAPI d3d_viewport_AddLight(IDirect3DViewport3 *viewport, IDirec
|
||||||
}
|
}
|
||||||
|
|
||||||
light_impl->active_viewport = vp;
|
light_impl->active_viewport = vp;
|
||||||
viewport_alloc_active_light_index(light_impl);
|
|
||||||
if (!light_impl->active_light_index)
|
|
||||||
{
|
|
||||||
light_impl->active_viewport = NULL;
|
|
||||||
wined3d_mutex_unlock();
|
|
||||||
return DDERR_INVALIDPARAMS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add the light in the 'linked' chain */
|
/* Add the light in the 'linked' chain */
|
||||||
list_add_head(&vp->light_list, &light_impl->entry);
|
list_add_head(&vp->light_list, &light_impl->entry);
|
||||||
IDirect3DLight_AddRef(light);
|
IDirect3DLight_AddRef(light);
|
||||||
|
|
||||||
/* Attach the light to the viewport */
|
|
||||||
light_activate(light_impl);
|
light_activate(light_impl);
|
||||||
|
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
|
@ -851,8 +860,6 @@ static HRESULT WINAPI d3d_viewport_DeleteLight(IDirect3DViewport3 *iface, IDirec
|
||||||
list_remove(&l->entry);
|
list_remove(&l->entry);
|
||||||
l->active_viewport = NULL;
|
l->active_viewport = NULL;
|
||||||
IDirect3DLight_Release(lpDirect3DLight);
|
IDirect3DLight_Release(lpDirect3DLight);
|
||||||
--viewport->active_lights_count;
|
|
||||||
viewport->map_lights &= ~(1 << l->active_light_index);
|
|
||||||
|
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue