From 18c0c9dea9ff73f1526473aacb85f9a6bb272b13 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sun, 10 Jan 2021 14:46:13 -0800 Subject: GLTF loader: reworked initial texture data to be stored as user data in the texture/allocation to make sure that GPU data is always initialized before the first use --- AssetLoader/interface/GLTFResourceManager.hpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'AssetLoader/interface') diff --git a/AssetLoader/interface/GLTFResourceManager.hpp b/AssetLoader/interface/GLTFResourceManager.hpp index 0e47137..a65f9e1 100644 --- a/AssetLoader/interface/GLTFResourceManager.hpp +++ b/AssetLoader/interface/GLTFResourceManager.hpp @@ -78,7 +78,8 @@ public: RefCntAutoPtr AllocateTextureSpace(TEXTURE_FORMAT Fmt, Uint32 Width, Uint32 Height, - const char* CacheId = nullptr); + const char* CacheId = nullptr, + IObject* pUserData = nullptr); RefCntAutoPtr FindAllocation(const char* CacheId); @@ -116,6 +117,23 @@ public: return cache_it->second->GetTexture(pDevice, pContext); } + // NB: can't return reference here! + TextureDesc GetAtlasDesc(TEXTURE_FORMAT Fmt) + { + { + std::lock_guard Lock{m_AtlasesMtx}; + + auto cache_it = m_Atlases.find(Fmt); + if (cache_it != m_Atlases.end()) + return cache_it->second->GetAtlasDesc(); + } + + // Atlas is not present in the map - use default description + TextureDesc Desc = m_DefaultAtlasDesc.Desc; + Desc.Format = Fmt; + return Desc; + } + private: template friend class Diligent::MakeNewRCObj; -- cgit v1.2.3