Skip to content

Commit aec5216

Browse files
GraphicsEngine: don't use auto where unnecessary
1 parent 20f4245 commit aec5216

File tree

7 files changed

+74
-74
lines changed

7 files changed

+74
-74
lines changed

Graphics/GraphicsEngine/src/DefaultShaderSourceStreamFactory.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2024 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -97,10 +97,10 @@ void DefaultShaderSourceStreamFactory::CreateInputStream2(const Char*
9797
}
9898
else
9999
{
100-
for (const auto& SearchDir : m_SearchDirectories)
100+
for (const std::string& SearchDir : m_SearchDirectories)
101101
{
102-
const auto FullPath = SearchDir + ((Name[0] == '\\' || Name[0] == '/') ? Name + 1 : Name);
103-
pFileStream = CreateFileStream(FullPath.c_str());
102+
const std::string FullPath = SearchDir + ((Name[0] == '\\' || Name[0] == '/') ? Name + 1 : Name);
103+
pFileStream = CreateFileStream(FullPath.c_str());
104104
if (pFileStream)
105105
break;
106106
}
@@ -126,8 +126,8 @@ void CreateDefaultShaderSourceStreamFactory(const Char* Se
126126
DEV_CHECK_ERR(ppShaderSourceStreamFactory != nullptr, "ppShaderSourceStreamFactory must not be null.");
127127
DEV_CHECK_ERR(*ppShaderSourceStreamFactory == nullptr, "*ppShaderSourceStreamFactory is not null. Make sure the pointer is null to avoid memory leaks.");
128128

129-
auto& Allocator = GetRawAllocator();
130-
auto* pStreamFactory =
129+
IMemoryAllocator& Allocator = GetRawAllocator();
130+
DefaultShaderSourceStreamFactory* pStreamFactory =
131131
NEW_RC_OBJ(Allocator, "DefaultShaderSourceStreamFactory instance", DefaultShaderSourceStreamFactory)(SearchDirectories);
132132
pStreamFactory->QueryInterface(IID_IShaderSourceInputStreamFactory, reinterpret_cast<IObject**>(ppShaderSourceStreamFactory));
133133
}

Graphics/GraphicsEngine/src/DeviceMemoryBase.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 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.
@@ -44,7 +44,7 @@ void ValidateDeviceMemoryDesc(const DeviceMemoryDesc& Desc, const IRenderDevice*
4444
{
4545
if (Desc.Type == DEVICE_MEMORY_TYPE_SPARSE)
4646
{
47-
const auto& SparseRes = pDevice->GetAdapterInfo().SparseResources;
47+
const SparseResourceProperties& SparseRes = pDevice->GetAdapterInfo().SparseResources;
4848

4949
VERIFY_DEVMEMORY(Desc.PageSize != 0, "page size must not be zero");
5050

Graphics/GraphicsEngine/src/DeviceObjectArchive.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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.
@@ -261,8 +261,8 @@ void DeviceObjectArchive::Serialize(IDataBlob** ppDataBlob) const
261261

262262
for (const auto& res_it : m_NamedResources)
263263
{
264-
const auto* Name = res_it.first.GetName();
265-
const auto ResType = res_it.first.GetType();
264+
const char* Name = res_it.first.GetName();
265+
const ResourceType ResType = res_it.first.GetType();
266266

267267
res = Ser(ResType, Name);
268268
VERIFY(res, "Failed to serialize resource type and name");
@@ -271,7 +271,7 @@ void DeviceObjectArchive::Serialize(IDataBlob** ppDataBlob) const
271271
VERIFY(res, "Failed to serialize resource data");
272272
}
273273

274-
for (auto& Shaders : m_DeviceShaders)
274+
for (const std::vector<SerializedData>& Shaders : m_DeviceShaders)
275275
{
276276
res = ArchiveSer.SerializeShaders(Shaders);
277277
VERIFY(res, "Failed to serialize shaders");
@@ -281,7 +281,7 @@ void DeviceObjectArchive::Serialize(IDataBlob** ppDataBlob) const
281281
Serializer<SerializerMode::Measure> Measurer;
282282
SerializeThis(Measurer);
283283

284-
auto pDataBlob = DataBlobImpl::Create(Measurer.GetSize());
284+
RefCntAutoPtr<DataBlobImpl> pDataBlob = DataBlobImpl::Create(Measurer.GetSize());
285285

286286
Serializer<SerializerMode::Write> Writer{SerializedData{pDataBlob->GetDataPtr(), pDataBlob->GetSize()}};
287287
SerializeThis(Writer);
@@ -411,7 +411,7 @@ std::string DeviceObjectArchive::ToString() const
411411
if (Resources.empty())
412412
continue;
413413

414-
const auto ResType = Resources.front().get().first.GetType();
414+
const ResourceType ResType = Resources.front().get().first.GetType();
415415
Output << SeparatorLine
416416
<< ResourceTypeToString(ResType) << " (" << Resources.size() << ")\n";
417417
// ------------------
@@ -423,27 +423,27 @@ std::string DeviceObjectArchive::ToString() const
423423
Output << Ident1 << it.first.GetName() << '\n';
424424
// ..Test PRS
425425

426-
const auto& Res = it.second;
426+
const ResourceData& Res = it.second;
427427

428-
auto MaxSize = Res.Common.Size();
428+
size_t MaxSize = Res.Common.Size();
429429
size_t MaxDevNameLen = strlen(CommonDataName);
430430
for (Uint32 i = 0; i < Res.DeviceSpecific.size(); ++i)
431431
{
432-
const auto DevDataSize = Res.DeviceSpecific[i].Size();
432+
const size_t DevDataSize = Res.DeviceSpecific[i].Size();
433433

434434
MaxSize = std::max(MaxSize, DevDataSize);
435435
if (DevDataSize != 0)
436436
MaxDevNameLen = std::max(MaxDevNameLen, strlen(ArchiveDeviceTypeToString(i)));
437437
}
438-
const auto SizeFieldW = GetNumFieldWidth(MaxSize);
438+
const size_t SizeFieldW = GetNumFieldWidth(MaxSize);
439439

440440
Output << Ident2 << std::setw(static_cast<int>(MaxDevNameLen)) << std::left << CommonDataName << ' '
441441
<< std::setw(static_cast<int>(SizeFieldW)) << std::right << Res.Common.Size() << " bytes\n";
442442
// ....Common 1015 bytes
443443

444444
for (Uint32 i = 0; i < Res.DeviceSpecific.size(); ++i)
445445
{
446-
const auto DevDataSize = Res.DeviceSpecific[i].Size();
446+
const size_t DevDataSize = Res.DeviceSpecific[i].Size();
447447
if (DevDataSize > 0)
448448
{
449449
Output << Ident2 << std::setw(static_cast<int>(MaxDevNameLen)) << std::left << ArchiveDeviceTypeToString(i) << ' '
@@ -467,7 +467,7 @@ std::string DeviceObjectArchive::ToString() const
467467
// [1] 'Test PS' 7380 bytes
468468
{
469469
bool HasShaders = false;
470-
for (const auto& Shaders : m_DeviceShaders)
470+
for (const std::vector<SerializedData>& Shaders : m_DeviceShaders)
471471
{
472472
if (!Shaders.empty())
473473
HasShaders = true;
@@ -482,7 +482,7 @@ std::string DeviceObjectArchive::ToString() const
482482

483483
for (Uint32 dev = 0; dev < m_DeviceShaders.size(); ++dev)
484484
{
485-
const auto& Shaders = m_DeviceShaders[dev];
485+
const std::vector<SerializedData>& Shaders = m_DeviceShaders[dev];
486486
if (Shaders.empty())
487487
continue;
488488
Output << Ident1 << ArchiveDeviceTypeToString(dev) << '(' << Shaders.size() << ")\n";
@@ -493,7 +493,7 @@ std::string DeviceObjectArchive::ToString() const
493493

494494
size_t MaxSize = 0;
495495
size_t MaxNameLen = 0;
496-
for (const auto& ShaderData : Shaders)
496+
for (const SerializedData& ShaderData : Shaders)
497497
{
498498
MaxSize = std::max(MaxSize, ShaderData.Size());
499499

@@ -506,8 +506,8 @@ std::string DeviceObjectArchive::ToString() const
506506
MaxNameLen = std::max(MaxNameLen, ShaderNames.back().size());
507507
}
508508

509-
const auto IdxFieldW = GetNumFieldWidth(Shaders.size());
510-
const auto SizeFieldW = GetNumFieldWidth(MaxSize);
509+
const size_t IdxFieldW = GetNumFieldWidth(Shaders.size());
510+
const size_t SizeFieldW = GetNumFieldWidth(MaxSize);
511511
for (Uint32 idx = 0; idx < Shaders.size(); ++idx)
512512
{
513513
Output << Ident2 << '[' << std::setw(static_cast<int>(IdxFieldW)) << std::right << idx << "] "
@@ -533,18 +533,18 @@ void DeviceObjectArchive::RemoveDeviceData(DeviceType Dev) noexcept(false)
533533

534534
void DeviceObjectArchive::AppendDeviceData(const DeviceObjectArchive& Src, DeviceType Dev) noexcept(false)
535535
{
536-
auto& Allocator = GetRawAllocator();
536+
IMemoryAllocator& Allocator = GetRawAllocator();
537537
for (auto& dst_res_it : m_NamedResources)
538538
{
539-
auto& DstData = dst_res_it.second.DeviceSpecific[static_cast<size_t>(Dev)];
539+
SerializedData& DstData = dst_res_it.second.DeviceSpecific[static_cast<size_t>(Dev)];
540540
// Clear dst device data to make sure we don't have invalid shader indices
541541
DstData = {};
542542

543543
auto src_res_it = Src.m_NamedResources.find(dst_res_it.first);
544544
if (src_res_it == Src.m_NamedResources.end())
545545
continue;
546546

547-
const auto& SrcData{src_res_it->second.DeviceSpecific[static_cast<size_t>(Dev)]};
547+
const SerializedData& SrcData{src_res_it->second.DeviceSpecific[static_cast<size_t>(Dev)]};
548548
// Always copy src data even if it is empty
549549
DstData = SrcData.MakeCopy(Allocator);
550550
}
@@ -553,7 +553,7 @@ void DeviceObjectArchive::AppendDeviceData(const DeviceObjectArchive& Src, Devic
553553
const auto& SrcShaders = Src.m_DeviceShaders[static_cast<size_t>(Dev)];
554554
auto& DstShaders = m_DeviceShaders[static_cast<size_t>(Dev)];
555555
DstShaders.clear();
556-
for (const auto& SrcShader : SrcShaders)
556+
for (const SerializedData& SrcShader : SrcShaders)
557557
DstShaders.emplace_back(SrcShader.MakeCopy(Allocator));
558558
}
559559

@@ -564,7 +564,7 @@ void DeviceObjectArchive::Merge(const DeviceObjectArchive& Src) noexcept(false)
564564

565565
static_assert(static_cast<size_t>(ResourceType::Count) == 8, "Did you add a new resource type? You may need to handle it here.");
566566

567-
auto& Allocator = GetRawAllocator();
567+
IMemoryAllocator& Allocator = GetRawAllocator();
568568
DynamicLinearAllocator DynAllocator{Allocator, 512};
569569

570570
// Copy shaders
@@ -577,15 +577,15 @@ void DeviceObjectArchive::Merge(const DeviceObjectArchive& Src) noexcept(false)
577577
if (SrcShaders.empty())
578578
continue;
579579
DstShaders.reserve(DstShaders.size() + SrcShaders.size());
580-
for (const auto& SrcShader : SrcShaders)
580+
for (const SerializedData& SrcShader : SrcShaders)
581581
DstShaders.emplace_back(SrcShader.MakeCopy(Allocator));
582582
}
583583

584584
// Copy named resources
585585
for (auto& src_res_it : Src.m_NamedResources)
586586
{
587-
const auto ResType = src_res_it.first.GetType();
588-
const auto* ResName = src_res_it.first.GetName();
587+
const ResourceType ResType = src_res_it.first.GetType();
588+
const char* ResName = src_res_it.first.GetName();
589589

590590
auto it_inserted = m_NamedResources.emplace(NamedResourceKey{ResType, ResName, /*CopyName = */ true}, src_res_it.second.MakeCopy(Allocator));
591591
if (!it_inserted.second)
@@ -598,7 +598,7 @@ void DeviceObjectArchive::Merge(const DeviceObjectArchive& Src) noexcept(false)
598598
}
599599

600600
const auto IsStandaloneShader = (ResType == ResourceType::StandaloneShader);
601-
const auto IsPipeline =
601+
const bool IsPipeline =
602602
(ResType == ResourceType::GraphicsPipeline ||
603603
ResType == ResourceType::ComputePipeline ||
604604
ResType == ResourceType::RayTracingPipeline ||
@@ -609,9 +609,9 @@ void DeviceObjectArchive::Merge(const DeviceObjectArchive& Src) noexcept(false)
609609
{
610610
for (size_t i = 0; i < static_cast<size_t>(DeviceType::Count); ++i)
611611
{
612-
const auto BaseIdx = ShaderBaseIndices[i];
612+
const Uint32 BaseIdx = ShaderBaseIndices[i];
613613

614-
auto& DeviceData = it_inserted.first->second.DeviceSpecific[i];
614+
SerializedData& DeviceData = it_inserted.first->second.DeviceSpecific[i];
615615
if (!DeviceData)
616616
continue;
617617

@@ -646,7 +646,7 @@ void DeviceObjectArchive::Merge(const DeviceObjectArchive& Src) noexcept(false)
646646
}
647647

648648
std::vector<Uint32> NewIndices{ShaderIndices.pIndices, ShaderIndices.pIndices + ShaderIndices.Count};
649-
for (auto& Idx : NewIndices)
649+
for (Uint32& Idx : NewIndices)
650650
Idx += BaseIdx;
651651

652652
{

Graphics/GraphicsEngine/src/EngineFactoryBase.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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.
@@ -49,7 +49,7 @@ void VerifyEngineCreateInfo(const EngineCreateInfo& EngineCI, const GraphicsAdap
4949
LOG_ERROR_AND_THROW("If NumImmediateContexts is not zero, pContextInfo must not be null");
5050
}
5151

52-
constexpr auto MaxImmediateContexts = 8 * std::min(sizeof(decltype(BufferDesc::ImmediateContextMask)), sizeof(decltype(TextureDesc::ImmediateContextMask)));
52+
constexpr size_t MaxImmediateContexts = 8 * std::min(sizeof(decltype(BufferDesc::ImmediateContextMask)), sizeof(decltype(TextureDesc::ImmediateContextMask)));
5353
static_assert(MAX_COMMAND_QUEUES == MaxImmediateContexts, "Number of bits in MaxImmediateContexts must be equal to MAX_COMMAND_QUEUES");
5454

5555
if (EngineCI.NumImmediateContexts >= MaxImmediateContexts)
@@ -60,7 +60,7 @@ void VerifyEngineCreateInfo(const EngineCreateInfo& EngineCI, const GraphicsAdap
6060
std::array<Uint32, DILIGENT_MAX_ADAPTER_QUEUES> QueueCount = {};
6161
for (Uint32 CtxInd = 0; CtxInd < EngineCI.NumImmediateContexts; ++CtxInd)
6262
{
63-
const auto& ContextInfo = EngineCI.pImmediateContextInfo[CtxInd];
63+
const ImmediateContextCreateInfo& ContextInfo = EngineCI.pImmediateContextInfo[CtxInd];
6464

6565
if (ContextInfo.QueueId >= AdapterInfo.NumQueues)
6666
{

0 commit comments

Comments
 (0)