summaryrefslogtreecommitdiffstats
path: root/AssetLoader/interface/GLTFLoader.hpp
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/interface/GLTFLoader.hpp
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/interface/GLTFLoader.hpp')
-rw-r--r--AssetLoader/interface/GLTFLoader.hpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/AssetLoader/interface/GLTFLoader.hpp b/AssetLoader/interface/GLTFLoader.hpp
index 8effc2b..1632bb0 100644
--- a/AssetLoader/interface/GLTFLoader.hpp
+++ b/AssetLoader/interface/GLTFLoader.hpp
@@ -342,23 +342,36 @@ struct Model
void PrepareGPUResources(IDeviceContext* pCtx);
- IBuffer* GetBuffer(BUFFER_ID BuffId, Uint32& Offset)
+ IBuffer* GetBuffer(BUFFER_ID BuffId)
{
VERIFY_EXPR(BuffId < BUFFER_ID_NUM_BUFFERS);
auto& Buff = Buffers[BuffId];
if (Buff.pBuffer)
- {
- Offset = 0;
return Buff.pBuffer;
- }
- else if (CacheInfo.pResourceMgr != nullptr)
- {
- Offset = static_cast<Uint32>(Buff.CacheAllocation.Region.UnalignedOffset);
+ else if (Buff.CacheAllocation.IsValid())
return CacheInfo.pResourceMgr->GetBuffer(Buff.CacheAllocation);
- }
+ else
+ return nullptr;
+ }
- Offset = 0;
- return nullptr;
+ Uint32 GetFirstIndexLocation() const
+ {
+ auto& IndBuff = Buffers[BUFFER_ID_INDEX];
+ VERIFY(!IndBuff.CacheAllocation.IsValid() || IndBuff.CacheAllocation.Region.UnalignedOffset % sizeof(Uint32) == 0,
+ "Allocation offset is not multiple of sizeof(Uint32)");
+ return IndBuff.CacheAllocation.IsValid() ?
+ static_cast<Uint32>(IndBuff.CacheAllocation.Region.UnalignedOffset / sizeof(Uint32)) :
+ 0;
+ }
+
+ Uint32 GetBaseVertex() const
+ {
+ auto& VertBuff = Buffers[BUFFER_ID_VERTEX0];
+ VERIFY(!VertBuff.CacheAllocation.IsValid() || VertBuff.CacheAllocation.Region.UnalignedOffset % sizeof(VertexAttribs0) == 0,
+ "Allocation offset is not multiple of sizeof(VertexAttribs0)");
+ return VertBuff.CacheAllocation.IsValid() ?
+ static_cast<Uint32>(VertBuff.CacheAllocation.Region.UnalignedOffset / sizeof(VertexAttribs0)) :
+ 0;
}
ITexture* GetTexture(Uint32 Index)
@@ -366,7 +379,7 @@ struct Model
auto& TexInfo = Textures[Index];
if (TexInfo.pTexture)
return TexInfo.pTexture;
- else if (CacheInfo.pResourceMgr)
+ else if (TexInfo.CacheAllocation.IsValid())
return CacheInfo.pResourceMgr->GetTexture(TexInfo.CacheAllocation);
else
return nullptr;