summaryrefslogtreecommitdiffstats
path: root/AssetLoader/src/GLTFResourceManager.cpp
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-12-01 05:40:10 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-12-01 05:40:10 +0000
commit8cb15ebb5da1fc825a211548d51a7e77bb981647 (patch)
tree672f8cf5e267d898abb30a83425af3b0a5567357 /AssetLoader/src/GLTFResourceManager.cpp
parentGLTF Loader: implemented buffer suballocation in cache (diff)
downloadDiligentTools-8cb15ebb5da1fc825a211548d51a7e77bb981647.tar.gz
DiligentTools-8cb15ebb5da1fc825a211548d51a7e77bb981647.zip
GLTF Loader: added GetFirstIndexLocation and GetBaseVertex methods
Diffstat (limited to 'AssetLoader/src/GLTFResourceManager.cpp')
-rw-r--r--AssetLoader/src/GLTFResourceManager.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/AssetLoader/src/GLTFResourceManager.cpp b/AssetLoader/src/GLTFResourceManager.cpp
index 54724ea..c6f627c 100644
--- a/AssetLoader/src/GLTFResourceManager.cpp
+++ b/AssetLoader/src/GLTFResourceManager.cpp
@@ -80,13 +80,16 @@ GLTFResourceManager::BufferAllocation GLTFResourceManager::AllocateBufferSpace(U
std::lock_guard<std::mutex> Lock{BuffCache.Mtx};
BufferAllocation Allocation;
- Allocation.BufferIndex = BufferIndex;
- Allocation.Region = BuffCache.Mgr.Allocate(Size, Alignment);
+ Allocation.Region = BuffCache.Mgr.Allocate(Size, Alignment);
+ if (Allocation.Region.IsValid())
+ Allocation.BufferIndex = BufferIndex;
return Allocation;
}
void GLTFResourceManager::FreeBufferSpace(BufferAllocation&& Allocation)
{
+ VERIFY_EXPR(Allocation.IsValid());
+
auto& BuffCache = m_Buffers[Allocation.BufferIndex];
std::lock_guard<std::mutex> Lock{BuffCache.Mtx};
@@ -103,10 +106,11 @@ GLTFResourceManager::TextureAllocation GLTFResourceManager::AllocateTextureSpace
std::lock_guard<std::mutex> Lock{TexCache.Mtx};
TextureAllocation Allocation;
- Allocation.TextureIndex = TextureIndex;
- Allocation.Region = TexCache.Mgr.Allocate(Width, Height);
+ Allocation.Region = TexCache.Mgr.Allocate(Width, Height);
if (!Allocation.Region.IsEmpty())
{
+ Allocation.TextureIndex = TextureIndex;
+
Allocation.Region.x *= TexCache.Granularity;
Allocation.Region.y *= TexCache.Granularity;
Allocation.Region.width *= TexCache.Granularity;
@@ -117,6 +121,8 @@ GLTFResourceManager::TextureAllocation GLTFResourceManager::AllocateTextureSpace
void GLTFResourceManager::FreeTextureSpace(TextureAllocation&& Allocation)
{
+ VERIFY_EXPR(Allocation.IsValid());
+
auto& TexCache = m_Textures[Allocation.TextureIndex];
auto& Region = Allocation.Region;