Browse Source

Merge remote-tracking branch 'rt/mesh-master' into merge-dxil-1-5

Tex Riddell 6 years ago
parent
commit
6b4c3b4710

+ 14 - 2
lib/HLSL/ComputeViewIdStateBuilder.cpp

@@ -342,7 +342,13 @@ void DxilViewIdStateBuilder::AnalyzeFunctions(EntryInfo &Entry) {
           GetUnsignedVal(SO.get_rowIndex(), (uint32_t*)&row);
           IFTBOOL(GetUnsignedVal(SO.get_colIndex(), &col), DXC_E_GENERAL_INTERNAL_ERROR);
           Entry.Outputs.emplace(CI);
-        } else if (DxilInst_StorePOutput SPO = DxilInst_StorePOutput(CI)) {
+        } else if (DxilInst_StoreVertexOutput SVO = DxilInst_StoreVertexOutput(CI)) {
+          pDynIdxElems = &m_OutSigDynIdxElems;
+          IFTBOOL(GetUnsignedVal(SVO.get_outputSigId(), &id), DXC_E_GENERAL_INTERNAL_ERROR);
+          GetUnsignedVal(SVO.get_rowIndex(), (uint32_t*)&row);
+          IFTBOOL(GetUnsignedVal(SVO.get_colIndex(), &col), DXC_E_GENERAL_INTERNAL_ERROR);
+          Entry.Outputs.emplace(CI);
+        } else if (DxilInst_StorePrimitiveOutput SPO = DxilInst_StorePrimitiveOutput(CI)) {
           pDynIdxElems = &m_PCSigDynIdxElems;
           IFTBOOL(GetUnsignedVal(SPO.get_outputSigId(), &id), DXC_E_GENERAL_INTERNAL_ERROR);
           GetUnsignedVal(SPO.get_rowIndex(), (uint32_t*)&row);
@@ -420,7 +426,13 @@ void DxilViewIdStateBuilder::CollectValuesContributingToOutputs(EntryInfo &Entry
       GetUnsignedVal(SO.get_outputSigId(), &id);
       GetUnsignedVal(SO.get_colIndex(), &col);
       GetUnsignedVal(SO.get_rowIndex(), (uint32_t*)&startRow);
-    } else if (DxilInst_StorePOutput SPO = DxilInst_StorePOutput(CI)) {
+    } else if (DxilInst_StoreVertexOutput SVO = DxilInst_StoreVertexOutput(CI)) {
+      pDxilSig = &m_pModule->GetPatchConstOrPrimSignature();
+      pContributingValue = SVO.get_value();
+      GetUnsignedVal(SVO.get_outputSigId(), &id);
+      GetUnsignedVal(SVO.get_colIndex(), &col);
+      GetUnsignedVal(SVO.get_rowIndex(), (uint32_t*)&startRow);
+    } else if (DxilInst_StorePrimitiveOutput SPO = DxilInst_StorePrimitiveOutput(CI)) {
       pDxilSig = &m_pModule->GetPatchConstOrPrimSignature();
       pContributingValue = SPO.get_value();
       GetUnsignedVal(SPO.get_outputSigId(), &id);

+ 1 - 1
lib/HLSL/DxilPreserveAllOutputs.cpp

@@ -44,7 +44,7 @@ public:
 
   DxilSignatureElement &GetSignatureElement(DxilModule &DM) const {
     if (DxilInst_StorePatchConstant(m_Call) || DxilInst_StorePrimitiveOutput(m_Call))
-      return DM.GetPatchConstantSignature().GetElement(GetSignatureID());
+      return DM.GetPatchConstOrPrimSignature().GetElement(GetSignatureID());
     else
       return DM.GetOutputSignature().GetElement(GetSignatureID());
   }

+ 1 - 1
tools/clang/lib/SPIRV/DeclResultIdMapper.cpp

@@ -2254,7 +2254,7 @@ bool DeclResultIdMapper::createPayloadStageVars(
                       getLocationCount(astContext, type));
     const auto name = namePrefix.str() + "." + decl->getNameAsString();
     SpirvVariable *varInstr =
-        spvBuilder.addStageIOVar(type, sc, name, /*isPrecise=*/false);
+        spvBuilder.addStageIOVar(type, sc, name, /*isPrecise=*/false, loc);
 
     if (!varInstr)
       return false;

+ 6 - 4
tools/clang/lib/SPIRV/GlPerVertex.cpp

@@ -567,8 +567,9 @@ void GlPerVertex::writeClipCullArrayFromType(
                                                    llvm::APInt(32, i));
         auto *ptr = spvBuilder.createAccessChain(
             f32Type, clipCullVar,
-            {spvBuilder.createBinaryOp(
-                spv::Op::OpIAdd, astContext.UnsignedIntTy, offset, constant)},
+            {spvBuilder.createBinaryOp(spv::Op::OpIAdd,
+                                       astContext.UnsignedIntTy, offset,
+                                       constant, loc)},
             loc);
         auto *subValue =
             spvBuilder.createCompositeExtract(f32Type, fromValue, {i}, loc);
@@ -616,7 +617,8 @@ void GlPerVertex::writeClipCullArrayFromType(
            spvBuilder.createBinaryOp(
                spv::Op::OpIAdd, astContext.UnsignedIntTy, offset,
                spvBuilder.getConstantInt(astContext.UnsignedIntTy,
-                                         llvm::APInt(32, i)))},
+                                         llvm::APInt(32, i)),
+               loc)},
           loc);
 
       auto *subValue =
@@ -690,7 +692,7 @@ bool GlPerVertex::writeField(hlsl::Semantic::Kind semanticKind,
     }
     type = elemType;
     offset = spvBuilder.createBinaryOp(
-        spv::Op::OpIAdd, astContext.UnsignedIntTy, vecComponent, offset);
+        spv::Op::OpIAdd, astContext.UnsignedIntTy, vecComponent, offset, loc);
   }
   writeClipCullArrayFromType(invocationId, isClip, offset, type, *value, loc);
   return true;

+ 12 - 8
tools/clang/lib/SPIRV/SpirvEmitter.cpp

@@ -6141,7 +6141,7 @@ void SpirvEmitter::assignToMSOutIndices(
     assert(numValues == 1);
     // create accesschain for PrimitiveIndicesNV[vertIndex].
     auto *ptr = spvBuilder.createAccessChain(astContext.UnsignedIntTy, var,
-                                             vertIndex, loc);
+                                             {vertIndex}, loc);
     // finally create store for PrimitiveIndicesNV[vertIndex] = value.
     spvBuilder.createStore(ptr, value, loc);
   } else {
@@ -6151,16 +6151,18 @@ void SpirvEmitter::assignToMSOutIndices(
     auto *baseOffset = spvBuilder.createBinaryOp(
         spv::Op::OpIMul, astContext.UnsignedIntTy, vertIndex,
         spvBuilder.getConstantInt(astContext.UnsignedIntTy,
-                                  llvm::APInt(32, numVertices)));
+                                  llvm::APInt(32, numVertices)),
+        loc);
     if (vecComponent) {
       // write an individual vector component of uint2 or uint3.
       assert(numValues == 1);
       // set baseOffset = baseOffset + vecComponent.
-      baseOffset = spvBuilder.createBinaryOp(
-          spv::Op::OpIAdd, astContext.UnsignedIntTy, baseOffset, vecComponent);
+      baseOffset =
+          spvBuilder.createBinaryOp(spv::Op::OpIAdd, astContext.UnsignedIntTy,
+                                    baseOffset, vecComponent, loc);
       // create accesschain for PrimitiveIndicesNV[baseOffset].
       auto *ptr = spvBuilder.createAccessChain(astContext.UnsignedIntTy, var,
-                                               baseOffset, loc);
+                                               {baseOffset}, loc);
       // finally create store for PrimitiveIndicesNV[baseOffset] = value.
       spvBuilder.createStore(ptr, value, loc);
     } else {
@@ -6173,11 +6175,12 @@ void SpirvEmitter::assignToMSOutIndices(
           curOffset = spvBuilder.createBinaryOp(
               spv::Op::OpIAdd, astContext.UnsignedIntTy, baseOffset,
               spvBuilder.getConstantInt(astContext.UnsignedIntTy,
-                                        llvm::APInt(32, i)));
+                                        llvm::APInt(32, i)),
+              loc);
         }
         // create accesschain for PrimitiveIndicesNV[curOffset].
         auto *ptr = spvBuilder.createAccessChain(astContext.UnsignedIntTy, var,
-                                                 curOffset, loc);
+                                                 {curOffset}, loc);
         // finally create store for PrimitiveIndicesNV[curOffset] = value[i].
         spvBuilder.createStore(ptr,
                                spvBuilder.createCompositeExtract(
@@ -9615,7 +9618,8 @@ void SpirvEmitter::processDispatchMesh(const CallExpr *callExpr) {
   auto *taskCount = spvBuilder.createBinaryOp(
       spv::Op::OpIMul, astContext.UnsignedIntTy, threadX,
       spvBuilder.createBinaryOp(spv::Op::OpIMul, astContext.UnsignedIntTy,
-                                threadY, threadZ));
+                                threadY, threadZ, loc),
+      loc);
   spvBuilder.createStore(var, taskCount, loc);
 
   // 3) create PerTaskNV out attribute block and store MeshPayload info.