Nameless Engine
Loading...
Searching...
No Matches
ne::DynamicCpuWriteShaderResourceArrayManager Class Reference

#include <DynamicCpuWriteShaderResourceArrayManager.h>

Public Member Functions

 DynamicCpuWriteShaderResourceArrayManager (const DynamicCpuWriteShaderResourceArrayManager &)=delete
 
DynamicCpuWriteShaderResourceArrayManageroperator= (const DynamicCpuWriteShaderResourceArrayManager &)=delete
 
std::variant< std::unique_ptr< DynamicCpuWriteShaderResourceArraySlot >, ErrorreserveSlotsInArray (ShaderCpuWriteResourceBinding *pShaderResource)
 
DynamicCpuWriteShaderResourceArraygetArrayForShaderResource (const std::string &sShaderResourceName)
 

Private Member Functions

 DynamicCpuWriteShaderResourceArrayManager (GpuResourceManager *pResourceManager)
 
void removeEmptyArrays ()
 

Static Private Member Functions

static std::string formatBytesToMegabytes (size_t iSizeInBytes)
 

Private Attributes

GpuResourceManager *const pResourceManager = nullptr
 
std::pair< std::recursive_mutex, std::unordered_map< std::string, std::unique_ptr< DynamicCpuWriteShaderResourceArray > > > mtxCpuWriteShaderResourceArrays
 

Friends

class GpuResourceManager
 

Detailed Description

Manages CPU-write arrays to shader resource arrays.

Its main purpose is to avoid possible duplication of shader resource arrays (when 2 or more arrays handle the same shader resource).

Constructor & Destructor Documentation

◆ DynamicCpuWriteShaderResourceArrayManager()

ne::DynamicCpuWriteShaderResourceArrayManager::DynamicCpuWriteShaderResourceArrayManager ( GpuResourceManager pResourceManager)
private

Resource manager that owns this manager

Parameters
pResourceManagerOwner manager.

Member Function Documentation

◆ formatBytesToMegabytes()

std::string ne::DynamicCpuWriteShaderResourceArrayManager::formatBytesToMegabytes ( size_t  iSizeInBytes)
staticprivate

Formats the specified size in bytes to the following format: "<number> MB", for example the number 1512 will be formatted to the following text: "0.0014 MB".

Parameters
iSizeInBytesSize in bytes to format.
Returns
Formatted text.

◆ getArrayForShaderResource()

DynamicCpuWriteShaderResourceArray * ne::DynamicCpuWriteShaderResourceArrayManager::getArrayForShaderResource ( const std::string &  sShaderResourceName)

Attempts to find an array that handles shader resource of the specified name.

Remarks
Mostly used for automated testing.
Parameters
sShaderResourceNameName of the shader resource (from shader code).
Returns
nullptr if not found, otherwise a valid pointer.

◆ removeEmptyArrays()

void ne::DynamicCpuWriteShaderResourceArrayManager::removeEmptyArrays ( )
private

Goes through all arrays in mtxCpuWriteShaderResourceArrays and removed empty ones.

◆ reserveSlotsInArray()

std::variant< std::unique_ptr< DynamicCpuWriteShaderResourceArraySlot >, Error > ne::DynamicCpuWriteShaderResourceArrayManager::reserveSlotsInArray ( ShaderCpuWriteResourceBinding pShaderResource)

Requests a new slot in the array to be reserved. If an array for the shader resource (that the binding references) was never requested previously it will be created by this manager and the array will be binded to all pipelines that use this shader resource as a global shader resource binding.

Remarks
There is no erase function because slot destruction automatically uses internal erase, see documentation on the returned slot object.
Parameters
pShaderResourceShader resource that requires a slot in the array. If the array will resize, the specified resource (if it has an active slot in the array) will be automatically marked as "needs update" through the shader resource manager.
Returns
Error if something went wrong, otherwise slot of the newly added element in the array.

Member Data Documentation

◆ mtxCpuWriteShaderResourceArrays

std::pair< std::recursive_mutex, std::unordered_map<std::string, std::unique_ptr<DynamicCpuWriteShaderResourceArray> > > ne::DynamicCpuWriteShaderResourceArrayManager::mtxCpuWriteShaderResourceArrays
private

Stores pairs of "shader resource name" - "array that handles the shader resource", where "shader resource name" is the name of the resource written in the shader file.

◆ pResourceManager

GpuResourceManager* const ne::DynamicCpuWriteShaderResourceArrayManager::pResourceManager = nullptr
private

Owner of this manager.


The documentation for this class was generated from the following files: