@@ -116,6 +116,36 @@ unsigned int KernelArg::calcElemAllocateSize(const Argument* arg, const DataLayo
116
116
return int_cast<unsigned int >(DL->getTypeAllocSize (arg->getType ()->getScalarType ()));
117
117
}
118
118
119
+ // First member of pair is ArgType of buffer.
120
+ // When ArgType is SAMPLER, second member should be true.
121
+ // When ArgType is NOT_TO_ALLOCATE, second member should be false.
122
+ // ArgType enum uses same values for SAMPLER and NOT_TO_ALLOCATE.
123
+ // This function helps disambiguate between the two values.
124
+ KernelArg::BufferArgType KernelArg::getBufferType (const Argument* arg, const StringRef typeStr)
125
+ {
126
+ if (arg->getType ()->getTypeID () != Type::PointerTyID)
127
+ return { KernelArg::ArgType::SAMPLER, true };
128
+
129
+ PointerType* ptrType = cast<PointerType>(arg->getType ());
130
+
131
+ int address_space = ptrType->getPointerAddressSpace ();
132
+ bool directIdx = false ;
133
+ unsigned int bufId = 0 ;
134
+ BufferType bufType = DecodeAS4GFXResource (address_space, directIdx, bufId);
135
+
136
+ // Check if this arg is an image
137
+ if (bufType == BufferType::UAV)
138
+ {
139
+ ArgType imgArgType;
140
+ // Check if argument is image
141
+ if (isImage (arg, typeStr, imgArgType)) return { imgArgType, false };
142
+ }
143
+ else if (bufType == BufferType::SAMPLER)
144
+ return { KernelArg::ArgType::SAMPLER, true };
145
+
146
+ return { KernelArg::ArgType::NOT_TO_ALLOCATE, false };
147
+ }
148
+
119
149
KernelArg::ArgType KernelArg::calcArgType (const Argument* arg, const StringRef typeStr)
120
150
{
121
151
switch (arg->getType ()->getTypeID ())
@@ -185,22 +215,7 @@ KernelArg::ArgType KernelArg::calcArgType(const Argument* arg, const StringRef t
185
215
IGC_ASSERT_MESSAGE(0, "Unrecognized address space");
186
216
#endif
187
217
// This is a buffer. Try to decode this
188
- int address_space = ptrType->getPointerAddressSpace ();
189
- bool directIdx = false ;
190
- unsigned int bufId = 0 ;
191
- BufferType bufType = DecodeAS4GFXResource (address_space, directIdx, bufId);
192
-
193
- // Check if this arg is an image
194
- if (bufType == BufferType::UAV)
195
- {
196
- ArgType imgArgType;
197
- // Check if argument is image
198
- if (isImage (arg, typeStr, imgArgType)) return imgArgType;
199
- }
200
- else if (bufType == BufferType::SAMPLER)
201
- return KernelArg::ArgType::SAMPLER;
202
-
203
- return KernelArg::ArgType::NOT_TO_ALLOCATE;
218
+ return getBufferType (arg, typeStr).type ;
204
219
}
205
220
}
206
221
case Type::IntegerTyID:
0 commit comments