@@ -12,7 +12,6 @@ SPDX-License-Identifier: MIT
12
12
#include " common/secure_mem.h"
13
13
#include " DynamicTextureFolding.h"
14
14
#include " Probe/Assertion.h"
15
-
16
15
using namespace llvm ;
17
16
using namespace IGC ;
18
17
@@ -36,15 +35,29 @@ DynamicTextureFolding::DynamicTextureFolding() : FunctionPass(ID)
36
35
void DynamicTextureFolding::FoldSingleTextureValue (CallInst& I)
37
36
{
38
37
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 ;
39
42
40
43
unsigned addrSpace = 0 ;
41
44
if (SampleIntrinsic *sInst = dyn_cast<SampleIntrinsic>(&I))
42
45
{
43
46
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
+ }
44
52
}
45
53
else if (SamplerLoadIntrinsic * lInst = dyn_cast<SamplerLoadIntrinsic>(&I))
46
54
{
47
55
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
+ }
48
61
}
49
62
else
50
63
{
@@ -56,15 +69,11 @@ void DynamicTextureFolding::FoldSingleTextureValue(CallInst& I)
56
69
DecodeAS4GFXResource (addrSpace, directIdx, textureIndex);
57
70
IRBuilder<> builder (&I);
58
71
// if the current texture index is found in modMD as uniform texture, replace the texture load/sample as constant.
72
+
59
73
auto it = modMD->inlineDynTextures .find (textureIndex);
60
74
if (it != modMD->inlineDynTextures .end ())
61
75
{
62
- bool skipBoundaryCheck = 0 ;
63
76
Value* cmpInstA = nullptr ;
64
- if (it->second [7 ]==0 )
65
- {
66
- skipBoundaryCheck = 1 ;
67
- }
68
77
if (!skipBoundaryCheck)
69
78
{
70
79
builder.SetInsertPoint (&I);
@@ -339,6 +348,7 @@ bool DynamicTextureFolding::doFinalization(llvm::Module& M)
339
348
bool DynamicTextureFolding::runOnFunction (Function& F)
340
349
{
341
350
m_context = getAnalysis<CodeGenContextWrapper>().getCodeGenContext ();
351
+ m_module = F.getParent ();
342
352
visit (F);
343
353
for (auto *insn : InstsToRemove)
344
354
insn->eraseFromParent ();
0 commit comments