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
53 [[nodiscard]] std::optional<Error> createGlobalShaderResourceBindingResourcePerFrame(
54 const std::string& sShaderResourceName,
55 std::array<GpuResource*, FrameResourceManager::getFrameResourceCount()> vResourcesToBind);
56
73 [[nodiscard]] std::optional<Error> createGlobalShaderResourceBindingSingleResource(
74 const std::string& sShaderResourceName, GpuResource* pResourceToBind);
75
78
79 private:
86
95 [[nodiscard]] std::optional<Error> onNewGraphicsPipelineCreated(Pipeline* pNewPipeline);
96
103 [[nodiscard]] std::optional<Error> onAllGraphicsPipelinesRecreatedInternalResources();
104
114 [[nodiscard]] std::optional<Error> registerNewBinding(GlobalShaderResourceBinding* pBinding);
115
124
131 std::pair<std::recursive_mutex, std::unordered_set<GlobalShaderResourceBinding*>> mtxActiveBindings;
132
135 };
136}
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:131
~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:134
Definition: GlobalShaderResourceBinding.h:27
Definition: GpuResource.h:16
Definition: PipelineManager.h:98
Definition: Pipeline.h:20
Definition: Renderer.h:43