Browse Source

Skip structured buffers when setting usage, since it's not gathered

Tex Riddell 7 years ago
parent
commit
406f9a94e0
1 changed files with 4 additions and 1 deletions
  1. 4 1
      lib/HLSL/DxilContainerReflection.cpp

+ 4 - 1
lib/HLSL/DxilContainerReflection.cpp

@@ -1478,7 +1478,10 @@ static void SetCBufVarUsage(CShaderReflectionConstantBuffer &cb,
 void DxilShaderReflection::SetCBufferUsage() {
   hlsl::OP *hlslOP = m_pDxilModule->GetOP();
   LLVMContext &Ctx = m_pDxilModule->GetCtx();
-  unsigned cbSize = m_CBs.size();
+
+  // Indexes >= cbuffer size from DxilModule are SRV or UAV structured buffers.
+  // We only collect usage for actual cbuffers, so don't go clearing usage on other buffers.
+  unsigned cbSize = std::min(m_CBs.size(), m_pDxilModule->GetCBuffers().size());
   std::vector< std::vector<unsigned> > cbufUsage(cbSize);
 
   Function *createHandle = hlslOP->GetOpFunc(DXIL::OpCode::CreateHandle, Type::getVoidTy(Ctx));