瀏覽代碼

Disable eliminate output dynamic indexing for HS. (#1655)

* Disable eliminate output dynamic indexing for HS.

* Fix build warning and remove test.
Xiang Li 6 年之前
父節點
當前提交
238e6a4f41

+ 4 - 6
lib/HLSL/DxilEliminateOutputDynamicIndexing.cpp

@@ -34,17 +34,15 @@ public:
   explicit DxilEliminateOutputDynamicIndexing() : ModulePass(ID) {}
 
   const char *getPassName() const override {
-    return "DXIL eliminate ouptut dynamic indexing";
+    return "DXIL eliminate output dynamic indexing";
   }
 
   bool runOnModule(Module &M) override {
     DxilModule &DM = M.GetOrCreateDxilModule();
     bool bUpdated = false;
     if (DM.GetShaderModel()->IsHS()) {
-      hlsl::OP *hlslOP = DM.GetOP();
-      bUpdated = EliminateDynamicOutput(
-          hlslOP, DXIL::OpCode::StorePatchConstant,
-          DM.GetPatchConstantSignature(), DM.GetPatchConstantFunction());
+      // HS write outputs into share memory, dynamic indexing is OK.
+      return bUpdated;
     }
 
     // Skip pass thru entry.
@@ -208,4 +206,4 @@ ModulePass *llvm::createDxilEliminateOutputDynamicIndexingPass() {
 
 INITIALIZE_PASS(DxilEliminateOutputDynamicIndexing,
                 "hlsl-dxil-eliminate-output-dynamic",
-                "DXIL eliminate ouptut dynamic indexing", false, false)
+                "DXIL eliminate output dynamic indexing", false, false)

+ 9 - 8
lib/HLSL/HLOperationLower.cpp

@@ -4576,14 +4576,15 @@ Value *TranslateDot2Add(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
                         bool &Translated) {
   hlsl::OP *hlslOP = &helper.hlslOP;
   Value *src0 = CI->getArgOperand(HLOperandIndex::kTrinaryOpSrc0Idx);
-  Type *srcTy = src0->getType();
   const unsigned vecSize = 2;
-  DXASSERT(srcTy->isVectorTy() && vecSize == srcTy->getVectorNumElements() &&
-           srcTy->getScalarType()->isHalfTy(),
+  DXASSERT(src0->getType()->isVectorTy() &&
+               vecSize == src0->getType()->getVectorNumElements() &&
+               src0->getType()->getScalarType()->isHalfTy(),
            "otherwise, unexpected input dimension or component type");
 
   Value *src1 = CI->getArgOperand(HLOperandIndex::kTrinaryOpSrc1Idx);
-  DXASSERT(srcTy == src1->getType(), "otherwise, mismatched argument types");
+  DXASSERT(src0->getType() == src1->getType(),
+           "otherwise, mismatched argument types");
   Value *accArg = CI->getArgOperand(HLOperandIndex::kTrinaryOpSrc2Idx);
   Type *accTy = accArg->getType();
   DXASSERT(!accTy->isVectorTy() && accTy->isFloatTy(),
@@ -4609,11 +4610,11 @@ Value *TranslateDot4AddPacked(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
                               bool &Translated) {
   hlsl::OP *hlslOP = &helper.hlslOP;
   Value *src0 = CI->getArgOperand(HLOperandIndex::kTrinaryOpSrc0Idx);
-  Type *srcTy = src0->getType();
-  DXASSERT(!srcTy->isVectorTy() && srcTy->isIntegerTy(32),
-    "otherwise, unexpected vector support in high level intrinsic tempalte");
+  DXASSERT(
+      !src0->getType()->isVectorTy() && src0->getType()->isIntegerTy(32),
+      "otherwise, unexpected vector support in high level intrinsic tempalte");
   Value *src1 = CI->getArgOperand(HLOperandIndex::kTrinaryOpSrc1Idx);
-  DXASSERT(srcTy == src1->getType(), "otherwise, mismatched argument types");
+  DXASSERT(src0->getType() == src1->getType(), "otherwise, mismatched argument types");
   Value *accArg = CI->getArgOperand(HLOperandIndex::kTrinaryOpSrc2Idx);
   Type *accTy = accArg->getType();
   DXASSERT(!accTy->isVectorTy() && accTy->isIntegerTy(32),

+ 0 - 92
tools/clang/test/HLSL/eliminate_dynamic_output5.hlsl

@@ -1,92 +0,0 @@
-// RUN: %dxc -E main -T hs_6_0  %s | %opt -S -hlsl-dxil-eliminate-output-dynamic | %FileCheck %s
-
-// CHECK-NOT: storePatchConstant.f32(i32 106, i32 2, i32 %i
-
-
-// CHECK: storePatchConstant.f32(i32 106, i32 2, i32 0, i8 0
-// CHECK: storePatchConstant.f32(i32 106, i32 2, i32 1, i8 0
-// CHECK: storePatchConstant.f32(i32 106, i32 2, i32 2, i8 0
-// CHECK: storePatchConstant.f32(i32 106, i32 2, i32 3, i8 0
-// CHECK: storePatchConstant.f32(i32 106, i32 2, i32 4, i8 0
-// CHECK: storePatchConstant.f32(i32 106, i32 2, i32 5, i8 0
-// CHECK: storePatchConstant.f32(i32 106, i32 2, i32 6, i8 0
-// CHECK: storePatchConstant.f32(i32 106, i32 2, i32 7, i8 0
-
-
-//--------------------------------------------------------------------------------------
-// SimpleTessellation.hlsl
-//
-// Advanced Technology Group (ATG)
-// Copyright (C) Microsoft Corporation. All rights reserved.
-//--------------------------------------------------------------------------------------
-
-struct PSSceneIn
-{
-    float4 pos  : SV_Position;
-    float2 tex  : TEXCOORD0;
-    float3 norm : NORMAL;
-
-uint   RTIndex      : SV_RenderTargetArrayIndex;
-};
-
-
-//////////////////////////////////////////////////////////////////////////////////////////
-// Simple forwarding Tessellation shaders
-
-struct HSPerVertexData
-{
-    // This is just the original vertex verbatim. In many real life cases this would be a
-    // control point instead
-    PSSceneIn v;
-};
-
-struct HSPerPatchData
-{
-    // We at least have to specify tess factors per patch
-    // As we're tesselating triangles, there will be 4 tess factors
-    // In real life case this might contain face normal, for example
-	float	edges[ 3 ]	: SV_TessFactor;
-	float	inside		: SV_InsideTessFactor;
-        float   custom[8]       : CCC;
-};
-
-float4 HSPerPatchFunc()
-{
-    return 1.8;
-}
-
-int  count;
-float4 c[16];
-
-HSPerPatchData HSPerPatchFunc( const InputPatch< PSSceneIn, 3 > points )
-{
-    HSPerPatchData d;
-
-    d.edges[ 0 ] = 1;
-    d.edges[ 1 ] = 1;
-    d.edges[ 2 ] = 1;
-    d.inside = 1;
-    for (uint i=0;i<count;i++) {
-        d.custom[i] = c[i].x;
-    }    
-    return d;
-}
-
-// hull per-control point shader
-[domain("tri")]
-[partitioning("fractional_odd")]
-[outputtopology("triangle_cw")]
-[patchconstantfunc("HSPerPatchFunc")]
-[outputcontrolpoints(3)]
-HSPerVertexData main( const uint id : SV_OutputControlPointID,
-                               const InputPatch< PSSceneIn, 3 > points )
-{
-    HSPerVertexData v;
-
-    // Just forward the vertex
-    v.v = points[ id ];
-
-	return v;
-}
-
-

+ 0 - 5
tools/clang/unittests/HLSL/CompilerTest.cpp

@@ -356,7 +356,6 @@ public:
   TEST_METHOD(CodeGenEliminateDynamicIndexing2)
   TEST_METHOD(CodeGenEliminateDynamicIndexing3)
   TEST_METHOD(CodeGenEliminateDynamicIndexing4)
-  TEST_METHOD(CodeGenEliminateDynamicIndexing5)
   TEST_METHOD(CodeGenEliminateDynamicIndexing6)
   TEST_METHOD(CodeGenEmpty)
   TEST_METHOD(CodeGenEmptyStruct)
@@ -3344,10 +3343,6 @@ TEST_F(CompilerTest, CodeGenEliminateDynamicIndexing4) {
   CodeGenTestCheck(L"eliminate_dynamic_output4.hlsl");
 }
 
-TEST_F(CompilerTest, CodeGenEliminateDynamicIndexing5) {
-  CodeGenTestCheck(L"eliminate_dynamic_output5.hlsl");
-}
-
 TEST_F(CompilerTest, CodeGenEliminateDynamicIndexing6) {
   CodeGenTestCheck(L"eliminate_dynamic_output6.hlsl");
 }