Lugdunum  0.1.0
Forward.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <unordered_map>
4 
21 
22 namespace lug {
23 namespace Graphics {
24 namespace Vulkan {
25 
26 namespace API {
27 class Queue;
28 } // API
29 
30 namespace Render {
31 namespace Technique {
32 
33 class LUG_GRAPHICS_API Forward final : public Technique {
34 private:
35  struct DepthBuffer {
38  };
39 
40  struct FrameData {
43 
46 
50 
51  const BufferPool::SubBuffer* cameraBuffer{nullptr};
52  std::vector<const BufferPool::SubBuffer*> lightBuffers;
53  std::vector<const BufferPool::SubBuffer*> materialBuffers;
54 
55  const DescriptorSetPool::DescriptorSet* cameraDescriptorSet{nullptr};
56  const DescriptorSetPool::DescriptorSet* skyBoxDescriptorSet{nullptr};
57  std::vector<const DescriptorSetPool::DescriptorSet*> lightDescriptorSets;
58  std::vector<const DescriptorSetPool::DescriptorSet*> materialDescriptorSets;
59  std::vector<const DescriptorSetPool::DescriptorSet*> materialTexturesDescriptorSets;
60  };
61 
62 public:
63  Forward(Renderer& renderer, const View& renderView);
64 
65  Forward(const Forward&) = delete;
66  Forward(Forward&&) = delete;
67 
68  Forward& operator=(const Forward&) = delete;
69  Forward& operator=(Forward&&) = delete;
70 
71  ~Forward();
72 
73  bool render(
74  const Render::Queue& renderQueue,
75  const API::Semaphore& imageReadySemaphore,
76  const API::Semaphore& drawCompleteSemaphore,
77  uint32_t currentImageIndex
78  ) override final;
79 
80  bool init(const std::vector<API::ImageView>& imageViews) override final;
81  void destroy() override final;
82 
83  bool initDepthBuffers(const std::vector<API::ImageView>& imageViews) override final;
84  bool initFramebuffers(const std::vector<API::ImageView>& imageViews) override final;
85 
86 private:
87  API::DeviceMemory _depthBufferMemory;
88 
89  std::vector<FrameData> _framesData;
90 
91  const API::Queue* _graphicsQueue{nullptr};
93 
94  const API::Queue* _transferQueue{nullptr};
96 
97 private:
98  // TODO: Use shared_ptr in the instance and static weak_ptr to avoid problem when we delete one forward renderer and not the others
99  static std::unique_ptr<BufferPool::Camera> _cameraBufferPool;
100  static std::unique_ptr<BufferPool::Light> _lightBufferPool;
101  static std::unique_ptr<BufferPool::Material> _materialBufferPool;
102 
103  static std::unique_ptr<DescriptorSetPool::Camera> _cameraDescriptorSetPool;
104  static std::unique_ptr<DescriptorSetPool::Light> _lightDescriptorSetPool;
105  static std::unique_ptr<DescriptorSetPool::Material> _materialDescriptorSetPool;
106  static std::unique_ptr<DescriptorSetPool::MaterialTextures> _materialTexturesDescriptorSetPool;
107  static std::unique_ptr<DescriptorSetPool::SkyBox> _skyBoxDescriptorSetPool;
108 
109  static uint32_t _forwardCount;
110 };
111 
112 } // Technique
113 } // Render
114 } // Vulkan
115 } // Graphics
116 } // lug
std::vector< const DescriptorSetPool::DescriptorSet * > lightDescriptorSets
Definition: Forward.hpp:57
static std::unique_ptr< BufferPool::Material > _materialBufferPool
Definition: Forward.hpp:101
#define LUG_GRAPHICS_API
Definition: Export.hpp:11
std::vector< const DescriptorSetPool::DescriptorSet * > materialTexturesDescriptorSets
Definition: Forward.hpp:59
std::vector< const DescriptorSetPool::DescriptorSet * > materialDescriptorSets
Definition: Forward.hpp:58
static std::unique_ptr< DescriptorSetPool::MaterialTextures > _materialTexturesDescriptorSetPool
Definition: Forward.hpp:106
std::vector< const BufferPool::SubBuffer * > lightBuffers
Definition: Forward.hpp:52
static std::unique_ptr< DescriptorSetPool::Material > _materialDescriptorSetPool
Definition: Forward.hpp:105
static std::unique_ptr< BufferPool::Light > _lightBufferPool
Definition: Forward.hpp:100
static std::unique_ptr< DescriptorSetPool::SkyBox > _skyBoxDescriptorSetPool
Definition: Forward.hpp:107
static std::unique_ptr< BufferPool::Camera > _cameraBufferPool
Definition: Forward.hpp:99
std::vector< const BufferPool::SubBuffer * > materialBuffers
Definition: Forward.hpp:53
static std::unique_ptr< DescriptorSetPool::Camera > _cameraDescriptorSetPool
Definition: Forward.hpp:103
static std::unique_ptr< DescriptorSetPool::Light > _lightDescriptorSetPool
Definition: Forward.hpp:104