浏览代码

Add tracerayinline to access tracking (#2751)

Co-authored-by: Jeff Noyle <[email protected]>
Jeff Noyle 5 年之前
父节点
当前提交
abfbc8af69
共有 2 个文件被更改,包括 31 次插入2 次删除
  1. 14 2
      lib/DxilPIXPasses/DxilShaderAccessTracking.cpp
  2. 17 0
      tools/clang/test/HLSLFileCheck/pix/TraceRayInline.hlsl

+ 14 - 2
lib/DxilPIXPasses/DxilShaderAccessTracking.cpp

@@ -553,10 +553,22 @@ bool DxilShaderAccessTracking::runOnModule(Module &M) {
           readWrite = ShaderAccessFlags::Counter;
           break;
         case DXIL::OpCode::TraceRay:
-        case DXIL::OpCode::RayQuery_TraceRayInline:
           // Read of AccelerationStructure; doesn't match function attribute
           // readWrite = ShaderAccessFlags::Read;  // TODO: Support
-          // TraceRay[Inline]
+          continue;
+        case DXIL::OpCode::RayQuery_TraceRayInline: {
+          // Read of AccelerationStructure; doesn't match function attribute
+          auto res = GetResourceFromHandle(Call->getArgOperand(2), DM);
+          if (EmitResourceAccess(
+            res, 
+            Call, 
+            HlslOP, 
+            Ctx,
+            ShaderAccessFlags::Read)) 
+          {
+            Modified = true;
+          }
+        }
           continue;
         default:
           break;

+ 17 - 0
tools/clang/test/HLSLFileCheck/pix/TraceRayInline.hlsl

@@ -0,0 +1,17 @@
+// RUN: %dxc -T vs_6_5 -E main %s | %opt -S -hlsl-dxil-pix-shader-access-instrumentation,config=S0:1:1i1;U0:2:10i0;.. | FileCheck %s
+
+// CHECK: call void @dx.op.rayQuery_TraceRayInline
+// CHECK: call void @dx.op.bufferStore.i32(i32 69, %dx.types.Handle
+
+RaytracingAccelerationStructure RTAS;
+
+void DoTrace(RayQuery<RAY_FLAG_FORCE_OPAQUE|RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES> rayQuery, RayDesc rayDesc) {
+  rayQuery.TraceRayInline(RTAS, 0, 1, rayDesc);
+}
+
+float main(RayDesc rayDesc : RAYDESC) : OUT {
+  RayQuery<RAY_FLAG_FORCE_OPAQUE|RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES> rayQuery;
+  DoTrace(rayQuery, rayDesc);
+  rayQuery.TraceRayInline(RTAS, 1, 2, rayDesc);
+  return 0;
+}