pipeline.cpp

1
2
3
4
#include <planet/vk/descriptors.hpp>
#include <planet/vk/device.hpp>
#include <planet/vk/pipeline.hpp>
#include <planet/vk/shader_module.hpp>

planet::vk::pipeline_layout

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
planet::vk::pipeline_layout::pipeline_layout(vk::device &d) : device{d} {
    VkPipelineLayoutCreateInfo info = {};
    info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
    handle.create<vkCreatePipelineLayout>(device.get(), info);
}


planet::vk::pipeline_layout::pipeline_layout(
        vk::device &d, descriptor_set_layout const &dsl)
: device{d} {
    VkPipelineLayoutCreateInfo info = {};
    info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
    info.setLayoutCount = 1;
    info.pSetLayouts = dsl.address();
    handle.create<vkCreatePipelineLayout>(device.get(), info);
}


planet::vk::pipeline_layout::pipeline_layout(
        vk::device &d,
        std::span<VkDescriptorSetLayout const> const s,
        std::span<VkPushConstantRange const> const p)
: device{d} {
    VkPipelineLayoutCreateInfo info = {};
    info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
    info.setLayoutCount = s.size();
    info.pSetLayouts = s.data();
    info.pushConstantRangeCount = p.size();
    info.pPushConstantRanges = p.data();
    handle.create<vkCreatePipelineLayout>(device.get(), info);
}


planet::vk::pipeline_layout::pipeline_layout(
        vk::device &d, VkPipelineLayoutCreateInfo const &info)
: device{d} {
    handle.create<vkCreatePipelineLayout>(device.get(), info);
}

planet::vk::graphics_pipeline

53
54
55
56
57
58
59
60
61
62
63
64
65
66
planet::vk::graphics_pipeline::graphics_pipeline(
        vk::device &d,
        VkGraphicsPipelineCreateInfo &info,
        vk::render_pass &rp,
        pipeline_layout pl)
: device{d}, render_pass{rp}, layout{std::move(pl)} {
    info.renderPass = render_pass.get();
    info.layout = layout.get();

    VkPipeline ph = VK_NULL_HANDLE;
    planet::vk::worked(vkCreateGraphicsPipelines(
            device.get(), VK_NULL_HANDLE, 1, &info, nullptr, &ph));
    handle = handle_type::bind(device.get(), ph);
}