From 99e83a4ab891509fd188028f5b58fa56a3794e67 Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Sat, 2 Mar 2024 12:49:11 -0800 Subject: [PATCH] vk_graphics_pipeline: Add shader SPIRV interface Direct creation of `Shader` from `u32` source --- src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | 5 +++++ src/video_core/renderer_vulkan/vk_graphics_pipeline.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 5ef3eb513..603ae0b9b 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -58,6 +58,11 @@ Shader::Shader(const Instance& instance, vk::ShaderStageFlagBits stage, std::str MarkDone(); } +Shader::Shader(const Instance& instance, std::span code) : Shader{instance} { + module = CompileSPV(code, instance.GetDevice()); + MarkDone(); +} + Shader::~Shader() { if (device && module) { device.destroyShaderModule(module); diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h index 38cd988d1..4bb3b446e 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h @@ -152,6 +152,7 @@ struct PipelineInfo { struct Shader : public Common::AsyncHandle { explicit Shader(const Instance& instance); explicit Shader(const Instance& instance, vk::ShaderStageFlagBits stage, std::string code); + explicit Shader(const Instance& instance, std::span code); ~Shader(); [[nodiscard]] vk::ShaderModule Handle() const noexcept {