From 64852f05c3db1f51a0f1b3cfc86b2b29faf7486c Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Mon, 16 Aug 2021 17:09:03 +0100 Subject: [PATCH] [d3d9] Track fixed function sampler bitfields Cleans some stuff up a little bit and makes FF draws faster when this gets incorrectly invalidated. --- src/d3d9/d3d9_device.cpp | 14 ++++---------- src/d3d9/d3d9_device.h | 1 + 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 606756ffa..457a414d2 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -5815,12 +5815,8 @@ namespace dxvk { const uint32_t textureBitMask = 0b11u << offset; const uint32_t textureBits = textureType << offset; - if ((m_samplerTypeBitfield & textureBitMask) != textureBits) { - m_flags.set(D3D9DeviceFlag::DirtyFFPixelShader); - - m_samplerTypeBitfield &= ~textureBitMask; - m_samplerTypeBitfield |= textureBits; - } + m_samplerTypeBitfield &= ~textureBitMask; + m_samplerTypeBitfield |= textureBits; } EmitCs([ @@ -5842,9 +5838,6 @@ namespace dxvk { for (uint32_t i : bit::BitMask(mask & pixelShaderMask)) typeMask |= 0b11u << (i * 2u); - if ((m_samplerTypeBitfield & typeMask) != 0) { - m_flags.set(D3D9DeviceFlag::DirtyFFPixelShader); - m_samplerTypeBitfield &= ~typeMask; } @@ -6570,8 +6563,9 @@ namespace dxvk { void D3D9DeviceEx::UpdateFixedFunctionPS() { // Shader... - if (m_flags.test(D3D9DeviceFlag::DirtyFFPixelShader)) { + if (m_flags.test(D3D9DeviceFlag::DirtyFFPixelShader) || m_lastSamplerTypeBitfieldFF != m_samplerTypeBitfield) { m_flags.clr(D3D9DeviceFlag::DirtyFFPixelShader); + m_lastSamplerTypeBitfieldFF = m_samplerTypeBitfield; // Used args for a given operation. auto ArgsMask = [](DWORD Op) { diff --git a/src/d3d9/d3d9_device.h b/src/d3d9/d3d9_device.h index 5f4de42da..1d49f4af9 100644 --- a/src/d3d9/d3d9_device.h +++ b/src/d3d9/d3d9_device.h @@ -1211,6 +1211,7 @@ namespace dxvk { uint32_t m_lastPointMode = 0; uint32_t m_lastFetch4 = 0; uint32_t m_lastHazardsDS = 0; + uint32_t m_lastSamplerTypeBitfieldFF = 0; D3D9ShaderMasks m_vsShaderMasks = D3D9ShaderMasks(); D3D9ShaderMasks m_psShaderMasks = FixedFunctionMask;