Nameless Engine
|
#include <GpuResourceManager.h>
Public Member Functions | |
virtual size_t | getTotalVideoMemoryInMb () const =0 |
virtual size_t | getUsedVideoMemoryInMb () const =0 |
virtual std::variant< std::unique_ptr< GpuResource >, Error > | loadTextureFromDisk (const std::string &sResourceName, const std::filesystem::path &pathToTextureFile)=0 |
virtual std::variant< std::unique_ptr< UploadBuffer >, Error > | createResourceWithCpuWriteAccess (const std::string &sResourceName, size_t iElementSizeInBytes, size_t iElementCount, std::optional< bool > isUsedInShadersAsArrayResource)=0 |
virtual std::variant< std::unique_ptr< GpuResource >, Error > | createResourceWithData (const std::string &sResourceName, const void *pBufferData, size_t iElementSizeInBytes, size_t iElementCount, ResourceUsageType usage, bool bIsShaderReadWriteResource)=0 |
virtual std::variant< std::unique_ptr< GpuResource >, Error > | createResource (const std::string &sResourceName, size_t iElementSizeInBytes, size_t iElementCount, ResourceUsageType usage, bool bIsShaderReadWriteResource)=0 |
virtual std::variant< std::unique_ptr< GpuResource >, Error > | createShaderReadWriteTextureResource (const std::string &sResourceName, unsigned int iWidth, unsigned int iHeight, ShaderReadWriteTextureResourceFormat format)=0 |
virtual std::string | getCurrentStateInfo ()=0 |
Renderer * | getRenderer () const |
TextureManager * | getTextureManager () const |
ShadowMapManager * | getShadowMapManager () const |
DynamicCpuWriteShaderResourceArrayManager * | getDynamicCpuWriteShaderResourceArrayManager () const |
size_t | getTotalAliveResourceCount () |
Protected Member Functions | |
virtual std::variant< std::unique_ptr< GpuResource >, Error > | createShadowMapTexture (const std::string &sResourceName, unsigned int iTextureSize, bool bPointLightColorCubemap)=0 |
GpuResourceManager (Renderer *pRenderer) | |
void | resetManagers () |
Static Protected Member Functions | |
static std::variant< std::unique_ptr< GpuResourceManager >, Error > | create (Renderer *pRenderer) |
static std::variant< std::unique_ptr< GpuResourceManager >, Error > | createRendererSpecificManager (Renderer *pRenderer) |
Private Attributes | |
std::unique_ptr< TextureManager > | pTextureManager |
std::unique_ptr< ShadowMapManager > | pShadowMapManager |
std::unique_ptr< DynamicCpuWriteShaderResourceArrayManager > | pDynamicCpuWriteShaderResourceArrayManager |
std::atomic< size_t > | iAliveResourceCount {0} |
Renderer *const | pRenderer = nullptr |
Friends | |
class | Renderer |
class | ShadowMapManager |
class | GpuResource |
Allows creating GPU resources.
|
protected |
|
staticprotected |
|
staticprotected |
|
pure virtual |
Creates a new GPU resource (buffer, not a texture) without any initial data.
sResourceName | Resource name, used for logging. |
iElementSizeInBytes | Size of one buffer element in bytes. |
iElementCount | Number of elements in the resulting buffer. |
usage | Describes how you plan to use this resource. |
bIsShaderReadWriteResource | Specify true if you plan to modify the resource from shaders, otherwise false . |
Implemented in ne::DirectXResourceManager, and ne::VulkanResourceManager.
|
pure virtual |
Creates a new GPU resource with available CPU write access (only CPU write not read), typically used for resources that needs to be frequently updated from the CPU side.
Example:
sResourceName | Resource name, used for logging. |
iElementSizeInBytes | Size of one buffer element in bytes. |
iElementCount | Number of elements in the resulting buffer. |
isUsedInShadersAsArrayResource | Specify empty if this resource is not going to be used in shaders, false if this resource will be used in shaders as a single constant (cbuffer in HLSL, uniform in GLSL), might cause padding to 256 bytes and size limitation up to 64 KB, specify true if this resource will be used in shaders as an array resource (StructuredBuffer in HLSL, storage buffer in GLSL - not an array but it will be a storage buffer). |
Implemented in ne::DirectXResourceManager, and ne::VulkanResourceManager.
|
pure virtual |
Creates a new GPU resource (buffer, not a texture) and fills it with the specified data.
Example:
sResourceName | Resource name, used for logging. |
pBufferData | Pointer to the data that the new resource will contain. |
iElementSizeInBytes | Size of one buffer element in bytes. |
iElementCount | Number of elements in the resulting buffer. |
usage | Describes how you plan to use this resource. |
bIsShaderReadWriteResource | Specify true if you plan to modify the resource from shaders, otherwise false . |
Implemented in ne::DirectXResourceManager, and ne::VulkanResourceManager.
|
pure virtual |
Creates a texture resource that is available as a read/write resource in shaders.
sResourceName | Resource name, used for logging. |
iWidth | Width of the texture in pixels. |
iHeight | Height of the texture in pixels. |
format | Format of the texture. |
Implemented in ne::DirectXResourceManager, and ne::VulkanResourceManager.
|
protectedpure virtual |
Creates a GPU resource to be used as a shadow map.
sResourceName | Resource name, used for logging. |
iTextureSize | Size of one dimension of the texture in pixels. Must be power of 2 (128, 256, 512, 1024, 2048, etc.). |
bPointLightColorCubemap | false is you need a single 2D texture resource or true to have 6 2D textures arranged as a cube map specifically for point lights. |
Implemented in ne::DirectXResourceManager, and ne::VulkanResourceManager.
|
pure virtual |
Dumps internal state of the resource manager in JSON format.
Implemented in ne::DirectXResourceManager, and ne::VulkanResourceManager.
DynamicCpuWriteShaderResourceArrayManager * ne::GpuResourceManager::getDynamicCpuWriteShaderResourceArrayManager | ( | ) | const |
Returns CPU-write shader resource array manager.
Renderer * ne::GpuResourceManager::getRenderer | ( | ) | const |
Returns renderer that owns this resource manager.
ShadowMapManager * ne::GpuResourceManager::getShadowMapManager | ( | ) | const |
Returns shadow map manager.
TextureManager * ne::GpuResourceManager::getTextureManager | ( | ) | const |
Returns texture manager.
size_t ne::GpuResourceManager::getTotalAliveResourceCount | ( | ) |
Returns the total number of GPU resources currently alive.
|
pure virtual |
Returns total video memory size (VRAM) in megabytes.
Implemented in ne::DirectXResourceManager, and ne::VulkanResourceManager.
|
pure virtual |
Returns the amount of video memory (VRAM) occupied by all currently allocated resources.
Implemented in ne::DirectXResourceManager, and ne::VulkanResourceManager.
|
pure virtual |
Loads a texture from the specified path in the GPU memory.
sResourceName | Resource name, used for logging. |
pathToTextureFile | Path to the image file that stores texture data. |
Implemented in ne::DirectXResourceManager, and ne::VulkanResourceManager.
|
protected |
Sets nullptr
to all texture/shadow/etc managers' unique ptr to force destroy them (if exist).
|
private |
Total number of created resources that were not destroyed yet.
|
private |
Manages dynamic CPU-write shader arrays.
|
private |
Do not delete (free) this pointer. Renderer that owns this manager.
|
private |
Stores all shadow maps.
|
private |
Stores all texture GPU resources.