Skip to content

Commit 32e4b30

Browse files
GLTF Resource Manager: added GetVertexPoolIndex method
1 parent f544b7a commit 32e4b30

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

AssetLoader/interface/GLTFLoader.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2023 Diligent Graphics LLC
2+
* Copyright 2019-2024 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -1047,6 +1047,7 @@ struct Model
10471047
std::vector<Uint32> Strides;
10481048
std::vector<RefCntAutoPtr<IBuffer>> Buffers;
10491049
RefCntAutoPtr<IVertexPoolAllocation> pAllocation;
1050+
Uint32 PoolId = 0; // Vertex pool allocation Id
10501051
Uint32 EnabledAttributeFlags = 0;
10511052
};
10521053
VertexDataInfo VertexData;

AssetLoader/interface/GLTFResourceManager.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ class ResourceManager final : public ObjectBase<IObject>
234234
/// Returns all vertex pools for the given key.
235235
std::vector<IVertexPool*> GetVertexPools(const VertexLayoutKey& Key);
236236

237+
/// Returns index of the vertex pool with the give key.
238+
/// If the pool does not exist, InvalidIndex (0xFFFFFFFF) is returned.
239+
Uint32 GetVertexPoolIndex(const VertexLayoutKey& Key, IVertexPool* pPool);
237240

238241
/// Updates the atlas texture for the given format.
239242
/// If the atlas does not exist, null is returned.

AssetLoader/src/GLTFBuilder.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ void ModelBuilder::InitVertexBuffers(IRenderDevice* pDevice)
318318
auto pBuffInitData = BufferInitData::Create();
319319
pBuffInitData->Data = std::move(m_VertexData);
320320
m_Model.VertexData.pAllocation->SetUserData(pBuffInitData);
321+
m_Model.VertexData.PoolId = m_CI.pResourceManager->GetVertexPoolIndex(LayoutKey, m_Model.VertexData.pAllocation->GetPool());
322+
VERIFY_EXPR(m_Model.VertexData.PoolId != ~0u);
321323
}
322324
else
323325
{

AssetLoader/src/GLTFResourceManager.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,23 @@ std::vector<IVertexPool*> ResourceManager::GetVertexPools(const VertexLayoutKey&
394394
return Pools;
395395
}
396396

397+
Uint32 ResourceManager::GetVertexPoolIndex(const VertexLayoutKey& Key, IVertexPool* pPool)
398+
{
399+
std::lock_guard<std::mutex> Guard{m_VertexPoolsMtx};
400+
401+
const auto pools_it = m_VertexPools.find(Key);
402+
if (pools_it != m_VertexPools.end())
403+
{
404+
for (Uint32 i = 0; i < pools_it->second.size(); ++i)
405+
{
406+
if (pPool == pools_it->second[i])
407+
return i;
408+
}
409+
}
410+
411+
return ~0u;
412+
}
413+
397414
ITexture* ResourceManager::UpdateTexture(TEXTURE_FORMAT Fmt, IRenderDevice* pDevice, IDeviceContext* pContext)
398415
{
399416
decltype(m_Atlases)::iterator cache_it; // NB: can't initialize it without locking the mutex

0 commit comments

Comments
 (0)