[PATCH 1/6] d3d9: Retrieve textures from the primary stateblock.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> --- dlls/d3d9/device.c | 24 +++++++++++++++++------- dlls/d3d9/stateblock.c | 6 ++---- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 1ff178881c..3d2dd38d9c 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2512,19 +2512,30 @@ static HRESULT WINAPI d3d9_device_GetClipStatus(IDirect3DDevice9Ex *iface, D3DCL return hr; } -static HRESULT WINAPI d3d9_device_GetTexture(IDirect3DDevice9Ex *iface, DWORD stage, IDirect3DBaseTexture9 **texture) +static HRESULT WINAPI d3d9_device_GetTexture(IDirect3DDevice9Ex *iface, + DWORD sampler_idx, IDirect3DBaseTexture9 **texture) { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct wined3d_texture *wined3d_texture = NULL; struct d3d9_texture *texture_impl; - TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture); + TRACE("iface %p, sampler_idx %u, texture %p.\n", iface, sampler_idx, texture); if (!texture) return D3DERR_INVALIDCALL; + if (sampler_idx >= WINED3DVERTEXTEXTURESAMPLER0 && sampler_idx <= WINED3DVERTEXTEXTURESAMPLER3) + sampler_idx -= (WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS); + + if (sampler_idx >= WINED3D_MAX_COMBINED_SAMPLERS) + { + WARN("Invalid sampler %u.\n", sampler_idx); + *texture = NULL; + return D3D_OK; + } + wined3d_mutex_lock(); - if ((wined3d_texture = wined3d_device_get_texture(device->wined3d_device, stage))) + if ((wined3d_texture = wined3d_stateblock_get_state(device->state)->textures[sampler_idx])) { texture_impl = wined3d_texture_get_parent(wined3d_texture); *texture = &texture_impl->IDirect3DBaseTexture9_iface; @@ -2815,16 +2826,15 @@ static float WINAPI d3d9_device_GetNPatchMode(IDirect3DDevice9Ex *iface) /* wined3d critical section must be taken by the caller. */ static void d3d9_generate_auto_mipmaps(struct d3d9_device *device) { + const struct wined3d_stateblock_state *state = wined3d_stateblock_get_state(device->state); struct wined3d_texture *texture; - unsigned int i, stage, map; + unsigned int i, map; map = device->auto_mipmaps; while (map) { i = wined3d_bit_scan(&map); - - stage = i >= 16 ? i - 16 + D3DVERTEXTEXTURESAMPLER0 : i; - if ((texture = wined3d_device_get_texture(device->wined3d_device, stage))) + if ((texture = state->textures[i])) d3d9_texture_gen_auto_mipmap(wined3d_texture_get_parent(texture)); } } diff --git a/dlls/d3d9/stateblock.c b/dlls/d3d9/stateblock.c index dfb8d8d755..a65fa1cd8d 100644 --- a/dlls/d3d9/stateblock.c +++ b/dlls/d3d9/stateblock.c @@ -116,9 +116,9 @@ static HRESULT WINAPI d3d9_stateblock_Apply(IDirect3DStateBlock9 *iface) { struct d3d9_stateblock *stateblock = impl_from_IDirect3DStateBlock9(iface); struct wined3d_texture *wined3d_texture; - unsigned int i, offset, stride, stage; struct wined3d_buffer *wined3d_buffer; struct d3d9_vertexbuffer *buffer; + unsigned int i, offset, stride; enum wined3d_format_id format; struct d3d9_texture *texture; struct d3d9_device *device; @@ -151,9 +151,7 @@ static HRESULT WINAPI d3d9_stateblock_Apply(IDirect3DStateBlock9 *iface) device->auto_mipmaps = 0; for (i = 0; i < D3D9_MAX_TEXTURE_UNITS; ++i) { - stage = i >= 16 ? i - 16 + D3DVERTEXTEXTURESAMPLER0 : i; - - if ((wined3d_texture = wined3d_device_get_texture(device->wined3d_device, stage)) + if ((wined3d_texture = wined3d_stateblock_get_state(device->state)->textures[i]) && (texture = wined3d_texture_get_parent(wined3d_texture)) && texture->usage & D3DUSAGE_AUTOGENMIPMAP) device->auto_mipmaps |= 1u << i; -- 2.25.0
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> --- dlls/d3d9/device.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 3d2dd38d9c..6df43ccb66 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2567,9 +2567,6 @@ static HRESULT WINAPI d3d9_device_SetTexture(IDirect3DDevice9Ex *iface, DWORD st unsigned int i = stage < 16 || (stage >= D3DVERTEXTEXTURESAMPLER0 && stage <= D3DVERTEXTEXTURESAMPLER3) ? stage < 16 ? stage : stage - D3DVERTEXTEXTURESAMPLER0 + 16 : ~0u; - wined3d_device_set_texture(device->wined3d_device, stage, - texture_impl ? texture_impl->wined3d_texture : NULL); - if (i < D3D9_MAX_TEXTURE_UNITS) { if (texture_impl && texture_impl->usage & D3DUSAGE_AUTOGENMIPMAP) -- 2.25.0
Hi, While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=64968 Your paranoid android. === debian10 (32 bit report) === === debian10 (32 bit Chinese:China report) === === debian10 (32 bit WoW report) === === debian10 (64 bit WoW report) ===
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> --- dlls/d3d9/device.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 6df43ccb66..730032755e 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2660,14 +2660,24 @@ static HRESULT WINAPI d3d9_device_SetTextureStageState(IDirect3DDevice9Ex *iface } static HRESULT WINAPI d3d9_device_GetSamplerState(IDirect3DDevice9Ex *iface, - DWORD sampler, D3DSAMPLERSTATETYPE state, DWORD *value) + DWORD sampler_idx, D3DSAMPLERSTATETYPE state, DWORD *value) { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); - TRACE("iface %p, sampler %u, state %#x, value %p.\n", iface, sampler, state, value); + TRACE("iface %p, sampler_idx %u, state %#x, value %p.\n", iface, sampler_idx, state, value); + + if (sampler_idx >= WINED3DVERTEXTEXTURESAMPLER0 && sampler_idx <= WINED3DVERTEXTEXTURESAMPLER3) + sampler_idx -= (WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS); + + if (sampler_idx >= WINED3D_MAX_COMBINED_SAMPLERS) + { + WARN("Invalid sampler %u.\n", sampler_idx); + *value = 0; + return D3D_OK; + } wined3d_mutex_lock(); - *value = wined3d_device_get_sampler_state(device->wined3d_device, sampler, state); + *value = wined3d_stateblock_get_state(device->state)->sampler_states[sampler_idx][state]; wined3d_mutex_unlock(); return D3D_OK; -- 2.25.0
Hi, While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=64969 Your paranoid android. === debian10 (32 bit report) === === debian10 (32 bit Chinese:China report) === === debian10 (32 bit WoW report) === === debian10 (64 bit WoW report) ===
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> --- dlls/d3d9/device.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 730032755e..e7e956dcf3 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2692,8 +2692,6 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_SetSamplerState(IDirect3DDev wined3d_mutex_lock(); wined3d_stateblock_set_sampler_state(device->update_state, sampler, state, value); - if (!device->recording) - wined3d_device_set_sampler_state(device->wined3d_device, sampler, state, value); wined3d_mutex_unlock(); return D3D_OK; -- 2.25.0
Hi, While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=64970 Your paranoid android. === debian10 (32 bit report) === === debian10 (32 bit Chinese:China report) === === debian10 (32 bit WoW report) === === debian10 (64 bit WoW report) ===
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> --- dlls/d3d9/device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index e7e956dcf3..15400d309c 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2618,20 +2618,20 @@ static const enum wined3d_texture_stage_state tss_lookup[] = }; static HRESULT WINAPI d3d9_device_GetTextureStageState(IDirect3DDevice9Ex *iface, - DWORD stage, D3DTEXTURESTAGESTATETYPE state, DWORD *value) + DWORD sampler_idx, D3DTEXTURESTAGESTATETYPE state, DWORD *value) { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); - TRACE("iface %p, stage %u, state %#x, value %p.\n", iface, stage, state, value); + TRACE("iface %p, sampler_idx %u, state %#x, value %p.\n", iface, sampler_idx, state, value); - if (state >= ARRAY_SIZE(tss_lookup)) + if (state >= ARRAY_SIZE(tss_lookup) || tss_lookup[state] == WINED3D_TSS_INVALID) { WARN("Invalid state %#x passed.\n", state); return D3D_OK; } wined3d_mutex_lock(); - *value = wined3d_device_get_texture_stage_state(device->wined3d_device, stage, tss_lookup[state]); + *value = wined3d_stateblock_get_state(device->state)->texture_states[sampler_idx][tss_lookup[state]]; wined3d_mutex_unlock(); return D3D_OK; -- 2.25.0
Hi, While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=64971 Your paranoid android. === debian10 (32 bit report) === === debian10 (32 bit Chinese:China report) === === debian10 (32 bit WoW report) === === debian10 (64 bit WoW report) ===
On Wed, 12 Feb 2020 at 04:55, Zebediah Figura <z.figura12(a)gmail.com> wrote:
static HRESULT WINAPI d3d9_device_GetTextureStageState(IDirect3DDevice9Ex *iface, - DWORD stage, D3DTEXTURESTAGESTATETYPE state, DWORD *value) + DWORD sampler_idx, D3DTEXTURESTAGESTATETYPE state, DWORD *value)
The change of "stage" to "sampler_idx" may be defensible for GetTexture(), although it's still a little ugly to use different terminology for GetTexture() and SetTexture(). I think it's more questionable here; texture stage states are only incidentally related to samplers. Depending on the specific state set, a particular stage may not reference any texture or sampler at all.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> --- dlls/d3d9/device.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 15400d309c..57c402ad93 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2652,8 +2652,6 @@ static HRESULT WINAPI d3d9_device_SetTextureStageState(IDirect3DDevice9Ex *iface wined3d_mutex_lock(); wined3d_stateblock_set_texture_stage_state(device->update_state, stage, tss_lookup[state], value); - if (!device->recording) - wined3d_device_set_texture_stage_state(device->wined3d_device, stage, tss_lookup[state], value); wined3d_mutex_unlock(); return D3D_OK; -- 2.25.0
Hi, While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=64972 Your paranoid android. === debian10 (32 bit report) === === debian10 (32 bit Chinese:China report) === === debian10 (32 bit WoW report) === === debian10 (64 bit WoW report) ===
Hi, While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=64967 Your paranoid android. === debian10 (32 bit report) === === debian10 (32 bit Chinese:China report) === === debian10 (32 bit WoW report) === === debian10 (64 bit WoW report) ===
participants (3)
-
Henri Verbeet -
Marvin -
Zebediah Figura