wined3d: Get rid of the vertex sampler offset.
Do the offsetting in d3d9 instead. Notice that this also fixes vertex sampler handling in wined3d_stateblock_apply(), since it was using the adjusted "stage" to index the sampler_states[] array. (Coverity) Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5c8903a0a9
commit
038b561b10
|
@ -2514,8 +2514,8 @@ static HRESULT WINAPI d3d9_device_GetTexture(IDirect3DDevice9Ex *iface, DWORD st
|
||||||
if (!texture)
|
if (!texture)
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3)
|
if (stage >= D3DVERTEXTEXTURESAMPLER0 && stage <= D3DVERTEXTEXTURESAMPLER3)
|
||||||
stage -= (WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS);
|
stage -= D3DVERTEXTEXTURESAMPLER0 - WINED3D_VERTEX_SAMPLER_OFFSET;
|
||||||
|
|
||||||
if (stage >= ARRAY_SIZE(state->textures))
|
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);
|
texture_impl = unsafe_impl_from_IDirect3DBaseTexture9(texture);
|
||||||
|
|
||||||
|
if (stage >= D3DVERTEXTEXTURESAMPLER0 && stage <= D3DVERTEXTEXTURESAMPLER3)
|
||||||
|
stage -= D3DVERTEXTEXTURESAMPLER0 - WINED3D_VERTEX_SAMPLER_OFFSET;
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
wined3d_mutex_lock();
|
||||||
wined3d_stateblock_set_texture(device->update_state, stage,
|
wined3d_stateblock_set_texture(device->update_state, stage,
|
||||||
texture_impl ? texture_impl->wined3d_texture : NULL);
|
texture_impl ? texture_impl->wined3d_texture : NULL);
|
||||||
if (!device->recording)
|
if (!device->recording)
|
||||||
{
|
{
|
||||||
unsigned int i = stage < 16 || (stage >= D3DVERTEXTEXTURESAMPLER0 && stage <= D3DVERTEXTEXTURESAMPLER3)
|
if (stage < D3D9_MAX_TEXTURE_UNITS)
|
||||||
? stage < 16 ? stage : stage - D3DVERTEXTEXTURESAMPLER0 + 16 : ~0u;
|
|
||||||
|
|
||||||
if (i < D3D9_MAX_TEXTURE_UNITS)
|
|
||||||
{
|
{
|
||||||
if (texture_impl && texture_impl->usage & D3DUSAGE_AUTOGENMIPMAP)
|
if (texture_impl && texture_impl->usage & D3DUSAGE_AUTOGENMIPMAP)
|
||||||
device->auto_mipmaps |= 1u << i;
|
device->auto_mipmaps |= 1u << stage;
|
||||||
else
|
else
|
||||||
device->auto_mipmaps &= ~(1u << i);
|
device->auto_mipmaps &= ~(1u << stage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wined3d_mutex_unlock();
|
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);
|
TRACE("iface %p, sampler_idx %u, state %#x, value %p.\n", iface, sampler_idx, state, value);
|
||||||
|
|
||||||
if (sampler_idx >= WINED3DVERTEXTEXTURESAMPLER0 && sampler_idx <= WINED3DVERTEXTEXTURESAMPLER3)
|
if (sampler_idx >= D3DVERTEXTEXTURESAMPLER0 && sampler_idx <= D3DVERTEXTEXTURESAMPLER3)
|
||||||
sampler_idx -= (WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS);
|
sampler_idx -= D3DVERTEXTEXTURESAMPLER0 - WINED3D_VERTEX_SAMPLER_OFFSET;
|
||||||
|
|
||||||
if (sampler_idx >= ARRAY_SIZE(device_state->sampler_states))
|
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);
|
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_mutex_lock();
|
||||||
wined3d_stateblock_set_sampler_state(device->update_state, sampler, state, value);
|
wined3d_stateblock_set_sampler_state(device->update_state, sampler, state, value);
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
|
|
|
@ -1758,9 +1758,6 @@ static void wined3d_device_set_sampler_state(struct wined3d_device *device,
|
||||||
TRACE("device %p, sampler_idx %u, state %s, value %#x.\n",
|
TRACE("device %p, sampler_idx %u, state %s, value %#x.\n",
|
||||||
device, sampler_idx, debug_d3dsamplerstate(state), value);
|
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])
|
if (value == device->state.sampler_states[sampler_idx][state])
|
||||||
{
|
{
|
||||||
TRACE("Application is setting the old value over, nothing to do.\n");
|
TRACE("Application is setting the old value over, nothing to do.\n");
|
||||||
|
@ -3452,9 +3449,6 @@ static void wined3d_device_set_texture(struct wined3d_device *device,
|
||||||
|
|
||||||
TRACE("device %p, stage %u, texture %p.\n", device, stage, texture);
|
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. */
|
/* Windows accepts overflowing this array... we do not. */
|
||||||
if (stage >= ARRAY_SIZE(device->state.textures))
|
if (stage >= ARRAY_SIZE(device->state.textures))
|
||||||
{
|
{
|
||||||
|
@ -3492,7 +3486,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
|
||||||
BOOL set_blend_state = FALSE, set_rasterizer_state = FALSE;
|
BOOL set_blend_state = FALSE, set_rasterizer_state = FALSE;
|
||||||
unsigned int i, j, start, idx;
|
unsigned int i, j, start, idx;
|
||||||
struct wined3d_range range;
|
struct wined3d_range range;
|
||||||
DWORD map, stage;
|
uint32_t map;
|
||||||
|
|
||||||
TRACE("device %p, stateblock %p.\n", device, stateblock);
|
TRACE("device %p, stateblock %p.\n", device, stateblock);
|
||||||
|
|
||||||
|
@ -3732,14 +3726,11 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(changed->samplerState); ++i)
|
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];
|
map = changed->samplerState[i];
|
||||||
while (map)
|
while (map)
|
||||||
{
|
{
|
||||||
j = wined3d_bit_scan(&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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3788,10 +3779,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
|
||||||
while (map)
|
while (map)
|
||||||
{
|
{
|
||||||
i = wined3d_bit_scan(&map);
|
i = wined3d_bit_scan(&map);
|
||||||
stage = i;
|
wined3d_device_set_texture(device, i, state->textures[i]);
|
||||||
if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS)
|
|
||||||
stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS;
|
|
||||||
wined3d_device_set_texture(device, stage, state->textures[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
map = changed->clipplane;
|
map = changed->clipplane;
|
||||||
|
|
|
@ -1075,7 +1075,6 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
|
||||||
DWORD stage = stateblock->contained_sampler_states[i].stage;
|
DWORD stage = stateblock->contained_sampler_states[i].stage;
|
||||||
DWORD sampler_state = stateblock->contained_sampler_states[i].state;
|
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,
|
wined3d_stateblock_set_sampler_state(device_state, stage, sampler_state,
|
||||||
state->sampler_states[stage][sampler_state]);
|
state->sampler_states[stage][sampler_state]);
|
||||||
}
|
}
|
||||||
|
@ -1127,13 +1126,8 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
|
||||||
map = stateblock->changed.textures;
|
map = stateblock->changed.textures;
|
||||||
for (i = 0; map; map >>= 1, ++i)
|
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)
|
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;
|
map = stateblock->changed.clipplane;
|
||||||
|
@ -1353,9 +1347,6 @@ void CDECL wined3d_stateblock_set_sampler_state(struct wined3d_stateblock *state
|
||||||
TRACE("stateblock %p, sampler_idx %u, state %s, value %#x.\n",
|
TRACE("stateblock %p, sampler_idx %u, state %s, value %#x.\n",
|
||||||
stateblock, sampler_idx, debug_d3dsamplerstate(state), value);
|
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))
|
if (sampler_idx >= ARRAY_SIZE(stateblock->stateblock_state.sampler_states))
|
||||||
{
|
{
|
||||||
WARN("Invalid sampler %u.\n", sampler_idx);
|
WARN("Invalid sampler %u.\n", sampler_idx);
|
||||||
|
@ -1394,9 +1385,6 @@ void CDECL wined3d_stateblock_set_texture(struct wined3d_stateblock *stateblock,
|
||||||
{
|
{
|
||||||
TRACE("stateblock %p, stage %u, texture %p.\n", stateblock, stage, texture);
|
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))
|
if (stage >= ARRAY_SIZE(stateblock->stateblock_state.textures))
|
||||||
{
|
{
|
||||||
WARN("Ignoring invalid stage %u.\n", stage);
|
WARN("Ignoring invalid stage %u.\n", stage);
|
||||||
|
|
|
@ -1035,10 +1035,7 @@ enum wined3d_shader_type
|
||||||
|
|
||||||
/* VTF defines */
|
/* VTF defines */
|
||||||
#define WINED3DDMAPSAMPLER 0x100
|
#define WINED3DDMAPSAMPLER 0x100
|
||||||
#define WINED3DVERTEXTEXTURESAMPLER0 (WINED3DDMAPSAMPLER + 1)
|
#define WINED3D_VERTEX_SAMPLER_OFFSET WINED3D_MAX_FRAGMENT_SAMPLERS
|
||||||
#define WINED3DVERTEXTEXTURESAMPLER1 (WINED3DDMAPSAMPLER + 2)
|
|
||||||
#define WINED3DVERTEXTEXTURESAMPLER2 (WINED3DDMAPSAMPLER + 3)
|
|
||||||
#define WINED3DVERTEXTEXTURESAMPLER3 (WINED3DDMAPSAMPLER + 4)
|
|
||||||
|
|
||||||
#define WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020
|
#define WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020
|
||||||
#define WINED3DCAPS3_LINEAR_TO_SRGB_PRESENTATION 0x00000080
|
#define WINED3DCAPS3_LINEAR_TO_SRGB_PRESENTATION 0x00000080
|
||||||
|
|
Loading…
Reference in New Issue