Skip to content

Commit

Permalink
Implement dedicated logic for handling discards in DynamicRayManagem…
Browse files Browse the repository at this point in the history
…entPass

Implement dedicated logic for handling discards in DynamicRayManagementPass
  • Loading branch information
jaladreips authored and igcbot committed Dec 17, 2024
1 parent 9f4f28c commit 9f32f88
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
15 changes: 14 additions & 1 deletion IGC/AdaptorCommon/RayTracing/DynamicRayManagementPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ bool DynamicRayManagementPass::requiresSplittingCheckReleaseRegion(Instruction&
return
isa<ContinuationHLIntrinsic>(I) ||
isBarrierIntrinsic(&I) ||
isUserFunctionCall(&I);
isUserFunctionCall(&I) ||
isDiscardInstruction(&I);
}

void DynamicRayManagementPass::FindProceedsInOperands(Instruction* I, SetVector<TraceRaySyncProceedHLIntrinsic*>& proceeds, SmallPtrSetImpl<Instruction*>& cache)
Expand Down Expand Up @@ -993,6 +994,18 @@ void DynamicRayManagementPass::HandleComplexControlFlow(Function& F)
break;
}

if (isDiscardInstruction(&I) && !m_CGCtx->platform.allowDivergentControlFlowRayQueryCheckRelease())
{
rayQueryReleaseIntrinsic->eraseFromParent();
rayQueryCheckIntrinsic->eraseFromParent();

// Remove the pair from the vector in case more Barriers or External
// calls are between them.
m_RayQueryCheckReleasePairs.erase(m_RayQueryCheckReleasePairs.begin() + rayQueryCheckReleasePairIndex);

break;
}

// The barrier/call instruction is within the RayQueryCheck-Release pair.
// Insert RayQueryRelease before it, and RaytQueryCheck after, to re-enable
// Dynamic Ray Management.
Expand Down
5 changes: 5 additions & 0 deletions IGC/Compiler/CISACodeGen/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,11 @@ namespace IGC
return isUserFunction;
}

bool isDiscardInstruction(const llvm::Instruction* I)
{
return isa<GenIntrinsicInst>(I) && cast<GenIntrinsicInst>(I)->getIntrinsicID() == GenISAIntrinsic::GenISA_discard;
}

bool isURBWriteIntrinsic(const llvm::Instruction* I)
{
const GenIntrinsicInst* GII = dyn_cast<GenIntrinsicInst>(I);
Expand Down
2 changes: 2 additions & 0 deletions IGC/Compiler/CISACodeGen/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ namespace IGC

bool isUserFunctionCall(const llvm::Instruction* I);

bool isDiscardInstruction(const llvm::Instruction* I);

bool IsMemLoadIntrinsic(llvm::GenISAIntrinsic::ID id);

bool IsStatelessMemLoadIntrinsic(llvm::GenISAIntrinsic::ID id);
Expand Down

0 comments on commit 9f32f88

Please sign in to comment.