From 942e21003781c787a26571ae65776bb036374f2d Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Fri, 21 Feb 2020 17:04:49 -0600 Subject: [PATCH] d3d8: Retrieve texture states from the primary stateblock. Signed-off-by: Zebediah Figura Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d8/device.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 7c1a6fe9fd4..41384d84bcb 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -2251,26 +2251,38 @@ tss_lookup[] = }; static HRESULT WINAPI d3d8_device_GetTextureStageState(IDirect3DDevice8 *iface, - DWORD stage, D3DTEXTURESTAGESTATETYPE Type, DWORD *value) + DWORD stage, D3DTEXTURESTAGESTATETYPE state, DWORD *value) { struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); + const struct wined3d_stateblock_state *device_state; const struct tss_lookup *l; - TRACE("iface %p, stage %u, state %#x, value %p.\n", iface, stage, Type, value); + TRACE("iface %p, stage %u, state %#x, value %p.\n", iface, stage, state, value); - if (Type >= ARRAY_SIZE(tss_lookup)) + if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3) + stage -= (WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS); + + if (stage >= WINED3D_MAX_COMBINED_SAMPLERS) { - WARN("Invalid Type %#x passed.\n", Type); + WARN("Invalid stage %u.\n", stage); + *value = 0; return D3D_OK; } - l = &tss_lookup[Type]; + if (state >= ARRAY_SIZE(tss_lookup)) + { + WARN("Invalid state %#x.\n", state); + return D3D_OK; + } + + l = &tss_lookup[state]; wined3d_mutex_lock(); + device_state = wined3d_stateblock_get_state(device->state); if (l->sampler_state) - *value = wined3d_device_get_sampler_state(device->wined3d_device, stage, l->u.sampler_state); + *value = device_state->sampler_states[stage][l->u.sampler_state]; else - *value = wined3d_device_get_texture_stage_state(device->wined3d_device, stage, l->u.texture_state); + *value = device_state->texture_states[stage][l->u.texture_state]; wined3d_mutex_unlock(); return D3D_OK;