[clang] [HLSL][SPIR-V] Handle SV_Postion builtin in PS (PR #141759)

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 6 10:31:29 PDT 2025


================
@@ -407,6 +429,13 @@ llvm::Value *CGHLSLRuntime::emitInputSemantic(IRBuilder<> &B,
     llvm::Function *GroupIDIntrinsic = CGM.getIntrinsic(getGroupIdIntrinsic());
     return buildVectorInput(B, GroupIDIntrinsic, Ty);
   }
+  if (D.hasAttr<HLSLSV_PositionAttr>()) {
+    if (getArch() == llvm::Triple::spirv)
+      return createSPIRVBuiltinLoad(B, CGM.getModule(), Ty, "sv_position",
+                                    /* BuiltIn::Position */ 0);
+    llvm_unreachable(
+        "Shader signature for semantics not implemented for DXIL.");
----------------
farzonl wrote:

this is techincally an unreachable for all targets the way you did the conditional but this should be fine because there are only two targets right now for HLSL.

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


More information about the cfe-commits mailing list