[llvm] [SPIR-V] Add Vertex execution model (PR #142369)
Nathan Gauër via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 2 04:39:29 PDT 2025
https://github.com/Keenuts created https://github.com/llvm/llvm-project/pull/142369
Adds backend handling of the vertex shader type compiling from HLSL.
>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] [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" }
More information about the llvm-commits
mailing list