[llvm] [SPIR-V] Add Vertex execution model (PR #142369)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 2 04:40:03 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-spir-v
Author: Nathan Gauër (Keenuts)
<details>
<summary>Changes</summary>
Adds backend handling of the vertex shader type compiling from HLSL.
---
Full diff: https://github.com/llvm/llvm-project/pull/142369.diff
2 Files Affected:
- (modified) llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp (+2)
- (added) llvm/test/CodeGen/SPIRV/ExecutionMode_Vertex.ll (+12)
``````````diff
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" }
``````````
</details>
https://github.com/llvm/llvm-project/pull/142369
More information about the llvm-commits
mailing list