HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
gfx_pipeline_vulkan_intf.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
12hi_export_module(hikogui.GFX : gfx_pipeline_intf);
13
14hi_export namespace hi::inline v1 {
15class gfx_device;
16class gfx_surface;
17class draw_context;
18
20public:
21 vk::Pipeline intrinsic;
22 gfx_surface *surface = nullptr;
23
24 gfx_pipeline(gfx_surface *surface) : surface(surface) {}
25
26 virtual ~gfx_pipeline() = default;
27 gfx_pipeline(const gfx_pipeline &) = delete;
28 gfx_pipeline &operator=(const gfx_pipeline &) = delete;
29 gfx_pipeline(gfx_pipeline &&) = delete;
30 gfx_pipeline &operator=(gfx_pipeline &&) = delete;
31
32 virtual void draw_in_command_buffer(vk::CommandBuffer commandBuffer, draw_context const &context);
33
34 void build_for_new_device();
35 void teardown_for_device_lost();
36 void build_for_new_swapchain(vk::RenderPass renderPass, uint32_t renderSubpass, vk::Extent2D extent);
37 void teardown_for_swapchain_lost();
38
39protected:
40 vk::DescriptorSet descriptorSet;
41 size_t descriptorSetVersion = 0;
42 vk::Extent2D extent;
43 vk::DescriptorSetLayout descriptorSetLayout;
44 vk::PipelineLayout pipelineLayout;
45 vk::DescriptorPool descriptorPool;
46
47 [[nodiscard]] gfx_device *device() const noexcept;
48
49 [[nodiscard]] virtual std::vector<vk::PipelineShaderStageCreateInfo> createShaderStages() const = 0;
50 [[nodiscard]] virtual std::vector<vk::DescriptorSetLayoutBinding> createDescriptorSetLayoutBindings() const = 0;
51 [[nodiscard]] virtual std::vector<vk::WriteDescriptorSet> createWriteDescriptorSet() const = 0;
52 [[nodiscard]] virtual size_t getDescriptorSetVersion() const = 0;
53 [[nodiscard]] virtual std::vector<vk::PushConstantRange> createPushConstantRanges() const
54 {
55 return {};
56 }
57 [[nodiscard]] virtual vk::VertexInputBindingDescription createVertexInputBindingDescription() const
58 {
59 return {};
60 }
61 [[nodiscard]] virtual std::vector<vk::VertexInputAttributeDescription> createVertexInputAttributeDescriptions() const
62 {
63 return {};
64 }
65
66 [[nodiscard]] virtual vk::PipelineDepthStencilStateCreateInfo getPipelineDepthStencilStateCreateInfo() const;
67 [[nodiscard]] virtual std::vector<vk::PipelineColorBlendAttachmentState> getPipelineColorBlendAttachmentStates() const;
68
69 virtual void build_vertex_buffers(){};
70 virtual void teardown_vertex_buffers(){};
71 virtual void build_descriptor_sets();
72 virtual void teardown_descriptor_sets();
73 virtual void build_pipeline(vk::RenderPass renderPass, uint32_t renderSubpass, vk::Extent2D extent);
74 virtual void teardown_pipeline();
75};
76
77} // namespace hi::inline v1
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
Definition gfx_device_vulkan_intf.hpp:26
Definition gfx_pipeline_vulkan_intf.hpp:19
Definition gfx_surface_vulkan_intf.hpp:33