vk_graphics_pipeline: Add shader SPIRV interface

Direct creation of `Shader` from `u32` source
This commit is contained in:
Wunkolo 2024-03-02 12:49:11 -08:00
parent 882f75c02c
commit 99e83a4ab8
2 changed files with 6 additions and 0 deletions

View File

@ -58,6 +58,11 @@ Shader::Shader(const Instance& instance, vk::ShaderStageFlagBits stage, std::str
MarkDone();
}
Shader::Shader(const Instance& instance, std::span<const u32> code) : Shader{instance} {
module = CompileSPV(code, instance.GetDevice());
MarkDone();
}
Shader::~Shader() {
if (device && module) {
device.destroyShaderModule(module);

View File

@ -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<const u32> code);
~Shader();
[[nodiscard]] vk::ShaderModule Handle() const noexcept {