Skip to content

Commit ca4c69c

Browse files
committed
address Tex
1 parent b7dab0d commit ca4c69c

4 files changed

Lines changed: 38 additions & 5 deletions

File tree

include/dxc/HLSL/HLOperations.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ const unsigned kAnnotateHandleResourceTypeOpIdx = 3;
398398
const unsigned kTraceRayRayDescOpIdx = 7;
399399
const unsigned kTraceRayPayLoadOpIdx = 8;
400400

401+
// AllocateRayQuery
402+
const unsigned kAllocateRayQueryRayFlagsIdx = 1;
403+
const unsigned kAllocateRayQueryRayQueryFlagsIdx = 2;
404+
401405
// CallShader.
402406
const unsigned kCallShaderPayloadOpIdx = 2;
403407

lib/HLSL/HLOperationLower.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5674,16 +5674,20 @@ Value *TranslateAllocateRayQuery(CallInst *CI, IntrinsicOp IOP,
56745674
DXASSERT(CI->getNumArgOperands() == 3,
56755675
"hlopcode for allocaterayquery always expects 3 arguments");
56765676

5677-
llvm::Value *Arg = CI->getOperand(2);
5677+
llvm::Value *Arg =
5678+
CI->getArgOperand(HLOperandIndex::kAllocateRayQueryRayQueryFlagsIdx);
56785679
llvm::ConstantInt *ConstVal = llvm::dyn_cast<llvm::ConstantInt>(Arg);
56795680
DXASSERT(ConstVal,
56805681
"2nd argument to allocaterayquery must always be a constant value");
56815682
if (ConstVal->getValue().getZExtValue() != 0) {
5682-
Value *refArgs[3] = {nullptr, CI->getOperand(1), CI->getOperand(2)};
5683+
Value *refArgs[3] = {
5684+
nullptr, CI->getOperand(HLOperandIndex::kAllocateRayQueryRayFlagsIdx),
5685+
CI->getOperand(HLOperandIndex::kAllocateRayQueryRayQueryFlagsIdx)};
56835686
opcode = OP::OpCode::AllocateRayQuery2;
56845687
return TrivialDxilOperation(opcode, refArgs, helper.voidTy, CI, hlslOP);
56855688
}
5686-
Value *refArgs[2] = {nullptr, CI->getOperand(1)};
5689+
Value *refArgs[2] = {
5690+
nullptr, CI->getOperand(HLOperandIndex::kAllocateRayQueryRayFlagsIdx)};
56875691
return TrivialDxilOperation(opcode, refArgs, helper.voidTy, CI, hlslOP);
56885692
}
56895693

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %dxc -T lib_6_9 -fcgl %s | FileCheck %s
2+
3+
// CHECK: %"class.RayQuery<1024, 1>" = type { i32 }
4+
// CHECK: %"class.RayQuery<1, 0>" = type { i32 }
5+
6+
7+
8+
9+
RaytracingAccelerationStructure RTAS;
10+
// DXR entry point to ensure RDAT flags match during validation.
11+
[shader("vertex")]
12+
void main(RayDesc rayDesc : RAYDESC) {
13+
14+
// CHECK: alloca %"class.RayQuery<1024, 1>", align 4
15+
// CHECK: alloca %"class.RayQuery<1, 0>", align 4
16+
17+
// CHECK: call i32 @"dx.hl.op..i32 (i32, i32, i32)"(i32 [[ARQ:[0-9]*]], i32 1024, i32 1)
18+
RayQuery<RAY_FLAG_FORCE_OMM_2_STATE, RAYQUERY_FLAG_ALLOW_OPACITY_MICROMAPS> rayQuery1;
19+
20+
rayQuery1.TraceRayInline(RTAS, RAY_FLAG_FORCE_OMM_2_STATE, 2, rayDesc);
21+
22+
// CHECK: call i32 @"dx.hl.op..i32 (i32, i32, i32)"(i32 [[ARQ]], i32 1, i32 0)
23+
RayQuery<RAY_FLAG_FORCE_OPAQUE> rayQuery2;
24+
rayQuery2.TraceRayInline(RTAS, 0, 2, rayDesc);
25+
}

tools/clang/test/CodeGenHLSL/allocateRayQuery2.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ RaytracingAccelerationStructure RTAS;
55
[shader("vertex")]
66
void main(RayDesc rayDesc : RAYDESC) {
77

8-
// CHECK: call i32 @dx.op.allocateRayQuery2(i32 258, i32 1024, i32 1) ; AllocateRayQuery2(constRayFlags,constRayQueryFlags)
8+
// CHECK: call i32 @dx.op.allocateRayQuery2(i32 258, i32 1024, i32 1)
99
RayQuery<RAY_FLAG_FORCE_OMM_2_STATE, RAYQUERY_FLAG_ALLOW_OPACITY_MICROMAPS> rayQuery1;
1010

1111
rayQuery1.TraceRayInline(RTAS, RAY_FLAG_FORCE_OMM_2_STATE, 2, rayDesc);
1212

13-
// CHECK: call i32 @dx.op.allocateRayQuery(i32 178, i32 1) ; AllocateRayQuery(constRayFlags)
13+
// CHECK: call i32 @dx.op.allocateRayQuery(i32 178, i32 1)
1414
RayQuery<RAY_FLAG_FORCE_OPAQUE> rayQuery2;
1515
rayQuery2.TraceRayInline(RTAS, 0, 2, rayDesc);
1616
}

0 commit comments

Comments
 (0)