[clang] [llvm] [HLSL][SPIR-V] Implements SV_Position for VS/PS I/O (PR #168735)

Nathan Gauër via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 21 07:23:39 PST 2025


================
@@ -730,10 +730,18 @@ llvm::Value *CGHLSLRuntime::emitSystemSemanticLoad(
   }
 
   if (SemanticName == "SV_POSITION") {
-    if (CGM.getTriple().getEnvironment() == Triple::EnvironmentType::Pixel)
-      return createSPIRVBuiltinLoad(B, CGM.getModule(), Type,
-                                    Semantic->getAttrName()->getName(),
-                                    /* BuiltIn::FragCoord */ 15);
+    if (CGM.getTriple().getEnvironment() == Triple::EnvironmentType::Pixel) {
+      if (CGM.getTarget().getTriple().isSPIRV())
+        return createSPIRVBuiltinLoad(B, CGM.getModule(), Type,
+                                      Semantic->getAttrName()->getName(),
+                                      /* BuiltIn::FragCoord */ 15);
+      if (CGM.getTarget().getTriple().isDXIL())
+        return emitDXILUserSemanticLoad(B, Type, Semantic, Index);
+    }
+
+    if (CGM.getTriple().getEnvironment() == Triple::EnvironmentType::Vertex) {
+      return emitUserSemanticLoad(B, Type, Decl, Semantic, Index);
+    }
   }
 
   llvm_unreachable("non-handled system semantic. FIXME.");
----------------
Keenuts wrote:

Sure, rephrased it a bit. Note this should never happen unless the implementation is halfway done. If the user uses an unknown semantic, or a semantic we don't support yet, SEMA will catch it. This is about a sync issue between the Sema and codegen code.

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


More information about the llvm-commits mailing list