Do the offsetting in d3d9 instead.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d9/device.c | 23 +++++++++++++---------- dlls/wined3d/device.c | 18 +++--------------- dlls/wined3d/stateblock.c | 14 +------------- include/wine/wined3d.h | 5 +---- 4 files changed, 18 insertions(+), 42 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 8ffe04c94d7..d6a3d9e0b87 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2514,8 +2514,8 @@ static HRESULT WINAPI d3d9_device_GetTexture(IDirect3DDevice9Ex *iface, DWORD st if (!texture) return D3DERR_INVALIDCALL;
- if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3) - stage -= (WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS); + if (stage >= D3DVERTEXTEXTURESAMPLER0 && stage <= D3DVERTEXTEXTURESAMPLER3) + stage -= D3DVERTEXTEXTURESAMPLER0 - WINED3D_VERTEX_SAMPLER_OFFSET;
if (stage >= ARRAY_SIZE(state->textures)) { @@ -2550,20 +2550,20 @@ static HRESULT WINAPI d3d9_device_SetTexture(IDirect3DDevice9Ex *iface, DWORD st
texture_impl = unsafe_impl_from_IDirect3DBaseTexture9(texture);
+ if (stage >= D3DVERTEXTEXTURESAMPLER0 && stage <= D3DVERTEXTEXTURESAMPLER3) + stage -= D3DVERTEXTEXTURESAMPLER0 - WINED3D_VERTEX_SAMPLER_OFFSET; + wined3d_mutex_lock(); wined3d_stateblock_set_texture(device->update_state, stage, texture_impl ? texture_impl->wined3d_texture : NULL); if (!device->recording) { - unsigned int i = stage < 16 || (stage >= D3DVERTEXTEXTURESAMPLER0 && stage <= D3DVERTEXTEXTURESAMPLER3) - ? stage < 16 ? stage : stage - D3DVERTEXTEXTURESAMPLER0 + 16 : ~0u; - - if (i < D3D9_MAX_TEXTURE_UNITS) + if (stage < D3D9_MAX_TEXTURE_UNITS) { if (texture_impl && texture_impl->usage & D3DUSAGE_AUTOGENMIPMAP) - device->auto_mipmaps |= 1u << i; + device->auto_mipmaps |= 1u << stage; else - device->auto_mipmaps &= ~(1u << i); + device->auto_mipmaps &= ~(1u << stage); } } wined3d_mutex_unlock(); @@ -2656,8 +2656,8 @@ static HRESULT WINAPI d3d9_device_GetSamplerState(IDirect3DDevice9Ex *iface,
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 >= D3DVERTEXTEXTURESAMPLER0 && sampler_idx <= D3DVERTEXTEXTURESAMPLER3) + sampler_idx -= D3DVERTEXTEXTURESAMPLER0 - WINED3D_VERTEX_SAMPLER_OFFSET;
if (sampler_idx >= ARRAY_SIZE(device_state->sampler_states)) { @@ -2681,6 +2681,9 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_SetSamplerState(IDirect3DDev
TRACE("iface %p, sampler %u, state %#x, value %#x.\n", iface, sampler, state, value);
+ if (sampler >= D3DVERTEXTEXTURESAMPLER0 && sampler <= D3DVERTEXTEXTURESAMPLER3) + sampler -= D3DVERTEXTEXTURESAMPLER0 - WINED3D_VERTEX_SAMPLER_OFFSET; + wined3d_mutex_lock(); wined3d_stateblock_set_sampler_state(device->update_state, sampler, state, value); wined3d_mutex_unlock(); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 21f9af9566d..70dce23fbde 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1746,9 +1746,6 @@ static void wined3d_device_set_sampler_state(struct wined3d_device *device, TRACE("device %p, sampler_idx %u, state %s, value %#x.\n", device, sampler_idx, debug_d3dsamplerstate(state), value);
- if (sampler_idx >= WINED3DVERTEXTEXTURESAMPLER0 && sampler_idx <= WINED3DVERTEXTEXTURESAMPLER3) - sampler_idx -= (WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS); - if (value == device->state.sampler_states[sampler_idx][state]) { TRACE("Application is setting the old value over, nothing to do.\n"); @@ -3492,9 +3489,6 @@ static void wined3d_device_set_texture(struct wined3d_device *device,
TRACE("device %p, stage %u, texture %p.\n", device, stage, texture);
- if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3) - stage -= (WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS); - /* Windows accepts overflowing this array... we do not. */ if (stage >= ARRAY_SIZE(device->state.textures)) { @@ -3534,7 +3528,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, struct wined3d_color colour; struct wined3d_range range; BOOL set_blend_state; - DWORD map, stage; + DWORD map;
TRACE("device %p, stateblock %p.\n", device, stateblock);
@@ -3657,14 +3651,11 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
for (i = 0; i < ARRAY_SIZE(changed->samplerState); ++i) { - stage = i; - if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS) - stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS; map = changed->samplerState[i]; while (map) { j = wined3d_bit_scan(&map); - wined3d_device_set_sampler_state(device, stage, j, state->sampler_states[i][j]); + wined3d_device_set_sampler_state(device, i, j, state->sampler_states[i][j]); } }
@@ -3713,10 +3704,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, while (map) { i = wined3d_bit_scan(&map); - stage = i; - if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS) - stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS; - wined3d_device_set_texture(device, stage, state->textures[i]); + wined3d_device_set_texture(device, i, state->textures[i]); }
map = changed->clipplane; diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 70943afddaa..6e9060c0254 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1092,7 +1092,6 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock, DWORD stage = stateblock->contained_sampler_states[i].stage; DWORD sampler_state = stateblock->contained_sampler_states[i].state;
- if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS) stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS; wined3d_stateblock_set_sampler_state(device_state, stage, sampler_state, state->sampler_states[stage][sampler_state]); } @@ -1144,13 +1143,8 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock, map = stateblock->changed.textures; for (i = 0; map; map >>= 1, ++i) { - DWORD stage = i; - - if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS) - stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS; - if (map & 1) - wined3d_stateblock_set_texture(device_state, stage, state->textures[i]); + wined3d_stateblock_set_texture(device_state, i, state->textures[i]); }
map = stateblock->changed.clipplane; @@ -1380,9 +1374,6 @@ void CDECL wined3d_stateblock_set_sampler_state(struct wined3d_stateblock *state TRACE("stateblock %p, sampler_idx %u, state %s, value %#x.\n", stateblock, sampler_idx, debug_d3dsamplerstate(state), value);
- if (sampler_idx >= WINED3DVERTEXTEXTURESAMPLER0 && sampler_idx <= WINED3DVERTEXTEXTURESAMPLER3) - sampler_idx -= (WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS); - if (sampler_idx >= ARRAY_SIZE(stateblock->stateblock_state.sampler_states)) { WARN("Invalid sampler %u.\n", sampler_idx); @@ -1421,9 +1412,6 @@ void CDECL wined3d_stateblock_set_texture(struct wined3d_stateblock *stateblock, { TRACE("stateblock %p, stage %u, texture %p.\n", stateblock, stage, texture);
- if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3) - stage -= (WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS); - if (stage >= ARRAY_SIZE(stateblock->stateblock_state.textures)) { WARN("Ignoring invalid stage %u.\n", stage); diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index cb8f19981aa..e4b31e7f9c7 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -1035,10 +1035,7 @@ enum wined3d_shader_type
/* VTF defines */ #define WINED3DDMAPSAMPLER 0x100 -#define WINED3DVERTEXTEXTURESAMPLER0 (WINED3DDMAPSAMPLER + 1) -#define WINED3DVERTEXTEXTURESAMPLER1 (WINED3DDMAPSAMPLER + 2) -#define WINED3DVERTEXTEXTURESAMPLER2 (WINED3DDMAPSAMPLER + 3) -#define WINED3DVERTEXTEXTURESAMPLER3 (WINED3DDMAPSAMPLER + 4) +#define WINED3D_VERTEX_SAMPLER_OFFSET WINED3D_MAX_FRAGMENT_SAMPLERS
#define WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020 #define WINED3DCAPS3_LINEAR_TO_SRGB_PRESENTATION 0x00000080