shader-pipeline.cpp

1
2
#include <planet/vk/device.hpp>
#include <planet/vk/shader_module.hpp>

planet::vk::shader_module

 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
planet::vk::shader_module::shader_module(
        vk::device &d, std::vector<std::byte> bc)
: spirv{std::move(bc)}, device{d} {
    VkShaderModuleCreateInfo info = {};
    info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
    info.codeSize = spirv.size();
    info.pCode = reinterpret_cast<std::uint32_t *>(spirv.data());
    handle.create<vkCreateShaderModule>(device.get(), info);
}


VkPipelineShaderStageCreateInfo planet::vk::shader_module::shader_stage_info(
        VkShaderStageFlagBits const flags, char const *entry) {
    VkPipelineShaderStageCreateInfo info = {};
    info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
    info.stage = flags;
    info.module = handle.get();
    info.pName = entry;
    return info;
}