Toast Engine
Loading...
Searching...
No Matches
ui_pass.hpp
Go to the documentation of this file.
1
8
9#pragma once
10#include <array>
11#include <memory>
12#include <optional>
13#include <toast/renderer/render_pass_base.hpp>
14#include <toast/renderer/shader_layout.hpp>
15#include <toast/renderer/vulkan_common.hpp>
16#include <toast/renderer/vulkan_pipeline.hpp>
17#include <vector>
18
19namespace renderer {
20class VulkanCore;
21}
22
23namespace ui {
24
25class UIPass : public IRenderPass {
26public:
28 static constexpr vk::Format k_color_format = vk::Format::eR8G8B8A8Unorm;
29
30 [[nodiscard]]
31 static auto selectStencilFormat(const renderer::VulkanCore& core) -> vk::Format;
32
33 UIPass(const renderer::VulkanCore& core, vk::Format output_color_format, vk::Format output_depth_format, vk::Extent2D extent);
34
37 [[nodiscard]]
38 auto stage() const -> RenderStage override {
39 return RenderStage::overlay;
40 }
41
42 [[nodiscard]]
43 auto name() const -> std::string_view override {
44 return "UI";
45 }
46
47 void recordPre(vk::CommandBuffer cmd, uint32_t frame_index, uint32_t image_index) override;
48 void record(vk::CommandBuffer cmd, uint32_t frame_index, uint32_t image_index) override;
49
50private:
51 const renderer::VulkanCore* m_core = nullptr;
52
53 vk::raii::Sampler m_sampler = nullptr;
54 renderer::ShaderLayout m_shader_layout;
55 renderer::VulkanPipeline m_composite_pipeline;
56 std::array<std::vector<vk::raii::DescriptorSet>, 3> m_frame_sets;
57 uint32_t m_draw_count = 0;
58
59 // Keeps the command pool slot of the UI buffers alive per frame in flight
60 std::array<std::shared_ptr<const void>, 3> m_executing_guards;
61};
62
63}
Definition render_pass_base.hpp:19
Definition shader_layout.hpp:12
Definition vulkan_core.hpp:48
Definition vulkan_pipeline.hpp:19
static constexpr vk::Format k_color_format
UI layers always render in this format regardless of the output target.
Definition ui_pass.hpp:28
void recordPre(vk::CommandBuffer cmd, uint32_t frame_index, uint32_t image_index) override
Records outside any rendering scope before the main scope opens.
Definition ui_pass.cpp:73
auto stage() const -> RenderStage override
Definition ui_pass.hpp:38