diff --git a/include/dxc/DXIL/DxilConstants.h b/include/dxc/DXIL/DxilConstants.h index 9c71eb329e..723abe552f 100644 --- a/include/dxc/DXIL/DxilConstants.h +++ b/include/dxc/DXIL/DxilConstants.h @@ -503,32 +503,11 @@ enum class OpCode : unsigned { ReservedA1 = 260, // reserved ReservedA2 = 261, // reserved ReservedB0 = 262, // reserved - ReservedB10 = 272, // reserved - ReservedB11 = 273, // reserved - ReservedB12 = 274, // reserved - ReservedB13 = 275, // reserved - ReservedB14 = 276, // reserved - ReservedB15 = 277, // reserved - ReservedB16 = 278, // reserved - ReservedB17 = 279, // reserved - ReservedB18 = 280, // reserved - ReservedB19 = 281, // reserved - ReservedB20 = 282, // reserved - ReservedB21 = 283, // reserved - ReservedB22 = 284, // reserved - ReservedB23 = 285, // reserved - ReservedB24 = 286, // reserved - ReservedB25 = 287, // reserved - ReservedB26 = 288, // reserved - ReservedB27 = 289, // reserved ReservedB28 = 290, // reserved ReservedB29 = 291, // reserved ReservedB30 = 292, // reserved ReservedB5 = 267, // reserved ReservedB6 = 268, // reserved - ReservedB7 = 269, // reserved - ReservedB8 = 270, // reserved - ReservedB9 = 271, // reserved ReservedC0 = 293, // reserved ReservedC1 = 294, // reserved ReservedC2 = 295, // reserved @@ -914,13 +893,42 @@ enum class OpCode : unsigned { // operation with a mipmap-level offset // Shader Execution Reordering + HitObject_Attributes = 289, // Returns the attributes set for this HitObject HitObject_FromRayQuery = 263, // Creates a new HitObject representing a // committed hit from a RayQuery HitObject_FromRayQueryWithAttrs = 264, // Creates a new HitObject representing a committed hit from a // RayQuery and committed attributes + HitObject_GeometryIndex = 281, // Returns the geometry index committed on hit + HitObject_HitKind = 285, // Returns the HitKind of the hit + HitObject_InstanceID = 283, // Returns the instance id committed on hit + HitObject_InstanceIndex = 282, // Returns the instance index committed on hit + HitObject_IsHit = 270, // Returns `true` if the HitObject is a NOP-HitObject + HitObject_IsMiss = 269, // Returns `true` if the HitObject represents a miss + HitObject_IsNop = 271, // Returns `true` if the HitObject represents a nop + HitObject_LoadLocalRootTableConstant = + 288, // Returns the root table constant for this HitObject and offset HitObject_MakeMiss = 265, // Creates a new HitObject representing a miss HitObject_MakeNop = 266, // Creates an empty nop HitObject + HitObject_ObjectRayDirection = + 278, // Returns the ray direction in object space + HitObject_ObjectRayOrigin = 277, // Returns the ray origin in object space + HitObject_ObjectToWorld3x4 = 279, // Returns the object to world space + // transformation matrix in 3x4 form + HitObject_PrimitiveIndex = + 284, // Returns the primitive index committed on hit + HitObject_RayFlags = 272, // Returns the ray flags set in the HitObject + HitObject_RayTCurrent = + 274, // Returns the current T value set in the HitObject + HitObject_RayTMin = 273, // Returns the TMin value set in the HitObject + HitObject_SetShaderTableIndex = + 287, // Returns a HitObject with updated shader table index + HitObject_ShaderTableIndex = + 286, // Returns the shader table index set for this HitObject + HitObject_WorldRayDirection = 276, // Returns the ray direction in world space + HitObject_WorldRayOrigin = 275, // Returns the ray origin in world space + HitObject_WorldToObject3x4 = 280, // Returns the world to object space + // transformation matrix in 3x4 form // Synchronization AtomicBinOp = 78, // performs an atomic operation on two operands @@ -1297,10 +1305,16 @@ enum class OpCodeClass : unsigned { WriteSamplerFeedbackLevel, // Shader Execution Reordering + HitObject_Attributes, HitObject_FromRayQuery, HitObject_FromRayQueryWithAttrs, + HitObject_LoadLocalRootTableConstant, HitObject_MakeMiss, HitObject_MakeNop, + HitObject_SetShaderTableIndex, + HitObject_StateMatrix, + HitObject_StateScalar, + HitObject_StateVector, // Synchronization AtomicBinOp, @@ -1366,7 +1380,7 @@ enum class OpCodeClass : unsigned { NumOpClasses_Dxil_1_7 = 153, NumOpClasses_Dxil_1_8 = 174, - NumOpClasses = 181 // exclusive last value of enumeration + NumOpClasses = 187 // exclusive last value of enumeration }; // OPCODECLASS-ENUM:END diff --git a/include/dxc/DXIL/DxilInstructions.h b/include/dxc/DXIL/DxilInstructions.h index 15f7a1362b..2655124c2d 100644 --- a/include/dxc/DXIL/DxilInstructions.h +++ b/include/dxc/DXIL/DxilInstructions.h @@ -8987,6 +8987,691 @@ struct DxilInst_HitObject_MakeNop { bool requiresUniformInputs() const { return false; } }; +/// This instruction Returns `true` if the HitObject represents a miss +struct DxilInst_HitObject_IsMiss { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_IsMiss(llvm::Instruction *pInstr) : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::HitObject_IsMiss); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } +}; + +/// This instruction Returns `true` if the HitObject is a NOP-HitObject +struct DxilInst_HitObject_IsHit { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_IsHit(llvm::Instruction *pInstr) : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::HitObject_IsHit); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } +}; + +/// This instruction Returns `true` if the HitObject represents a nop +struct DxilInst_HitObject_IsNop { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_IsNop(llvm::Instruction *pInstr) : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::HitObject_IsNop); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } +}; + +/// This instruction Returns the ray flags set in the HitObject +struct DxilInst_HitObject_RayFlags { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_RayFlags(llvm::Instruction *pInstr) : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::HitObject_RayFlags); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } +}; + +/// This instruction Returns the TMin value set in the HitObject +struct DxilInst_HitObject_RayTMin { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_RayTMin(llvm::Instruction *pInstr) : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::HitObject_RayTMin); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } +}; + +/// This instruction Returns the current T value set in the HitObject +struct DxilInst_HitObject_RayTCurrent { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_RayTCurrent(llvm::Instruction *pInstr) : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::HitObject_RayTCurrent); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } +}; + +/// This instruction Returns the ray origin in world space +struct DxilInst_HitObject_WorldRayOrigin { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_WorldRayOrigin(llvm::Instruction *pInstr) + : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::HitObject_WorldRayOrigin); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + arg_component = 2, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } + llvm::Value *get_component() const { return Instr->getOperand(2); } + void set_component(llvm::Value *val) { Instr->setOperand(2, val); } + int32_t get_component_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_component_val(int32_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } +}; + +/// This instruction Returns the ray direction in world space +struct DxilInst_HitObject_WorldRayDirection { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_WorldRayDirection(llvm::Instruction *pInstr) + : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::HitObject_WorldRayDirection); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + arg_component = 2, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } + llvm::Value *get_component() const { return Instr->getOperand(2); } + void set_component(llvm::Value *val) { Instr->setOperand(2, val); } + int32_t get_component_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_component_val(int32_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } +}; + +/// This instruction Returns the ray origin in object space +struct DxilInst_HitObject_ObjectRayOrigin { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_ObjectRayOrigin(llvm::Instruction *pInstr) + : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::HitObject_ObjectRayOrigin); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + arg_component = 2, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } + llvm::Value *get_component() const { return Instr->getOperand(2); } + void set_component(llvm::Value *val) { Instr->setOperand(2, val); } + int32_t get_component_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_component_val(int32_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } +}; + +/// This instruction Returns the ray direction in object space +struct DxilInst_HitObject_ObjectRayDirection { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_ObjectRayDirection(llvm::Instruction *pInstr) + : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::HitObject_ObjectRayDirection); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + arg_component = 2, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } + llvm::Value *get_component() const { return Instr->getOperand(2); } + void set_component(llvm::Value *val) { Instr->setOperand(2, val); } + int32_t get_component_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_component_val(int32_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } +}; + +/// This instruction Returns the object to world space transformation matrix in +/// 3x4 form +struct DxilInst_HitObject_ObjectToWorld3x4 { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_ObjectToWorld3x4(llvm::Instruction *pInstr) + : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::HitObject_ObjectToWorld3x4); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + arg_row = 2, + arg_col = 3, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } + llvm::Value *get_row() const { return Instr->getOperand(2); } + void set_row(llvm::Value *val) { Instr->setOperand(2, val); } + int32_t get_row_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_row_val(int32_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } + llvm::Value *get_col() const { return Instr->getOperand(3); } + void set_col(llvm::Value *val) { Instr->setOperand(3, val); } + int32_t get_col_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(3)) + ->getZExtValue()); + } + void set_col_val(int32_t val) { + Instr->setOperand(3, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } +}; + +/// This instruction Returns the world to object space transformation matrix in +/// 3x4 form +struct DxilInst_HitObject_WorldToObject3x4 { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_WorldToObject3x4(llvm::Instruction *pInstr) + : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::HitObject_WorldToObject3x4); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (4 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + arg_row = 2, + arg_col = 3, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } + llvm::Value *get_row() const { return Instr->getOperand(2); } + void set_row(llvm::Value *val) { Instr->setOperand(2, val); } + int32_t get_row_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(2)) + ->getZExtValue()); + } + void set_row_val(int32_t val) { + Instr->setOperand(2, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } + llvm::Value *get_col() const { return Instr->getOperand(3); } + void set_col(llvm::Value *val) { Instr->setOperand(3, val); } + int32_t get_col_val() const { + return (int32_t)(llvm::dyn_cast(Instr->getOperand(3)) + ->getZExtValue()); + } + void set_col_val(int32_t val) { + Instr->setOperand(3, llvm::Constant::getIntegerValue( + llvm::IntegerType::get(Instr->getContext(), 32), + llvm::APInt(32, (uint64_t)val))); + } +}; + +/// This instruction Returns the geometry index committed on hit +struct DxilInst_HitObject_GeometryIndex { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_GeometryIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::HitObject_GeometryIndex); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } +}; + +/// This instruction Returns the instance index committed on hit +struct DxilInst_HitObject_InstanceIndex { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_InstanceIndex(llvm::Instruction *pInstr) : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::HitObject_InstanceIndex); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } +}; + +/// This instruction Returns the instance id committed on hit +struct DxilInst_HitObject_InstanceID { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_InstanceID(llvm::Instruction *pInstr) : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::HitObject_InstanceID); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } +}; + +/// This instruction Returns the primitive index committed on hit +struct DxilInst_HitObject_PrimitiveIndex { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_PrimitiveIndex(llvm::Instruction *pInstr) + : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::HitObject_PrimitiveIndex); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } +}; + +/// This instruction Returns the HitKind of the hit +struct DxilInst_HitObject_HitKind { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_HitKind(llvm::Instruction *pInstr) : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst(Instr, + hlsl::OP::OpCode::HitObject_HitKind); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } +}; + +/// This instruction Returns the shader table index set for this HitObject +struct DxilInst_HitObject_ShaderTableIndex { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_ShaderTableIndex(llvm::Instruction *pInstr) + : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::HitObject_ShaderTableIndex); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (2 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } +}; + +/// This instruction Returns a HitObject with updated shader table index +struct DxilInst_HitObject_SetShaderTableIndex { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_SetShaderTableIndex(llvm::Instruction *pInstr) + : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::HitObject_SetShaderTableIndex); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + arg_shaderTableIndex = 2, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } + llvm::Value *get_shaderTableIndex() const { return Instr->getOperand(2); } + void set_shaderTableIndex(llvm::Value *val) { Instr->setOperand(2, val); } +}; + +/// This instruction Returns the root table constant for this HitObject and +/// offset +struct DxilInst_HitObject_LoadLocalRootTableConstant { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_LoadLocalRootTableConstant(llvm::Instruction *pInstr) + : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::HitObject_LoadLocalRootTableConstant); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + arg_offset = 2, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } + llvm::Value *get_offset() const { return Instr->getOperand(2); } + void set_offset(llvm::Value *val) { Instr->setOperand(2, val); } +}; + +/// This instruction Returns the attributes set for this HitObject +struct DxilInst_HitObject_Attributes { + llvm::Instruction *Instr; + // Construction and identification + DxilInst_HitObject_Attributes(llvm::Instruction *pInstr) : Instr(pInstr) {} + operator bool() const { + return hlsl::OP::IsDxilOpFuncCallInst( + Instr, hlsl::OP::OpCode::HitObject_Attributes); + } + // Validation support + bool isAllowed() const { return true; } + bool isArgumentListValid() const { + if (3 != llvm::dyn_cast(Instr)->getNumArgOperands()) + return false; + return true; + } + // Metadata + bool requiresUniformInputs() const { return false; } + // Operand indexes + enum OperandIdx { + arg_hitObject = 1, + arg_attributes = 2, + }; + // Accessors + llvm::Value *get_hitObject() const { return Instr->getOperand(1); } + void set_hitObject(llvm::Value *val) { Instr->setOperand(1, val); } + llvm::Value *get_attributes() const { return Instr->getOperand(2); } + void set_attributes(llvm::Value *val) { Instr->setOperand(2, val); } +}; + /// This instruction reads from a raw buffer and structured buffer struct DxilInst_RawBufferVectorLoad { llvm::Instruction *Instr; diff --git a/lib/DXIL/DxilOperations.cpp b/lib/DXIL/DxilOperations.cpp index 7945197eba..d9276fc7d6 100644 --- a/lib/DXIL/DxilOperations.cpp +++ b/lib/DXIL/DxilOperations.cpp @@ -2362,174 +2362,177 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = { 0, {}, {}}, // Overloads: v - {OC::ReservedB7, - "ReservedB7", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB8, - "ReservedB8", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB9, - "ReservedB9", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB10, - "ReservedB10", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB11, - "ReservedB11", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB12, - "ReservedB12", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB13, - "ReservedB13", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB14, - "ReservedB14", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB15, - "ReservedB15", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB16, - "ReservedB16", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB17, - "ReservedB17", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB18, - "ReservedB18", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB19, - "ReservedB19", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB20, - "ReservedB20", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB21, - "ReservedB21", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB22, - "ReservedB22", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB23, - "ReservedB23", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB24, - "ReservedB24", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB25, - "ReservedB25", - OCC::Reserved, - "reserved", - Attribute::None, - 0, - {}, - {}}, // Overloads: v - {OC::ReservedB26, - "ReservedB26", - OCC::Reserved, - "reserved", - Attribute::None, + + // Shader Execution Reordering + {OC::HitObject_IsMiss, + "HitObject_IsMiss", + OCC::HitObject_StateScalar, + "hitObject_StateScalar", + Attribute::ReadNone, + 1, + {{0x8}}, + {{0x0}}}, // Overloads: 1 + {OC::HitObject_IsHit, + "HitObject_IsHit", + OCC::HitObject_StateScalar, + "hitObject_StateScalar", + Attribute::ReadNone, + 1, + {{0x8}}, + {{0x0}}}, // Overloads: 1 + {OC::HitObject_IsNop, + "HitObject_IsNop", + OCC::HitObject_StateScalar, + "hitObject_StateScalar", + Attribute::ReadNone, + 1, + {{0x8}}, + {{0x0}}}, // Overloads: 1 + {OC::HitObject_RayFlags, + "HitObject_RayFlags", + OCC::HitObject_StateScalar, + "hitObject_StateScalar", + Attribute::ReadNone, + 1, + {{0x40}}, + {{0x0}}}, // Overloads: i + {OC::HitObject_RayTMin, + "HitObject_RayTMin", + OCC::HitObject_StateScalar, + "hitObject_StateScalar", + Attribute::ReadNone, + 1, + {{0x2}}, + {{0x0}}}, // Overloads: f + {OC::HitObject_RayTCurrent, + "HitObject_RayTCurrent", + OCC::HitObject_StateScalar, + "hitObject_StateScalar", + Attribute::ReadNone, + 1, + {{0x2}}, + {{0x0}}}, // Overloads: f + {OC::HitObject_WorldRayOrigin, + "HitObject_WorldRayOrigin", + OCC::HitObject_StateVector, + "hitObject_StateVector", + Attribute::ReadNone, + 1, + {{0x2}}, + {{0x0}}}, // Overloads: f + {OC::HitObject_WorldRayDirection, + "HitObject_WorldRayDirection", + OCC::HitObject_StateVector, + "hitObject_StateVector", + Attribute::ReadNone, + 1, + {{0x2}}, + {{0x0}}}, // Overloads: f + {OC::HitObject_ObjectRayOrigin, + "HitObject_ObjectRayOrigin", + OCC::HitObject_StateVector, + "hitObject_StateVector", + Attribute::ReadNone, + 1, + {{0x2}}, + {{0x0}}}, // Overloads: f + {OC::HitObject_ObjectRayDirection, + "HitObject_ObjectRayDirection", + OCC::HitObject_StateVector, + "hitObject_StateVector", + Attribute::ReadNone, + 1, + {{0x2}}, + {{0x0}}}, // Overloads: f + {OC::HitObject_ObjectToWorld3x4, + "HitObject_ObjectToWorld3x4", + OCC::HitObject_StateMatrix, + "hitObject_StateMatrix", + Attribute::ReadNone, + 1, + {{0x2}}, + {{0x0}}}, // Overloads: f + {OC::HitObject_WorldToObject3x4, + "HitObject_WorldToObject3x4", + OCC::HitObject_StateMatrix, + "hitObject_StateMatrix", + Attribute::ReadNone, + 1, + {{0x2}}, + {{0x0}}}, // Overloads: f + {OC::HitObject_GeometryIndex, + "HitObject_GeometryIndex", + OCC::HitObject_StateScalar, + "hitObject_StateScalar", + Attribute::ReadNone, + 1, + {{0x40}}, + {{0x0}}}, // Overloads: i + {OC::HitObject_InstanceIndex, + "HitObject_InstanceIndex", + OCC::HitObject_StateScalar, + "hitObject_StateScalar", + Attribute::ReadNone, + 1, + {{0x40}}, + {{0x0}}}, // Overloads: i + {OC::HitObject_InstanceID, + "HitObject_InstanceID", + OCC::HitObject_StateScalar, + "hitObject_StateScalar", + Attribute::ReadNone, + 1, + {{0x40}}, + {{0x0}}}, // Overloads: i + {OC::HitObject_PrimitiveIndex, + "HitObject_PrimitiveIndex", + OCC::HitObject_StateScalar, + "hitObject_StateScalar", + Attribute::ReadNone, + 1, + {{0x40}}, + {{0x0}}}, // Overloads: i + {OC::HitObject_HitKind, + "HitObject_HitKind", + OCC::HitObject_StateScalar, + "hitObject_StateScalar", + Attribute::ReadNone, + 1, + {{0x40}}, + {{0x0}}}, // Overloads: i + {OC::HitObject_ShaderTableIndex, + "HitObject_ShaderTableIndex", + OCC::HitObject_StateScalar, + "hitObject_StateScalar", + Attribute::ReadNone, + 1, + {{0x40}}, + {{0x0}}}, // Overloads: i + {OC::HitObject_SetShaderTableIndex, + "HitObject_SetShaderTableIndex", + OCC::HitObject_SetShaderTableIndex, + "hitObject_SetShaderTableIndex", + Attribute::ReadNone, 0, {}, {}}, // Overloads: v - {OC::ReservedB27, - "ReservedB27", - OCC::Reserved, - "reserved", - Attribute::None, + {OC::HitObject_LoadLocalRootTableConstant, + "HitObject_LoadLocalRootTableConstant", + OCC::HitObject_LoadLocalRootTableConstant, + "hitObject_LoadLocalRootTableConstant", + Attribute::ReadOnly, 0, {}, {}}, // Overloads: v + {OC::HitObject_Attributes, + "HitObject_Attributes", + OCC::HitObject_Attributes, + "hitObject_Attributes", + Attribute::ArgMemOnly, + 1, + {{0x100}}, + {{0x0}}}, // Overloads: u + {OC::ReservedB28, "ReservedB28", OCC::Reserved, @@ -3448,8 +3451,17 @@ void OP::GetMinShaderModelAndMask(OpCode C, bool bWithTranslation, } // Instructions: HitObject_FromRayQuery=263, // HitObject_FromRayQueryWithAttrs=264, HitObject_MakeMiss=265, - // HitObject_MakeNop=266 - if ((263 <= op && op <= 266)) { + // HitObject_MakeNop=266, HitObject_IsMiss=269, HitObject_IsHit=270, + // HitObject_IsNop=271, HitObject_RayFlags=272, HitObject_RayTMin=273, + // HitObject_RayTCurrent=274, HitObject_WorldRayOrigin=275, + // HitObject_WorldRayDirection=276, HitObject_ObjectRayOrigin=277, + // HitObject_ObjectRayDirection=278, HitObject_ObjectToWorld3x4=279, + // HitObject_WorldToObject3x4=280, HitObject_GeometryIndex=281, + // HitObject_InstanceIndex=282, HitObject_InstanceID=283, + // HitObject_PrimitiveIndex=284, HitObject_HitKind=285, + // HitObject_ShaderTableIndex=286, HitObject_SetShaderTableIndex=287, + // HitObject_LoadLocalRootTableConstant=288, HitObject_Attributes=289 + if ((263 <= op && op <= 266) || (269 <= op && op <= 289)) { major = 6; minor = 9; mask = @@ -5666,90 +5678,126 @@ Function *OP::GetOpFunc(OpCode opCode, Type *pOverloadType) { A(pV); A(pI32); break; - case OpCode::ReservedB7: - A(pV); + + // Shader Execution Reordering + case OpCode::HitObject_IsMiss: + A(pI1); A(pI32); + A(pHit); break; - case OpCode::ReservedB8: - A(pV); + case OpCode::HitObject_IsHit: + A(pI1); A(pI32); + A(pHit); break; - case OpCode::ReservedB9: - A(pV); + case OpCode::HitObject_IsNop: + A(pI1); A(pI32); + A(pHit); break; - case OpCode::ReservedB10: - A(pV); + case OpCode::HitObject_RayFlags: A(pI32); + A(pI32); + A(pHit); break; - case OpCode::ReservedB11: - A(pV); + case OpCode::HitObject_RayTMin: + A(pF32); A(pI32); + A(pHit); break; - case OpCode::ReservedB12: - A(pV); + case OpCode::HitObject_RayTCurrent: + A(pF32); A(pI32); + A(pHit); break; - case OpCode::ReservedB13: - A(pV); + case OpCode::HitObject_WorldRayOrigin: + A(pF32); + A(pI32); + A(pHit); A(pI32); break; - case OpCode::ReservedB14: - A(pV); + case OpCode::HitObject_WorldRayDirection: + A(pF32); + A(pI32); + A(pHit); A(pI32); break; - case OpCode::ReservedB15: - A(pV); + case OpCode::HitObject_ObjectRayOrigin: + A(pF32); + A(pI32); + A(pHit); A(pI32); break; - case OpCode::ReservedB16: - A(pV); + case OpCode::HitObject_ObjectRayDirection: + A(pF32); + A(pI32); + A(pHit); A(pI32); break; - case OpCode::ReservedB17: - A(pV); + case OpCode::HitObject_ObjectToWorld3x4: + A(pF32); + A(pI32); + A(pHit); + A(pI32); A(pI32); break; - case OpCode::ReservedB18: - A(pV); + case OpCode::HitObject_WorldToObject3x4: + A(pF32); + A(pI32); + A(pHit); + A(pI32); A(pI32); break; - case OpCode::ReservedB19: - A(pV); + case OpCode::HitObject_GeometryIndex: A(pI32); + A(pI32); + A(pHit); break; - case OpCode::ReservedB20: - A(pV); + case OpCode::HitObject_InstanceIndex: + A(pI32); A(pI32); + A(pHit); break; - case OpCode::ReservedB21: - A(pV); + case OpCode::HitObject_InstanceID: A(pI32); + A(pI32); + A(pHit); break; - case OpCode::ReservedB22: - A(pV); + case OpCode::HitObject_PrimitiveIndex: + A(pI32); A(pI32); + A(pHit); break; - case OpCode::ReservedB23: - A(pV); + case OpCode::HitObject_HitKind: A(pI32); + A(pI32); + A(pHit); break; - case OpCode::ReservedB24: - A(pV); + case OpCode::HitObject_ShaderTableIndex: A(pI32); + A(pI32); + A(pHit); break; - case OpCode::ReservedB25: - A(pV); + case OpCode::HitObject_SetShaderTableIndex: + A(pHit); + A(pI32); + A(pHit); A(pI32); break; - case OpCode::ReservedB26: - A(pV); + case OpCode::HitObject_LoadLocalRootTableConstant: + A(pI32); + A(pI32); + A(pHit); A(pI32); break; - case OpCode::ReservedB27: + case OpCode::HitObject_Attributes: A(pV); A(pI32); + A(pHit); + A(udt); break; + + // case OpCode::ReservedB28: A(pV); A(pI32); @@ -5959,6 +6007,7 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { case OpCode::TempRegStore: case OpCode::CallShader: case OpCode::Pack4x8: + case OpCode::HitObject_Attributes: if (FT->getNumParams() <= 2) return nullptr; return FT->getParamType(2); @@ -6092,27 +6141,8 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { case OpCode::HitObject_MakeNop: case OpCode::ReservedB5: case OpCode::ReservedB6: - case OpCode::ReservedB7: - case OpCode::ReservedB8: - case OpCode::ReservedB9: - case OpCode::ReservedB10: - case OpCode::ReservedB11: - case OpCode::ReservedB12: - case OpCode::ReservedB13: - case OpCode::ReservedB14: - case OpCode::ReservedB15: - case OpCode::ReservedB16: - case OpCode::ReservedB17: - case OpCode::ReservedB18: - case OpCode::ReservedB19: - case OpCode::ReservedB20: - case OpCode::ReservedB21: - case OpCode::ReservedB22: - case OpCode::ReservedB23: - case OpCode::ReservedB24: - case OpCode::ReservedB25: - case OpCode::ReservedB26: - case OpCode::ReservedB27: + case OpCode::HitObject_SetShaderTableIndex: + case OpCode::HitObject_LoadLocalRootTableConstant: case OpCode::ReservedB28: case OpCode::ReservedB29: case OpCode::ReservedB30: @@ -6164,6 +6194,13 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { case OpCode::RayQuery_CommittedInstanceContributionToHitGroupIndex: case OpCode::StartVertexLocation: case OpCode::StartInstanceLocation: + case OpCode::HitObject_RayFlags: + case OpCode::HitObject_GeometryIndex: + case OpCode::HitObject_InstanceIndex: + case OpCode::HitObject_InstanceID: + case OpCode::HitObject_PrimitiveIndex: + case OpCode::HitObject_HitKind: + case OpCode::HitObject_ShaderTableIndex: return IntegerType::get(Ctx, 32); case OpCode::CalculateLOD: case OpCode::DomainLocation: @@ -6190,6 +6227,14 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { case OpCode::RayQuery_CandidateObjectRayDirection: case OpCode::RayQuery_CommittedObjectRayOrigin: case OpCode::RayQuery_CommittedObjectRayDirection: + case OpCode::HitObject_RayTMin: + case OpCode::HitObject_RayTCurrent: + case OpCode::HitObject_WorldRayOrigin: + case OpCode::HitObject_WorldRayDirection: + case OpCode::HitObject_ObjectRayOrigin: + case OpCode::HitObject_ObjectRayDirection: + case OpCode::HitObject_ObjectToWorld3x4: + case OpCode::HitObject_WorldToObject3x4: return Type::getFloatTy(Ctx); case OpCode::MakeDouble: case OpCode::SplitDouble: @@ -6200,6 +6245,9 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) { case OpCode::RayQuery_CommittedTriangleFrontFace: case OpCode::IsHelperLane: case OpCode::QuadVote: + case OpCode::HitObject_IsMiss: + case OpCode::HitObject_IsHit: + case OpCode::HitObject_IsNop: return IntegerType::get(Ctx, 1); case OpCode::CBufferLoadLegacy: case OpCode::Sample: diff --git a/tools/clang/test/LitDXILValidation/ser_hitobject_accessors_passing.ll b/tools/clang/test/LitDXILValidation/ser_hitobject_accessors_passing.ll new file mode 100644 index 0000000000..e527125009 --- /dev/null +++ b/tools/clang/test/LitDXILValidation/ser_hitobject_accessors_passing.ll @@ -0,0 +1,110 @@ +; REQUIRES: dxil-1-9 +; RUN: %dxv %s 2>&1 | FileCheck %s + +; CHECK: Validation succeeded. + +target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64" +target triple = "dxil-ms-dx" + +%struct.AttribType = type { float, float } +%dx.types.HitObject = type { i8* } + +; Function Attrs: nounwind +define void @"\01?main@@YAXXZ"() #0 { + %attrs = alloca %struct.AttribType, align 4 + %nop = call %dx.types.HitObject @dx.op.hitObject_MakeNop(i32 266) ; HitObject_MakeNop() + + %r269 = call i1 @dx.op.hitObject_StateScalar.i1(i32 269, %dx.types.HitObject %nop) ; HitObject_IsMiss(hitObject) + + %r270 = call i1 @dx.op.hitObject_StateScalar.i1(i32 270, %dx.types.HitObject %nop) ; HitObject_IsHit(hitObject) + + %r271 = call i1 @dx.op.hitObject_StateScalar.i1(i32 271, %dx.types.HitObject %nop) ; HitObject_IsNop(hitObject) + + %r272 = call i32 @dx.op.hitObject_StateScalar.i32(i32 272, %dx.types.HitObject %nop) ; HitObject_RayFlags(hitObject) + + %r273 = call float @dx.op.hitObject_StateScalar.f32(i32 273, %dx.types.HitObject %nop) ; HitObject_RayTMin(hitObject) + + %r274 = call float @dx.op.hitObject_StateScalar.f32(i32 274, %dx.types.HitObject %nop) ; HitObject_RayTCurrent(hitObject) + + %r275 = call float @dx.op.hitObject_StateVector.f32(i32 275, %dx.types.HitObject %nop, i32 0) ; HitObject_WorldRayOrigin(hitObject,component) + + %r276 = call float @dx.op.hitObject_StateVector.f32(i32 276, %dx.types.HitObject %nop, i32 0) ; HitObject_WorldRayDirection(hitObject,component) + + %r277 = call float @dx.op.hitObject_StateVector.f32(i32 277, %dx.types.HitObject %nop, i32 0) ; HitObject_ObjectRayOrigin(hitObject,component) + + %r278 = call float @dx.op.hitObject_StateVector.f32(i32 278, %dx.types.HitObject %nop, i32 0) ; HitObject_ObjectRayDirection(hitObject,component) + + %r279 = call float @dx.op.hitObject_StateMatrix.f32(i32 279, %dx.types.HitObject %nop, i32 0, i32 0) ; HitObject_ObjectToWorld3x4(hitObject,row,col) + + %r280 = call float @dx.op.hitObject_StateMatrix.f32(i32 280, %dx.types.HitObject %nop, i32 0, i32 0) ; HitObject_WorldToObject3x4(hitObject,row,col) + + %r281 = call i32 @dx.op.hitObject_StateScalar.i32(i32 281, %dx.types.HitObject %nop) ; HitObject_GeometryIndex(hitObject) + + %r282 = call i32 @dx.op.hitObject_StateScalar.i32(i32 282, %dx.types.HitObject %nop) ; HitObject_InstanceIndex(hitObject) + + %r283 = call i32 @dx.op.hitObject_StateScalar.i32(i32 283, %dx.types.HitObject %nop) ; HitObject_InstanceID(hitObject) + + %r284 = call i32 @dx.op.hitObject_StateScalar.i32(i32 284, %dx.types.HitObject %nop) ; HitObject_PrimitiveIndex(hitObject) + + %r285 = call i32 @dx.op.hitObject_StateScalar.i32(i32 285, %dx.types.HitObject %nop) ; HitObject_HitKind(hitObject) + + %r286 = call i32 @dx.op.hitObject_StateScalar.i32(i32 286, %dx.types.HitObject %nop) ; HitObject_ShaderTableIndex(hitObject) + + %r287 = call %dx.types.HitObject @dx.op.hitObject_SetShaderTableIndex(i32 287, %dx.types.HitObject %nop, i32 1) ; HitObject_SetShaderTableIndex(hitObject,shaderTableIndex) + + %r288 = call i32 @dx.op.hitObject_LoadLocalRootTableConstant(i32 288, %dx.types.HitObject %nop, i32 42) ; HitObject_LoadLocalRootTableConstant(hitObject,offset) + + call void @dx.op.hitObject_Attributes.struct.AttribType(i32 289, %dx.types.HitObject %nop, %struct.AttribType* nonnull %attrs) ; HitObject_Attributes(hitObject,attributes) + ret void +} + +; Function Attrs: nounwind readnone +declare %dx.types.HitObject @dx.op.hitObject_MakeNop(i32) #1 + +; Function Attrs: nounwind readnone +declare %dx.types.HitObject @dx.op.hitObject_SetShaderTableIndex(i32, %dx.types.HitObject, i32) #1 + +; Function Attrs: nounwind readnone +declare i1 @dx.op.hitObject_StateScalar.i1(i32, %dx.types.HitObject) #1 + +; Function Attrs: nounwind readnone +declare i32 @dx.op.hitObject_StateScalar.i32(i32, %dx.types.HitObject) #1 + +; Function Attrs: nounwind readonly +declare i32 @dx.op.hitObject_LoadLocalRootTableConstant(i32, %dx.types.HitObject, i32) #2 + +; Function Attrs: nounwind readnone +declare float @dx.op.hitObject_StateVector.f32(i32, %dx.types.HitObject, i32) #1 + +; Function Attrs: nounwind argmemonly +declare void @dx.op.hitObject_Attributes.struct.AttribType(i32, %dx.types.HitObject, %struct.AttribType*) #3 + +; Function Attrs: nounwind readnone +declare float @dx.op.hitObject_StateScalar.f32(i32, %dx.types.HitObject) #1 + +; Function Attrs: nounwind readnone +declare float @dx.op.hitObject_StateMatrix.f32(i32, %dx.types.HitObject, i32, i32) #1 + +attributes #0 = { nounwind } +attributes #1 = { nounwind readnone } +attributes #2 = { nounwind readonly } +attributes #3 = { nounwind argmemonly } + +!dx.version = !{!0} +!dx.valver = !{!0} +!dx.shaderModel = !{!1} +!dx.typeAnnotations = !{!2} +!dx.entryPoints = !{!3, !4} + +!0 = !{i32 1, i32 9} +!1 = !{!"lib", i32 6, i32 9} +!2 = !{i32 1, void ()* @"\01?main@@YAXXZ", !5} +!3 = !{null, !"", null, null, !6} +!4 = !{void ()* @"\01?main@@YAXXZ", !"\01?main@@YAXXZ", null, null, !7} +!5 = !{!8} +!6 = !{i32 0, i64 0} +!7 = !{i32 8, i32 7, i32 5, !9} +!8 = !{i32 1, !10, !10} +!9 = !{i32 0} +!10 = !{} + diff --git a/utils/hct/hctdb.py b/utils/hct/hctdb.py index b3b9c82528..28695a4036 100644 --- a/utils/hct/hctdb.py +++ b/utils/hct/hctdb.py @@ -851,6 +851,11 @@ def populate_categories_and_models(self): for i in ( "HitObject_MakeMiss,HitObject_MakeNop" + ",HitObject_FromRayQuery,HitObject_FromRayQueryWithAttrs" + + ",HitObject_IsMiss,HitObject_IsHit,HitObject_IsNop" + + ",HitObject_RayFlags,HitObject_RayTMin,HitObject_RayTCurrent,HitObject_GeometryIndex,HitObject_InstanceIndex,HitObject_InstanceID,HitObject_PrimitiveIndex,HitObject_HitKind,HitObject_ShaderTableIndex" + + ",HitObject_WorldRayOrigin,HitObject_WorldRayDirection,HitObject_ObjectRayOrigin,HitObject_ObjectRayDirection" + + ",HitObject_ObjectToWorld3x4,HitObject_WorldToObject3x4" + + ",HitObject_SetShaderTableIndex,HitObject_LoadLocalRootTableConstant,HitObject_Attributes" ).split(","): self.name_idx[i].category = "Shader Execution Reordering" self.name_idx[i].shader_model = 6, 9 @@ -5817,7 +5822,342 @@ def UFI(name, **mappings): ) next_op_idx += 1 - next_op_idx = self.reserve_dxil_op_range("ReservedB", next_op_idx, 26, 5) + next_op_idx = self.reserve_dxil_op_range("ReservedB", next_op_idx, 2, 5) + + self.add_dxil_op( + "HitObject_IsMiss", + next_op_idx, + "HitObject_StateScalar", + "Returns `true` if the HitObject represents a miss", + "1", + "rn", + [ + db_dxil_param(0, "i1", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_IsHit", + next_op_idx, + "HitObject_StateScalar", + "Returns `true` if the HitObject is a NOP-HitObject", + "1", + "rn", + [ + db_dxil_param(0, "i1", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_IsNop", + next_op_idx, + "HitObject_StateScalar", + "Returns `true` if the HitObject represents a nop", + "1", + "rn", + [ + db_dxil_param(0, "i1", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_RayFlags", + next_op_idx, + "HitObject_StateScalar", + "Returns the ray flags set in the HitObject", + "i", + "rn", + [ + db_dxil_param(0, "i32", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_RayTMin", + next_op_idx, + "HitObject_StateScalar", + "Returns the TMin value set in the HitObject", + "f", + "rn", + [ + db_dxil_param(0, "f", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_RayTCurrent", + next_op_idx, + "HitObject_StateScalar", + "Returns the current T value set in the HitObject", + "f", + "rn", + [ + db_dxil_param(0, "f", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_WorldRayOrigin", + next_op_idx, + "HitObject_StateVector", + "Returns the ray origin in world space", + "f", + "rn", + [ + db_dxil_param(0, "f", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + db_dxil_param(3, "i32", "component", "component [0..2]", is_const=True), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_WorldRayDirection", + next_op_idx, + "HitObject_StateVector", + "Returns the ray direction in world space", + "f", + "rn", + [ + db_dxil_param(0, "f", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + db_dxil_param(3, "i32", "component", "component [0..2]", is_const=True), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_ObjectRayOrigin", + next_op_idx, + "HitObject_StateVector", + "Returns the ray origin in object space", + "f", + "rn", + [ + db_dxil_param(0, "f", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + db_dxil_param(3, "i32", "component", "component [0..2]", is_const=True), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_ObjectRayDirection", + next_op_idx, + "HitObject_StateVector", + "Returns the ray direction in object space", + "f", + "rn", + [ + db_dxil_param(0, "f", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + db_dxil_param(3, "i32", "component", "component [0..2]", is_const=True), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_ObjectToWorld3x4", + next_op_idx, + "HitObject_StateMatrix", + "Returns the object to world space transformation matrix in 3x4 form", + "f", + "rn", + [ + db_dxil_param(0, "f", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + db_dxil_param( + 3, + "i32", + "row", + "row [0..2], , relative to the element", + is_const=True, + ), + db_dxil_param( + 4, + "i32", + "col", + "column [0..3], relative to the element", + is_const=True, + ), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_WorldToObject3x4", + next_op_idx, + "HitObject_StateMatrix", + "Returns the world to object space transformation matrix in 3x4 form", + "f", + "rn", + [ + db_dxil_param(0, "f", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + db_dxil_param( + 3, + "i32", + "row", + "row [0..2], relative to the element", + is_const=True, + ), + db_dxil_param( + 4, + "i32", + "col", + "column [0..3], relative to the element", + is_const=True, + ), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_GeometryIndex", + next_op_idx, + "HitObject_StateScalar", + "Returns the geometry index committed on hit", + "i", + "rn", + [ + db_dxil_param(0, "i32", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_InstanceIndex", + next_op_idx, + "HitObject_StateScalar", + "Returns the instance index committed on hit", + "i", + "rn", + [ + db_dxil_param(0, "i32", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_InstanceID", + next_op_idx, + "HitObject_StateScalar", + "Returns the instance id committed on hit", + "i", + "rn", + [ + db_dxil_param(0, "i32", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_PrimitiveIndex", + next_op_idx, + "HitObject_StateScalar", + "Returns the primitive index committed on hit", + "i", + "rn", + [ + db_dxil_param(0, "i32", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_HitKind", + next_op_idx, + "HitObject_StateScalar", + "Returns the HitKind of the hit", + "i", + "rn", + [ + db_dxil_param(0, "i32", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_ShaderTableIndex", + next_op_idx, + "HitObject_StateScalar", + "Returns the shader table index set for this HitObject", + "i", + "rn", + [ + db_dxil_param(0, "i32", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_SetShaderTableIndex", + next_op_idx, + "HitObject_SetShaderTableIndex", + "Returns a HitObject with updated shader table index", + "v", + "rn", + [ + db_dxil_param( + 0, "hit_object", "hitObject", "hit with shader table index set" + ), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + db_dxil_param(3, "i32", "shaderTableIndex", "shader table index"), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_LoadLocalRootTableConstant", + next_op_idx, + "HitObject_LoadLocalRootTableConstant", + "Returns the root table constant for this HitObject and offset", + "v", + "ro", + [ + db_dxil_param(0, "i32", "", "operation result"), + db_dxil_param(2, "hit_object", "hitObject", "hit"), + db_dxil_param(3, "i32", "offset", "offset"), + ], + ) + next_op_idx += 1 + + self.add_dxil_op( + "HitObject_Attributes", + next_op_idx, + "HitObject_Attributes", + "Returns the attributes set for this HitObject", + "u", + "amo", + [ + retvoid_param, + db_dxil_param(2, "hit_object", "hitObject", "hit"), + db_dxil_param( + 3, "udt", "attributes", "pointer to store the attributes to" + ), + ], + ) + next_op_idx += 1 + + next_op_idx = self.reserve_dxil_op_range("ReservedB", next_op_idx, 3, 28) # Reserved block C next_op_idx = self.reserve_dxil_op_range("ReservedC", next_op_idx, 10)