@@ -2210,42 +2210,33 @@ bool SemaHLSL::IsTypedResourceElementCompatible(clang::QualType QT) {
22102210 return false ;
22112211 }
22122212
2213- llvm::SmallVector<QualType, 4 > QTTypes;
2214- BuildFlattenedTypeList (QT, QTTypes);
2215-
2216- // empty element type is not typed resource element compatible
2217- if (QTTypes.size () == 0 )
2218- return false ;
2219-
2220- QualType FirstQT = SemaRef.Context .getCanonicalType (QTTypes[0 ]);
2213+ // the only other valid builtin types are scalars or vectors
2214+ if (const BuiltinType *BT = CanonicalType->getAs <BuiltinType>()) {
2215+ if (BT->isBooleanType () || BT->isEnumeralType ())
2216+ return false ;
22212217
2222- // element count cannot exceed 4
2223- if (QTTypes.size () > 4 )
2224- return false ;
2218+ int TotalSizeInBytes = SemaRef.Context .getTypeSize (BT) / 8 ;
22252219
2226- for (QualType TempQT : QTTypes) {
2227- // ensure homogeneity
2228- if (!getASTContext ().hasSameUnqualifiedType (FirstQT, TempQT))
2220+ if (TotalSizeInBytes > 16 )
22292221 return false ;
2222+ return true ;
22302223 }
22312224
2232- if (const BuiltinType *BT = FirstQT->getAs <BuiltinType>()) {
2233- if (BT->isBooleanType () || BT->isEnumeralType ())
2225+ if (const VectorType *VT = CanonicalType->getAs <VectorType>()) {
2226+ int ArraySize = VT->getNumElements ();
2227+
2228+ if (ArraySize > 4 )
22342229 return false ;
22352230
2236- // Check if it is an array type.
2237- if (FirstQT->isArrayType ())
2231+ QualType ElTy = VT->getElementType ();
2232+ int TotalSizeInBytes = (SemaRef.Context .getTypeSize (ElTy) / 8 ) * ArraySize;
2233+
2234+ if (TotalSizeInBytes > 16 )
22382235 return false ;
2236+ return true ;
22392237 }
22402238
2241- // if the loop above completes without returning, then
2242- // we've guaranteed homogeneity
2243- int TotalSizeInBytes =
2244- (SemaRef.Context .getTypeSize (FirstQT) / 8 ) * QTTypes.size ();
2245- if (TotalSizeInBytes > 16 )
2246- return false ;
2247-
2248- return true ;
2239+ return false ;
22492240}
22502241
22512242bool SemaHLSL::IsScalarizedLayoutCompatible (QualType T1, QualType T2) const {
0 commit comments