Zebediah Figura : wined3d: Store lights in the wined3d_stateblock_state structure.
Alexandre Julliard
julliard at winehq.org
Wed Feb 13 15:30:41 CST 2019
Module: wine
Branch: master
Commit: d2fa2624e94fc487b5656c9a8d4a4dc7e3193784
URL: https://source.winehq.org/git/wine.git/?a=commit;h=d2fa2624e94fc487b5656c9a8d4a4dc7e3193784
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Tue Feb 12 10:45:07 2019 -0600
wined3d: Store lights in the wined3d_stateblock_state structure.
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wined3d/device.c | 32 ++++++++++++++++++++++++--------
dlls/wined3d/stateblock.c | 25 ++++++++++++++++++++-----
dlls/wined3d/wined3d_private.h | 2 ++
3 files changed, 46 insertions(+), 13 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 3e03470..6831c63 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1608,7 +1608,12 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device,
return WINED3DERR_INVALIDCALL;
}
- if (FAILED(hr = wined3d_light_state_set_light(&device->update_state->light_state, light_idx, light, &object)))
+ if (FAILED(hr = wined3d_light_state_set_light(&device->update_stateblock_state->light_state, light_idx, light, &object)))
+ return hr;
+ if (device->recording)
+ return WINED3D_OK;
+
+ if (FAILED(hr = wined3d_light_state_set_light(&device->state.light_state, light_idx, light, &object)))
return hr;
/* Initialize the object. */
@@ -1697,8 +1702,7 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device,
FIXME("Unrecognized light type %#x.\n", light->type);
}
- if (!device->recording)
- wined3d_cs_emit_set_light(device->cs, object);
+ wined3d_cs_emit_set_light(device->cs, object);
return WINED3D_OK;
}
@@ -1723,25 +1727,37 @@ HRESULT CDECL wined3d_device_get_light(const struct wined3d_device *device,
HRESULT CDECL wined3d_device_set_light_enable(struct wined3d_device *device, UINT light_idx, BOOL enable)
{
struct wined3d_light_info *light_info;
+ HRESULT hr;
TRACE("device %p, light_idx %u, enable %#x.\n", device, light_idx, enable);
+ if (!(light_info = wined3d_light_state_get_light(&device->update_stateblock_state->light_state, light_idx)))
+ {
+ if (FAILED(hr = wined3d_light_state_set_light(&device->update_stateblock_state->light_state, light_idx,
+ &WINED3D_default_light, &light_info)))
+ return hr;
+ }
+ wined3d_light_state_enable_light(&device->update_stateblock_state->light_state,
+ &device->adapter->d3d_info, light_info, enable);
+
+ if (device->recording)
+ return WINED3D_OK;
+
/* Special case - enabling an undefined light creates one with a strict set of parameters. */
- if (!(light_info = wined3d_light_state_get_light(&device->update_state->light_state, light_idx)))
+ if (!(light_info = wined3d_light_state_get_light(&device->state.light_state, light_idx)))
{
TRACE("Light enabled requested but light not defined, so defining one!\n");
wined3d_device_set_light(device, light_idx, &WINED3D_default_light);
- if (!(light_info = wined3d_light_state_get_light(&device->update_state->light_state, light_idx)))
+ if (!(light_info = wined3d_light_state_get_light(&device->state.light_state, light_idx)))
{
FIXME("Adding default lights has failed dismally\n");
return WINED3DERR_INVALIDCALL;
}
}
- wined3d_light_state_enable_light(&device->update_state->light_state, &device->adapter->d3d_info, light_info, enable);
- if (!device->recording)
- wined3d_cs_emit_set_light_enable(device->cs, light_idx, enable);
+ wined3d_light_state_enable_light(&device->state.light_state, &device->adapter->d3d_info, light_info, enable);
+ wined3d_cs_emit_set_light_enable(device->cs, light_idx, enable);
return WINED3D_OK;
}
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index b5409ba..65f953f 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -1013,7 +1013,7 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
stateblock->stateblock_state.ps = state->ps;
}
- wined3d_state_record_lights(&stateblock->state.light_state, &src_state->light_state);
+ wined3d_state_record_lights(&stateblock->stateblock_state.light_state, &state->light_state);
TRACE("Capture done.\n");
}
@@ -1057,12 +1057,18 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
1, &stateblock->stateblock_state.vs_consts_b[stateblock->contained_vs_consts_b[i]]);
}
- for (i = 0; i < ARRAY_SIZE(stateblock->state.light_state.light_map); ++i)
+ for (i = 0; i < ARRAY_SIZE(stateblock->stateblock_state.light_state.light_map); ++i)
{
const struct wined3d_light_info *light;
+ struct wined3d_light_info *new_light;
- LIST_FOR_EACH_ENTRY(light, &stateblock->state.light_state.light_map[i], struct wined3d_light_info, entry)
+ LIST_FOR_EACH_ENTRY(light, &stateblock->stateblock_state.light_state.light_map[i], struct wined3d_light_info, entry)
{
+ 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);
}
@@ -1526,6 +1532,13 @@ static void stateblock_state_init_default(struct wined3d_stateblock_state *state
void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state,
const struct wined3d_device *device, DWORD flags)
{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(state->light_state.light_map); i++)
+ {
+ list_init(&state->light_state.light_map[i]);
+ }
+
if (flags & WINED3D_STATE_INIT_DEFAULT)
stateblock_state_init_default(state, &device->adapter->d3d_info);
}
@@ -1548,7 +1561,8 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
switch (type)
{
case WINED3D_SBT_ALL:
- stateblock_init_lights(stateblock->state.light_state.light_map, device->state.light_state.light_map);
+ stateblock_init_lights(stateblock->stateblock_state.light_state.light_map,
+ device->stateblock_state.light_state.light_map);
stateblock_savedstates_set_all(&stateblock->changed,
d3d_info->limits.vs_uniform_count, d3d_info->limits.ps_uniform_count);
break;
@@ -1559,7 +1573,8 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock,
break;
case WINED3D_SBT_VERTEX_STATE:
- stateblock_init_lights(stateblock->state.light_state.light_map, device->state.light_state.light_map);
+ stateblock_init_lights(stateblock->stateblock_state.light_state.light_map,
+ device->stateblock_state.light_state.light_map);
stateblock_savedstates_set_vertex(&stateblock->changed,
d3d_info->limits.vs_uniform_count);
break;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index fbd7f41..eaca69b 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3007,6 +3007,8 @@ struct wined3d_stateblock_state
struct wined3d_material material;
struct wined3d_viewport viewport;
RECT scissor_rect;
+
+ struct wined3d_light_state light_state;
};
struct wined3d_device
More information about the wine-cvs
mailing list