1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-20 01:54:16 +01:00

[d3d9] Clean up SetStateSamplerState

This commit is contained in:
Joshua Ashton 2021-08-09 03:20:06 +01:00 committed by Joshie
parent ea4aa87336
commit 1823a098a1

View File

@ -3644,48 +3644,47 @@ namespace dxvk {
auto& state = m_state.samplerStates;
bool changed = state[StateSampler][Type] != Value;
if (state[StateSampler][Type] == Value)
return D3D_OK;
if (likely(changed)) {
state[StateSampler][Type] = Value;
state[StateSampler][Type] = Value;
if (Type == D3DSAMP_ADDRESSU
|| Type == D3DSAMP_ADDRESSV
|| Type == D3DSAMP_ADDRESSW
|| Type == D3DSAMP_MAGFILTER
|| Type == D3DSAMP_MINFILTER
|| Type == D3DSAMP_MIPFILTER
|| Type == D3DSAMP_MAXANISOTROPY
|| Type == D3DSAMP_MIPMAPLODBIAS
|| Type == D3DSAMP_MAXMIPLEVEL
|| Type == D3DSAMP_BORDERCOLOR)
m_dirtySamplerStates |= 1u << StateSampler;
else if (Type == D3DSAMP_SRGBTEXTURE && m_state.textures[StateSampler] != nullptr)
m_dirtyTextures |= 1u << StateSampler;
if (Type == D3DSAMP_ADDRESSU
|| Type == D3DSAMP_ADDRESSV
|| Type == D3DSAMP_ADDRESSW
|| Type == D3DSAMP_MAGFILTER
|| Type == D3DSAMP_MINFILTER
|| Type == D3DSAMP_MIPFILTER
|| Type == D3DSAMP_MAXANISOTROPY
|| Type == D3DSAMP_MIPMAPLODBIAS
|| Type == D3DSAMP_MAXMIPLEVEL
|| Type == D3DSAMP_BORDERCOLOR)
m_dirtySamplerStates |= 1u << StateSampler;
else if (Type == D3DSAMP_SRGBTEXTURE && m_state.textures[StateSampler] != nullptr)
m_dirtyTextures |= 1u << StateSampler;
constexpr DWORD Fetch4Enabled = MAKEFOURCC('G', 'E', 'T', '4');
constexpr DWORD Fetch4Disabled = MAKEFOURCC('G', 'E', 'T', '1');
constexpr DWORD Fetch4Enabled = MAKEFOURCC('G', 'E', 'T', '4');
constexpr DWORD Fetch4Disabled = MAKEFOURCC('G', 'E', 'T', '1');
if (unlikely(Type == D3DSAMP_MIPMAPLODBIAS)) {
if (unlikely(Value == Fetch4Enabled)) {
m_fetch4Enabled |= 1u << StateSampler;
if (state[StateSampler][D3DSAMP_MAGFILTER] == D3DTEXF_POINT)
m_fetch4 |= 1u << StateSampler;
}
else if (unlikely(Value == Fetch4Disabled)) {
m_fetch4Enabled &= ~(1u << StateSampler);
m_fetch4 &= ~(1u << StateSampler);
}
if (unlikely(Type == D3DSAMP_MIPMAPLODBIAS)) {
if (unlikely(Value == Fetch4Enabled)) {
m_fetch4Enabled |= 1u << StateSampler;
if (state[StateSampler][D3DSAMP_MAGFILTER] == D3DTEXF_POINT)
m_fetch4 |= 1u << StateSampler;
}
if (unlikely(Type == D3DSAMP_MAGFILTER && m_fetch4Enabled & (1u << StateSampler))) {
if (Value == D3DTEXF_POINT)
m_fetch4 |= 1u << StateSampler;
else
m_fetch4 &= ~(1u << StateSampler);
else if (unlikely(Value == Fetch4Disabled)) {
m_fetch4Enabled &= ~(1u << StateSampler);
m_fetch4 &= ~(1u << StateSampler);
}
}
if (unlikely(Type == D3DSAMP_MAGFILTER && m_fetch4Enabled & (1u << StateSampler))) {
if (Value == D3DTEXF_POINT)
m_fetch4 |= 1u << StateSampler;
else
m_fetch4 &= ~(1u << StateSampler);
}
return D3D_OK;
}