Nameless Engine
Loading...
Searching...
No Matches
GlobalShaderResourceBindingManager.h
1#pragma once
2
3// Standard.
4#include <mutex>
5#include <optional>
6#include <unordered_set>
7
8// Custom.
9#include "render/general/resource/frame/FrameResourceManager.h"
10#include "misc/Error.h"
11
12namespace ne {
13 class GpuResource;
14 class Pipeline;
15 class GlobalShaderResourceBinding;
16
22 // Only renderer should create this manager.
23 friend class Renderer;
24
25 // Pipeline manager will notify this object about pipelines being re-created.
26 friend class PipelineManager;
27
28 // Bindings will notify the manager upon construction and destruction.
29 friend class GlobalShaderResourceBinding;
30
31 public:
33
63 [[nodiscard]] std::optional<Error> createGlobalShaderResourceBindingResourcePerFrame(
64 const std::string& sShaderResourceName,
65 std::array<GpuResource*, FrameResourceManager::getFrameResourceCount()> vResourcesToBind);
66
85 [[nodiscard]] std::optional<Error> createGlobalShaderResourceBindingSingleResource(
86 const std::string& sShaderResourceName, GpuResource* pResourceToBind);
87
90
91 private:
98
107 [[nodiscard]] std::optional<Error> onNewGraphicsPipelineCreated(Pipeline* pNewPipeline);
108
115 [[nodiscard]] std::optional<Error> onAllGraphicsPipelinesRecreatedInternalResources();
116
126 [[nodiscard]] std::optional<Error> registerNewBinding(GlobalShaderResourceBinding* pBinding);
127
136
143 std::pair<std::recursive_mutex, std::unordered_set<GlobalShaderResourceBinding*>> mtxActiveBindings;
144
147 };
148}
static constexpr unsigned int getFrameResourceCount()
Definition: FrameResourceManager.h:74
Definition: GlobalShaderResourceBindingManager.h:21
std::pair< std::recursive_mutex, std::unordered_set< GlobalShaderResourceBinding * > > mtxActiveBindings
Definition: GlobalShaderResourceBindingManager.h:143
~GlobalShaderResourceBindingManager()
Definition: GlobalShaderResourceBindingManager.cpp:75
std::optional< Error > createGlobalShaderResourceBindingSingleResource(const std::string &sShaderResourceName, GpuResource *pResourceToBind)
Definition: GlobalShaderResourceBindingManager.cpp:32
void unregisterBinding(GlobalShaderResourceBinding *pBinding)
Definition: GlobalShaderResourceBindingManager.cpp:111
std::optional< Error > createGlobalShaderResourceBindingResourcePerFrame(const std::string &sShaderResourceName, std::array< GpuResource *, FrameResourceManager::getFrameResourceCount()> vResourcesToBind)
Definition: GlobalShaderResourceBindingManager.cpp:14
std::optional< Error > onAllGraphicsPipelinesRecreatedInternalResources()
Definition: GlobalShaderResourceBindingManager.cpp:59
std::optional< Error > registerNewBinding(GlobalShaderResourceBinding *pBinding)
Definition: GlobalShaderResourceBindingManager.cpp:90
std::optional< Error > onNewGraphicsPipelineCreated(Pipeline *pNewPipeline)
Definition: GlobalShaderResourceBindingManager.cpp:42
PipelineManager *const pPipelineManager
Definition: GlobalShaderResourceBindingManager.h:146
Definition: GlobalShaderResourceBinding.h:27
Definition: GpuResource.h:16
Definition: PipelineManager.h:54
Definition: Pipeline.h:20
Definition: Renderer.h:43