From 804eca9cadb7e2f9f3b2988b303912fa829ab827 Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Wed, 17 Nov 2021 15:47:37 +0100 Subject: [PATCH] [d3d9] Respect shader defined constants for HWVP/PS buffer binding range --- src/d3d9/d3d9_device.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 57825d77..e6261368 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -4996,11 +4996,16 @@ namespace dxvk { constSet.dirty = false; - const uint32_t floatCount = ShaderStage == DxsoProgramType::VertexShader ? m_vsFloatConstsCount : m_psFloatConstsCount; + uint32_t floatCount = ShaderStage == DxsoProgramType::VertexShader ? m_vsFloatConstsCount : m_psFloatConstsCount; + if (constSet.meta.needsConstantCopies) { + auto shader = GetCommonShader(Shader); + floatCount = std::max(floatCount, shader->GetMaxDefinedConstant()); + } + floatCount = std::min(constSet.meta.maxConstIndexF, floatCount); const uint32_t intRange = caps::MaxOtherConstants * sizeof(Vector4i); const uint32_t intDataSize = constSet.meta.maxConstIndexI * sizeof(Vector4i); - uint32_t floatDataSize = std::min(constSet.meta.maxConstIndexF, floatCount) * sizeof(Vector4); + uint32_t floatDataSize = floatCount * sizeof(Vector4); const uint32_t alignment = std::max(m_robustUBOAlignment, 64u); // Make sure we do not recreate the buffer because the new one has to be a tiny bit larger const uint32_t bufferSize = align(std::max(floatDataSize + intRange, alignment), alignment); floatDataSize = bufferSize - intRange; // Read additional floats for padding so we don't end up with garbage data