From 1cc24c223b10c74f6d4d46f3b342e8dc02f2fe88 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 26 Jan 2019 17:12:23 +0100 Subject: [PATCH] [dxbc] Reduce length of tessellation i/o arrays to minimum This allows us to fix a violation of the Vulkan specification where using the same location range for per-vertex and per-patch i/o is illegal. May also help certain drivers figure out what's actually needed. --- src/dxbc/dxbc_compiler.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index f843e6e0..6417641c 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -6855,6 +6855,9 @@ namespace dxvk { void DxbcCompiler::emitHsOutputSetup() { uint32_t outputPerPatch = emitTessInterfacePerPatch(spv::StorageClassOutput); + if (!outputPerPatch) + return; + uint32_t vecType = getVectorTypeId({ DxbcScalarType::Float32, 4 }); uint32_t srcPtrType = m_module.defPointerType(vecType, spv::StorageClassPrivate); @@ -6881,8 +6884,13 @@ namespace dxvk { if (storageClass == spv::StorageClassOutput) name = "oPatch"; + uint32_t arrLen = m_psgn != nullptr ? m_psgn->maxRegisterCount() : 0; + + if (!arrLen) + return 0; + uint32_t vecType = m_module.defVectorType (m_module.defFloatType(32), 4); - uint32_t arrType = m_module.defArrayType (vecType, m_module.constu32(32)); + uint32_t arrType = m_module.defArrayType (vecType, m_module.constu32(arrLen)); uint32_t ptrType = m_module.defPointerType(arrType, storageClass); uint32_t varId = m_module.newVar (ptrType, storageClass); @@ -6902,14 +6910,25 @@ namespace dxvk { uint32_t DxbcCompiler::emitTessInterfacePerVertex(spv::StorageClass storageClass, uint32_t vertexCount) { const bool isInput = storageClass == spv::StorageClassInput; + uint32_t arrLen = isInput + ? (m_isgn != nullptr ? m_isgn->maxRegisterCount() : 0) + : (m_osgn != nullptr ? m_osgn->maxRegisterCount() : 0); + + if (!arrLen) + return 0; + + uint32_t locIdx = m_psgn != nullptr + ? m_psgn->maxRegisterCount() + : 0; + uint32_t vecType = m_module.defVectorType (m_module.defFloatType(32), 4); - uint32_t arrTypeInner = m_module.defArrayType (vecType, m_module.constu32(32)); + uint32_t arrTypeInner = m_module.defArrayType (vecType, m_module.constu32(arrLen)); uint32_t arrTypeOuter = m_module.defArrayType (arrTypeInner, m_module.constu32(vertexCount)); uint32_t ptrType = m_module.defPointerType(arrTypeOuter, storageClass); uint32_t varId = m_module.newVar (ptrType, storageClass); m_module.setDebugName (varId, isInput ? "vVertex" : "oVertex"); - m_module.decorateLocation (varId, 0); + m_module.decorateLocation (varId, locIdx); if (storageClass != spv::StorageClassPrivate) m_entryPointInterfaces.push_back(varId);