Merge rayquery into merge-dxil-1-5
This commit is contained in:
Коммит
afbe50930c
|
@ -2308,6 +2308,7 @@ ID Name Description
|
|||
210 RayQuery_CommittedPrimitiveIndex returns committed hit geometry index
|
||||
211 RayQuery_CommittedObjectRayOrigin returns committed hit object ray origin
|
||||
212 RayQuery_CommittedObjectRayDirection returns committed object ray direction
|
||||
213 GeometryIndex The autogenerated index of the current geometry in the bottom-level structure
|
||||
=== ============================================== =======================================================================================================================================================================================================================
|
||||
|
||||
|
||||
|
|
|
@ -510,6 +510,9 @@ namespace DXIL {
|
|||
// Raytracing hit 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.
|
||||
|
||||
// Raytracing object space uint System Values, raytracing tier 1.1
|
||||
GeometryIndex = 213, // The autogenerated index of the current geometry in the bottom-level structure
|
||||
|
||||
// Raytracing object space uint System Values
|
||||
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
|
||||
|
@ -642,9 +645,9 @@ namespace DXIL {
|
|||
NumOpCodes_Dxil_1_2 = 141,
|
||||
NumOpCodes_Dxil_1_3 = 162,
|
||||
NumOpCodes_Dxil_1_4 = 165,
|
||||
NumOpCodes_Dxil_1_5 = 213,
|
||||
NumOpCodes_Dxil_1_5 = 214,
|
||||
|
||||
NumOpCodes = 213 // exclusive last value of enumeration
|
||||
NumOpCodes = 214 // exclusive last value of enumeration
|
||||
};
|
||||
// OPCODE-ENUM:END
|
||||
|
||||
|
@ -795,6 +798,9 @@ namespace DXIL {
|
|||
// Raytracing hit uint System Values
|
||||
HitKind,
|
||||
|
||||
// Raytracing object space uint System Values, raytracing tier 1.1
|
||||
GeometryIndex,
|
||||
|
||||
// Raytracing object space uint System Values
|
||||
InstanceID,
|
||||
InstanceIndex,
|
||||
|
@ -885,9 +891,9 @@ namespace DXIL {
|
|||
NumOpClasses_Dxil_1_2 = 97,
|
||||
NumOpClasses_Dxil_1_3 = 118,
|
||||
NumOpClasses_Dxil_1_4 = 120,
|
||||
NumOpClasses_Dxil_1_5 = 142,
|
||||
NumOpClasses_Dxil_1_5 = 143,
|
||||
|
||||
NumOpClasses = 142 // exclusive last value of enumeration
|
||||
NumOpClasses = 143 // exclusive last value of enumeration
|
||||
};
|
||||
// OPCODECLASS-ENUM:END
|
||||
|
||||
|
|
|
@ -6895,5 +6895,23 @@ struct DxilInst_RayQuery_CommittedObjectRayDirection {
|
|||
int8_t get_component_val() const { return (int8_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(2))->getZExtValue()); }
|
||||
void set_component_val(int8_t val) { Instr->setOperand(2, llvm::Constant::getIntegerValue(llvm::IntegerType::get(Instr->getContext(), 8), llvm::APInt(8, (uint64_t)val))); }
|
||||
};
|
||||
|
||||
/// This instruction The autogenerated index of the current geometry in the bottom-level structure
|
||||
struct DxilInst_GeometryIndex {
|
||||
llvm::Instruction *Instr;
|
||||
// Construction and identification
|
||||
DxilInst_GeometryIndex(llvm::Instruction *pInstr) : Instr(pInstr) {}
|
||||
operator bool() const {
|
||||
return hlsl::OP::IsDxilOpFuncCallInst(Instr, hlsl::OP::OpCode::GeometryIndex);
|
||||
}
|
||||
// Validation support
|
||||
bool isAllowed() const { return true; }
|
||||
bool isArgumentListValid() const {
|
||||
if (1 != llvm::dyn_cast<llvm::CallInst>(Instr)->getNumArgOperands()) return false;
|
||||
return true;
|
||||
}
|
||||
// Metadata
|
||||
bool requiresUniformInputs() const { return false; }
|
||||
};
|
||||
// INSTR-HELPER:END
|
||||
} // namespace hlsl
|
||||
|
|
|
@ -36,6 +36,7 @@ import hctdb_instrhelp
|
|||
IOP_EvaluateAttributeAtSample,
|
||||
IOP_EvaluateAttributeCentroid,
|
||||
IOP_EvaluateAttributeSnapped,
|
||||
IOP_GeometryIndex,
|
||||
IOP_GetAttributeAtVertex,
|
||||
IOP_GetRenderTargetSampleCount,
|
||||
IOP_GetRenderTargetSamplePosition,
|
||||
|
|
|
@ -374,6 +374,9 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = {
|
|||
{ OC::RayQuery_CommittedPrimitiveIndex, "RayQuery_CommittedPrimitiveIndex", OCC::RayQuery_StateScalar, "rayQuery_StateScalar", { false, false, false, false, false, false, false, true, false, false, false}, Attribute::ReadOnly, },
|
||||
{ OC::RayQuery_CommittedObjectRayOrigin, "RayQuery_CommittedObjectRayOrigin", OCC::RayQuery_StateVector, "rayQuery_StateVector", { false, false, true, false, false, false, false, false, false, false, false}, Attribute::ReadOnly, },
|
||||
{ OC::RayQuery_CommittedObjectRayDirection, "RayQuery_CommittedObjectRayDirection", OCC::RayQuery_StateVector, "rayQuery_StateVector", { false, false, true, false, false, false, false, false, false, false, false}, Attribute::ReadOnly, },
|
||||
|
||||
// Raytracing object space uint System Values, raytracing tier 1.1 void, h, f, d, i1, i8, i16, i32, i64, udt, obj , function attribute
|
||||
{ OC::GeometryIndex, "GeometryIndex", OCC::GeometryIndex, "geometryIndex", { false, false, false, false, false, false, false, true, false, false, false}, Attribute::ReadNone, },
|
||||
};
|
||||
// OPCODE-OLOADS:END
|
||||
|
||||
|
@ -744,6 +747,12 @@ void OP::GetMinShaderModelAndMask(OpCode C, bool bWithTranslation,
|
|||
mask = SFLAG(Amplification);
|
||||
return;
|
||||
}
|
||||
// Instructions: GeometryIndex=213
|
||||
if (op == 213) {
|
||||
major = 6; minor = 5;
|
||||
mask = SFLAG(Library) | SFLAG(Intersection) | SFLAG(AnyHit) | SFLAG(ClosestHit);
|
||||
return;
|
||||
}
|
||||
// Instructions: WriteSamplerFeedback=174, WriteSamplerFeedbackBias=175
|
||||
if ((174 <= op && op <= 175)) {
|
||||
major = 6; minor = 5;
|
||||
|
@ -1210,6 +1219,9 @@ Function *OP::GetOpFunc(OpCode opCode, Type *pOverloadType) {
|
|||
case OpCode::RayQuery_CommittedPrimitiveIndex:A(pI32); A(pI32); A(pI32); break;
|
||||
case OpCode::RayQuery_CommittedObjectRayOrigin:A(pF32); A(pI32); A(pI32); A(pI8); break;
|
||||
case OpCode::RayQuery_CommittedObjectRayDirection:A(pF32); A(pI32); A(pI32); A(pI8); break;
|
||||
|
||||
// Raytracing object space uint System Values, raytracing tier 1.1
|
||||
case OpCode::GeometryIndex: A(pI32); A(pI32); break;
|
||||
// OPCODE-OLOAD-FUNCS:END
|
||||
default: DXASSERT(false, "otherwise unhandled case"); break;
|
||||
}
|
||||
|
@ -1412,6 +1424,7 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) {
|
|||
case OpCode::RayQuery_CommittedInstanceID:
|
||||
case OpCode::RayQuery_CommittedGeometryIndex:
|
||||
case OpCode::RayQuery_CommittedPrimitiveIndex:
|
||||
case OpCode::GeometryIndex:
|
||||
return IntegerType::get(m_Ctx, 32);
|
||||
case OpCode::CalculateLOD:
|
||||
case OpCode::DomainLocation:
|
||||
|
|
|
@ -390,6 +390,7 @@ ShaderFlags ShaderFlags::CollectShaderFlags(const Function *F,
|
|||
hasViewID = true;
|
||||
break;
|
||||
case DXIL::OpCode::AllocateRayQuery:
|
||||
case DXIL::OpCode::GeometryIndex:
|
||||
hasRaytracingTier1_1 = true;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -452,7 +452,7 @@ bool DxilShaderAccessTracking::runOnModule(Module &M)
|
|||
|
||||
|
||||
// todo: should "GetDimensions" mean a resource access?
|
||||
static_assert(DXIL::OpCode::NumOpCodes == static_cast<DXIL::OpCode>(213), "Please update PIX passes if any resource access opcodes are added");
|
||||
static_assert(DXIL::OpCode::NumOpCodes == static_cast<DXIL::OpCode>(214), "Please update PIX passes if any resource access opcodes are added");
|
||||
ResourceAccessFunction raFunctions[] = {
|
||||
{ DXIL::OpCode::CBufferLoadLegacy , ShaderAccessFlags::Read , f32i32f64 },
|
||||
{ DXIL::OpCode::CBufferLoad , ShaderAccessFlags::Read , f16f32f64i16i32i64 },
|
||||
|
|
|
@ -904,6 +904,10 @@ static bool ValidateOpcodeInProfile(DXIL::OpCode opcode,
|
|||
if (op == 173)
|
||||
return (major > 6 || (major == 6 && minor >= 5))
|
||||
&& (SK == DXIL::ShaderKind::Amplification);
|
||||
// Instructions: GeometryIndex=213
|
||||
if (op == 213)
|
||||
return (major > 6 || (major == 6 && minor >= 5))
|
||||
&& (SK == DXIL::ShaderKind::Library || SK == DXIL::ShaderKind::Intersection || SK == DXIL::ShaderKind::AnyHit || SK == DXIL::ShaderKind::ClosestHit);
|
||||
// Instructions: WriteSamplerFeedback=174, WriteSamplerFeedbackBias=175
|
||||
if ((174 <= op && op <= 175))
|
||||
return (major > 6 || (major == 6 && minor >= 5))
|
||||
|
|
|
@ -5096,6 +5096,7 @@ IntrinsicLower gLowerTable[] = {
|
|||
{IntrinsicOp::IOP_EvaluateAttributeAtSample, TranslateEvalSample, DXIL::OpCode::NumOpCodes},
|
||||
{IntrinsicOp::IOP_EvaluateAttributeCentroid, TranslateEvalCentroid, DXIL::OpCode::EvalCentroid},
|
||||
{IntrinsicOp::IOP_EvaluateAttributeSnapped, TranslateEvalSnapped, DXIL::OpCode::NumOpCodes},
|
||||
{IntrinsicOp::IOP_GeometryIndex, TrivialNoArgWithRetOperation, DXIL::OpCode::GeometryIndex},
|
||||
{IntrinsicOp::IOP_GetAttributeAtVertex, TranslateGetAttributeAtVertex, DXIL::OpCode::AttributeAtVertex},
|
||||
{IntrinsicOp::IOP_GetRenderTargetSampleCount, TrivialNoArgOperation, DXIL::OpCode::RenderTargetGetSampleCount},
|
||||
{IntrinsicOp::IOP_GetRenderTargetSamplePosition, TranslateGetRTSamplePos, DXIL::OpCode::NumOpCodes},
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -2,8 +2,8 @@
|
|||
|
||||
// CHECK: %[[RTAS:[^ ]+]] = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 0, i32 0, i32 0, i1 false)
|
||||
// CHECK: %[[RQ:[^ ]+]] = call i32 @dx.op.allocateRayQuery(i32 168, i32 1)
|
||||
// CHECK: call void @dx.op.traceRayInline(i32 169, i32 %[[RQ]], %dx.types.Handle %[[RTAS]], i32 0, i32 1,
|
||||
// CHECK: call void @dx.op.traceRayInline(i32 169, i32 %[[RQ]], %dx.types.Handle %[[RTAS]], i32 1, i32 2,
|
||||
// CHECK: call void @dx.op.rayQuery_TraceRayInline(i32 169, i32 %[[RQ]], %dx.types.Handle %[[RTAS]], i32 0, i32 1,
|
||||
// CHECK: call void @dx.op.rayQuery_TraceRayInline(i32 169, i32 %[[RQ]], %dx.types.Handle %[[RTAS]], i32 1, i32 2,
|
||||
|
||||
RaytracingAccelerationStructure RTAS;
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
// RUN: %dxc -T lib_6_5 -auto-binding-space 11 %s | FileCheck %s
|
||||
|
||||
// CHECK: define void [[anyhit1:@"\\01\?anyhit1@[^\"]+"]](%struct.MyPayload* noalias nocapture %payload, %struct.MyAttributes* nocapture readonly %attr) #0 {
|
||||
// CHECK: call float @dx.op.objectRayOrigin.f32(i32 149, i8 2)
|
||||
// CHECK: call float @dx.op.objectRayDirection.f32(i32 150, i8 2)
|
||||
// CHECK: call float @dx.op.rayTCurrent.f32(i32 154)
|
||||
// CHECK: call void @dx.op.acceptHitAndEndSearch(i32 156)
|
||||
// CHECK: call void @dx.op.ignoreHit(i32 155)
|
||||
// CHECK: [[GeometryIndex:%[^ ]+]] = call i32 @dx.op.geometryIndex.i32(i32 203)
|
||||
// CHECK: %[[color:[^ ]+]] = getelementptr inbounds %struct.MyPayload, %struct.MyPayload* %payload, i32 0, i32 0
|
||||
// CHECK: store <4 x float> {{.*}}, <4 x float>* %[[color]], align 4
|
||||
// CHECK: ret void
|
||||
|
||||
struct MyPayload {
|
||||
float4 color;
|
||||
uint2 pos;
|
||||
};
|
||||
|
||||
struct MyAttributes {
|
||||
float2 bary;
|
||||
uint id;
|
||||
};
|
||||
|
||||
[shader("anyhit")] void anyhit1(inout MyPayload payload
|
||||
: SV_RayPayload,
|
||||
in MyAttributes attr
|
||||
: SV_IntersectionAttributes) {
|
||||
float3 hitLocation = ObjectRayOrigin() + ObjectRayDirection() * RayTCurrent();
|
||||
if (hitLocation.z < attr.bary.x)
|
||||
AcceptHitAndEndSearch(); // aborts function
|
||||
if (hitLocation.z < attr.bary.y)
|
||||
IgnoreHit(); // aborts function
|
||||
if (GeometryIndex() == 0) {
|
||||
payload.color += float4(0.125, 0.25, 0.5, 1.0);
|
||||
} else {
|
||||
payload.color += float4(0.2, 0.3, 0.3, 1.0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
// RUN: %dxc -T lib_6_5 -auto-binding-space 11 %s | FileCheck %s
|
||||
|
||||
// CHECK: define void [[closesthit1:@"\\01\?closesthit1@[^\"]+"]](%struct.MyPayload* noalias nocapture %payload, %struct.BuiltInTriangleIntersectionAttributes* nocapture readonly %attr) #0 {
|
||||
// CHECK: [[GeometryIndex:%[^ ]+]] = call i32 @dx.op.geometryIndex.i32(i32 203)
|
||||
// CHECK: call void @dx.op.callShader.struct.MyParam(i32 159, i32 {{.*}}, %struct.MyParam* nonnull {{.*}})
|
||||
// CHECK: %[[color:[^ ]+]] = getelementptr inbounds %struct.MyPayload, %struct.MyPayload* %payload, i32 0, i32 0
|
||||
// CHECK: store <4 x float> {{.*}}, <4 x float>* %[[color]], align 4
|
||||
// CHECK: ret void
|
||||
|
||||
struct MyPayload {
|
||||
float4 color;
|
||||
uint2 pos;
|
||||
};
|
||||
|
||||
struct MyParam {
|
||||
float2 coord;
|
||||
float4 output;
|
||||
};
|
||||
|
||||
[shader("closesthit")] void closesthit1(inout MyPayload payload
|
||||
: SV_RayPayload,
|
||||
in BuiltInTriangleIntersectionAttributes attr
|
||||
: SV_IntersectionAttributes) {
|
||||
MyParam param = {attr.barycentrics, {0, 0, 0, 0}};
|
||||
if (GeometryIndex() == 0) {
|
||||
CallShader(7, param);
|
||||
}
|
||||
payload.color += param.output;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
// RUN: %dxc -T lib_6_5 -auto-binding-space 11 %s | FileCheck %s
|
||||
|
||||
// CHECK: define void [[intersection1:@"\\01\?intersection1@[^\"]+"]]() #0 {
|
||||
// CHECK: [[rayTCurrent:%[^ ]+]] = call float @dx.op.rayTCurrent.f32(i32 154)
|
||||
// CHECK: [[GeometryIndex:%[^ ]+]] = call i32 @dx.op.geometryIndex.i32(i32 203)
|
||||
// CHECK: call i1 @dx.op.reportHit.struct.MyAttributes(i32 158, float [[rayTCurrent]], i32 0, %struct.MyAttributes* nonnull {{.*}})
|
||||
// CHECK: ret void
|
||||
|
||||
struct MyAttributes {
|
||||
float2 bary;
|
||||
uint id;
|
||||
};
|
||||
|
||||
[shader("intersection")] void intersection1() {
|
||||
float hitT = RayTCurrent();
|
||||
MyAttributes attr = (MyAttributes)0;
|
||||
if (GeometryIndex() == 0) {
|
||||
bool bReported = ReportHit(hitT, 0, attr);
|
||||
}
|
||||
}
|
|
@ -1238,7 +1238,8 @@ static const char *OpCodeSignatures[] = {
|
|||
"(rayQueryHandle)", // RayQuery_CommittedGeometryIndex
|
||||
"(rayQueryHandle)", // RayQuery_CommittedPrimitiveIndex
|
||||
"(rayQueryHandle,component)", // RayQuery_CommittedObjectRayOrigin
|
||||
"(rayQueryHandle,component)" // RayQuery_CommittedObjectRayDirection
|
||||
"(rayQueryHandle,component)", // RayQuery_CommittedObjectRayDirection
|
||||
"()" // GeometryIndex
|
||||
};
|
||||
// OPCODE-SIGS:END
|
||||
|
||||
|
|
|
@ -299,6 +299,7 @@ float [[rn]] RayTCurrent();
|
|||
uint [[rn]] PrimitiveIndex();
|
||||
uint [[rn]] InstanceID();
|
||||
uint [[rn]] InstanceIndex();
|
||||
uint [[rn]] GeometryIndex();
|
||||
uint [[rn]] HitKind();
|
||||
uint [[rn]] RayFlags();
|
||||
// group: Ray Transforms
|
||||
|
|
|
@ -332,6 +332,10 @@ class db_dxil(object):
|
|||
self.name_idx[i].category = "Raytracing object space uint System Values"
|
||||
self.name_idx[i].shader_model = 6,3
|
||||
self.name_idx[i].shader_stages = ("library","intersection","anyhit","closesthit")
|
||||
for i in "GeometryIndex".split(","):
|
||||
self.name_idx[i].category = "Raytracing object space uint System Values, raytracing tier 1.1"
|
||||
self.name_idx[i].shader_model = 6,5
|
||||
self.name_idx[i].shader_stages = ("library","intersection","anyhit","closesthit")
|
||||
for i in "HitKind".split(","):
|
||||
self.name_idx[i].category = "Raytracing hit uint System Values"
|
||||
self.name_idx[i].shader_model = 6,3
|
||||
|
@ -1689,9 +1693,13 @@ class db_dxil(object):
|
|||
db_dxil_param(3, "i8", "component", "component [0..2]",is_const=True)])
|
||||
next_op_idx += 1
|
||||
|
||||
self.add_dxil_op("GeometryIndex", next_op_idx, "GeometryIndex", "The autogenerated index of the current geometry in the bottom-level structure", "i", "rn", [
|
||||
db_dxil_param(0, "i32", "", "result")])
|
||||
next_op_idx += 1
|
||||
|
||||
# End of DXIL 1.5 opcodes.
|
||||
self.set_op_count_for_version(1, 5, next_op_idx)
|
||||
assert next_op_idx == 213, "213 is expected next operation index but encountered %d and thus opcodes are broken" % next_op_idx
|
||||
assert next_op_idx == 214, "214 is expected next operation index but encountered %d and thus opcodes are broken" % next_op_idx
|
||||
|
||||
# Set interesting properties.
|
||||
self.build_indices()
|
||||
|
|
Загрузка…
Ссылка в новой задаче