Nameless Engine
|
#include <DynamicCpuWriteShaderResourceArrayManager.h>
Public Member Functions | |
DynamicCpuWriteShaderResourceArrayManager (const DynamicCpuWriteShaderResourceArrayManager &)=delete | |
DynamicCpuWriteShaderResourceArrayManager & | operator= (const DynamicCpuWriteShaderResourceArrayManager &)=delete |
std::variant< std::unique_ptr< DynamicCpuWriteShaderResourceArraySlot >, Error > | reserveSlotsInArray (ShaderCpuWriteResourceBinding *pShaderResource) |
DynamicCpuWriteShaderResourceArray * | getArrayForShaderResource (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 |
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).
|
private |
Resource manager that owns this manager
pResourceManager | Owner manager. |
|
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".
iSizeInBytes | Size in bytes to format. |
DynamicCpuWriteShaderResourceArray * ne::DynamicCpuWriteShaderResourceArrayManager::getArrayForShaderResource | ( | const std::string & | sShaderResourceName | ) |
Attempts to find an array that handles shader resource of the specified name.
sShaderResourceName | Name of the shader resource (from shader code). |
nullptr
if not found, otherwise a valid pointer.
|
private |
Goes through all arrays in mtxCpuWriteShaderResourceArrays and removed empty ones.
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.
erase
function because slot destruction automatically uses internal erase
, see documentation on the returned slot object.pShaderResource | Shader 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. |
|
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.
|
private |
Owner of this manager.