summaryrefslogtreecommitdiffstats
path: root/AssetLoader/interface
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-12-02 03:48:27 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-12-02 03:48:27 +0000
commitd50d08bd494764564f8f4d516667acf3daf09d30 (patch)
tree38da1da4361599e7d7fbfb1d02b2e7d4c507fa59 /AssetLoader/interface
parentRefcactored GLTFResourceManager: made allocations ref-counted objects (diff)
downloadDiligentTools-d50d08bd494764564f8f4d516667acf3daf09d30.tar.gz
DiligentTools-d50d08bd494764564f8f4d516667acf3daf09d30.zip
GLTFResourceManager: added texture allocation cache
Diffstat (limited to 'AssetLoader/interface')
-rw-r--r--AssetLoader/interface/GLTFLoader.hpp13
-rw-r--r--AssetLoader/interface/GLTFResourceManager.hpp20
2 files changed, 17 insertions, 16 deletions
diff --git a/AssetLoader/interface/GLTFLoader.hpp b/AssetLoader/interface/GLTFLoader.hpp
index e66e808..b395c8c 100644
--- a/AssetLoader/interface/GLTFLoader.hpp
+++ b/AssetLoader/interface/GLTFLoader.hpp
@@ -316,18 +316,7 @@ struct Model
{
std::mutex TexturesMtx;
- struct TextureInfo
- {
- RefCntWeakPtr<ITexture> wpTexture;
-
- const float4 UVScaleBias;
-
- TextureInfo(ITexture* pTex, const float4& _UVScaleBias) :
- wpTexture{pTex},
- UVScaleBias{_UVScaleBias}
- {}
- };
- std::unordered_map<std::string, TextureInfo> Textures;
+ std::unordered_map<std::string, RefCntWeakPtr<ITexture>> Textures;
};
Model(IRenderDevice* pDevice,
diff --git a/AssetLoader/interface/GLTFResourceManager.hpp b/AssetLoader/interface/GLTFResourceManager.hpp
index 9a8397c..e0b007d 100644
--- a/AssetLoader/interface/GLTFResourceManager.hpp
+++ b/AssetLoader/interface/GLTFResourceManager.hpp
@@ -29,6 +29,7 @@
#include <mutex>
#include <vector>
+#include <unordered_map>
#include "../../../DiligentCore/Graphics/GraphicsEngine/interface/RenderDevice.h"
#include "../../../DiligentCore/Graphics/GraphicsEngine/interface/DeviceContext.h"
@@ -94,11 +95,15 @@ public:
TextureAllocation(IReferenceCounters* pRefCounters,
RefCntAutoPtr<GLTFResourceManager> pResourceMg,
TextureCache& ParentCache,
+ Uint32 Width,
+ Uint32 Height,
DynamicAtlasManager::Region&& Region) :
// clang-format off
ObjectBase<IObject>{pRefCounters},
m_pResMgr {std::move(pResourceMg)},
m_ParentCache {ParentCache},
+ m_Width {Width},
+ m_Height {Height},
m_Region {std::move(Region)}
// clang-format on
{
@@ -125,9 +130,14 @@ public:
return m_Region;
}
+ Uint32 GetWidth() const { return m_Width; }
+ Uint32 GetHeight() const { return m_Height; }
+
private:
RefCntAutoPtr<GLTFResourceManager> m_pResMgr;
TextureCache& m_ParentCache;
+ const Uint32 m_Width;
+ const Uint32 m_Height;
DynamicAtlasManager::Region m_Region;
};
@@ -153,10 +163,9 @@ public:
return m_Buffers[BufferIndex].Allocate(Size, Alignment);
}
- RefCntAutoPtr<TextureAllocation> AllocateTextureSpace(Uint32 TextureIndex, Uint32 Width, Uint32 Height)
- {
- return m_Textures[TextureIndex].Allocate(Width, Height);
- }
+ RefCntAutoPtr<TextureAllocation> AllocateTextureSpace(Uint32 TextureIndex, Uint32 Width, Uint32 Height, const char* CacheId = nullptr);
+
+ RefCntAutoPtr<TextureAllocation> FindAllocation(const char* CacheId);
private:
template <typename AllocatorType, typename ObjectType>
@@ -253,6 +262,9 @@ private:
RefCntAutoPtr<ITexture> m_pTexture;
};
std::vector<TextureCache> m_Textures;
+
+ std::mutex m_AllocationsMtx;
+ std::unordered_map<std::string, RefCntWeakPtr<TextureAllocation>> m_Allocations;
};
} // namespace Diligent