Skip to content

Commit

Permalink
Add getPrimitiveIndexDelta
Browse files Browse the repository at this point in the history
Add getPrimitiveIndexDelta and minor refactor.
  • Loading branch information
JaroszPiotr authored and igcbot committed Nov 26, 2024
1 parent 7456319 commit ef7a1aa
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
10 changes: 10 additions & 0 deletions IGC/AdaptorCommon/RayTracing/AutoGenRTStackAccessPrivateOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,16 @@ auto* _getGeometryIndex_Xe(Value* arg_0, Value* arg_1, Value* arg_2, const Twine
return V_18;
}

auto* _getPrimitiveIndexDelta_Xe(Value* arg_0, Value* arg_1, const Twine& _ReturnName = "")
{
auto* V_2 = CreateInBoundsGEP(_struct_RTStackFormat__RTStack(*Ctx.getModule()), arg_0, { getInt64(0), getInt32(0), getInt32(3) });
auto* V_3 = CreateInBoundsGEP(_struct_RTStackFormat__RTStack(*Ctx.getModule()), arg_0, { getInt64(0), getInt32(1), getInt32(3) });
auto* V_4 = CreateSelect(arg_1, V_2, V_3);
auto* V_5 = CreateLoad(getInt32Ty(), V_4);
auto* V_6 = CreateAnd(V_5, getInt32(65535), _ReturnName);
return V_6;
}

void _createPotentialHit2CommittedHit_Xe(Value* arg_0)
{
auto* V_1 = CreateInBoundsGEP(_struct_RTStackFormat__RTStack(*Ctx.getModule()), arg_0, { getInt64(0), getInt32(1), getInt32(0) });
Expand Down
33 changes: 17 additions & 16 deletions IGC/AdaptorCommon/RayTracing/RTBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ using namespace llvm;
using namespace RTStackFormat;
using namespace IGC;


namespace {
class VAdapt
{
Expand Down Expand Up @@ -871,11 +872,11 @@ Value* RTBuilder::getPrimitiveIndex(
}
}

PHINode* RTBuilder::getPrimitiveIndex(
Value* RTBuilder::getPrimitiveIndex(
RTBuilder::StackPointerVal* perLaneStackPtr, Value* leafType, bool Committed)
{
switch (getMemoryStyle())
{
switch (getMemoryStyle())
{
#define STYLE(X) \
case RTMemoryStyle::X: \
return _getPrimitiveIndex_##X( \
Expand All @@ -885,11 +886,12 @@ PHINode* RTBuilder::getPrimitiveIndex(
VALUE_NAME("primitiveIndex"));
#include "RayTracingMemoryStyle.h"
#undef STYLE
}
IGC_ASSERT(0);
return {};
}
IGC_ASSERT(0);
return nullptr;
}


Value* RTBuilder::getGeometryIndex(
RTBuilder::StackPointerVal* perLaneStackPtr,
Instruction* I,
Expand All @@ -904,37 +906,36 @@ Value* RTBuilder::getGeometryIndex(
auto [ValidBB, PN] =
validateInstanceLeafPtr(perLaneStackPtr, I, (ShaderTy == CallableShaderTypeMD::ClosestHit));
this->SetInsertPoint(ValidBB->getTerminator());
Value* validGeomIndex = getGeometryIndex(perLaneStackPtr, &*BB->rbegin(), leafType, ShaderTy);
Value* validGeomIndex = getGeometryIndex(perLaneStackPtr, leafType, ShaderTy == CallableShaderTypeMD::ClosestHit);
PN->addIncoming(validGeomIndex, getUnsetPhiBlock(PN));
this->SetInsertPoint(I);
return PN;
}
else
{
return getGeometryIndex(perLaneStackPtr, I, leafType, ShaderTy);
return getGeometryIndex(perLaneStackPtr, leafType, ShaderTy == CallableShaderTypeMD::ClosestHit);
}
}

Value* RTBuilder::getGeometryIndex(
RTBuilder::StackPointerVal* perLaneStackPtr,
Instruction* I,
Value* leafType,
IGC::CallableShaderTypeMD ShaderTy)
bool committed)
{
switch (getMemoryStyle())
{
switch (getMemoryStyle())
{
#define STYLE(X) \
case RTMemoryStyle::X: \
return _getGeometryIndex_##X( \
perLaneStackPtr, \
leafType, \
VAdapt{ *this, ShaderTy == ClosestHit }, \
VAdapt{ *this, committed }, \
VALUE_NAME("geometryIndex"));
#include "RayTracingMemoryStyle.h"
#undef STYLE
}
IGC_ASSERT(0);
return {};
}
IGC_ASSERT(0);
return nullptr;
}

Value* RTBuilder::getInstanceContributionToHitGroupIndex(
Expand Down
5 changes: 3 additions & 2 deletions IGC/AdaptorCommon/RayTracing/RTBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class RTBuilder : public IGCIRBuilder<>
//TODO: this is hardcoded string, we might want to put all "printf" of different adaptors to one place eventually
static constexpr char *PrintfFuncName = "printf";


bool isChildOfXe2 = false;

// Field for explicit GlobalBufferPtr - used on OpenCL path.
Expand Down Expand Up @@ -400,8 +401,8 @@ class RTBuilder : public IGCIRBuilder<>
Value* getRTStackSize(uint32_t Align);
SyncStackPointerVal* getSyncStackPointer(Value* syncStackOffset, RTBuilder::RTMemoryAccessMode Mode);
Value* getGeometryIndex(
StackPointerVal* perLaneStackPtr, Instruction* I, Value* leafType, IGC::CallableShaderTypeMD ShaderTy);
PHINode* getPrimitiveIndex(
StackPointerVal* perLaneStackPtr, Value* leafType, bool committed);
Value* getPrimitiveIndex(
StackPointerVal* perLaneStackPtr, Value* leafType, bool Committed);
Value* getInstanceIndex(
StackPointerVal* perLaneStackPtr, IGC::CallableShaderTypeMD ShaderTy);
Expand Down

0 comments on commit ef7a1aa

Please sign in to comment.