11/*
2- * Copyright 2019-2024 Diligent Graphics LLC
2+ * Copyright 2019-2025 Diligent Graphics LLC
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -51,7 +51,7 @@ size_t ModelBuilder::PrimitiveKey::Hasher::operator()(const PrimitiveKey& Key) c
5151 if (Key.Hash == 0 )
5252 {
5353 Key.Hash = ComputeHash (Key.AccessorIds .size ());
54- for (auto Id : Key.AccessorIds )
54+ for (int Id : Key.AccessorIds )
5555 HashCombine (Key.Hash , Id);
5656 }
5757 return Key.Hash ;
@@ -79,7 +79,7 @@ inline Uint8 ConvertElement<Uint8, false, float>(float Src)
7979template <>
8080inline Int8 ConvertElement<Int8, true , float >(float Src)
8181{
82- auto r = Src > 0 .f ? +0 .5f : -0 .5f ;
82+ float r = Src > 0 .f ? +0 .5f : -0 .5f ;
8383 return static_cast <Int8>(clamp (Src * 127 .f + r, -127 .f , 127 .f ));
8484}
8585
@@ -128,7 +128,7 @@ inline void WriteGltfData(const void* pSrc,
128128{
129129 for (size_t elem = 0 ; elem < NumElements; ++elem)
130130 {
131- const auto * pSrcCmp = reinterpret_cast <const SrcType*>(static_cast <const Uint8*>(pSrc) + SrcElemStride * elem);
131+ const SrcType * pSrcCmp = reinterpret_cast <const SrcType*>(static_cast <const Uint8*>(pSrc) + SrcElemStride * elem);
132132
133133 auto comp_it = dst_it + DstElementStride * elem;
134134 for (Uint32 cmp = 0 ; cmp < NumComponents; ++cmp, comp_it += sizeof (DstType))
@@ -140,7 +140,7 @@ inline void WriteGltfData(const void* pSrc,
140140
141141void ModelBuilder::WriteGltfData (const WriteGltfDataAttribs& Attribs)
142142{
143- const auto NumComponentsToCopy = std::min (Attribs.NumSrcComponents , Attribs.NumDstComponents );
143+ const Uint32 NumComponentsToCopy = std::min (Attribs.NumSrcComponents , Attribs.NumDstComponents );
144144
145145#define INNER_CASE (SrcType, DstType ) \
146146 case DstType: \
@@ -205,7 +205,7 @@ void ModelBuilder::WriteDefaultAttibuteValue(const void* pDefau
205205 Uint32 DstElementStride,
206206 Uint32 NumElements)
207207{
208- auto ElementSize = GetValueSize (DstType) * NumDstComponents;
208+ Uint32 ElementSize = GetValueSize (DstType) * NumDstComponents;
209209 VERIFY (DstElementStride >= ElementSize, " Destination element stride is too small" );
210210 for (size_t elem = 0 ; elem < NumElements; ++elem)
211211 {
@@ -216,13 +216,13 @@ void ModelBuilder::WriteDefaultAttibuteValue(const void* pDefau
216216
217217void ModelBuilder::WriteDefaultAttibutes (Uint32 BufferId, size_t StartOffset, size_t EndOffset)
218218{
219- const auto VertexStride = m_Model.VertexData .Strides [BufferId];
219+ const Uint32 VertexStride = m_Model.VertexData .Strides [BufferId];
220220 VERIFY (StartOffset % VertexStride == 0 , " Start offset is not aligned to vertex stride" );
221221 VERIFY (EndOffset % VertexStride == 0 , " End offset is not aligned to vertex stride" );
222- const auto NumVertices = static_cast <Uint32>((EndOffset - StartOffset) / VertexStride);
222+ const Uint32 NumVertices = static_cast <Uint32>((EndOffset - StartOffset) / VertexStride);
223223 for (Uint32 i = 0 ; i < m_Model.GetNumVertexAttributes (); ++i)
224224 {
225- const auto & Attrib = m_Model.VertexAttributes [i];
225+ const VertexAttributeDesc & Attrib = m_Model.VertexAttributes [i];
226226 if (BufferId != Attrib.BufferId || Attrib.pDefaultValue == nullptr )
227227 continue ;
228228
@@ -244,14 +244,14 @@ void ModelBuilder::InitIndexBuffer(IRenderDevice* pDevice)
244244 VERIFY_EXPR ((m_IndexData.size () % m_Model.IndexData .IndexSize ) == 0 );
245245 VERIFY (!m_Model.IndexData .pBuffer && !m_Model.IndexData .pAllocation , " Index buffer has already been initialized" );
246246
247- const auto DataSize = static_cast <Uint32>(m_IndexData.size ());
247+ const Uint32 DataSize = static_cast <Uint32>(m_IndexData.size ());
248248 if (m_CI.pResourceManager != nullptr )
249249 {
250250 m_Model.IndexData .pAllocation = m_CI.pResourceManager ->AllocateIndices (DataSize, 4 );
251251
252252 if (m_Model.IndexData .pAllocation )
253253 {
254- auto pBuffInitData = BufferInitData::Create ();
254+ RefCntAutoPtr<BufferInitData> pBuffInitData = BufferInitData::Create ();
255255 pBuffInitData->Data .emplace_back (std::move (m_IndexData));
256256 m_Model.IndexData .pAllocation ->SetUserData (pBuffInitData);
257257
@@ -265,8 +265,8 @@ void ModelBuilder::InitIndexBuffer(IRenderDevice* pDevice)
265265 }
266266 else
267267 {
268- const auto BindFlags = m_CI.IndBufferBindFlags != BIND_NONE ? m_CI.IndBufferBindFlags : BIND_INDEX_BUFFER;
269- BufferDesc BuffDesc{" GLTF index buffer" , DataSize, BindFlags, USAGE_IMMUTABLE};
268+ const BIND_FLAGS BindFlags = m_CI.IndBufferBindFlags != BIND_NONE ? m_CI.IndBufferBindFlags : BIND_INDEX_BUFFER;
269+ BufferDesc BuffDesc{" GLTF index buffer" , DataSize, BindFlags, USAGE_IMMUTABLE};
270270 if (BuffDesc.BindFlags & (BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS))
271271 {
272272 BuffDesc.Mode = BUFFER_MODE_FORMATTED;
@@ -286,7 +286,7 @@ void ModelBuilder::InitVertexBuffers(IRenderDevice* pDevice)
286286 return ;
287287 }
288288
289- const auto VBCount = m_Model.GetVertexBufferCount ();
289+ const size_t VBCount = m_Model.GetVertexBufferCount ();
290290 VERIFY_EXPR (m_VertexData.size () == VBCount);
291291
292292 size_t NumVertices = 0 ;
@@ -317,16 +317,16 @@ void ModelBuilder::InitVertexBuffers(IRenderDevice* pDevice)
317317 LayoutKey.Elements .reserve (VBCount);
318318 for (Uint32 i = 0 ; i < VBCount; ++i)
319319 {
320- const auto BindFlags = m_CI.VertBufferBindFlags [i] != BIND_NONE ? m_CI.VertBufferBindFlags [i] : BIND_VERTEX_BUFFER;
320+ const BIND_FLAGS BindFlags = m_CI.VertBufferBindFlags [i] != BIND_NONE ? m_CI.VertBufferBindFlags [i] : BIND_VERTEX_BUFFER;
321321 LayoutKey.Elements .emplace_back (m_Model.VertexData .Strides [i], BindFlags);
322322 }
323323
324324 VERIFY (!m_Model.VertexData .pAllocation , " This vertex buffer has already been initialized" );
325325 m_Model.VertexData .pAllocation = m_CI.pResourceManager ->AllocateVertices (LayoutKey, static_cast <Uint32>(NumVertices));
326326 if (m_Model.VertexData .pAllocation )
327327 {
328- auto pBuffInitData = BufferInitData::Create ();
329- pBuffInitData->Data = std::move (m_VertexData);
328+ RefCntAutoPtr<BufferInitData> pBuffInitData = BufferInitData::Create ();
329+ pBuffInitData->Data = std::move (m_VertexData);
330330 m_Model.VertexData .pAllocation ->SetUserData (pBuffInitData);
331331 m_Model.VertexData .PoolId = m_CI.pResourceManager ->GetVertexPoolIndex (LayoutKey, m_Model.VertexData .pAllocation ->GetPool ());
332332 VERIFY_EXPR (m_Model.VertexData .PoolId != ~0u );
@@ -342,16 +342,16 @@ void ModelBuilder::InitVertexBuffers(IRenderDevice* pDevice)
342342 m_Model.VertexData .Buffers .resize (VBCount);
343343 for (Uint32 i = 0 ; i < VBCount; ++i)
344344 {
345- const auto & Data = m_VertexData[i];
345+ const std::vector<Uint8> & Data = m_VertexData[i];
346346 if (Data.empty ())
347347 continue ;
348348
349- const auto DataSize = static_cast <Uint32>(Data.size ());
350- const auto Name = std::string{" GLTF vertex buffer " } + std::to_string (i);
351- const auto BindFlags = m_CI.VertBufferBindFlags [i] != BIND_NONE ? m_CI.VertBufferBindFlags [i] : BIND_VERTEX_BUFFER;
352- BufferDesc BuffDesc{Name.c_str (), DataSize, BindFlags, USAGE_IMMUTABLE};
349+ const Uint32 DataSize = static_cast <Uint32>(Data.size ());
350+ const std::string Name = std::string{" GLTF vertex buffer " } + std::to_string (i);
351+ const BIND_FLAGS BindFlags = m_CI.VertBufferBindFlags [i] != BIND_NONE ? m_CI.VertBufferBindFlags [i] : BIND_VERTEX_BUFFER;
352+ BufferDesc BuffDesc{Name.c_str (), DataSize, BindFlags, USAGE_IMMUTABLE};
353353
354- const auto ElementStride = m_Model.VertexData .Strides [i];
354+ const Uint32 ElementStride = m_Model.VertexData .Strides [i];
355355 VERIFY_EXPR (ElementStride > 0 );
356356 VERIFY_EXPR (Data.size () % ElementStride == 0 );
357357
0 commit comments