Skip to content

Commit 707ef15

Browse files
jhananitigcbot
authored andcommitted
Adding support to detect Bindless Constant Address
Adding support to get bindless constant Address
1 parent fde9e22 commit 707ef15

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

IGC/Compiler/CISACodeGen/helper.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ namespace IGC
800800
}
801801

802802
// Get constant address from load/ldraw instruction
803-
bool getConstantAddress(llvm::Instruction& I, ConstantAddress& cl, CodeGenContext* pContext, bool& directBuf, bool& statelessBuf, bool& bindlessBuf)
803+
bool getConstantAddress(llvm::Instruction& I, ConstantAddress& cl, CodeGenContext* pContext, bool& directBuf, bool& statelessBuf, bool& bindlessBuf, unsigned int& TableOffset)
804804
{
805805
// Check if the load instruction is with constant buffer address
806806
unsigned as;
@@ -828,7 +828,20 @@ namespace IGC
828828
as = ldRaw->getResourceValue()->getType()->getPointerAddressSpace();
829829
ptrVal = ldRaw->getResourceValue();
830830
offsetVal = ldRaw->getOffsetValue();
831-
bindlessBuf = (DecodeBufferType(as) == SSH_BINDLESS_CONSTANT_BUFFER);
831+
bindlessBuf = (DecodeBufferType(as) == SSH_BINDLESS_CONSTANT_BUFFER) ||
832+
(DecodeBufferType(as) == BINDLESS_CONSTANT_BUFFER);
833+
if (IntToPtrInst* ptrToInt = dyn_cast<IntToPtrInst>(ptrVal))
834+
{
835+
if (Instruction* instr = dyn_cast<Instruction>(ptrToInt->getOperand(0)))
836+
{
837+
if (instr->getOpcode() == Instruction::Add &&
838+
isa<ConstantInt>(instr->getOperand(1)))
839+
{
840+
ConstantInt* src1 = cast<ConstantInt>(instr->getOperand(1));
841+
TableOffset = int_cast<unsigned int>(src1->getZExtValue()) >> pContext->platform.getBSOLocInExtDescriptor();
842+
}
843+
}
844+
}
832845
}
833846
else
834847
return false;
@@ -858,6 +871,14 @@ namespace IGC
858871
break;
859872
}
860873
}
874+
for (unsigned int& runtimeValueIndex : pushInfo.bindlessPushInfo)
875+
{
876+
if (bufIdOrGRFOffset == runtimeValueIndex)
877+
{
878+
isPushableAddr = true;
879+
break;
880+
}
881+
}
861882
}
862883
}
863884
else

IGC/Compiler/CISACodeGen/helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ namespace IGC
162162
bool GetStatelessBufferInfo(llvm::Value* pointer, unsigned& bufIdOrGRFOffset, IGC::BufferType& bufferTy, llvm::Value*& bufferSrcPtr, bool& isDirectBuf);
163163
// try to evaluate the address if it is constant.
164164
bool EvalConstantAddress(llvm::Value* address, unsigned int& offset, const llvm::DataLayout* pDL, llvm::Value* ptrSrc = nullptr);
165-
bool getConstantAddress(llvm::Instruction& I, ConstantAddress& cl, CodeGenContext* pContext, bool& directBuf, bool& statelessBuf, bool& bindlessBuf);
165+
bool getConstantAddress(llvm::Instruction& I, ConstantAddress& cl, CodeGenContext* pContext, bool& directBuf, bool& statelessBuf, bool& bindlessBuf, unsigned int& TableOffset);
166166

167167

168168
bool isSampleLoadGather4InfoInstruction(llvm::Instruction* inst);

IGC/Compiler/CustomSafeOptPass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3113,8 +3113,8 @@ Constant* IGCConstProp::replaceShaderConstant(Instruction* inst)
31133113
bool directBuf = false;
31143114
bool statelessBuf = false;
31153115
bool bindlessBuf = false;
3116-
3117-
if (getConstantAddress(*inst, cl, ctx, directBuf, statelessBuf, bindlessBuf))
3116+
unsigned int tableOffset = 0;
3117+
if (getConstantAddress(*inst, cl, ctx, directBuf, statelessBuf, bindlessBuf, tableOffset))
31183118
{
31193119
if (size_in_bytes)
31203120
{

IGC/common/MDFrameWork.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ namespace IGC
386386
std::vector<StatelessPushInfo> pushableAddresses;
387387

388388
// Indices of RuntimeValues that can be used to compute surface state
389-
// offsets for the bindless push.
389+
// offsets for the bindless push along with the Descriptor Table Offset.
390390
std::vector<unsigned int> bindlessPushInfo;
391391

392392
// Dynamic buffer offsets info.

0 commit comments

Comments
 (0)