GLTF resource manager. More...
#include <GLTFResourceManager.hpp>
Classes | |
struct | CreateInfo |
Resource manager create info. More... | |
struct | DefaultVertexPoolDesc |
struct | TransitionResourceStatesInfo |
Parameters of the TransitionResourceStates() method. More... | |
struct | VertexLayoutKey |
Vertex layout key used to select the vertex pool. More... | |
Public Member Functions | |
RefCntAutoPtr< ITextureAtlasSuballocation > | AllocateTextureSpace (TEXTURE_FORMAT Fmt, Uint32 Width, Uint32 Height, const char *CacheId=nullptr, IObject *pUserData=nullptr) |
Allocates texture space in the texture atlas that matches the specified format. | |
RefCntAutoPtr< ITextureAtlasSuballocation > | FindTextureAllocation (const char *CacheId) |
Finds texture allocation in the texture atlas that matches the specified cache ID. | |
RefCntAutoPtr< IBufferSuballocation > | AllocateIndices (Uint32 Size, Uint32 Alignment=4) |
Allocates indices in the index buffer. | |
RefCntAutoPtr< IVertexPoolAllocation > | AllocateVertices (const VertexLayoutKey &LayoutKey, Uint32 VertexCount) |
Allocates vertices in the vertex pool that matches the specified layout. | |
Uint32 | GetTextureVersion () const |
Uint32 | GetIndexBufferVersion () const |
Returns the index buffer version. | |
Uint32 | GetVertexPoolsVersion () const |
Returns the combined vertex pool version, i.e. the sum all vertex pool versions. | |
IBuffer * | UpdateIndexBuffer (IRenderDevice *pDevice, IDeviceContext *pContext, Uint32 Index=0) |
Updates the index buffer, if necessary. | |
void | UpdateIndexBuffers (IRenderDevice *pDevice, IDeviceContext *pContext) |
Updates all index buffers. | |
size_t | GetIndexBufferCount () const |
Returns the number of index buffers. | |
Uint32 | GetIndexAllocatorIndex (IBufferSuballocator *pAllocator) const |
Returns the index allocator index. | |
void | UpdateVertexBuffers (IRenderDevice *pDevice, IDeviceContext *pContext) |
Updates the vertex buffers, if necessary. | |
IBuffer * | GetIndexBuffer (Uint32 Index=0) const |
Returns a pointer to the index buffer. | |
IVertexPool * | GetVertexPool (const VertexLayoutKey &Key, Uint32 Index=0) |
size_t | GetVertexPoolCount (const VertexLayoutKey &Key) const |
Returns the number of vertex pools for the given key. | |
std::vector< IVertexPool * > | GetVertexPools (const VertexLayoutKey &Key) const |
Returns all vertex pools for the given key. | |
Uint32 | GetVertexPoolIndex (const VertexLayoutKey &Key, IVertexPool *pPool) const |
ITexture * | UpdateTexture (TEXTURE_FORMAT Fmt, IRenderDevice *pDevice, IDeviceContext *pContext) |
void | UpdateTextures (IRenderDevice *pDevice, IDeviceContext *pContext) |
Updates all atlas textures. | |
ITexture * | GetTexture (TEXTURE_FORMAT Fmt) const |
void | UpdateAllResources (IRenderDevice *pDevice, IDeviceContext *pContext) |
Uint32 | GetAllocationAlignment (TEXTURE_FORMAT Fmt, Uint32 Width, Uint32 Height) |
Returns the texture atlas allocation alignment for the given format. | |
BufferSuballocatorUsageStats | GetIndexBufferUsageStats () |
Returns the index buffer usage stats. | |
DynamicTextureAtlasUsageStats | GetAtlasUsageStats (TEXTURE_FORMAT Fmt=TEX_FORMAT_UNKNOWN) |
Returns the texture atlas usage stats. | |
VertexPoolUsageStats | GetVertexPoolUsageStats (const VertexLayoutKey &Key=VertexLayoutKey{}) |
Returns the vertex pool usage stats. | |
void | TransitionResourceStates (IRenderDevice *pDevice, IDeviceContext *pContext, const TransitionResourceStatesInfo &Info) |
Transitions resource states of all vertex buffers, index buffer and texture atlases. | |
std::vector< TEXTURE_FORMAT > | GetAllocatedAtlasFormats () const |
Returns the formats of the allocated texture atlases. | |
Static Public Member Functions | |
static RefCntAutoPtr< ResourceManager > | Create (IRenderDevice *pDevice, const CreateInfo &CI) |
Creates a new resource manager instance. | |
GLTF resource manager.
RefCntAutoPtr< ITextureAtlasSuballocation > Diligent::GLTF::ResourceManager::AllocateTextureSpace | ( | TEXTURE_FORMAT | Fmt, |
Uint32 | Width, | ||
Uint32 | Height, | ||
const char * | CacheId = nullptr, | ||
IObject * | pUserData = nullptr ) |
Allocates texture space in the texture atlas that matches the specified format.
[in] | Fmt | - Texture format. |
[in] | Width | - Texture width. |
[in] | Height | - Texture height. |
[in] | CacheId | - Optional cache ID. |
[in] | pUserData | - Optional user data to set in the texture atlas suballocation. |
If the texture atlas for the given format does not exist and if the default atlas description allows creating new atlases (Desc.Type != Diligent::RESOURCE_DIM_UNDEFINED), new atlas will be added. Otherwise, the function will return null.
RefCntAutoPtr< IVertexPoolAllocation > Diligent::GLTF::ResourceManager::AllocateVertices | ( | const VertexLayoutKey & | LayoutKey, |
Uint32 | VertexCount ) |
Allocates vertices in the vertex pool that matches the specified layout.
[in] | LayoutKey | - Vertex layout key, see VertexLayoutKey. |
[in] | VertexCount | - The number of vertices to allocate. |
If the vertex pool for the given key does not exist and if the default pool description allows creating new pools (VertexCount != 0), new pool will be added.
If existing pools run out of space, a new vertex pool will be created and vertices will be allocated from this pool.
If no pull exists for the given key and the default pool description does not allow creating new pools (VertexCount == 0), the function returns null.
DynamicTextureAtlasUsageStats Diligent::GLTF::ResourceManager::GetAtlasUsageStats | ( | TEXTURE_FORMAT | Fmt = TEX_FORMAT_UNKNOWN | ) |
Returns the texture atlas usage stats.
If fmt
is not Diligent::TEX_FORMAT_UNKNOWN, returns the stats for the atlas matching the specified format. Otherwise, returns the net usage stats for all atlases.
ITexture * Diligent::GLTF::ResourceManager::GetTexture | ( | TEXTURE_FORMAT | Fmt | ) | const |
Returns the atlas texture for the given format. If the atlas does not exist, null is returned.
Uint32 Diligent::GLTF::ResourceManager::GetTextureVersion | ( | ) | const |
Returns the combined texture atlas version, i.e. the sum of the texture versions of all atlases.
IVertexPool * Diligent::GLTF::ResourceManager::GetVertexPool | ( | const VertexLayoutKey & | Key, |
Uint32 | Index = 0 ) |
Returns a pointer to the vertex pool for the given key and index. If the pool does not exist, null is returned.
If multiple vertex pools with the same key may exist, an application can use the GetVertexPools() method to get all pools for the given key.
Uint32 Diligent::GLTF::ResourceManager::GetVertexPoolIndex | ( | const VertexLayoutKey & | Key, |
IVertexPool * | pPool ) const |
Returns index of the vertex pool with the give key. If the pool does not exist, InvalidIndex (0xFFFFFFFF) is returned.
VertexPoolUsageStats Diligent::GLTF::ResourceManager::GetVertexPoolUsageStats | ( | const VertexLayoutKey & | Key = VertexLayoutKey{} | ) |
Returns the vertex pool usage stats.
If the key is not equal the default key, returns the stats for the vertex pool matching the key. Otherwise, returns the net usage stats for all pools.
void Diligent::GLTF::ResourceManager::TransitionResourceStates | ( | IRenderDevice * | pDevice, |
IDeviceContext * | pContext, | ||
const TransitionResourceStatesInfo & | Info ) |
Transitions resource states of all vertex buffers, index buffer and texture atlases.
[in] | pDevice | - Pointer to the render device. |
[in] | pContext | - Pointer to the device context. |
[in] | Info | - Resource state transition info, see Diligent::ResourceManager::TransitionResourceStatesInfo. |
void Diligent::GLTF::ResourceManager::UpdateAllResources | ( | IRenderDevice * | pDevice, |
IDeviceContext * | pContext ) |
Updates all vertex buffers, index buffer and atlas textures.
This method is equivalent to calling UpdateIndexBuffer(), UpdateVertexBuffers() and UpdateTextures().
ITexture * Diligent::GLTF::ResourceManager::UpdateTexture | ( | TEXTURE_FORMAT | Fmt, |
IRenderDevice * | pDevice, | ||
IDeviceContext * | pContext ) |
Updates the atlas texture for the given format. If the atlas does not exist, null is returned.