[clang] [HLSL] add IsLineVectorLayoutCompatible type trait (PR #113730)

Joshua Batista via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 30 16:00:23 PDT 2024


================
@@ -2163,6 +2163,51 @@ static void BuildFlattenedTypeList(QualType BaseTy,
   }
 }
 
+bool SemaHLSL::IsLineVectorLayoutCompatibleType(clang::QualType QT) {
+  if (QT.isNull())
+    return false;
+
+  llvm::SmallVector<QualType, 16> QTTypes;
+  BuildFlattenedTypeList(QT, QTTypes);
----------------
bob80905 wrote:

Understandable, though I think this way is significantly simpler, and won't be much of a perf hit.
We allocate at most 4 elements in the list per resource, never any more for valid shaders. We would need to allocate at least one subelement with which to compare other subelements against using your method. It may be slightly less performant, but I think this is readable and it doesn't drag the performance down from O(1) to O(N) for valid shaders.(N being number of subelements)


https://github.com/llvm/llvm-project/pull/113730


More information about the cfe-commits mailing list