Nameless Engine
|
#include <ShaderCpuWriteResourceBindingManager.h>
Classes | |
struct | Resources |
Public Member Functions | |
ShaderCpuWriteResourceBindingManager (const ShaderCpuWriteResourceBindingManager &)=delete | |
ShaderCpuWriteResourceBindingManager & | operator= (const ShaderCpuWriteResourceBindingManager &)=delete |
~ShaderCpuWriteResourceBindingManager () | |
std::variant< ShaderCpuWriteResourceBindingUniquePtr, Error > | createShaderCpuWriteResource (const std::string &sShaderResourceName, const std::string &sResourceAdditionalInfo, size_t iResourceDataSizeInBytes, const std::unordered_set< Pipeline * > &pipelinesToUse, const std::function< void *()> &onStartedUpdatingResource, const std::function< void()> &onFinishedUpdatingResource) |
void | updateResources (size_t iCurrentFrameResourceIndex) |
void | markResourceAsNeedsUpdate (ShaderCpuWriteResourceBinding *pResourceToDestroy) |
std::pair< std::recursive_mutex, Resources > * | getResources () |
Private Member Functions | |
ShaderCpuWriteResourceBindingManager (Renderer *pRenderer) | |
std::variant< ShaderCpuWriteResourceBindingUniquePtr, Error > | handleResourceCreation (std::variant< std::unique_ptr< ShaderCpuWriteResourceBinding >, Error > result) |
void | destroyResource (ShaderCpuWriteResourceBinding *pResourceToDestroy) |
Private Attributes | |
Renderer * | pRenderer = nullptr |
std::pair< std::recursive_mutex, Resources > | mtxShaderCpuWriteResources |
Friends | |
class | Renderer |
class | ShaderCpuWriteResourceBindingUniquePtr |
Stores all shader resource bindings that have CPU write access.
ne::ShaderCpuWriteResourceBindingManager::~ShaderCpuWriteResourceBindingManager | ( | ) |
Makes sure that no resource exists.
|
private |
Initializes manager.
pRenderer |
std::variant< ShaderCpuWriteResourceBindingUniquePtr, Error > ne::ShaderCpuWriteResourceBindingManager::createShaderCpuWriteResource | ( | const std::string & | sShaderResourceName, |
const std::string & | sResourceAdditionalInfo, | ||
size_t | iResourceDataSizeInBytes, | ||
const std::unordered_set< Pipeline * > & | pipelinesToUse, | ||
const std::function< void *()> & | onStartedUpdatingResource, | ||
const std::function< void()> & | onFinishedUpdatingResource | ||
) |
Creates a new render-specific shader resource.
sShaderResourceName | Name of the resource we are referencing (should be exactly the same as the resource name written in the shader file we are referencing). |
sResourceAdditionalInfo | Additional text that we will append to created resource name (used for logging). |
iResourceDataSizeInBytes | Size of the data that this resource will contain. |
pipelinesToUse | Pipelines that use shader/parameters we are referencing. |
onStartedUpdatingResource | Function that will be called when started updating resource data. Function returns pointer to data of the specified resource data size that needs to be copied into the resource. |
onFinishedUpdatingResource | Function that will be called when finished updating (usually used for unlocking resource data mutex). |
|
private |
Called by shader CPU write resource unique pointers to destroy the specified resource because it will no longer be used.
pResourceToDestroy | Resource to destroy. |
std::pair< std::recursive_mutex, ShaderCpuWriteResourceBindingManager::Resources > * ne::ShaderCpuWriteResourceBindingManager::getResources | ( | ) |
Returns internal resources.
|
private |
Processes resource creation.
result | Result of resource creation function. |
void ne::ShaderCpuWriteResourceBindingManager::markResourceAsNeedsUpdate | ( | ShaderCpuWriteResourceBinding * | pResourceToDestroy | ) |
Marks resource as "needs update", this will cause resource's update callback function to be later called multiple times.
pResourceToDestroy | Resource to mark as "needs update". |
void ne::ShaderCpuWriteResourceBindingManager::updateResources | ( | size_t | iCurrentFrameResourceIndex | ) |
Updates all resources marked as "needs update" and copies new (updated) data to the GPU resource of the specified frame resource.
iCurrentFrameResourceIndex | Index of the frame resource that will be used to submit the next frame. |
|
private |
Shader CPU write resources.
|
private |
Renderer that owns this manager.