From 75c928fc878b7b3025c0d1b81e43ee5af8bb082b Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 16 Apr 2018 23:40:48 +0200 Subject: [PATCH] [dxbc] Remove is-bound check for constant buffer reads We do not have to do this anymore since we'll bind a large enough dummy buffer. Considerably reduces code size in shaders which access a large number of shader constants. --- src/dxbc/dxbc_compiler.cpp | 48 +------------------------------------- 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index dbb38d6b4..4575c4087 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -4668,53 +4668,7 @@ namespace dxvk { DxbcRegisterValue DxbcCompiler::emitRegisterLoadRaw( const DxbcRegister& reg) { - if (reg.type == DxbcOperandType::ConstantBuffer) { - // Constant buffer require special care if they are not bound - const uint32_t registerId = reg.idx[0].offset; - - const uint32_t labelMerge = m_module.allocateId(); - const uint32_t labelBound = m_module.allocateId(); - const uint32_t labelUnbound = m_module.allocateId(); - - m_module.opSelectionMerge(labelMerge, spv::SelectionControlMaskNone); - m_module.opBranchConditional( - m_constantBuffers.at(registerId).specId, - labelBound, labelUnbound); - - // Case 1: Constant buffer is bound. - // Load the register value normally. - m_module.opLabel(labelBound); - DxbcRegisterValue ifBound = emitValueLoad(emitGetOperandPtr(reg)); - m_module.opBranch(labelMerge); - - // Case 2: Constant buffer is not bound. - // Return zeroes unconditionally. - m_module.opLabel(labelUnbound); - DxbcRegisterValue ifUnbound = emitBuildConstVecf32( - 0.0f, 0.0f, 0.0f, 0.0f, - DxbcRegMask(true, true, true, true)); - m_module.opBranch(labelMerge); - - // Merge the results with a phi function - m_module.opLabel(labelMerge); - - const std::array phiLabels = {{ - { ifBound.id, labelBound }, - { ifUnbound.id, labelUnbound }, - }}; - - DxbcRegisterValue result; - result.type.ctype = DxbcScalarType::Float32; - result.type.ccount = 4; - result.id = m_module.opPhi( - getVectorTypeId(result.type), - phiLabels.size(), - phiLabels.data()); - return result; - } else { - // All other operand types can be accessed directly - return emitValueLoad(emitGetOperandPtr(reg)); - } + return emitValueLoad(emitGetOperandPtr(reg)); }