PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
render_stage_runtime.h
1#pragma once
2
3#include "pixelbullet/graphics/render_stage.h"
4
5#include <glm/glm.hpp>
6#include <volk.h>
7
8#include <map>
9#include <memory>
10#include <optional>
11#include <string>
12#include <vector>
13
14namespace pixelbullet
15{
16class Descriptor;
17class Framebuffers;
18class ImageDepth;
19class RenderDevice;
20class Renderpass;
21class RenderTarget2D;
22class Swapchain;
23
25{
26public:
27 explicit RenderStageRuntime(const RenderStage& specification);
29
30 void Update(const RenderDevice& render_device, const std::map<std::string, std::unique_ptr<RenderTarget2D>>& render_targets);
31 void Rebuild(const RenderDevice& render_device, const std::map<std::string, std::unique_ptr<RenderTarget2D>>& render_targets,
32 const Swapchain& swapchain);
33
34 const Descriptor* GetDescriptor(const std::string& name) const;
35 const Descriptor* GetDescriptor(uint32_t binding) const;
36 const VkFramebuffer& GetActiveFramebuffer(uint32_t active_swapchain_image) const;
37 const Renderpass* GetRenderpass() const
38 {
39 return renderpass_.get();
40 }
41 const ImageDepth* GetDepthStencil() const
42 {
43 return depth_stencil_.get();
44 }
45
46 const std::vector<VkClearValue>& GetClearValues() const
47 {
48 return clear_values_;
49 }
50 uint32_t GetAttachmentCount(uint32_t subpass) const
51 {
52 return subpass_attachment_count_[subpass];
53 }
54 bool HasSwapchain() const
55 {
56 return swapchain_attachment_.has_value();
57 }
58 bool IsOutOfDate() const
59 {
60 return out_of_date_;
61 }
62 const glm::uvec2& GetExtent() const
63 {
64 return extent_;
65 }
66 const glm::ivec2& GetOffset() const
67 {
68 return offset_;
69 }
70
71 const std::map<std::string, const Descriptor*>& GetDescriptors() const
72 {
73 return descriptors_;
74 }
75 const RenderStage& GetSpecification() const
76 {
77 return *specification_;
78 }
79
80private:
81 void RebuildDescriptors(const std::map<std::string, std::unique_ptr<RenderTarget2D>>& render_targets);
82
83private:
84 const RenderStage* specification_ = nullptr;
85
86 std::unique_ptr<Renderpass> renderpass_;
87 std::unique_ptr<ImageDepth> depth_stencil_;
88 std::unique_ptr<Framebuffers> framebuffers_;
89
90 std::map<std::string, const Descriptor*> descriptors_;
91 std::map<uint32_t, const Descriptor*> descriptors_by_binding_;
92
93 std::vector<VkClearValue> clear_values_;
94 std::vector<uint32_t> subpass_attachment_count_;
95 std::optional<Attachment> depth_attachment_;
96 std::optional<Attachment> swapchain_attachment_;
97 std::vector<bool> subpass_multisampled_;
98
99 glm::uvec2 extent_{ 0, 0 };
100 glm::ivec2 offset_{ 0, 0 };
101 float aspect_ratio_ = 1.0f;
102 bool out_of_date_ = false;
103};
104} // namespace pixelbullet
Definition descriptor.h:75
Definition render_device.h:16
Definition render_stage_runtime.h:25
Definition render_stage.h:160