Skip to content

Commit 4f5109c

Browse files
JaroszPiotrigcbot
authored andcommitted
AnyHit does not fill u, v and hit info in CommittedHit
If AnyHit shaders directly invokes ClosestHit shader, CommittedHit has to be manually filled with the data from PotentialHit. Copying u, v and HitInfo (3rd dword) was missing.
1 parent 5073c83 commit 4f5109c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

IGC/AdaptorCommon/RayTracing/LowerIntersectionAnyHit.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ class LowerIntersectionAnyHit : public ModulePass
102102
RTBuilder& IRB,
103103
RTBuilder::StackPointerVal* StackPointer,
104104
Value* THit,
105+
Value* PotentialHitU,
106+
Value* PotentialHitV,
107+
Value* PotentialHitInfo,
105108
Value* PotentialPrimVal,
106109
Value* PotentialInstVal);
107110
void injectExitCode(
@@ -168,6 +171,9 @@ void LowerIntersectionAnyHit::initializeCommittedHit(
168171
RTBuilder &IRB,
169172
RTBuilder::StackPointerVal* StackPointer,
170173
Value* THit,
174+
Value* PotentialHitU,
175+
Value* PotentialHitV,
176+
Value* PotentialHitInfo,
171177
Value* PotentialPrimVal,
172178
Value* PotentialInstVal)
173179
{
@@ -179,6 +185,15 @@ void LowerIntersectionAnyHit::initializeCommittedHit(
179185
//stack->committedHit.instLeafPtr = stack->potentialHit.instLeafPtr;
180186
//stack->committedHit.hitGroupRecPtr1 = stack->potentialHit.hitGroupRecPtr1;
181187
IRB.setCommittedHitTopInstLeafPtr(StackPointer, PotentialInstVal);
188+
189+
//stack->committedHit.u = stack->potentialHit.u;
190+
IRB.setHitBaryCentric(StackPointer, PotentialHitU, CallableShaderTypeMD::ClosestHit, 0);
191+
192+
//stack->committedHit.v = stack->potentialHit.v;
193+
IRB.setHitBaryCentric(StackPointer, PotentialHitV, CallableShaderTypeMD::ClosestHit, 1);
194+
195+
//stack->committedHit.'hitInfoDword' = stack->potentialHit.'hitInfoDword';
196+
IRB.setHitInfoDWord(StackPointer, CallableShaderTypeMD::ClosestHit, PotentialHitInfo);
182197
}
183198

184199
Value* LowerIntersectionAnyHit::isClosestHitNull(
@@ -345,11 +360,18 @@ void LowerIntersectionAnyHit::injectExitCode(
345360
StackPointer, CallableShaderTypeMD::AnyHit);
346361
Value* PotentialInstVal = IRB.getPotentialHitTopInstLeafPtr(StackPointer);
347362

363+
Value* PotentialHitU = IRB.getHitBaryCentric(StackPointer, CallableShaderTypeMD::AnyHit, 0);
364+
Value* PotentialHitV = IRB.getHitBaryCentric(StackPointer, CallableShaderTypeMD::AnyHit, 1);
365+
Value* PotentialHitInfo = IRB.getHitInfoDWord(StackPointer, CallableShaderTypeMD::AnyHit);
366+
348367
auto InitForCHS = [=](RTBuilder& IRB) {
349368
initializeCommittedHit(
350369
IRB,
351370
StackPointer,
352371
RayTFar,
372+
PotentialHitU,
373+
PotentialHitV,
374+
PotentialHitInfo,
353375
PotentialPrimVal,
354376
PotentialInstVal);
355377
};
@@ -547,12 +569,20 @@ CallInst* LowerIntersectionAnyHit::codeGenReportHit(
547569
IRB.SetInsertPoint(TermTrueBB);
548570
Value* PotentialPrimVal = IRB.getHitTopOfPrimLeafPtr(
549571
StackPointer, CallableShaderTypeMD::AnyHit);
572+
550573
Value* PotentialInstVal = IRB.getPotentialHitTopInstLeafPtr(StackPointer);
574+
Value* PotentialHitU = IRB.getHitBaryCentric(StackPointer, CallableShaderTypeMD::AnyHit, 0);
575+
Value* PotentialHitV = IRB.getHitBaryCentric(StackPointer, CallableShaderTypeMD::AnyHit, 1);
576+
Value* PotentialHitInfo = IRB.getHitInfoDWord(StackPointer, CallableShaderTypeMD::AnyHit);
577+
551578
auto InitForCHS = [=](RTBuilder& IRB) {
552579
initializeCommittedHit(
553580
IRB,
554581
StackPointer,
555582
RHI->getTHit(),
583+
PotentialHitU,
584+
PotentialHitV,
585+
PotentialHitInfo,
556586
PotentialPrimVal,
557587
PotentialInstVal);
558588
};

0 commit comments

Comments
 (0)