From 6f231165072ec8a4f725056c6deccce3c1a21f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathan=20Gau=C3=ABr?= Date: Tue, 10 Jun 2025 14:48:25 +0200 Subject: [PATCH] [SPIR-V] Add Vertex execution model (#142369) Adds backend handling of the vertex shader type compiling from HLSL. Fixes #136961 --- llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp | 4 ++++ llvm/test/CodeGen/SPIRV/ExecutionMode_Vertex.ll | 12 ++++++++++++ 2 files changed, 16 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 17be86db5406..98d3720df936 100644 --- a/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp +++ b/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp @@ -280,6 +280,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."); @@ -302,6 +304,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 000000000000..e93e7a9c302e --- /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 --target-env vulkan1.3 %} + +; CHECK: OpCapability Shader +; CHECK: OpEntryPoint Vertex %[[#entry:]] "main" + +define void @main() #1 { +entry: + ret void +} + +attributes #1 = { "hlsl.shader"="vertex" }