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

View File

@ -774,7 +774,8 @@ namespace dxvk {
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);