From bbb5aa36ce9b157ce6e7534525afa99716672cee Mon Sep 17 00:00:00 2001 From: WinterSnowfall Date: Wed, 5 Mar 2025 16:20:44 +0200 Subject: [PATCH] [d3d8] Enforce the pCaps->MaxVertexShaderConst limit on VS creation --- src/d3d9/d3d9_device.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index e090c2ea2..1d73d7190 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -3352,6 +3352,16 @@ namespace dxvk { &moduleInfo))) return D3DERR_INVALIDCALL; + + if (m_isD3D8Compatible && !m_isSWVP) { + const uint32_t maxVSConstantIndex = module.GetMaxDefinedConstant(); + // D3D8 enforces the value advertised in pCaps->MaxVertexShaderConst for HWVP + if (unlikely(maxVSConstantIndex > caps::MaxFloatConstantsVS - 1)) { + Logger::err(str::format("D3D9DeviceEx::CreateVertexShader: Invalid constant index ", maxVSConstantIndex)); + return D3DERR_INVALIDCALL; + } + } + *ppShader = ref(new D3D9VertexShader(this, &m_shaderAllocator, module,