1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-14 22:29:15 +01:00

[d3d9] Optimize UpdateAnyColorWrites for 0th case

This is the most common
This commit is contained in:
Joshua Ashton 2023-05-24 14:21:30 +01:00
parent cafd104783
commit b5c18a02ae
2 changed files with 16 additions and 12 deletions

View File

@ -1981,22 +1981,22 @@ namespace dxvk {
case D3DRS_COLORWRITEENABLE: case D3DRS_COLORWRITEENABLE:
if (likely(!old != !Value)) if (likely(!old != !Value))
UpdateAnyColorWrites(0, !!Value); UpdateAnyColorWrites<0>(!!Value);
m_flags.set(D3D9DeviceFlag::DirtyBlendState); m_flags.set(D3D9DeviceFlag::DirtyBlendState);
break; break;
case D3DRS_COLORWRITEENABLE1: case D3DRS_COLORWRITEENABLE1:
if (likely(!old != !Value)) if (likely(!old != !Value))
UpdateAnyColorWrites(1, !!Value); UpdateAnyColorWrites<1>(!!Value);
m_flags.set(D3D9DeviceFlag::DirtyBlendState); m_flags.set(D3D9DeviceFlag::DirtyBlendState);
break; break;
case D3DRS_COLORWRITEENABLE2: case D3DRS_COLORWRITEENABLE2:
if (likely(!old != !Value)) if (likely(!old != !Value))
UpdateAnyColorWrites(2, !!Value); UpdateAnyColorWrites<2>(!!Value);
m_flags.set(D3D9DeviceFlag::DirtyBlendState); m_flags.set(D3D9DeviceFlag::DirtyBlendState);
break; break;
case D3DRS_COLORWRITEENABLE3: case D3DRS_COLORWRITEENABLE3:
if (likely(!old != !Value)) if (likely(!old != !Value))
UpdateAnyColorWrites(3, !!Value); UpdateAnyColorWrites<3>(!!Value);
m_flags.set(D3D9DeviceFlag::DirtyBlendState); m_flags.set(D3D9DeviceFlag::DirtyBlendState);
break; break;
@ -5361,18 +5361,19 @@ namespace dxvk {
UpdateActiveHazardsRT(bit); UpdateActiveHazardsRT(bit);
} }
template <uint32_t Index>
inline void D3D9DeviceEx::UpdateAnyColorWrites(uint32_t index, bool has) { inline void D3D9DeviceEx::UpdateAnyColorWrites(bool has) {
const uint32_t bit = 1 << index; const uint32_t bit = 1 << Index;
m_anyColorWrites &= ~bit; m_anyColorWrites &= ~bit;
if (has) if (has)
m_anyColorWrites |= bit; m_anyColorWrites |= bit;
if (m_boundRTs & bit) { // The 0th RT is always bound.
if (Index == 0 || m_boundRTs & bit) {
m_flags.set(D3D9DeviceFlag::DirtyFramebuffer); m_flags.set(D3D9DeviceFlag::DirtyFramebuffer);
UpdateActiveRTs(index); UpdateActiveRTs(Index);
} }
} }
@ -7385,8 +7386,10 @@ namespace dxvk {
UpdatePixelBoolSpec(0u); UpdatePixelBoolSpec(0u);
UpdateCommonSamplerSpec(0u, 0u, 0u); UpdateCommonSamplerSpec(0u, 0u, 0u);
for (uint32_t i = 0; i < caps::MaxSimultaneousRenderTargets; i++) UpdateAnyColorWrites<0>(true);
UpdateAnyColorWrites(i, true); UpdateAnyColorWrites<1>(true);
UpdateAnyColorWrites<2>(true);
UpdateAnyColorWrites<3>(true);
} }

View File

@ -774,7 +774,8 @@ namespace dxvk {
void UpdateActiveRTs(uint32_t index); void UpdateActiveRTs(uint32_t index);
void UpdateAnyColorWrites(uint32_t index, bool has); template <uint32_t Index>
void UpdateAnyColorWrites(bool has);
void UpdateActiveTextures(uint32_t index, DWORD combinedUsage); void UpdateActiveTextures(uint32_t index, DWORD combinedUsage);