================
@@ -1028,6 +1034,52 @@ static bool isVkPipelineBuiltin(const ASTContext 
&AstContext, FunctionDecl *FD,
   }
 }
 
+static void validateVkBuiltinUsage(Sema &S, FunctionDecl *FD,
+                                   const DeclaratorDecl *D,
+                                   const HLSLVkBuiltInAttr *Attr,
+                                   IOType CurrentIOType) {
+  const ASTContext &AstContext = S.getASTContext();
+  if (AstContext.getTargetInfo().getTriple().getOS() != llvm::Triple::Vulkan)
+    return;
+
+  StringRef BuiltIn = Attr->getBuiltIn();
+
+  QualType T =
+      (D == FD ? FD->getReturnType() : D->getType()).getNonReferenceType();
+  const auto *ShaderAttr = FD->getAttr<HLSLShaderAttr>();
+  assert(ShaderAttr && "Entry point has no shader attribute");
+  llvm::Triple::EnvironmentType Stage = ShaderAttr->getType();
+  bool IsIn = any(CurrentIOType & IOType::In);
+  bool IsOut = any(CurrentIOType & IOType::Out);
+
+  if (BuiltIn == "PointSize") {
+    if (!T->isFloatingType())
+      S.Diag(Attr->getLocation(), diag::err_hlsl_vk_builtin_wrong_type)
+          << BuiltIn << S.getASTContext().FloatTy;
+
+    // PointSize is a per-vertex value, so patch-constant (hull/domain)
+    // and per-primitive (mesh) data never carries it.
+    // Note: Sema does not set this bit yet.
+    bool IsPatchConstantOrPrimitive =
+        any(CurrentIOType & IOType::PatchConstantOrPrimitive);
+    bool LegalStage =
+        !IsPatchConstantOrPrimitive &&
+        ((Stage == llvm::Triple::Vertex && IsOut) ||
+         Stage == llvm::Triple::Hull || Stage == llvm::Triple::Domain ||
+         Stage == llvm::Triple::Geometry ||
+         (Stage == llvm::Triple::Pixel && IsIn) ||
+         (Stage == llvm::Triple::Mesh && IsOut));
----------------
jzakharovnv wrote:

Fixed, thanks for catching

https://github.com/llvm/llvm-project/pull/231275
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to