[llvm] [SPIR-V] Add Vertex execution model (PR #142369)

Nathan Gauër via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 10 04:51:36 PDT 2025


https://github.com/Keenuts updated https://github.com/llvm/llvm-project/pull/142369

>From fb22e7c028d6ccbcb424429f3d4be22f7f6fd538 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nathan=20Gau=C3=ABr?= <brioche at google.com>
Date: Mon, 2 Jun 2025 13:31:11 +0200
Subject: [PATCH 1/2] [SPIR-V] Add Vertex execution model

Adds backend handling of the vertex shader type compiling from HLSL.
---
 llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp     |  2 ++
 llvm/test/CodeGen/SPIRV/ExecutionMode_Vertex.ll | 12 ++++++++++++
 2 files changed, 14 insertions(+)
 create mode 100644 llvm/test/CodeGen/SPIRV/ExecutionMode_Vertex.ll

diff --git a/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp b/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
index 17be86db54062..d9a178853c600 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
@@ -302,6 +302,8 @@ getExecutionModel(const SPIRVSubtarget &STI, const Function &F) {
   const auto value = attribute.getValueAsString();
   if (value == "compute")
     return SPIRV::ExecutionModel::GLCompute;
+  if (value == "vertex")
+    return SPIRV::ExecutionModel::Vertex;
 
   report_fatal_error("This HLSL entry point is not supported by this backend.");
 }
diff --git a/llvm/test/CodeGen/SPIRV/ExecutionMode_Vertex.ll b/llvm/test/CodeGen/SPIRV/ExecutionMode_Vertex.ll
new file mode 100644
index 0000000000000..19bba23b437fd
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/ExecutionMode_Vertex.ll
@@ -0,0 +1,12 @@
+; RUN: llc -O0 -mtriple=spirv-unknown-vulkan1.3-vertex %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan1.3-vertex %s -o - -filetype=obj | spirv-val %}
+
+; CHECK: OpCapability Shader
+; CHECK: OpEntryPoint Vertex %[[#entry:]] "main"
+
+define void @main() #1 {
+entry:
+  ret void
+}
+
+attributes #1 = { "hlsl.shader"="vertex" }

>From 827fb86215ce4926545f83e585d8f624920f3647 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nathan=20Gau=C3=ABr?= <brioche at google.com>
Date: Mon, 2 Jun 2025 17:26:21 +0200
Subject: [PATCH 2/2] add env to spirv-val

---
 llvm/test/CodeGen/SPIRV/ExecutionMode_Vertex.ll | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/test/CodeGen/SPIRV/ExecutionMode_Vertex.ll b/llvm/test/CodeGen/SPIRV/ExecutionMode_Vertex.ll
index 19bba23b437fd..e93e7a9c302e2 100644
--- a/llvm/test/CodeGen/SPIRV/ExecutionMode_Vertex.ll
+++ b/llvm/test/CodeGen/SPIRV/ExecutionMode_Vertex.ll
@@ -1,5 +1,5 @@
 ; RUN: llc -O0 -mtriple=spirv-unknown-vulkan1.3-vertex %s -o - | FileCheck %s
-; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan1.3-vertex %s -o - -filetype=obj | spirv-val %}
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan1.3-vertex %s -o - -filetype=obj | spirv-val --target-env vulkan1.3 %}
 
 ; CHECK: OpCapability Shader
 ; CHECK: OpEntryPoint Vertex %[[#entry:]] "main"



More information about the llvm-commits mailing list