From 35a2a0271421287b94b0a80d029b6d35eb6cc848 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 15 Apr 2019 03:11:39 +0200 Subject: [PATCH] [dxbc] Do not emit GS system values if rasterization is disabled Fixes issue in Star Citizen, which declares a max output vertex count of 128 in a geometry shader which emits eight components per vertex, which becomes 12 components in DXVK due to the gl_Position builtin. This should keep us below the magic limit of 1024 output components. --- src/dxbc/dxbc_compiler.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index c80cbed14..d4eb355fa 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -2196,7 +2196,8 @@ namespace dxvk { bool doCut = ins.op != DxbcOpcode::Emit && ins.op != DxbcOpcode::EmitStream; if (doEmit) { - emitOutputSetup(); + if (m_perVertexOut) + emitOutputSetup(); emitClipCullStore(DxbcSystemValue::ClipDistance, m_clipDistances); emitClipCullStore(DxbcSystemValue::CullDistance, m_cullDistances); emitXfbOutputSetup(streamId, false); @@ -6427,14 +6428,16 @@ namespace dxvk { // Declare the per-vertex output block. Outputs are not // declared as arrays, instead they will be flushed when // calling EmitVertex. - const uint32_t perVertexStruct = this->getPerVertexBlockId(); - const uint32_t perVertexPointer = m_module.defPointerType( - perVertexStruct, spv::StorageClassOutput); - - m_perVertexOut = m_module.newVar( - perVertexPointer, spv::StorageClassOutput); - m_entryPointInterfaces.push_back(m_perVertexOut); - m_module.setDebugName(m_perVertexOut, "gs_vertex_out"); + if (!m_moduleInfo.xfb || m_moduleInfo.xfb->rasterizedStream >= 0) { + const uint32_t perVertexStruct = this->getPerVertexBlockId(); + const uint32_t perVertexPointer = m_module.defPointerType( + perVertexStruct, spv::StorageClassOutput); + + m_perVertexOut = m_module.newVar( + perVertexPointer, spv::StorageClassOutput); + m_entryPointInterfaces.push_back(m_perVertexOut); + m_module.setDebugName(m_perVertexOut, "gs_vertex_out"); + } // Cull/clip distances as outputs m_clipDistances = emitDclClipCullDistanceArray(