Browse Source

Add res type map for RayTracingAccelerationStructure.

Xiang Li 7 years ago
parent
commit
b9ec4014d0
2 changed files with 10 additions and 3 deletions
  1. 3 2
      lib/HLSL/HLModule.cpp
  2. 7 1
      tools/clang/lib/CodeGen/CGHLSLMS.cpp

+ 3 - 2
lib/HLSL/HLModule.cpp

@@ -777,12 +777,13 @@ bool HLModule::IsHLSLObjectType(llvm::Type *Ty) {
     if (name.startswith("ConstantBuffer"))
       return true;
 
+    if (name == "RayTracingAccelerationStructure")
+      return true;
+
     name = name.ltrim("RasterizerOrdered");
     name = name.ltrim("RW");
     if (name == "ByteAddressBuffer")
       return true;
-    if (name == "RayTracingAccelerationStructure")
-      return true;
 
     if (name.startswith("Buffer"))
       return true;

+ 7 - 1
tools/clang/lib/CodeGen/CGHLSLMS.cpp

@@ -1129,7 +1129,13 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) {
         break;
       }
     }
-
+    if (intrinsicOpcode == (unsigned)IntrinsicOp::IOP_TraceRay) {
+      QualType recordTy = FD->getParamDecl(0)->getType();
+      llvm::Type *Ty = CGM.getTypes().ConvertType(recordTy);
+      MDNode *MD = GetOrAddResTypeMD(recordTy);
+      DXASSERT(MD, "else invalid resource type");
+      resMetadataMap[Ty] = MD;
+    }
     StringRef lower;
     if (hlsl::GetIntrinsicLowering(FD, lower))
       hlsl::SetHLLowerStrategy(F, lower);