ソースを参照

Add AcceptHitAndEndSearch, CallShader, CommitHitAndStopRay and change ReportIntersection into ReportHit.
Also change RayTracingAccelerationStructure into RaytracingAccelerationStructure.

Xiang Li 7 年 前
コミット
c45aa784ac

+ 20 - 19
docs/DXIL.rst

@@ -2137,25 +2137,26 @@ ID  Name                                         Description
 138 ViewID                                       returns the view index
 139 RawBufferLoad                                reads from a raw buffer and structured buffer
 140 RawBufferStore                               writes to a RWByteAddressBuffer or RWStructuredBuffer
-141 InstanceIndex                                The autogenerated index of the current instance in the top-level structure
-142 HitKind                                      Returns the value passed as HitKind in ReportIntersection().  If intersection was reported by fixed-function triangle intersection, HitKind will be one of HIT_KIND_TRIANGLE_FRONT_FACE or HIT_KIND_TRIANGLE_BACK_FACE.
-143 RayFlag                                      uint containing the current ray flags.
-144 RayDispatchIndex                             The current x and y location within the Width and Height
-145 RayDispatchDimension                         The Width and Height values from the D3D12_DISPATCH_RAYS_DESC structure provided to the originating DispatchRays() call.
-146 WorldRayOrigin                               The world-space origin for the current ray.
-147 WorldRayDirection                            The world-space direction for the current ray.
-148 ObjectRayOrigin                              Object-space origin for the current ray.
-149 ObjectRayDirection                           Object-space direction for the current ray.
-150 ObjectToWorld                                Matrix for transforming from object-space to world-space.
-151 WorldToObject                                Matrix for transforming from world-space to object-space.
-152 RayTMin                                      float representing the parametric starting point for the ray.
-153 CurrentRayT                                  float representing the current parametric ending point for the ray
-154 IgnoreIntersection                           returns the view index
-155 TerminateRay                                 returns the view index
-156 TraceRay                                     returns the view index
-157 ReportIntersection                           returns true if hit was accepted
-158 CallShader                                   returns the view index
-159 ReservedForLibCreateHandleFromResourceStruct returns the view index
+141 InstanceID                                   The user-provided InstanceID on the bottom-level acceleration structure instance within the top-level structure
+142 InstanceIndex                                The autogenerated index of the current instance in the top-level structure
+143 HitKind                                      Returns the value passed as HitKind in ReportIntersection().  If intersection was reported by fixed-function triangle intersection, HitKind will be one of HIT_KIND_TRIANGLE_FRONT_FACE or HIT_KIND_TRIANGLE_BACK_FACE.
+144 RayFlag                                      uint containing the current ray flags.
+145 RayDispatchIndex                             The current x and y location within the Width and Height
+146 RayDispatchDimension                         The Width and Height values from the D3D12_DISPATCH_RAYS_DESC structure provided to the originating DispatchRays() call.
+147 WorldRayOrigin                               The world-space origin for the current ray.
+148 WorldRayDirection                            The world-space direction for the current ray.
+149 ObjectRayOrigin                              Object-space origin for the current ray.
+150 ObjectRayDirection                           Object-space direction for the current ray.
+151 ObjectToWorld                                Matrix for transforming from object-space to world-space.
+152 WorldToObject                                Matrix for transforming from world-space to object-space.
+153 RayTMin                                      float representing the parametric starting point for the ray.
+154 CurrentRayT                                  float representing the current parametric ending point for the ray
+155 AcceptHitAndEndSearch                        Used in an any hit shader to reject an intersection and terminate the shader
+156 CommitHitAndStopRay                          Used in an any hit shader to abort the ray query and the intersection shader (if any). The current hit is committed and execution passes to the closest hit shader with the closest hit recorded so far
+157 TraceRay                                     returns the view index
+158 ReportHit                                    returns true if hit was accepted
+159 CallShader                                   Call a shader in the callable shader table supplied through the DispatchRays() API
+160 ReservedForLibCreateHandleFromResourceStruct returns the view index
 === ============================================ =======================================================================================================================================================================================================================
 
 

+ 68 - 40
include/dxc/HLSL/DxilConstants.h

@@ -287,6 +287,10 @@ namespace DXIL {
   // OPCODE-ENUM:BEGIN
   // Enumeration for operations specified by DXIL
   enum class OpCode : unsigned {
+    // AnyHit Terminals
+    AcceptHitAndEndSearch = 155, // Used in an any hit shader to reject an intersection and terminate the shader
+    CommitHitAndStopRay = 156, // Used in an any hit shader to abort the ray query and the intersection shader (if any). The current hit is committed and execution passes to the closest hit shader with the closest hit recorded so far
+  
     // Binary float
     FMax = 35, // returns a if a >= b, else b
     FMin = 36, // returns a if a < b, else b
@@ -357,10 +361,18 @@ namespace DXIL {
     PrimitiveID = 108, // PrimitiveID
     StorePatchConstant = 106, // StorePatchConstant
   
+    // Indirect Shader Invocation
+    CallShader = 159, // Call a shader in the callable shader table supplied through the DispatchRays() API
+    ReportHit = 158, // returns true if hit was accepted
+    TraceRay = 157, // returns the view index
+  
     // Legacy floating-point
     LegacyF16ToF32 = 131, // legacy fuction to convert half (f16) to float (f32) (this is not related to min-precision)
     LegacyF32ToF16 = 130, // legacy fuction to convert float (f32) to half (f16) (this is not related to min-precision)
   
+    // Library create handle from resource struct (like HL intrinsic)
+    ReservedForLibCreateHandleFromResourceStruct = 160, // returns the view index
+  
     // Other
     CycleCounterLegacy = 109, // CycleCounterLegacy
   
@@ -382,26 +394,29 @@ namespace DXIL {
     // Quaternary
     Bfi = 53, // Given a bit range from the LSB of a number, places that number of bits in another number at any offset
   
-    // Ray Tracing
-    CallShader = 158, // returns the view index
-    CurrentRayT = 153, // float representing the current parametric ending point for the ray
-    HitKind = 142, // Returns the value passed as HitKind in ReportIntersection().  If intersection was reported by fixed-function triangle intersection, HitKind will be one of HIT_KIND_TRIANGLE_FRONT_FACE or HIT_KIND_TRIANGLE_BACK_FACE.
-    IgnoreIntersection = 154, // returns the view index
-    InstanceIndex = 141, // The autogenerated index of the current instance in the top-level structure
-    ObjectRayDirection = 149, // Object-space direction for the current ray.
-    ObjectRayOrigin = 148, // Object-space origin for the current ray.
-    ObjectToWorld = 150, // Matrix for transforming from object-space to world-space.
-    RayDispatchDimension = 145, // The Width and Height values from the D3D12_DISPATCH_RAYS_DESC structure provided to the originating DispatchRays() call.
-    RayDispatchIndex = 144, // The current x and y location within the Width and Height
-    RayFlag = 143, // uint containing the current ray flags.
-    RayTMin = 152, // float representing the parametric starting point for the ray.
-    ReportIntersection = 157, // returns true if hit was accepted
-    ReservedForLibCreateHandleFromResourceStruct = 159, // returns the view index
-    TerminateRay = 155, // returns the view index
-    TraceRay = 156, // returns the view index
-    WorldRayDirection = 147, // The world-space direction for the current ray.
-    WorldRayOrigin = 146, // The world-space origin for the current ray.
-    WorldToObject = 151, // Matrix for transforming from world-space to object-space.
+    // Ray Dispatch Arguments
+    RayDispatchDimension = 146, // The Width and Height values from the D3D12_DISPATCH_RAYS_DESC structure provided to the originating DispatchRays() call.
+    RayDispatchIndex = 145, // The current x and y location within the Width and Height
+  
+    // Ray Transforms
+    ObjectToWorld = 151, // Matrix for transforming from object-space to world-space.
+    WorldToObject = 152, // Matrix for transforming from world-space to object-space.
+  
+    // Ray Vectors
+    ObjectRayDirection = 150, // Object-space direction for the current ray.
+    ObjectRayOrigin = 149, // Object-space origin for the current ray.
+    WorldRayDirection = 148, // The world-space direction for the current ray.
+    WorldRayOrigin = 147, // The world-space origin for the current ray.
+  
+    // RayT
+    CurrentRayT = 154, // float representing the current parametric ending point for the ray
+    RayTMin = 153, // float representing the parametric starting point for the ray.
+  
+    // Raytracing uint System Values
+    HitKind = 143, // Returns the value passed as HitKind in ReportIntersection().  If intersection was reported by fixed-function triangle intersection, HitKind will be one of HIT_KIND_TRIANGLE_FRONT_FACE or HIT_KIND_TRIANGLE_BACK_FACE.
+    InstanceID = 141, // The user-provided InstanceID on the bottom-level acceleration structure instance within the top-level structure
+    InstanceIndex = 142, // The autogenerated index of the current instance in the top-level structure
+    RayFlag = 144, // uint containing the current ray flags.
   
     // Resources - gather
     TextureGather = 73, // gathers the four texels that would be used in a bi-linear filtering operation
@@ -516,9 +531,8 @@ namespace DXIL {
     NumOpCodes_Dxil_1_0 = 137,
     NumOpCodes_Dxil_1_1 = 139,
     NumOpCodes_Dxil_1_2 = 141,
-    NumOpCodes_Dxil_1_3 = 160,
   
-    NumOpCodes = 160 // exclusive last value of enumeration
+    NumOpCodes = 161 // exclusive last value of enumeration
   };
   // OPCODE-ENUM:END
 
@@ -526,6 +540,10 @@ namespace DXIL {
   // OPCODECLASS-ENUM:BEGIN
   // Groups for DXIL operations with equivalent function templates
   enum class OpCodeClass : unsigned {
+    // AnyHit Terminals
+    AcceptHitAndEndSearch,
+    CommitHitAndStopRay,
+  
     // Binary uint with carry or borrow
     BinaryWithCarryOrBorrow,
   
@@ -582,6 +600,11 @@ namespace DXIL {
     PrimitiveID,
     StorePatchConstant,
   
+    // Indirect Shader Invocation
+    CallShader,
+    ReportHit,
+    TraceRay,
+  
     // LLVM Instructions
     LlvmInst,
   
@@ -589,6 +612,9 @@ namespace DXIL {
     LegacyF16ToF32,
     LegacyF32ToF16,
   
+    // Library create handle from resource struct (like HL intrinsic)
+    ReservedForLibCreateHandleFromResourceStruct,
+  
     // Other
     CycleCounterLegacy,
   
@@ -607,26 +633,29 @@ namespace DXIL {
     // Quaternary
     Quaternary,
   
-    // Ray Tracing
-    CallShader,
-    CurrentRayT,
-    HitKind,
-    IgnoreIntersection,
-    InstanceIndex,
-    ObjectRayDirection,
-    ObjectRayOrigin,
-    ObjectToWorld,
+    // Ray Dispatch Arguments
     RayDispatchDimension,
     RayDispatchIndex,
-    RayFlag,
-    RayTMin,
-    ReportIntersection,
-    ReservedForLibCreateHandleFromResourceStruct,
-    TerminateRay,
-    TraceRay,
+  
+    // Ray Transforms
+    ObjectToWorld,
+    WorldToObject,
+  
+    // Ray Vectors
+    ObjectRayDirection,
+    ObjectRayOrigin,
     WorldRayDirection,
     WorldRayOrigin,
-    WorldToObject,
+  
+    // RayT
+    CurrentRayT,
+    RayTMin,
+  
+    // Raytracing uint System Values
+    HitKind,
+    InstanceID,
+    InstanceIndex,
+    RayFlag,
   
     // Resources - gather
     TextureGather,
@@ -699,9 +728,8 @@ namespace DXIL {
     NumOpClasses_Dxil_1_0 = 93,
     NumOpClasses_Dxil_1_1 = 95,
     NumOpClasses_Dxil_1_2 = 97,
-    NumOpClasses_Dxil_1_3 = 116,
   
-    NumOpClasses = 116 // exclusive last value of enumeration
+    NumOpClasses = 117 // exclusive last value of enumeration
   };
   // OPCODECLASS-ENUM:END
 

+ 28 - 12
include/dxc/HLSL/DxilInstructions.h

@@ -4541,6 +4541,22 @@ struct DxilInst_RawBufferStore {
   void set_alignment_val(int32_t val) { Instr->setOperand(9, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 32), llvm::APInt(32, (uint64_t)val))); }
 };
 
+/// This instruction The user-provided InstanceID on the bottom-level acceleration structure instance within the top-level structure
+struct DxilInst_InstanceID {
+  llvm::Instruction *Instr;
+  // Construction and identification
+  DxilInst_InstanceID(llvm::Instruction *pInstr) : Instr(pInstr) {}
+  operator bool() const {
+    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::InstanceID);
+  }
+  // Validation support
+  bool isAllowed() const { return true; }
+  bool isArgumentListValid() const {
+    if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
+    return true;
+  }
+};
+
 /// This instruction The autogenerated index of the current instance in the top-level structure
 struct DxilInst_InstanceIndex {
   llvm::Instruction *Instr;
@@ -4811,13 +4827,13 @@ struct DxilInst_CurrentRayT {
   }
 };
 
-/// This instruction returns the view index
-struct DxilInst_IgnoreIntersection {
+/// This instruction Used in an any hit shader to reject an intersection and terminate the shader
+struct DxilInst_AcceptHitAndEndSearch {
   llvm::Instruction *Instr;
   // Construction and identification
-  DxilInst_IgnoreIntersection(llvm::Instruction *pInstr) : Instr(pInstr) {}
+  DxilInst_AcceptHitAndEndSearch(llvm::Instruction *pInstr) : Instr(pInstr) {}
   operator bool() const {
-    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::IgnoreIntersection);
+    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::AcceptHitAndEndSearch);
   }
   // Validation support
   bool isAllowed() const { return true; }
@@ -4827,13 +4843,13 @@ struct DxilInst_IgnoreIntersection {
   }
 };
 
-/// This instruction returns the view index
-struct DxilInst_TerminateRay {
+/// This instruction Used in an any hit shader to abort the ray query and the intersection shader (if any). The current hit is committed and execution passes to the closest hit shader with the closest hit recorded so far
+struct DxilInst_CommitHitAndStopRay {
   llvm::Instruction *Instr;
   // Construction and identification
-  DxilInst_TerminateRay(llvm::Instruction *pInstr) : Instr(pInstr) {}
+  DxilInst_CommitHitAndStopRay(llvm::Instruction *pInstr) : Instr(pInstr) {}
   operator bool() const {
-    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::TerminateRay);
+    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::CommitHitAndStopRay);
   }
   // Validation support
   bool isAllowed() const { return true; }
@@ -4909,12 +4925,12 @@ struct DxilInst_TraceRay {
 };
 
 /// This instruction returns true if hit was accepted
-struct DxilInst_ReportIntersection {
+struct DxilInst_ReportHit {
   llvm::Instruction *Instr;
   // Construction and identification
-  DxilInst_ReportIntersection(llvm::Instruction *pInstr) : Instr(pInstr) {}
+  DxilInst_ReportHit(llvm::Instruction *pInstr) : Instr(pInstr) {}
   operator bool() const {
-    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::ReportIntersection);
+    return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::ReportHit);
   }
   // Validation support
   bool isAllowed() const { return true; }
@@ -4937,7 +4953,7 @@ struct DxilInst_ReportIntersection {
   void set_Attributes(llvm::Value *val) { Instr->setOperand(3, val); }
 };
 
-/// This instruction returns the view index
+/// This instruction Call a shader in the callable shader table supplied through the DispatchRays() API
 struct DxilInst_CallShader {
   llvm::Instruction *Instr;
   // Construction and identification

+ 4 - 1
include/dxc/HlslIntrinsicOp.h

@@ -21,10 +21,13 @@ import hctdb_instrhelp
 
 /* <py::lines('HLSL-INTRINSICS')>hctdb_instrhelp.enum_hlsl_intrinsics()</py>*/
 // HLSL-INTRINSICS:BEGIN
+  IOP_AcceptHitAndEndSearch,
   IOP_AddUint64,
   IOP_AllMemoryBarrier,
   IOP_AllMemoryBarrierWithGroupSync,
+  IOP_CallShader,
   IOP_CheckAccessFullyMapped,
+  IOP_CommitHitAndStopRay,
   IOP_D3DCOLORtoUBYTE4,
   IOP_DeviceMemoryBarrier,
   IOP_DeviceMemoryBarrierWithGroupSync,
@@ -60,7 +63,7 @@ import hctdb_instrhelp
   IOP_QuadReadAcrossX,
   IOP_QuadReadAcrossY,
   IOP_QuadReadLaneAt,
-  IOP_ReportIntersection,
+  IOP_ReportHit,
   IOP_TraceRay,
   IOP_WaveActiveAllEqual,
   IOP_WaveActiveAllTrue,

+ 43 - 12
lib/HLSL/DxilOperations.cpp

@@ -265,25 +265,40 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = {
   {  OC::RawBufferLoad,           "RawBufferLoad",            OCC::RawBufferLoad,            "rawBufferLoad",              false,  true,  true, false, false, false,  true,  true, false, false, Attribute::ReadOnly, },
   {  OC::RawBufferStore,          "RawBufferStore",           OCC::RawBufferStore,           "rawBufferStore",             false,  true,  true, false, false, false,  true,  true, false, false, Attribute::None,     },
 
-  // Ray Tracing                                                                                                            void,     h,     f,     d,    i1,    i8,   i16,   i32,   i64,   udt,  function attribute
+  // Raytracing uint System Values                                                                                          void,     h,     f,     d,    i1,    i8,   i16,   i32,   i64,   udt,  function attribute
+  {  OC::InstanceID,              "InstanceID",               OCC::InstanceID,               "instanceID",                 false, false, false, false, false, false, false,  true, false, false, Attribute::ReadNone, },
   {  OC::InstanceIndex,           "InstanceIndex",            OCC::InstanceIndex,            "instanceIndex",              false, false, false, false, false, false, false,  true, false, false, Attribute::ReadNone, },
   {  OC::HitKind,                 "HitKind",                  OCC::HitKind,                  "hitKind",                    false, false, false, false, false, false, false,  true, false, false, Attribute::ReadNone, },
   {  OC::RayFlag,                 "RayFlag",                  OCC::RayFlag,                  "rayFlag",                    false, false, false, false, false, false, false,  true, false, false, Attribute::ReadNone, },
+
+  // Ray Dispatch Arguments                                                                                                 void,     h,     f,     d,    i1,    i8,   i16,   i32,   i64,   udt,  function attribute
   {  OC::RayDispatchIndex,        "RayDispatchIndex",         OCC::RayDispatchIndex,         "rayDispatchIndex",           false, false, false, false, false, false, false,  true, false, false, Attribute::ReadNone, },
   {  OC::RayDispatchDimension,    "RayDispatchDimension",     OCC::RayDispatchDimension,     "rayDispatchDimension",       false, false, false, false, false, false, false,  true, false, false, Attribute::ReadNone, },
+
+  // Ray Vectors                                                                                                            void,     h,     f,     d,    i1,    i8,   i16,   i32,   i64,   udt,  function attribute
   {  OC::WorldRayOrigin,          "WorldRayOrigin",           OCC::WorldRayOrigin,           "worldRayOrigin",             false, false,  true, false, false, false, false, false, false, false, Attribute::ReadNone, },
   {  OC::WorldRayDirection,       "WorldRayDirection",        OCC::WorldRayDirection,        "worldRayDirection",          false, false,  true, false, false, false, false, false, false, false, Attribute::ReadNone, },
   {  OC::ObjectRayOrigin,         "ObjectRayOrigin",          OCC::ObjectRayOrigin,          "objectRayOrigin",            false, false,  true, false, false, false, false, false, false, false, Attribute::ReadNone, },
   {  OC::ObjectRayDirection,      "ObjectRayDirection",       OCC::ObjectRayDirection,       "objectRayDirection",         false, false,  true, false, false, false, false, false, false, false, Attribute::ReadNone, },
+
+  // Ray Transforms                                                                                                         void,     h,     f,     d,    i1,    i8,   i16,   i32,   i64,   udt,  function attribute
   {  OC::ObjectToWorld,           "ObjectToWorld",            OCC::ObjectToWorld,            "objectToWorld",              false, false,  true, false, false, false, false, false, false, false, Attribute::ReadNone, },
   {  OC::WorldToObject,           "WorldToObject",            OCC::WorldToObject,            "worldToObject",              false, false,  true, false, false, false, false, false, false, false, Attribute::ReadNone, },
+
+  // RayT                                                                                                                   void,     h,     f,     d,    i1,    i8,   i16,   i32,   i64,   udt,  function attribute
   {  OC::RayTMin,                 "RayTMin",                  OCC::RayTMin,                  "rayTMin",                    false, false,  true, false, false, false, false, false, false, false, Attribute::ReadNone, },
   {  OC::CurrentRayT,             "CurrentRayT",              OCC::CurrentRayT,              "currentRayT",                false, false,  true, false, false, false, false, false, false, false, Attribute::ReadNone, },
-  {  OC::IgnoreIntersection,      "IgnoreIntersection",       OCC::IgnoreIntersection,       "ignoreIntersection",          true, false, false, false, false, false, false, false, false, false, Attribute::ReadNone, },
-  {  OC::TerminateRay,            "TerminateRay",             OCC::TerminateRay,             "terminateRay",                true, false, false, false, false, false, false, false, false, false, Attribute::ReadNone, },
+
+  // AnyHit Terminals                                                                                                       void,     h,     f,     d,    i1,    i8,   i16,   i32,   i64,   udt,  function attribute
+  {  OC::AcceptHitAndEndSearch,   "AcceptHitAndEndSearch",    OCC::AcceptHitAndEndSearch,    "acceptHitAndEndSearch",       true, false, false, false, false, false, false, false, false, false, Attribute::NoReturn, },
+  {  OC::CommitHitAndStopRay,     "CommitHitAndStopRay",      OCC::CommitHitAndStopRay,      "commitHitAndStopRay",         true, false, false, false, false, false, false, false, false, false, Attribute::NoReturn, },
+
+  // Indirect Shader Invocation                                                                                             void,     h,     f,     d,    i1,    i8,   i16,   i32,   i64,   udt,  function attribute
   {  OC::TraceRay,                "TraceRay",                 OCC::TraceRay,                 "traceRay",                   false, false, false, false, false, false, false, false, false,  true, Attribute::None,     },
-  {  OC::ReportIntersection,      "ReportIntersection",       OCC::ReportIntersection,       "reportIntersection",         false, false, false, false, false, false, false, false, false,  true, Attribute::ReadOnly, },
-  {  OC::CallShader,              "CallShader",               OCC::CallShader,               "callShader",                  true, false, false, false, false, false, false, false, false, false, Attribute::None,     },
+  {  OC::ReportHit,               "ReportHit",                OCC::ReportHit,                "reportHit",                  false, false, false, false, false, false, false, false, false,  true, Attribute::None,     },
+  {  OC::CallShader,              "CallShader",               OCC::CallShader,               "callShader",                 false, false, false, false, false, false, false, false, false,  true, Attribute::None,     },
+
+  // Library create handle from resource struct (like HL intrinsic)                                                         void,     h,     f,     d,    i1,    i8,   i16,   i32,   i64,   udt,  function attribute
   {  OC::ReservedForLibCreateHandleFromResourceStruct, "ReservedForLibCreateHandleFromResourceStruct", OCC::ReservedForLibCreateHandleFromResourceStruct, "reservedForLibCreateHandleFromResourceStruct",  false, false, false, false, false, false, false,  true, false, false, Attribute::ReadNone, },
 };
 // OPCODE-OLOADS:END
@@ -813,25 +828,40 @@ Function *OP::GetOpFunc(OpCode OpCode, Type *pOverloadType) {
   case OpCode::RawBufferLoad:          RRT(pETy);   A(pI32); A(pRes); A(pI32); A(pI32); A(pI8);  A(pI32); break;
   case OpCode::RawBufferStore:         A(pV);       A(pI32); A(pRes); A(pI32); A(pI32); A(pETy); A(pETy); A(pETy); A(pETy); A(pI8);  A(pI32); break;
 
-    // Ray Tracing
+    // Raytracing uint System Values
+  case OpCode::InstanceID:             A(pI32);     A(pI32); break;
   case OpCode::InstanceIndex:          A(pI32);     A(pI32); break;
   case OpCode::HitKind:                A(pI32);     A(pI32); break;
   case OpCode::RayFlag:                A(pI32);     A(pI32); break;
+
+    // Ray Dispatch Arguments
   case OpCode::RayDispatchIndex:       A(pI32);     A(pI32); A(pI8);  break;
   case OpCode::RayDispatchDimension:   A(pI32);     A(pI32); A(pI8);  break;
+
+    // Ray Vectors
   case OpCode::WorldRayOrigin:         A(pF32);     A(pI32); A(pI8);  break;
   case OpCode::WorldRayDirection:      A(pF32);     A(pI32); A(pI8);  break;
   case OpCode::ObjectRayOrigin:        A(pF32);     A(pI32); A(pI8);  break;
   case OpCode::ObjectRayDirection:     A(pF32);     A(pI32); A(pI8);  break;
+
+    // Ray Transforms
   case OpCode::ObjectToWorld:          A(pF32);     A(pI32); A(pI32); A(pI8);  break;
   case OpCode::WorldToObject:          A(pF32);     A(pI32); A(pI32); A(pI8);  break;
+
+    // RayT
   case OpCode::RayTMin:                A(pF32);     A(pI32); break;
   case OpCode::CurrentRayT:            A(pF32);     A(pI32); break;
-  case OpCode::IgnoreIntersection:     A(pV);       A(pI32); break;
-  case OpCode::TerminateRay:           A(pV);       A(pI32); break;
+
+    // AnyHit Terminals
+  case OpCode::AcceptHitAndEndSearch:  A(pV);       A(pI32); break;
+  case OpCode::CommitHitAndStopRay:    A(pV);       A(pI32); break;
+
+    // Indirect Shader Invocation
   case OpCode::TraceRay:               A(pV);       A(pI32); A(pRes); A(pI32); A(pI32); A(pI32); A(pI32); A(pI32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(pF32); A(udt);  break;
-  case OpCode::ReportIntersection:     A(pI1);      A(pI32); A(pF32); A(pI32); A(udt);  break;
+  case OpCode::ReportHit:              A(pI1);      A(pI32); A(pF32); A(pI32); A(udt);  break;
   case OpCode::CallShader:             A(pV);       A(pI32); A(pI32); A(udt);  break;
+
+    // Library create handle from resource struct (like HL intrinsic)
   case OpCode::ReservedForLibCreateHandleFromResourceStruct:A(pI32);     A(pI32); break;
   // OPCODE-OLOAD-FUNCS:END
   default: DXASSERT(false, "otherwise unhandled case"); break;
@@ -948,7 +978,7 @@ llvm::Type *OP::GetOverloadType(OpCode OpCode, llvm::Function *F) {
   case OpCode::TraceRay:
     DXASSERT_NOMSG(FT->getNumParams() > 15);
     return FT->getParamType(15);
-  case OpCode::ReportIntersection:
+  case OpCode::ReportHit:
     DXASSERT_NOMSG(FT->getNumParams() > 3);
     return FT->getParamType(3);
   case OpCode::CreateHandle:
@@ -982,8 +1012,8 @@ llvm::Type *OP::GetOverloadType(OpCode OpCode, llvm::Function *F) {
   case OpCode::LegacyDoubleToUInt32:
   case OpCode::WaveAllBitCount:
   case OpCode::WavePrefixBitCount:
-  case OpCode::IgnoreIntersection:
-  case OpCode::TerminateRay:
+  case OpCode::AcceptHitAndEndSearch:
+  case OpCode::CommitHitAndStopRay:
     return Type::getVoidTy(m_Ctx);
   case OpCode::CheckAccessFullyMapped:
   case OpCode::AtomicBinOp:
@@ -999,6 +1029,7 @@ llvm::Type *OP::GetOverloadType(OpCode OpCode, llvm::Function *F) {
   case OpCode::OutputControlPointID:
   case OpCode::PrimitiveID:
   case OpCode::ViewID:
+  case OpCode::InstanceID:
   case OpCode::InstanceIndex:
   case OpCode::HitKind:
   case OpCode::RayFlag:

+ 4 - 4
lib/HLSL/DxilResource.cpp

@@ -141,7 +141,7 @@ unsigned DxilResource::GetNumCoords(Kind ResourceKind) {
       0, // CBuffer,
       0, // Sampler,
       1, // TBuffer,
-      0, // RayTracingAccelerationStructure,
+      0, // RaytracingAccelerationStructure,
   };
   static_assert(_countof(CoordSizeTab) == (unsigned)Kind::NumEntries, "check helper array size");
   DXASSERT(ResourceKind > Kind::Invalid && ResourceKind < Kind::NumEntries, "otherwise the caller passed wrong resource type");
@@ -166,7 +166,7 @@ unsigned DxilResource::GetNumDimensions(Kind ResourceKind) {
       0, // CBuffer,
       0, // Sampler,
       1, // TBuffer,
-      0, // RayTracingAccelerationStructure,
+      0, // RaytracingAccelerationStructure,
   };
   static_assert(_countof(NumDimTab) == (unsigned)Kind::NumEntries, "check helper array size");
   DXASSERT(ResourceKind > Kind::Invalid && ResourceKind < Kind::NumEntries, "otherwise the caller passed wrong resource type");
@@ -191,7 +191,7 @@ unsigned DxilResource::GetNumDimensionsForCalcLOD(Kind ResourceKind) {
       0, // CBuffer,
       0, // Sampler,
       1, // TBuffer,
-      0, // RayTracingAccelerationStructure,
+      0, // RaytracingAccelerationStructure,
   };
   static_assert(_countof(NumDimTab) == (unsigned)Kind::NumEntries, "check helper array size");
   DXASSERT(ResourceKind > Kind::Invalid && ResourceKind < Kind::NumEntries, "otherwise the caller passed wrong resource type");
@@ -216,7 +216,7 @@ unsigned DxilResource::GetNumOffsets(Kind ResourceKind) {
       0, // CBuffer,
       0, // Sampler,
       1, // TBuffer,
-      0, // RayTracingAccelerationStructure,
+      0, // RaytracingAccelerationStructure,
   };
   static_assert(_countof(OffsetSizeTab) == (unsigned)Kind::NumEntries, "check helper array size");
   DXASSERT(ResourceKind > Kind::Invalid && ResourceKind < Kind::NumEntries, "otherwise the caller passed wrong resource type");

+ 1 - 1
lib/HLSL/DxilResourceBase.cpp

@@ -84,7 +84,7 @@ static const char *s_ResourceDimNames[(unsigned)DxilResourceBase::Kind::NumEntri
         "invalid", "1d",        "2d",      "2dMS",      "3d",
         "cube",    "1darray",   "2darray", "2darrayMS", "cubearray",
         "buf",     "rawbuf",    "structbuf", "cbuffer", "sampler",
-        "tbuffer", "rtacceleration",
+        "tbuffer", "raytracingacceleration",
 };
 
 const char *DxilResourceBase::GetResDimName() const {

+ 9 - 10
lib/HLSL/DxilValidation.cpp

@@ -603,16 +603,15 @@ static bool ValidateOpcodeInProfile(DXIL::OpCode opcode,
   // Instructions: RawBufferLoad=139, RawBufferStore=140
   if (139 <= op && op <= 140)
     return (pSM->GetMajor() > 6 || (pSM->GetMajor() == 6 && pSM->GetMinor() >= 2));
-  // Instructions: InstanceIndex=141, HitKind=142, RayFlag=143,
-  // RayDispatchIndex=144, RayDispatchDimension=145, WorldRayOrigin=146,
-  // WorldRayDirection=147, ObjectRayOrigin=148, ObjectRayDirection=149,
-  // ObjectToWorld=150, WorldToObject=151, RayTMin=152, CurrentRayT=153,
-  // IgnoreIntersection=154, TerminateRay=155, TraceRay=156,
-  // ReportIntersection=157, CallShader=158,
-  // ReservedForLibCreateHandleFromResourceStruct=159
-  if (141 <= op && op <= 159)
-    return (pSM->GetMajor() > 6 || (pSM->GetMajor() == 6 && pSM->GetMinor() >= 3))
-        && (pSM->IsLib());
+  // Instructions: InstanceID=141, InstanceIndex=142, HitKind=143, RayFlag=144,
+  // RayDispatchIndex=145, RayDispatchDimension=146, WorldRayOrigin=147,
+  // WorldRayDirection=148, ObjectRayOrigin=149, ObjectRayDirection=150,
+  // ObjectToWorld=151, WorldToObject=152, RayTMin=153, CurrentRayT=154,
+  // AcceptHitAndEndSearch=155, CommitHitAndStopRay=156, TraceRay=157,
+  // ReportHit=158, CallShader=159,
+  // ReservedForLibCreateHandleFromResourceStruct=160
+  if (141 <= op && op <= 160)
+    return (pSM->GetMajor() > 6 || (pSM->GetMajor() == 6 && pSM->GetMinor() >= 3));
   return true;
   // VALOPCODESM-TEXT:END
 }

+ 1 - 1
lib/HLSL/HLModule.cpp

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

+ 33 - 7
lib/HLSL/HLOperationLower.cpp

@@ -408,9 +408,14 @@ Value *TrivialDxilOperation(Function *dxilFunc, OP::OpCode opcode, ArrayRef<Valu
     }
     return retVal;
   } else {
-    Value *retVal =
-        Builder.CreateCall(dxilFunc, args, hlslOP->GetOpCodeName(opcode));
-    return retVal;
+    if (!RetTy->isVoidTy()) {
+      Value *retVal =
+          Builder.CreateCall(dxilFunc, args, hlslOP->GetOpCodeName(opcode));
+      return retVal;
+    } else {
+      // Cannot add name to void.
+      return Builder.CreateCall(dxilFunc, args);
+    }
   }
 }
 // Generates a DXIL operation over an overloaded type (Ty), returning a
@@ -4248,6 +4253,24 @@ Value *TranslateReportIntersection(CallInst *CI, IntrinsicOp IOP,
   IRBuilder<> Builder(CI);
   return Builder.CreateCall(F, {opArg, THit, HitKind, Attr});
 }
+
+Value *TranslateCallShader(CallInst *CI, IntrinsicOp IOP,
+                                   OP::OpCode opcode,
+                                   HLOperationLowerHelper &helper,
+                                   HLObjectOperationLowerHelper *pObjHelper,
+                                   bool &Translated) {
+  hlsl::OP *hlslOP = &helper.hlslOP;
+  Value *ShaderIndex = CI->getArgOperand(HLOperandIndex::kBinaryOpSrc0Idx);
+  Value *Parameter = CI->getArgOperand(HLOperandIndex::kBinaryOpSrc1Idx);
+  Value *opArg = hlslOP->GetU32Const(static_cast<unsigned>(opcode));
+
+  Type *Ty = Parameter->getType();
+  Function *F = hlslOP->GetOpFunc(opcode, Ty);
+
+  IRBuilder<> Builder(CI);
+  return Builder.CreateCall(F, {opArg, ShaderIndex, Parameter});
+}
+
 Value *TranslateTraceRay(CallInst *CI, IntrinsicOp IOP, OP::OpCode opcode,
                          HLOperationLowerHelper &helper,
                          HLObjectOperationLowerHelper *pObjHelper,
@@ -4337,11 +4360,14 @@ Value *StreamOutputLower(CallInst *CI, IntrinsicOp IOP, DXIL::OpCode opcode,
 }
 
 // This table has to match IntrinsicOp orders
-IntrinsicLower gLowerTable[static_cast<unsigned>(IntrinsicOp::Num_Intrinsics)] = {
+IntrinsicLower gLowerTable[static_cast<unsigned>(IntrinsicOp::Num_Intrinsics)] = {
+    {IntrinsicOp::IOP_AcceptHitAndEndSearch, TrivialNoArgOperation, DXIL::OpCode::AcceptHitAndEndSearch},
     {IntrinsicOp::IOP_AddUint64,  TranslateAddUint64,  DXIL::OpCode::UAddc},
     {IntrinsicOp::IOP_AllMemoryBarrier, TrivialBarrier, DXIL::OpCode::Barrier},
-    {IntrinsicOp::IOP_AllMemoryBarrierWithGroupSync, TrivialBarrier, DXIL::OpCode::Barrier},
-    {IntrinsicOp::IOP_CheckAccessFullyMapped, TranslateCheckAccess, DXIL::OpCode::CheckAccessFullyMapped},
+    {IntrinsicOp::IOP_AllMemoryBarrierWithGroupSync, TrivialBarrier, DXIL::OpCode::Barrier},
+    {IntrinsicOp::IOP_CallShader, TranslateCallShader, DXIL::OpCode::CallShader},
+    {IntrinsicOp::IOP_CheckAccessFullyMapped, TranslateCheckAccess, DXIL::OpCode::CheckAccessFullyMapped},
+    {IntrinsicOp::IOP_CommitHitAndStopRay, TrivialNoArgOperation, DXIL::OpCode::CommitHitAndStopRay},
     {IntrinsicOp::IOP_D3DCOLORtoUBYTE4, TranslateD3DColorToUByte4, DXIL::OpCode::NumOpCodes},
     {IntrinsicOp::IOP_DeviceMemoryBarrier, TrivialBarrier, DXIL::OpCode::Barrier},
     {IntrinsicOp::IOP_DeviceMemoryBarrierWithGroupSync, TrivialBarrier, DXIL::OpCode::Barrier},
@@ -4377,7 +4403,7 @@ IntrinsicLower gLowerTable[static_cast<unsigned>(IntrinsicOp::Num_Intrinsics)] =
     {IntrinsicOp::IOP_QuadReadAcrossX, TranslateQuadReadAcross, DXIL::OpCode::QuadOp},
     {IntrinsicOp::IOP_QuadReadAcrossY, TranslateQuadReadAcross, DXIL::OpCode::QuadOp},
     {IntrinsicOp::IOP_QuadReadLaneAt,  TranslateQuadReadLaneAt, DXIL::OpCode::NumOpCodes},
-    {IntrinsicOp::IOP_ReportIntersection, TranslateReportIntersection, DXIL::OpCode::ReportIntersection},
+    {IntrinsicOp::IOP_ReportHit, TranslateReportIntersection, DXIL::OpCode::ReportHit},
     {IntrinsicOp::IOP_TraceRay, TranslateTraceRay, DXIL::OpCode::TraceRay},
     {IntrinsicOp::IOP_WaveActiveAllEqual, TranslateWaveAllEqual, DXIL::OpCode::WaveActiveAllEqual},
     {IntrinsicOp::IOP_WaveActiveAllTrue, TranslateWaveA2B, DXIL::OpCode::WaveAllTrue},

+ 5 - 1
lib/Transforms/Scalar/ScalarReplAggregatesHLSL.cpp

@@ -3131,10 +3131,14 @@ void SROA_Helper::RewriteCall(CallInst *CI) {
                          /*bIn*/ true, /*bOut*/ true);
         }
       } break;
-      case IntrinsicOp::IOP_ReportIntersection: {
+      case IntrinsicOp::IOP_ReportHit: {
         RewriteCallArg(CI, HLOperandIndex::kReportIntersectionAttributeOpIdx,
                        /*bIn*/ true, /*bOut*/ false);
       } break;
+      case IntrinsicOp::IOP_CallShader: {
+        RewriteCallArg(CI, HLOperandIndex::kBinaryOpSrc1Idx,
+                       /*bIn*/ true, /*bOut*/ true);
+      } break;
       default:
         DXASSERT(0, "cannot flatten hlsl intrinsic.");
       }

+ 1 - 1
tools/clang/lib/AST/HlslTypes.cpp

@@ -380,7 +380,7 @@ bool IsHLSLResourceType(clang::QualType type) {
     if (name == "ConstantBuffer")
       return true;
 
-    if (name == "RayTracingAccelerationStructure")
+    if (name == "RaytracingAccelerationStructure")
       return true;
   }
   return false;

+ 2 - 2
tools/clang/lib/CodeGen/CGHLSLMS.cpp

@@ -1077,7 +1077,7 @@ static DxilResource::Kind KeywordToKind(StringRef keyword) {
   isBuffer |= keyword == "RasterizerOrderedBuffer";
   if (isBuffer)
     return DxilResource::Kind::TypedBuffer;
-  if (keyword == "RayTracingAccelerationStructure")
+  if (keyword == "RaytracingAccelerationStructure")
     return DxilResource::Kind::RTAccelerationStructure;
   return DxilResource::Kind::Invalid;
 }
@@ -2116,7 +2116,7 @@ static DxilResourceBase::Class KeywordToClass(const std::string &keyword) {
 
   bool isSRV = keyword == "Buffer";
   isSRV |= keyword == "ByteAddressBuffer";
-  isSRV |= keyword == "RayTracingAccelerationStructure";
+  isSRV |= keyword == "RaytracingAccelerationStructure";
   isSRV |= keyword == "StructuredBuffer";
   isSRV |= keyword == "Texture1D";
   isSRV |= keyword == "Texture1DArray";

+ 1 - 1
tools/clang/lib/Sema/SemaHLSL.cpp

@@ -1496,7 +1496,7 @@ const char* g_ArBasicTypeNames[] =
   "deprecated effect object",
   "wave_t",
   "ray_desc",
-  "RayTracingAccelerationStructure",
+  "RaytracingAccelerationStructure",
   "UserDefineType"
 };
 

ファイルの差分が大きいため隠しています
+ 161 - 144
tools/clang/lib/Sema/gen_intrin_main_tables_15.h


+ 1 - 1
tools/clang/test/CodeGenHLSL/abs1.hlsl

@@ -2,7 +2,7 @@
 
 // CHECK: main
 // After lowering, these would turn into multiple abs calls rather than a 4 x float
-// CHECK: call <4 x float> @"dx.hl.op..<4 x float> (i32, <4 x float>)"(i32 62,
+// CHECK: call <4 x float> @"dx.hl.op..<4 x float> (i32, <4 x float>)"(i32 65,
 
 float4 main(float4 a : A) : SV_TARGET {
   return abs(a*a.yxxx);

+ 2 - 2
tools/clang/test/CodeGenHLSL/quick-test/ray_trace1.hlsl

@@ -1,13 +1,13 @@
 // RUN: %dxc -T lib_6_2 %s | FileCheck %s
 
-// CHECK: call void @"dx.op.traceRay.%struct.Payload*"(i32 156,
+// CHECK: call void @"dx.op.traceRay.%struct.Payload*"(i32 157,
 
 struct Payload {
    float2 t;
    int3 t2;
 };
 
-RayTracingAccelerationStructure Acc;
+RaytracingAccelerationStructure Acc;
 
 uint RayFlags;
 uint InstanceInclusionMask;

+ 2 - 2
tools/clang/test/CodeGenHLSL/quick-test/ray_trace3.hlsl

@@ -1,6 +1,6 @@
 // RUN: %dxc -T lib_6_2 %s | FileCheck %s
 
-// CHECK: call i1 @"dx.op.reportIntersection.%struct.Attr*"(i32 157
+// CHECK: call i1 @"dx.op.reportHit.%struct.Attr*"(i32 158
 
 struct Attr {
    float2 t;
@@ -8,5 +8,5 @@ struct Attr {
 };
 
 float emit(float THit : t, uint HitKind : h, Attr a : A) {
-  return ReportIntersection(THit, HitKind, a);
+  return ReportHit(THit, HitKind, a);
 }

+ 1 - 1
tools/clang/test/CodeGenHLSL/quick-test/ray_trace4.hlsl

@@ -3,5 +3,5 @@
 //CHECK: User define type intrinsic arg must be struct
 
 float main(float THit : t, uint HitKind : h, float2 f2 : F) {
-  return ReportIntersection(THit, HitKind, f2);
+  return ReportHit(THit, HitKind, f2);
 }

+ 14 - 0
tools/clang/test/CodeGenHLSL/quick-test/ray_trace5.hlsl

@@ -0,0 +1,14 @@
+// RUN: %dxc -T lib_6_2 %s | FileCheck %s
+
+// CHECK: call void @"dx.op.callShader.%struct.Parameter*"(i32 159
+
+struct Parameter {
+   float2 t;
+   int3 t2;
+};
+
+float4 emit(uint shader, inout Parameter p )  {
+  CallShader(shader, p);
+
+   return 2.6;
+}

+ 12 - 0
tools/clang/test/CodeGenHLSL/quick-test/ray_trace6.hlsl

@@ -0,0 +1,12 @@
+// RUN: %dxc -T lib_6_2 %s | FileCheck %s
+
+// CHECK: call void @dx.op.acceptHitAndEndSearch(i32 155)
+// CHECK: call void @dx.op.commitHitAndStopRay(i32 156)
+
+float4 emit(uint shader)  {
+  if (shader < 2)
+    AcceptHitAndEndSearch();
+  if (shader < 9)
+    CommitHitAndStopRay();
+   return 2.6;
+}

+ 4 - 3
tools/clang/tools/dxcompiler/dxcdisassembler.cpp

@@ -967,6 +967,7 @@ static const char *OpCodeSignatures[] = {
   "()",  // ViewID
   "(srv,index,elementOffset,mask,alignment)",  // RawBufferLoad
   "(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)",  // RawBufferStore
+  "()",  // InstanceID
   "()",  // InstanceIndex
   "()",  // HitKind
   "()",  // RayFlag
@@ -980,10 +981,10 @@ static const char *OpCodeSignatures[] = {
   "(row,col)",  // WorldToObject
   "()",  // RayTMin
   "()",  // CurrentRayT
-  "()",  // IgnoreIntersection
-  "()",  // TerminateRay
+  "()",  // AcceptHitAndEndSearch
+  "()",  // CommitHitAndStopRay
   "(AccelerationStructure,RayFlags,InstanceInclusionMask,RayContributionToHitGroupIndex,MultiplierForGeometryContributionToShaderIndex,MissShaderIndex,Origin_X,Origin_Y,Origin_Z,TMin,Direction_X,Direction_Y,Direction_Z,TMax,payload)",  // TraceRay
-  "(THit,HitKind,Attributes)",  // ReportIntersection
+  "(THit,HitKind,Attributes)",  // ReportHit
   "(ShaderIndex,Parameter)",  // CallShader
   "()"  // ReservedForLibCreateHandleFromResourceStruct
 };

+ 1 - 1
tools/clang/unittests/HLSL/ExtensionTest.cpp

@@ -735,7 +735,7 @@ TEST_F(ExtensionTest, UnsignedOpcodeIsUnchanged) {
   // changes the test will need to be updated to reflect the new opcode.
   VERIFY_IS_TRUE(
     disassembly.npos !=
-    disassembly.find("call i32 @test_unsigned(i32 119, "));
+    disassembly.find("call i32 @test_unsigned(i32 122, "));
 }
 
 TEST_F(ExtensionTest, ResourceExtensionIntrinsic) {

+ 5 - 3
utils/hct/gen_intrin_main.txt

@@ -267,11 +267,13 @@ $type1 [[]] QuadReadAcrossX(in numeric<> value);
 $type1 [[]] QuadReadAcrossY(in numeric<> value);
 $type1 [[]] QuadReadAcrossDiagonal(in numeric<> value);
 
-// RayTracing
+// Raytracing
 void [[]]  TraceRay(in acceleration_struct AccelerationStructure, in uint RayFlags, in uint InstanceInclusionMask, in uint RayContributionToHitGroupIndex, in uint MultiplierForGeometryContributionToHitGroupIndex, in uint MissShaderIndex, in ray_desc Ray, inout udt Payload);
 
-bool [[]]  ReportIntersection(in float THit, in uint HitKind, in udt Attributes);
-
+bool [[]]  ReportHit(in float THit, in uint HitKind, in udt Attributes);
+void [[]]  CallShader(in uint ShaderIndex, inout udt Parameter);
+void [[]]  AcceptHitAndEndSearch();
+void [[]]  CommitHitAndStopRay();
 } namespace
 
 namespace StreamMethods {

+ 31 - 11
utils/hct/hctdb.py

@@ -293,9 +293,29 @@ class db_dxil(object):
             self.name_idx[i].shader_model = 6,1
         for i in "RawBufferLoad,RawBufferStore".split(","):
             self.name_idx[i].shader_model = 6,2
-        for i in "InstanceIndex,HitKind,RayFlag,RayDispatchIndex,RayDispatchDimension,WorldRayOrigin,WorldRayDirection,ObjectRayOrigin,ObjectRayDirection,ObjectToWorld,WorldToObject,RayTMin,CurrentRayT,IgnoreIntersection,TerminateRay,TraceRay,ReportIntersection,CallShader,ReservedForLibCreateHandleFromResourceStruct".split(","):
-            self.name_idx[i].category = "Ray Tracing"
-            self.name_idx[i].shader_stages = "lib"
+        for i in "InstanceID,InstanceIndex,HitKind,RayFlag".split(","):
+            self.name_idx[i].category = "Raytracing uint System Values"
+            self.name_idx[i].shader_model = 6,3
+        for i in "RayDispatchIndex,RayDispatchDimension".split(","):
+            self.name_idx[i].category = "Ray Dispatch Arguments"
+            self.name_idx[i].shader_model = 6,3
+        for i in "WorldRayOrigin,WorldRayDirection,ObjectRayOrigin,ObjectRayDirection".split(","):
+            self.name_idx[i].category = "Ray Vectors"
+            self.name_idx[i].shader_model = 6,3
+        for i in "ObjectToWorld,WorldToObject".split(","):
+            self.name_idx[i].category = "Ray Transforms"
+            self.name_idx[i].shader_model = 6,3
+        for i in "RayTMin,CurrentRayT".split(","):
+            self.name_idx[i].category = "RayT"
+            self.name_idx[i].shader_model = 6,3
+        for i in "AcceptHitAndEndSearch,CommitHitAndStopRay".split(","):
+            self.name_idx[i].category = "AnyHit Terminals"
+            self.name_idx[i].shader_model = 6,3
+        for i in "TraceRay,ReportHit,CallShader".split(","):
+            self.name_idx[i].category = "Indirect Shader Invocation"
+            self.name_idx[i].shader_model = 6,3
+        for i in "ReservedForLibCreateHandleFromResourceStruct".split(","):
+            self.name_idx[i].category = "Library create handle from resource struct (like HL intrinsic)"
             self.name_idx[i].shader_model = 6,3
 
     def populate_llvm_instructions(self):
@@ -1112,6 +1132,10 @@ class db_dxil(object):
         self.set_op_count_for_version(1, 2, next_op_idx)
         assert next_op_idx == 141, "next operation index is %d rather than 141 and thus opcodes are broken" % next_op_idx
 
+        self.add_dxil_op("InstanceID", next_op_idx, "InstanceID", "The user-provided InstanceID on the bottom-level acceleration structure instance within the top-level structure", "i", "rn", [
+            db_dxil_param(0, "i32", "", "result")])
+        next_op_idx += 1
+
         self.add_dxil_op("InstanceIndex", next_op_idx, "InstanceIndex", "The autogenerated index of the current instance in the top-level structure", "i", "rn", [
             db_dxil_param(0, "i32", "", "result")])
         next_op_idx += 1
@@ -1174,11 +1198,11 @@ class db_dxil(object):
             db_dxil_param(0, "f", "", "result")])
         next_op_idx += 1
 
-        self.add_dxil_op("IgnoreIntersection", next_op_idx, "IgnoreIntersection", "returns the view index", "v", "rn", [
+        self.add_dxil_op("AcceptHitAndEndSearch", next_op_idx, "AcceptHitAndEndSearch", "Used in an any hit shader to reject an intersection and terminate the shader", "v", "nr", [
             db_dxil_param(0, "v", "", "")])
         next_op_idx += 1
 
-        self.add_dxil_op("TerminateRay", next_op_idx, "TerminateRay", "returns the view index", "v", "rn", [
+        self.add_dxil_op("CommitHitAndStopRay", next_op_idx, "CommitHitAndStopRay", "Used in an any hit shader to abort the ray query and the intersection shader (if any). The current hit is committed and execution passes to the closest hit shader with the closest hit recorded so far", "v", "nr", [
             db_dxil_param(0, "v", "", "")])
         next_op_idx += 1
 
@@ -1201,14 +1225,14 @@ class db_dxil(object):
             db_dxil_param(16, "udt", "payload", "User-defined intersection attribute structure")])
         next_op_idx += 1
 
-        self.add_dxil_op("ReportIntersection", next_op_idx, "ReportIntersection", "returns true if hit was accepted", "u", "ro", [
+        self.add_dxil_op("ReportHit", next_op_idx, "ReportHit", "returns true if hit was accepted", "u", "", [
             db_dxil_param(0, "i1", "", "result"),
             db_dxil_param(2, "f", "THit", "parametric distance of the intersection"),
             db_dxil_param(3, "i32", "HitKind", "User-specified value in range of 0-127 to identify the type of hit. Read by any_hit or closes_hit shaders with HitKind()"),
             db_dxil_param(4, "udt", "Attributes", "User-defined intersection attribute structure")])
         next_op_idx += 1
 
-        self.add_dxil_op("CallShader", next_op_idx, "CallShader", "returns the view index", "v", "", [
+        self.add_dxil_op("CallShader", next_op_idx, "CallShader", "Call a shader in the callable shader table supplied through the DispatchRays() API", "u", "", [
             db_dxil_param(0, "v", "", "result"),
             db_dxil_param(2, "i32", "ShaderIndex", "Provides index into the callable shader table supplied through the DispatchRays() API"),
             db_dxil_param(3, "udt", "Parameter", "User-defined parameters to pass to the callable shader,This parameter structure must match the parameter structure used in the callable shader pointed to in the shader table")])
@@ -1218,10 +1242,6 @@ class db_dxil(object):
             db_dxil_param(0, "i32", "", "result")])
         next_op_idx += 1
 
-        # End of DXIL 1.3 opcodes.
-        self.set_op_count_for_version(1, 3, next_op_idx)
-        assert next_op_idx == 160, "next operation index is %d rather than 160 and thus opcodes are broken" % next_op_idx
-
         # Set interesting properties.
         self.build_indices()
         for i in "CalculateLOD,DerivCoarseX,DerivCoarseY,DerivFineX,DerivFineY,Sample,SampleBias,SampleCmp,TextureGather,TextureGatherCmp".split(","):

+ 2 - 5
utils/hct/hctdb_instrhelp.py

@@ -361,7 +361,7 @@ class db_oload_gen:
         f = lambda i,c : "true," if i.oload_types.find(c) >= 0 else "false,"
         lower_exceptions = { "CBufferLoad" : "cbufferLoad", "CBufferLoadLegacy" : "cbufferLoadLegacy", "GSInstanceID" : "gsInstanceID" }
         lower_fn = lambda t: lower_exceptions[t] if t in lower_exceptions else t[:1].lower() + t[1:]
-        attr_dict = { "": "None", "ro": "ReadOnly", "rn": "ReadNone", "nd": "NoDuplicate" }
+        attr_dict = { "": "None", "ro": "ReadOnly", "rn": "ReadNone", "nd": "NoDuplicate", "nr": "NoReturn" }
         attr_fn = lambda i : "Attribute::" + attr_dict[i.fn_attr] + ","
         for i in self.instrs:
             if last_category != i.category:
@@ -936,10 +936,7 @@ def get_valopcode_sm_text():
             model_cond = "pSM->GetMajor() > %d || (pSM->GetMajor() == %d && pSM->GetMinor() >= %d)" % (
                 last_model[0], last_model[0], last_model[1])
         if last_stage != "*":
-            if last_stage != "lib":
-                stage_cond = ' || '.join(["pSM->Is%sS()" % c.upper() for c in last_stage])
-            else:
-                stage_cond = ' || '.join(["pSM->IsLib()"])
+            stage_cond = ' || '.join(["pSM->Is%sS()" % c.upper() for c in last_stage])
         if model_cond or stage_cond:
             result += '\n      && '.join(
                 ["(%s)" % expr for expr in (model_cond, stage_cond) if expr] )

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません