Skip to content

Commit 7aee973

Browse files
jaladreipsigcbot
authored andcommitted
Modify RTBuilder functions to accept non-compile-time shader type
Modify RTBuilder functions to accept non-compile-time shader type
1 parent 3d77d82 commit 7aee973

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

IGC/AdaptorCommon/RayTracing/RTBuilder.cpp

+2-26
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ Value* RTBuilder::getPrimitiveIndex(
888888
Value* ShaderTy,
889889
bool checkInstanceLeafPtr)
890890
{
891-
if (checkInstanceLeafPtr)
891+
if (checkInstanceLeafPtr && IGC_IS_FLAG_ENABLED(ForceRTCheckInstanceLeafPtr))
892892
{
893893
auto [ValidBB, PN] =
894894
validateInstanceLeafPtr(perLaneStackPtr, I, CreateICmpEQ(ShaderTy, getInt32(CallableShaderTypeMD::ClosestHit)));
@@ -904,30 +904,6 @@ Value* RTBuilder::getPrimitiveIndex(
904904
}
905905
}
906906

907-
static Value* skipIfShaderIsNotHit(RTBuilder& IRB, Value* ShaderTy, std::function<Value* ()> Fn)
908-
{
909-
auto* isHit = IRB.CreateOr({
910-
IRB.CreateICmpEQ(ShaderTy, IRB.getInt32(CallableShaderTypeMD::ClosestHit)),
911-
IRB.CreateICmpEQ(ShaderTy, IRB.getInt32(CallableShaderTypeMD::AnyHit)),
912-
IRB.CreateICmpEQ(ShaderTy, IRB.getInt32(CallableShaderTypeMD::Intersection)),
913-
});
914-
915-
auto [isHitBB, joinBB] = IRB.createTriangleFlow(isHit, &*IRB.GetInsertPoint(), VALUE_NAME("skipIfShaderIsNotHit_isHitBB"), VALUE_NAME("skipIfShaderIsNotHit_joinBB"));
916-
917-
IRB.SetInsertPoint(isHitBB);
918-
auto* retV = Fn();
919-
920-
IRB.SetInsertPoint(isHitBB->getSinglePredecessor());
921-
auto* defaultV = IRB.CreateZExtOrBitCast(IRB.getInt1(0), retV->getType());
922-
923-
IRB.SetInsertPoint(joinBB);
924-
auto* phiV = IRB.CreatePHI(retV->getType(), 2);
925-
phiV->addIncoming(retV, isHitBB);
926-
phiV->addIncoming(defaultV, isHitBB->getSinglePredecessor());
927-
928-
return phiV;
929-
}
930-
931907
Value* RTBuilder::getPrimitiveIndex(
932908
RTBuilder::StackPointerVal* perLaneStackPtr, Value* leafType, Value* ShaderTy)
933909
{
@@ -955,7 +931,7 @@ Value* RTBuilder::getGeometryIndex(
955931
Value* ShaderTy,
956932
bool checkInstanceLeafPtr)
957933
{
958-
if (checkInstanceLeafPtr)
934+
if (checkInstanceLeafPtr && IGC_IS_FLAG_ENABLED(ForceRTCheckInstanceLeafPtr))
959935
{
960936
auto [ValidBB, PN] =
961937
validateInstanceLeafPtr(perLaneStackPtr, I, CreateICmpEQ(ShaderTy, getInt32(CallableShaderTypeMD::ClosestHit)));

0 commit comments

Comments
 (0)