Skip to content

Commit 1ede35b

Browse files
fftzengigcbot
authored andcommitted
check if the sampler is using array resources. If not, skip
the array size boundary check for texture folding check if the sampler is using array resources. If not, skip the array size boundary check for texture folding
1 parent e1eb115 commit 1ede35b

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

IGC/Compiler/DynamicTextureFolding.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ SPDX-License-Identifier: MIT
1212
#include "common/secure_mem.h"
1313
#include "DynamicTextureFolding.h"
1414
#include "Probe/Assertion.h"
15-
1615
using namespace llvm;
1716
using namespace IGC;
1817

@@ -36,15 +35,29 @@ DynamicTextureFolding::DynamicTextureFolding() : FunctionPass(ID)
3635
void DynamicTextureFolding::FoldSingleTextureValue(CallInst& I)
3736
{
3837
ModuleMetaData* modMD = m_context->getModuleMetaData();
38+
Type* type1DArray = GetResourceDimensionType(*m_module, RESOURCE_DIMENSION_TYPE::DIM_1D_ARRAY_TYPE);
39+
Type* type2DArray = GetResourceDimensionType(*m_module, RESOURCE_DIMENSION_TYPE::DIM_2D_ARRAY_TYPE);
40+
Type* typeCubeArray = GetResourceDimensionType(*m_module, RESOURCE_DIMENSION_TYPE::DIM_CUBE_ARRAY_TYPE);
41+
bool skipBoundaryCheck = 1;
3942

4043
unsigned addrSpace = 0;
4144
if (SampleIntrinsic *sInst = dyn_cast<SampleIntrinsic>(&I))
4245
{
4346
addrSpace = sInst->getTextureValue()->getType()->getPointerAddressSpace();
47+
Type* textureType = IGCLLVM::getNonOpaquePtrEltTy(sInst->getTextureValue()->getType());
48+
if (textureType == type1DArray || textureType == type2DArray || textureType == typeCubeArray)
49+
{
50+
skipBoundaryCheck = 0;
51+
}
4452
}
4553
else if (SamplerLoadIntrinsic * lInst = dyn_cast<SamplerLoadIntrinsic>(&I))
4654
{
4755
addrSpace = lInst->getTextureValue()->getType()->getPointerAddressSpace();
56+
Type* textureType = IGCLLVM::getNonOpaquePtrEltTy(lInst->getTextureValue()->getType());
57+
if (textureType == type1DArray || textureType == type2DArray || textureType == typeCubeArray)
58+
{
59+
skipBoundaryCheck = 0;
60+
}
4861
}
4962
else
5063
{
@@ -56,15 +69,11 @@ void DynamicTextureFolding::FoldSingleTextureValue(CallInst& I)
5669
DecodeAS4GFXResource(addrSpace, directIdx, textureIndex);
5770
IRBuilder<> builder(&I);
5871
// if the current texture index is found in modMD as uniform texture, replace the texture load/sample as constant.
72+
5973
auto it = modMD->inlineDynTextures.find(textureIndex);
6074
if (it != modMD->inlineDynTextures.end())
6175
{
62-
bool skipBoundaryCheck = 0;
6376
Value* cmpInstA = nullptr;
64-
if(it->second[7]==0)
65-
{
66-
skipBoundaryCheck = 1;
67-
}
6877
if (!skipBoundaryCheck)
6978
{
7079
builder.SetInsertPoint(&I);
@@ -339,6 +348,7 @@ bool DynamicTextureFolding::doFinalization(llvm::Module& M)
339348
bool DynamicTextureFolding::runOnFunction(Function& F)
340349
{
341350
m_context = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
351+
m_module = F.getParent();
342352
visit(F);
343353
for (auto *insn : InstsToRemove)
344354
insn->eraseFromParent();

IGC/Compiler/DynamicTextureFolding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ namespace IGC
5353
void visitCallInst(llvm::CallInst& I);
5454
private:
5555
CodeGenContext* m_context = nullptr;
56+
Module* m_module = nullptr;
5657
std::unordered_map<unsigned, SResInfoFoldingOutput> m_ResInfoFoldingOutput;
5758
void FoldSingleTextureValue(llvm::CallInst& I);
5859
template<typename ContextT>

0 commit comments

Comments
 (0)