Skip to content

Commit

Permalink
Skip stateless to bindless promotion in 'bindless-advanced-mode' if …
Browse files Browse the repository at this point in the history
…implicit arg not found

In 'bindless-advanced-mode', there must be a corresponding implicit arg BINDLESS_OFFSET for every explicit buffer arg in order for it to be promoted to bindless.
This change checks if this implcit arg exists, and skip promotion if we can't find it.
  • Loading branch information
dlei6g authored and igcbot committed Sep 25, 2023
1 parent 6599396 commit 0d6a129
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
14 changes: 14 additions & 0 deletions IGC/AdaptorCommon/ImplicitArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,20 @@ bool ImplicitArgs::isImplicitArgExist(
return isImplicitArgExist(pMdUtils->getFunctionsInfoItem(&F), argType);
}

bool ImplicitArgs::isImplicitArgExistForNumberedArg(ImplicitArg::ArgType argType, int argNum) const {
IGC_ASSERT_MESSAGE((argNum >= 0), "objectNum cannot be less than 0");

for (int i = 0, e = m_funcInfoMD->size_ImplicitArgInfoList(); i < e; ++i)
{
ArgInfoMetaDataHandle argInfo = m_funcInfoMD->getImplicitArgInfoListItem(i);
if (argInfo->getArgId() == argType && argInfo->getExplicitArgNum() == argNum)
{
return true;
}
}
return false;
}

unsigned int ImplicitArgs::getImageArgIndex(ImplicitArg::ArgType argType, const Argument* image) const {
IGC_ASSERT_MESSAGE(isImplicitImage(argType), "Non image/sampler implicit arg!");
return getNumberedArgIndex(argType, image->getArgNo());
Expand Down
7 changes: 7 additions & 0 deletions IGC/AdaptorCommon/ImplicitArgs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ namespace IGC
/// @return The implicit argument's index for a given argument type
unsigned int getNumberedArgIndex(ImplicitArg::ArgType argType, int argNum) const;

/// @brief Returns if an implicit arg exists for the given explicit argument
/// based on the argument type and argument number
/// @param argType The implicit argument type
/// (height/width/depth for images, normalized/address/snapwa for samplers)
/// @param argNum The explicit argument number of the type
bool isImplicitArgExistForNumberedArg(ImplicitArg::ArgType argType, int argNum) const;

/// @brief Returns the argument type of the argument at the given index
/// @param i The implicit argument index
/// @return The argument type of the argument at the given index
Expand Down
10 changes: 9 additions & 1 deletion IGC/Compiler/PromoteStatelessToBindless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,17 @@ void PromoteStatelessToBindless::PromoteStatelessToBindlessBuffers(Function& F)
// Do this only for legacy mode, since the resource type of the original
// kernel arg needs to be bindless for it to be reinterpreted as a bindless offset.
// In advanced mode, always keep the original kernel arg as stateless, and use the
// IMPLICIT_BUFFER_OFFSET arg for bindless access.
// BINDLESS_OFFSET arg for bindless access.
argInfo->type = ResourceTypeEnum::BindlessUAVResourceType;
}
else
{
// In advanced mode, there must be a corresponding implicit arg BINDLESS_OFFSET for every
// explicit buffer arg for it to be promoted to bindless. Check if this implcit arg exists,
// and skip promotion if we can't find it.
if (!implicitArgs.isImplicitArgExistForNumberedArg(ImplicitArg::BINDLESS_OFFSET, srcPtr->getArgNo()))
continue;
}

if (supportDynamicBTIsAllocation)
{
Expand Down

0 comments on commit 0d6a129

Please sign in to comment.