[llvm] [SPIR-V] Add Vertex execution model (PR #142369)
Nathan Gauër via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 2 08:26:37 PDT 2025
https://github.com/Keenuts updated https://github.com/llvm/llvm-project/pull/142369
>From 2f263fa1687d8ccb344e0a2d372567c270a849b3 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 5991a9af6364d..147cf7e8a2002 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
@@ -279,6 +279,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 6328faf20f86540f2e9c4afc67c6dd17236714c8 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