Nameless Engine
|
#include <GlobalShaderResourceBindingManager.h>
Public Member Functions | |
std::optional< Error > | createGlobalShaderResourceBindingResourcePerFrame (const std::string &sShaderResourceName, std::array< GpuResource *, FrameResourceManager::getFrameResourceCount()> vResourcesToBind) |
std::optional< Error > | createGlobalShaderResourceBindingSingleResource (const std::string &sShaderResourceName, GpuResource *pResourceToBind) |
~GlobalShaderResourceBindingManager () | |
Private Member Functions | |
GlobalShaderResourceBindingManager (PipelineManager *pPipelineManager) | |
std::optional< Error > | onNewGraphicsPipelineCreated (Pipeline *pNewPipeline) |
std::optional< Error > | onAllGraphicsPipelinesRecreatedInternalResources () |
std::optional< Error > | registerNewBinding (GlobalShaderResourceBinding *pBinding) |
void | unregisterBinding (GlobalShaderResourceBinding *pBinding) |
Private Attributes | |
std::pair< std::recursive_mutex, std::unordered_set< GlobalShaderResourceBinding * > > | mtxActiveBindings |
PipelineManager *const | pPipelineManager = nullptr |
Friends | |
class | Renderer |
class | PipelineManager |
class | GlobalShaderResourceBinding |
Manages bindings of GPU resources as global shader resources (that don't change on a per-object basis).
ne::GlobalShaderResourceBindingManager::~GlobalShaderResourceBindingManager | ( | ) |
Makes sure no active binding exists.
|
private |
Initializes a new manager.
pPipelineManager | Manager used to interact with pipelines. |
std::optional< Error > ne::GlobalShaderResourceBindingManager::createGlobalShaderResourceBindingResourcePerFrame | ( | const std::string & | sShaderResourceName, |
std::array< GpuResource *, FrameResourceManager::getFrameResourceCount()> | vResourcesToBind | ||
) |
Creates a new global shader resource binding (that don't change on a per-object basis) and assigns it to the specified resources. When resources will be destroyed the binding will also be removed.
sShaderResourceName | Name of the shader resource (name from shader code) to bind the resources. |
vResourcesToBind | Resources to bind to pipelines. This function will create a binding that binds a separate GPU resource per frame (can be used for some CPU-write resources). If you have a CPU-write GPU buffer that you plan to update without CPU-GPU synchronization (for example each time the CPU is submitting a new frame) then you need to pass a separate buffer per frame resource to avoid modifying a buffer that may be used by the GPU. |
std::optional< Error > ne::GlobalShaderResourceBindingManager::createGlobalShaderResourceBindingSingleResource | ( | const std::string & | sShaderResourceName, |
GpuResource * | pResourceToBind | ||
) |
Creates a new global shader resource binding (that don't change on a per-object basis) and assigns it to the specified resources. When resources will be destroyed the binding will also be removed.
sShaderResourceName | Name of the shader resource (name from shader code) to bind the resource. |
pResourceToBind | Resources to bind to pipelines. This function will create a binding that binds the same GPU resource for all frames in-flight (this can be used for textures or some buffer resources). This is used when you guarantee the CPU-GPU synchronization or don't plan to update the resource's contents. |
|
private |
Called by pipeline manager after all graphics pipelines re-created their internal state to re-bind all global shader resources to all pipelines.
|
private |
Should be called by bindings upon construction.
Registers the binding and binds it to all graphics pipelines that might need that binding.
pBinding | Binding to register. |
|
private |
Should be called by bindings in their destructor.
Unregisters a binding that was previously registered using registerNewBinding.
pBinding | Binding to unregister. |
|
private |
Set of all currently existing (active) bindings.
|
private |
Manager used to interact with pipelines.