Skip to content

Conversation

@Keenuts
Copy link
Contributor

@Keenuts Keenuts commented Jun 2, 2025

Adds backend handling of the vertex shader type compiling from HLSL.

Fixes #136961

@llvmbot
Copy link
Member

llvmbot commented Jun 2, 2025

@llvm/pr-subscribers-backend-spir-v

Author: Nathan Gauër (Keenuts)

Changes

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 --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" }

Copy link
Contributor

@s-perron s-perron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just a small note.

Keenuts added 2 commits June 10, 2025 13:40
Adds backend handling of the vertex shader type compiling from HLSL.
@Keenuts
Copy link
Contributor Author

Keenuts commented Jun 10, 2025

The shader type check condition has been duplicated in another change. Adapted this PR to match this. Will do the same on the fragment PR.

@Keenuts Keenuts merged commit 6f23116 into llvm:main Jun 10, 2025
7 of 8 checks passed
@Keenuts Keenuts deleted the vs-shader branch June 10, 2025 12:48
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
Adds backend handling of the vertex shader type compiling from HLSL.

Fixes llvm#136961
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HLSL][SPIRV] Implement vertex shaders

3 participants