Explorar o código

Remove no-longer-needed stream-out and RTV tracking (#1053)

* Remove no-longer-needed stream-out and RTV tracking

* restore similar enum to match PIX to reduce confusion
Jeff Noyle %!s(int64=7) %!d(string=hai) anos
pai
achega
bd399a59f4

+ 6 - 108
lib/HLSL/DxilShaderAccessTracking.cpp

@@ -49,15 +49,18 @@ enum class ShaderAccessFlags : uint32_t
   Counter = 1 << 2
 };
 
+// This enum doesn't have to match PIX's version, because the values are received from PIX encoded in ASCII.
+// However, for ease of comparing this code with PIX, and to be less confusing to future maintainers, this
+// enum does indeed match the same-named enum in PIX.
 enum class RegisterType
 {
   CBV,
   SRV,
   UAV,
-  RTV,
-  DSV,
+  RTV, // not used. 
+  DSV, // not used. 
   Sampler,
-  SOV,
+  SOV, // not used.
   Invalid,
   Terminator
 };
@@ -133,7 +136,6 @@ private:
 
 private:
   bool m_CheckForDynamicIndexing = false;
-  std::vector<std::pair<RSRegisterIdentifier, ShaderAccessFlags>> m_limitedAccessOutputs;
   std::map<RegisterTypeAndSpace, SlotRange> m_slotAssignments;
   CallInst *m_HandleForUAV;
   std::set<RSRegisterIdentifier> m_DynamicallyIndexedBindPoints;
@@ -164,10 +166,7 @@ static RegisterType ParseRegisterType(std::deque<char> & q) {
   case 'C': return RegisterType::CBV;
   case 'S': return RegisterType::SRV;
   case 'U': return RegisterType::UAV;
-  case 'R': return RegisterType::RTV;
-  case 'D': return RegisterType::DSV;
   case 'M': return RegisterType::Sampler;
-  case 'O': return RegisterType::SOV;
   case 'I': return RegisterType::Invalid;
   default: return RegisterType::Terminator;
   }
@@ -179,10 +178,7 @@ static char EncodeRegisterType(RegisterType r) {
   case RegisterType::CBV:     return 'C';
   case RegisterType::SRV:     return 'S';
   case RegisterType::UAV:     return 'U';
-  case RegisterType::RTV:     return 'R';
-  case RegisterType::DSV:     return 'D';
   case RegisterType::Sampler: return 'M';
-  case RegisterType::SOV:     return 'O';
   case RegisterType::Invalid: return 'I';
   }
   return '.';
@@ -227,27 +223,6 @@ void DxilShaderAccessTracking::applyOptions(PassOptions O) {
 
       rt = ParseRegisterType(config);
     }
-
-    // Parse limited access outputs
-    rt = ParseRegisterType(config);
-    while (rt != RegisterType::Terminator) {
-
-      RSRegisterIdentifier rid;
-      rid.Type = rt;
-
-      rid.Space = DeserializeInt(config);
-      ValidateDelimiter(config, ':');
-
-      rid.Index = DeserializeInt(config);
-      ValidateDelimiter(config, ':');
-
-      unsigned AccessFlags = DeserializeInt(config);
-      ValidateDelimiter(config, ';');
-
-      m_limitedAccessOutputs.emplace_back(rid, static_cast<ShaderAccessFlags>(AccessFlags));
-
-      rt = ParseRegisterType(config);
-    }
   }
 }
 
@@ -523,83 +498,6 @@ bool DxilShaderAccessTracking::runOnModule(Module &M)
       }
     }
 
-    // StoreOutput for render-targets:
-    for (const auto & Overload : f16f32i16i32) {
-      Function * TheFunction = HlslOP->GetOpFunc(DXIL::OpCode::StoreOutput, Overload);
-      auto FunctionUses = TheFunction->uses();
-      for (auto FI = FunctionUses.begin(); FI != FunctionUses.end(); ) {
-        auto & FunctionUse = *FI++;
-        auto FunctionUser = FunctionUse.getUser();
-        auto instruction = cast<Instruction>(FunctionUser);
-
-        unsigned outputId = cast<ConstantInt>(instruction->getOperand(1))->getLimitedValue();
-
-        const DxilSignatureElement & sig = DM.GetOutputSignature().GetElement(outputId);
-
-        if (sig.GetSemantic()->GetKind() == DXIL::SemanticKind::Target){
-
-          auto slot = m_slotAssignments.find({ RegisterType::RTV, 0 });
-
-          if (slot != m_slotAssignments.end()) {
-            IRBuilder<> Builder(instruction);
-            EmitAccess(
-              Ctx, 
-              HlslOP, 
-              Builder, 
-              HlslOP->GetU32Const(slot->second.startSlot + sig.GetSemanticStartIndex()), 
-              ShaderAccessFlags::Write);
-            Modified = true;
-          }
-
-          for (auto const & limited : m_limitedAccessOutputs) {
-
-            auto slot = m_slotAssignments.find({ limited.first.Type, limited.first.Space });
-
-            if (slot != m_slotAssignments.end()) {
-              IRBuilder<> Builder(instruction);
-              EmitAccess(
-                Ctx,
-                HlslOP,
-                Builder,
-                HlslOP->GetU32Const(slot->second.startSlot),
-                ShaderAccessFlags::Write);
-              Modified = true;
-            }
-          }
-
-          // We do the limited access outputs (e.g. depth) on the first StoreOutput to the render target,
-          // a moment in the shader which is a good proxy for "this invocation hasn't been discarded".
-          m_limitedAccessOutputs.clear();
-        }
-      }
-    }
-
-    // EmitStream for stream out
-    {
-      Function * TheFunction = HlslOP->GetOpFunc(DXIL::OpCode::EmitStream, Type::getVoidTy(Ctx));
-      auto FunctionUses = TheFunction->uses();
-      for (auto FI = FunctionUses.begin(); FI != FunctionUses.end(); ) {
-        auto & FunctionUse = *FI++;
-        auto FunctionUser = FunctionUse.getUser();
-        auto instruction = cast<Instruction>(FunctionUser);
-
-        unsigned outputId = cast<ConstantInt>(instruction->getOperand(DXIL::OperandIndex::kStreamEmitCutIDOpIdx))->getLimitedValue();
-
-        auto slot = m_slotAssignments.find({ RegisterType::SOV, 0 /* register space */ });
-
-        if (slot != m_slotAssignments.end()) {
-          IRBuilder<> Builder(instruction);
-          EmitAccess(
-            Ctx, 
-            HlslOP, 
-            Builder, 
-            HlslOP->GetU32Const(slot->second.startSlot + outputId),
-            ShaderAccessFlags::Write);
-          Modified = true;
-        }
-      }
-    }
-
     if (OSOverride != nullptr) {
       formatted_raw_ostream FOS(*OSOverride);
       FOS << "DynamicallyIndexedBindPoints=";

+ 0 - 24
tools/clang/test/HLSL/pix/AccessTrackingRTV.hlsl

@@ -1,24 +0,0 @@
-// RUN: %dxc -EPSMain -Tps_6_0 %s | %opt -S -hlsl-dxil-pix-shader-access-instrumentation,config=R0:1:2i1;.. | %FileCheck %s
-
-
-// Check for udpate of UAV for each target (last column is byte offset into UAV, indexed by RT array index)
-// CHECK: call i32 @dx.op.atomicBinOp.i32(i32 78, %dx.types.Handle %PIX_CountUAV_Handle, i32 2, i32 4
-// CHECK: call i32 @dx.op.atomicBinOp.i32(i32 78, %dx.types.Handle %PIX_CountUAV_Handle, i32 2, i32 8
-// CHECK: call i32 @dx.op.atomicBinOp.i32(i32 78, %dx.types.Handle %PIX_CountUAV_Handle, i32 2, i32 12
-
-struct PSOut
-{
-  float4 rt0 : SV_Target;
-  uint4 rt1 : SV_Target1;
-  int4 rt2 : SV_Target2;
-
-};
-
-PSOut PSMain()
-{
-  PSOut o;
-  o.rt0 = float4(1, 2, 3, 4);
-  o.rt1 = uint4(5, 6, 7, 8);
-  o.rt2 = int4(9, 10, 11, 12);
-  return o;
-}

+ 0 - 43
tools/clang/test/HLSL/pix/AccessTrackingStreamOut.hlsl

@@ -1,43 +0,0 @@
-// RUN: %dxc -Emain -Tgs_6_0 %s | %opt -S -hlsl-dxil-pix-shader-access-instrumentation,config=O0:1:3i1;.. | %FileCheck %s
-
-// Check for udpate of UAV for each stream (last column is byte offset into UAV, indexed by stream #)
-// CHECK: call i32 @dx.op.atomicBinOp.i32(i32 78, %dx.types.Handle %PIX_CountUAV_Handle, i32 2, i32 4
-// CHECK: call i32 @dx.op.atomicBinOp.i32(i32 78, %dx.types.Handle %PIX_CountUAV_Handle, i32 2, i32 8
-// CHECK: call i32 @dx.op.atomicBinOp.i32(i32 78, %dx.types.Handle %PIX_CountUAV_Handle, i32 2, i32 12
-
-struct MyStruct
-{
-  float4 pos : SV_Position;
-  float2 a : AAA;
-};
-
-struct MyStruct2
-{
-  uint3 X : XXX;
-  float4 p[3] : PPP;
-  uint3 Y : YYY;
-};
-
-[maxvertexcount(12)]
-void main(point float4 array[1] : COORD, inout PointStream<MyStruct> OutputStream0,
-  inout PointStream<MyStruct2> OutputStream1,
-  inout PointStream<MyStruct> OutputStream2)
-{
-  float4 r = array[0];
-  MyStruct a = (MyStruct)0;
-  MyStruct2 b = (MyStruct2)0;
-  a.pos = array[r.x];
-  a.a = r.xy;
-  b.X = r.xyz;
-  b.Y = a.pos.xyz;
-  b.p[2] = a.pos * 44;
-
-  OutputStream0.Append(a);
-  OutputStream0.RestartStrip();
-
-  OutputStream1.Append(b);
-  OutputStream1.RestartStrip();
-
-  OutputStream2.Append(a);
-  OutputStream2.RestartStrip();
-}

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

@@ -460,8 +460,6 @@ public:
   TEST_METHOD(PixDebugPreexistingSVVertex)
   TEST_METHOD(PixDebugPreexistingSVInstance)
   TEST_METHOD(PixAccessTracking)
-  TEST_METHOD(PixAccessTrackingRTV)
-  TEST_METHOD(PixAccessTrackingStreamOut)
 
   TEST_METHOD(CodeGenAbs1)
   TEST_METHOD(CodeGenAbs2)
@@ -3060,14 +3058,6 @@ TEST_F(CompilerTest, PixAccessTracking) {
   CodeGenTestCheck(L"pix\\AccessTracking.hlsl");
 }
 
-TEST_F(CompilerTest, PixAccessTrackingRTV) {
-  CodeGenTestCheck(L"pix\\AccessTrackingRTV.hlsl");
-}
-
-TEST_F(CompilerTest, PixAccessTrackingStreamOut) {
-  CodeGenTestCheck(L"pix\\AccessTrackingStreamOut.hlsl");
-}
-
 TEST_F(CompilerTest, CodeGenAbs1) {
   CodeGenTestCheck(L"..\\CodeGenHLSL\\abs1.hlsl");
 }