Skip to content

Commit 282fbcc

Browse files
jhananitigcbot
authored andcommitted
Adding support to detect Bindless Constant Address
Adding support to detect Bindless Constant Address
1 parent 756595a commit 282fbcc

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

IGC/Compiler/CISACodeGen/helper.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ namespace IGC
846846
}
847847

848848
// Get constant address from load/ldraw instruction
849-
bool getConstantAddress(llvm::Instruction& I, ConstantAddress& cl, CodeGenContext* pContext, bool& directBuf, bool& statelessBuf, bool& bindlessBuf)
849+
bool getConstantAddress(llvm::Instruction& I, ConstantAddress& cl, CodeGenContext* pContext, bool& directBuf, bool& statelessBuf, bool& bindlessBuf, unsigned int& TableOffset)
850850
{
851851
// Check if the load instruction is with constant buffer address
852852
unsigned as;
@@ -874,7 +874,23 @@ namespace IGC
874874
as = ldRaw->getResourceValue()->getType()->getPointerAddressSpace();
875875
ptrVal = ldRaw->getResourceValue();
876876
offsetVal = ldRaw->getOffsetValue();
877-
bindlessBuf = (DecodeBufferType(as) == SSH_BINDLESS_CONSTANT_BUFFER);
877+
bindlessBuf = (DecodeBufferType(as) == SSH_BINDLESS_CONSTANT_BUFFER) ||
878+
(DecodeBufferType(as) == BINDLESS_CONSTANT_BUFFER);
879+
if (bindlessBuf)
880+
{
881+
if (IntToPtrInst* ptrToInt = dyn_cast<IntToPtrInst>(ptrVal))
882+
{
883+
if (Instruction* instr = dyn_cast<Instruction>(ptrToInt->getOperand(0)))
884+
{
885+
if (instr->getOpcode() == Instruction::Add &&
886+
isa<ConstantInt>(instr->getOperand(1)))
887+
{
888+
ConstantInt* src1 = cast<ConstantInt>(instr->getOperand(1));
889+
TableOffset = int_cast<unsigned int>(src1->getZExtValue()) >> pContext->platform.getBSOLocInExtDescriptor();
890+
}
891+
}
892+
}
893+
}
878894
}
879895
else
880896
return false;

IGC/Compiler/CISACodeGen/helper.h

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

168168

169169
bool isSampleLoadGather4InfoInstruction(const llvm::Instruction* inst);

IGC/Compiler/CustomSafeOptPass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3408,8 +3408,8 @@ Constant* IGCConstProp::replaceShaderConstant(Instruction* inst)
34083408
bool directBuf = false;
34093409
bool statelessBuf = false;
34103410
bool bindlessBuf = false;
3411-
3412-
if (getConstantAddress(*inst, cl, ctx, directBuf, statelessBuf, bindlessBuf))
3411+
unsigned int tableOffset = 0;
3412+
if (getConstantAddress(*inst, cl, ctx, directBuf, statelessBuf, bindlessBuf, tableOffset))
34133413
{
34143414
if (size_in_bytes)
34153415
{

IGC/common/MDFrameWork.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,10 @@ namespace IGC
293293
unsigned int eltId = 0;
294294
unsigned int size = 0;
295295
};
296-
296+
struct ConstantAddressDescriptorTable : ConstantAddress
297+
{
298+
unsigned int tableOffset = 0;
299+
};
297300
bool operator < (const ConstantAddress &a, const ConstantAddress &b);
298301

299302
//to hold metadata of every function
@@ -303,7 +306,6 @@ namespace IGC
303306
WorkGroupWalkOrderMD workGroupWalkOrder;
304307
std::vector<FuncArgMD> funcArgs;
305308
FunctionTypeMD functionType = KernelFunction;
306-
std::map<ConstantAddress, uint32_t> inlineDynConstants;
307309
RayTraceShaderInfo rtInfo;
308310
ResourceAllocMD resAllocMD;
309311
std::vector<unsigned> maxByteOffsets;
@@ -531,7 +533,7 @@ namespace IGC
531533
std::vector<StatelessPushInfo> pushableAddresses;
532534

533535
// Indices of RuntimeValues that can be used to compute surface state
534-
// offsets for the bindless push.
536+
// offsets for the bindless push along with the Descriptor Table Offset.
535537
std::vector<unsigned int> bindlessPushInfo;
536538

537539
// Dynamic buffer offsets info.
@@ -597,6 +599,7 @@ namespace IGC
597599

598600
struct SPIRVCapabilities
599601
{
602+
600603
bool globalVariableDecorationsINTEL = false;
601604
};
602605

0 commit comments

Comments
 (0)