wined3d: Use wined3d_state_get_light() in wined3d_state_record_lights().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2018-12-02 18:28:37 -06:00 committed by Alexandre Julliard
parent 133d0668b6
commit 9f85d5dab0
1 changed files with 21 additions and 31 deletions

View File

@ -622,6 +622,8 @@ void wined3d_state_enable_light(struct wined3d_state *state, const struct wined3
static void wined3d_state_record_lights(struct wined3d_state *dst_state, const struct wined3d_state *src_state)
{
const struct wined3d_light_info *src;
struct wined3d_light_info *dst;
UINT i;
/* Lights... For a recorded state block, we just had a chain of actions
@ -629,48 +631,36 @@ static void wined3d_state_record_lights(struct wined3d_state *dst_state, const s
* differ. */
for (i = 0; i < LIGHTMAP_SIZE; ++i)
{
struct list *e, *f;
LIST_FOR_EACH(e, &dst_state->light_map[i])
LIST_FOR_EACH_ENTRY(dst, &dst_state->light_map[i], struct wined3d_light_info, entry)
{
BOOL updated = FALSE;
struct wined3d_light_info *src = LIST_ENTRY(e, struct wined3d_light_info, entry), *realLight;
/* Look up the light in the destination */
LIST_FOR_EACH(f, &src_state->light_map[i])
if ((src = wined3d_state_get_light(src_state, dst->OriginalIndex)))
{
realLight = LIST_ENTRY(f, struct wined3d_light_info, entry);
if (realLight->OriginalIndex == src->OriginalIndex)
dst->OriginalParms = src->OriginalParms;
if (src->glIndex == -1 && dst->glIndex != -1)
{
src->OriginalParms = realLight->OriginalParms;
if (realLight->glIndex == -1 && src->glIndex != -1)
{
/* Light disabled */
dst_state->lights[src->glIndex] = NULL;
}
else if (realLight->glIndex != -1 && src->glIndex == -1)
{
/* Light enabled */
dst_state->lights[realLight->glIndex] = src;
}
src->glIndex = realLight->glIndex;
updated = TRUE;
break;
/* Light disabled. */
dst_state->lights[dst->glIndex] = NULL;
}
else if (src->glIndex != -1 && dst->glIndex == -1)
{
/* Light enabled. */
dst_state->lights[src->glIndex] = dst;
}
dst->glIndex = src->glIndex;
}
if (!updated)
else
{
/* This can happen if the light was originally created as a
* default light for SetLightEnable() while recording. */
WARN("Light %u in dst_state %p does not exist in src_state %p.\n",
src->OriginalIndex, dst_state, src_state);
dst->OriginalIndex, dst_state, src_state);
src->OriginalParms = WINED3D_default_light;
if (src->glIndex != -1)
dst->OriginalParms = WINED3D_default_light;
if (dst->glIndex != -1)
{
dst_state->lights[src->glIndex] = NULL;
src->glIndex = -1;
dst_state->lights[dst->glIndex] = NULL;
dst->glIndex = -1;
}
}
}