[PATCH 3/4] d3d9: Retrieve light state from the primary stateblock.
Zebediah Figura
z.figura12 at gmail.com
Mon Feb 17 17:19:52 CST 2020
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/d3d9/device.c | 10 ++++++----
dlls/wined3d/stateblock.c | 15 +++++++++++++++
dlls/wined3d/wined3d.spec | 1 +
include/wine/wined3d.h | 2 ++
4 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index ac03c7e241..6f37dfddf2 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2232,13 +2232,14 @@ static HRESULT WINAPI d3d9_device_SetLight(IDirect3DDevice9Ex *iface, DWORD inde
static HRESULT WINAPI d3d9_device_GetLight(IDirect3DDevice9Ex *iface, DWORD index, D3DLIGHT9 *light)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
+ BOOL enabled;
HRESULT hr;
TRACE("iface %p, index %u, light %p.\n", iface, index, light);
/* Note: D3DLIGHT9 is compatible with struct wined3d_light. */
wined3d_mutex_lock();
- hr = wined3d_device_get_light(device->wined3d_device, index, (struct wined3d_light *)light);
+ hr = wined3d_stateblock_get_light(device->state, index, (struct wined3d_light *)light, &enabled);
wined3d_mutex_unlock();
return hr;
@@ -2260,15 +2261,16 @@ static HRESULT WINAPI d3d9_device_LightEnable(IDirect3DDevice9Ex *iface, DWORD i
return hr;
}
-static HRESULT WINAPI d3d9_device_GetLightEnable(IDirect3DDevice9Ex *iface, DWORD index, BOOL *enable)
+static HRESULT WINAPI d3d9_device_GetLightEnable(IDirect3DDevice9Ex *iface, DWORD index, BOOL *enabled)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
+ struct wined3d_light light;
HRESULT hr;
- TRACE("iface %p, index %u, enable %p.\n", iface, index, enable);
+ TRACE("iface %p, index %u, enabled %p.\n", iface, index, enabled);
wined3d_mutex_lock();
- hr = wined3d_device_get_light_enable(device->wined3d_device, index, enable);
+ hr = wined3d_stateblock_get_light(device->state, index, &light, enabled);
wined3d_mutex_unlock();
return hr;
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 499d23fbbd..ad1410f1bd 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -1699,6 +1699,21 @@ const struct wined3d_stateblock_state * CDECL wined3d_stateblock_get_state(const
return &stateblock->stateblock_state;
}
+HRESULT CDECL wined3d_stateblock_get_light(const struct wined3d_stateblock *stateblock,
+ UINT light_idx, struct wined3d_light *light, BOOL *enabled)
+{
+ struct wined3d_light_info *light_info;
+
+ if (!(light_info = wined3d_light_state_get_light(&stateblock->light_state, light_idx)))
+ {
+ TRACE("Light %u is not defined.\n", light_idx);
+ return WINED3DERR_INVALIDCALL;
+ }
+ *light = light_info->OriginalParms;
+ *enabled = light_info->enabled ? 128 : 0;
+ return WINED3D_OK;
+}
+
static void init_default_render_states(DWORD rs[WINEHIGHEST_RENDER_STATE + 1], const struct wined3d_d3d_info *d3d_info)
{
union
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index c8ef442c72..8538b3dcd6 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -260,6 +260,7 @@
@ cdecl wined3d_stateblock_capture(ptr ptr)
@ cdecl wined3d_stateblock_create(ptr ptr long ptr)
@ cdecl wined3d_stateblock_decref(ptr)
+@ cdecl wined3d_stateblock_get_light(ptr long ptr ptr)
@ cdecl wined3d_stateblock_get_state(ptr)
@ cdecl wined3d_stateblock_incref(ptr)
@ cdecl wined3d_stateblock_init_contained_states(ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index d313c7aec8..7fba4ea9f0 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2726,6 +2726,8 @@ void __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock,
HRESULT __cdecl wined3d_stateblock_create(struct wined3d_device *device, const struct wined3d_stateblock *device_state,
enum wined3d_stateblock_type type, struct wined3d_stateblock **stateblock);
ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock);
+HRESULT __cdecl wined3d_stateblock_get_light(const struct wined3d_stateblock *stateblock,
+ UINT light_idx, struct wined3d_light *light, BOOL *enabled);
const struct wined3d_stateblock_state * __cdecl wined3d_stateblock_get_state(const struct wined3d_stateblock *stateblock);
ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
void __cdecl wined3d_stateblock_init_contained_states(struct wined3d_stateblock *stateblock);
--
2.25.0
More information about the wine-devel
mailing list