HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
gfx_pipeline_vulkan.hpp
1// Copyright Take Vos 2019-2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "../macros.hpp"
8#include <vulkan/vulkan.hpp>
9#include <string>
10#include <vector>
11
12namespace hi::inline v1 {
13class gfx_device;
14class gfx_surface;
15class draw_context;
16
18public:
19 vk::Pipeline intrinsic;
20 gfx_surface *surface = nullptr;
21
22 gfx_pipeline(gfx_surface *surface) : surface(surface) {}
23
24 virtual ~gfx_pipeline() = default;
25 gfx_pipeline(const gfx_pipeline &) = delete;
26 gfx_pipeline &operator=(const gfx_pipeline &) = delete;
27 gfx_pipeline(gfx_pipeline &&) = delete;
28 gfx_pipeline &operator=(gfx_pipeline &&) = delete;
29
30 virtual void draw_in_command_buffer(vk::CommandBuffer commandBuffer, draw_context const &context);
31
32 void build_for_new_device();
33 void teardown_for_device_lost();
34 void build_for_new_swapchain(vk::RenderPass renderPass, uint32_t renderSubpass, vk::Extent2D extent);
35 void teardown_for_swapchain_lost();
36
37protected:
38 vk::DescriptorSet descriptorSet;
39 size_t descriptorSetVersion = 0;
40 vk::Extent2D extent;
41 vk::DescriptorSetLayout descriptorSetLayout;
42 vk::PipelineLayout pipelineLayout;
43 vk::DescriptorPool descriptorPool;
44
45 [[nodiscard]] gfx_device *device() const noexcept;
46
47 [[nodiscard]] virtual std::vector<vk::PipelineShaderStageCreateInfo> createShaderStages() const = 0;
48 [[nodiscard]] virtual std::vector<vk::DescriptorSetLayoutBinding> createDescriptorSetLayoutBindings() const = 0;
49 [[nodiscard]] virtual std::vector<vk::WriteDescriptorSet> createWriteDescriptorSet() const = 0;
50 [[nodiscard]] virtual size_t getDescriptorSetVersion() const = 0;
51 [[nodiscard]] virtual std::vector<vk::PushConstantRange> createPushConstantRanges() const
52 {
53 return {};
54 }
55 [[nodiscard]] virtual vk::VertexInputBindingDescription createVertexInputBindingDescription() const
56 {
57 return {};
58 }
59 [[nodiscard]] virtual std::vector<vk::VertexInputAttributeDescription> createVertexInputAttributeDescriptions() const
60 {
61 return {};
62 }
63
64 [[nodiscard]] virtual vk::PipelineDepthStencilStateCreateInfo getPipelineDepthStencilStateCreateInfo() const;
65 [[nodiscard]] virtual std::vector<vk::PipelineColorBlendAttachmentState> getPipelineColorBlendAttachmentStates() const;
66
67 virtual void build_vertex_buffers(){};
68 virtual void teardown_vertex_buffers(){};
69 virtual void build_descriptor_sets();
70 virtual void teardown_descriptor_sets();
71 virtual void build_pipeline(vk::RenderPass renderPass, uint32_t renderSubpass, vk::Extent2D extent);
72 virtual void teardown_pipeline();
73};
74
75} // namespace hi::inline v1
DOXYGEN BUG.
Definition algorithm.hpp:16
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
Definition gfx_device_vulkan.hpp:24
Definition gfx_pipeline_vulkan.hpp:17
Definition gfx_surface_vulkan.hpp:33