Skip to content

Commit 8271310

Browse files
Archiver: don't use auto where unnecessary
1 parent d98abb4 commit 8271310

12 files changed

+171
-163
lines changed

Graphics/Archiver/include/ArchiverImpl.hpp

Lines changed: 2 additions & 1 deletion
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.
@@ -96,6 +96,7 @@ class ArchiverImpl final : public ObjectBase<IArchiver>
9696
private:
9797
using DeviceType = DeviceObjectArchive::DeviceType;
9898
using ResourceType = DeviceObjectArchive::ResourceType;
99+
using ResourceData = DeviceObjectArchive::ResourceData;
99100

100101
RefCntAutoPtr<SerializationDeviceImpl> m_pSerializationDevice;
101102

Graphics/Archiver/src/ArchiverFactory.cpp

Lines changed: 9 additions & 9 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.
@@ -170,8 +170,8 @@ void ArchiverFactoryImpl::CreateArchiver(ISerializationDevice* pDevice, IArchive
170170
*ppArchiver = nullptr;
171171
try
172172
{
173-
auto& RawMemAllocator = GetRawAllocator();
174-
auto* pArchiverImpl(NEW_RC_OBJ(RawMemAllocator, "Archiver instance", ArchiverImpl)(ClassPtrCast<SerializationDeviceImpl>(pDevice)));
173+
IMemoryAllocator& RawMemAllocator = GetRawAllocator();
174+
ArchiverImpl* pArchiverImpl(NEW_RC_OBJ(RawMemAllocator, "Archiver instance", ArchiverImpl)(ClassPtrCast<SerializationDeviceImpl>(pDevice)));
175175
pArchiverImpl->QueryInterface(IID_Archiver, reinterpret_cast<IObject**>(ppArchiver));
176176
}
177177
catch (...)
@@ -189,8 +189,8 @@ void ArchiverFactoryImpl::CreateSerializationDevice(const SerializationDeviceCre
189189
*ppDevice = nullptr;
190190
try
191191
{
192-
auto& RawMemAllocator = GetRawAllocator();
193-
auto* pDeviceImpl(NEW_RC_OBJ(RawMemAllocator, "Serialization device instance", SerializationDeviceImpl)(CreateInfo));
192+
IMemoryAllocator& RawMemAllocator = GetRawAllocator();
193+
SerializationDeviceImpl* pDeviceImpl(NEW_RC_OBJ(RawMemAllocator, "Serialization device instance", SerializationDeviceImpl)(CreateInfo));
194194
pDeviceImpl->QueryInterface(IID_SerializationDevice, reinterpret_cast<IObject**>(ppDevice));
195195
}
196196
catch (...)
@@ -233,8 +233,8 @@ Bool ArchiverFactoryImpl::RemoveDeviceData(const IDataBlob* pSrcArchive
233233

234234
while (DeviceFlags != ARCHIVE_DEVICE_DATA_FLAG_NONE)
235235
{
236-
const auto DataTypeFlag = ExtractLSB(DeviceFlags);
237-
const auto ArchiveDeviceType = ArchiveDeviceDataFlagToArchiveDeviceType(DataTypeFlag);
236+
const ARCHIVE_DEVICE_DATA_FLAGS DataTypeFlag = ExtractLSB(DeviceFlags);
237+
const DeviceObjectArchive::DeviceType ArchiveDeviceType = ArchiveDeviceDataFlagToArchiveDeviceType(DataTypeFlag);
238238

239239
ObjectArchive.RemoveDeviceData(ArchiveDeviceType);
240240
}
@@ -277,8 +277,8 @@ Bool ArchiverFactoryImpl::AppendDeviceData(const IDataBlob* pSrcArchive
277277

278278
while (DeviceFlags != ARCHIVE_DEVICE_DATA_FLAG_NONE)
279279
{
280-
const auto DataTypeFlag = ExtractLSB(DeviceFlags);
281-
const auto ArchiveDeviceType = ArchiveDeviceDataFlagToArchiveDeviceType(DataTypeFlag);
280+
const ARCHIVE_DEVICE_DATA_FLAGS DataTypeFlag = ExtractLSB(DeviceFlags);
281+
const DeviceObjectArchive::DeviceType ArchiveDeviceType = ArchiveDeviceDataFlagToArchiveDeviceType(DataTypeFlag);
282282

283283
ObjectArchive.AppendDeviceData(DevObjectArchive, ArchiveDeviceType);
284284
}

Graphics/Archiver/src/ArchiverImpl.cpp

Lines changed: 32 additions & 32 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.
@@ -83,9 +83,9 @@ Bool ArchiverImpl::SerializeToBlob(Uint32 ContentVersion, IDataBlob** ppBlob)
8383
// Add pipelines and patched shaders
8484
for (const auto& pso_it : m_Pipelines)
8585
{
86-
const auto* Name = pso_it.first.GetName();
87-
const auto ResType = pso_it.first.GetType();
88-
auto& SrcPSO = *pso_it.second;
86+
const char* Name = pso_it.first.GetName();
87+
const ResourceType ResType = pso_it.first.GetType();
88+
SerializedPipelineStateImpl& SrcPSO = *pso_it.second;
8989

9090
const PIPELINE_STATE_STATUS PSOStatus = SrcPSO.GetStatus(/*WaitForCompletion = */ true);
9191
if (PSOStatus != PIPELINE_STATE_STATUS_READY)
@@ -98,8 +98,8 @@ Bool ArchiverImpl::SerializeToBlob(Uint32 ContentVersion, IDataBlob** ppBlob)
9898

9999
if (!SrcPSO.GetData().DoNotPackSignatures)
100100
{
101-
const auto& Signatures = SrcPSO.GetSignatures();
102-
for (auto& pSign : Signatures)
101+
const SerializedPipelineStateImpl::SignaturesVector& Signatures = SrcPSO.GetSignatures();
102+
for (const RefCntAutoPtr<IPipelineResourceSignature>& pSign : Signatures)
103103
{
104104
if (!AddPipelineResourceSignature(pSign))
105105
{
@@ -108,11 +108,11 @@ Bool ArchiverImpl::SerializeToBlob(Uint32 ContentVersion, IDataBlob** ppBlob)
108108
}
109109
}
110110

111-
const auto& SrcData = SrcPSO.GetData();
111+
const SerializedPipelineStateImpl::Data& SrcData = SrcPSO.GetData();
112112
VERIFY_EXPR(SafeStrEqual(Name, SrcPSO.GetDesc().Name));
113113
VERIFY_EXPR(ResType == PipelineTypeToArchiveResourceType(SrcPSO.GetDesc().PipelineType));
114114

115-
auto& DstData = Archive.GetResourceData(ResType, Name);
115+
ResourceData& DstData = Archive.GetResourceData(ResType, Name);
116116
// Add PSO common data
117117
// NB: since the Archive object is temporary, we do not need to copy the data
118118
DstData.Common = SerializedData{SrcData.Common.Ptr(), SrcData.Common.Size()};
@@ -128,7 +128,7 @@ Bool ArchiverImpl::SerializeToBlob(Uint32 ContentVersion, IDataBlob** ppBlob)
128128

129129
std::vector<Uint32> ShaderIndices;
130130
ShaderIndices.reserve(SrcShaders.size());
131-
for (const auto& SrcShader : SrcShaders)
131+
for (const SerializedPipelineStateImpl::Data::ShaderInfo& SrcShader : SrcShaders)
132132
{
133133
VERIFY_EXPR(SrcShader.Data);
134134

@@ -144,7 +144,7 @@ Bool ArchiverImpl::SerializeToBlob(Uint32 ContentVersion, IDataBlob** ppBlob)
144144
DeviceObjectArchive::ShaderIndexArray Indices{ShaderIndices.data(), StaticCast<Uint32>(ShaderIndices.size())};
145145

146146
// For pipelines, device-specific data is the shader indices
147-
auto& SerializedIndices = DstData.DeviceSpecific[device_type];
147+
SerializedData& SerializedIndices = DstData.DeviceSpecific[device_type];
148148

149149
Serializer<SerializerMode::Measure> MeasureSer;
150150
PSOSerializer<SerializerMode::Measure>::SerializeShaderIndices(MeasureSer, Indices, nullptr);
@@ -159,39 +159,39 @@ Bool ArchiverImpl::SerializeToBlob(Uint32 ContentVersion, IDataBlob** ppBlob)
159159
// Add resource signatures
160160
for (const auto& sign_it : m_Signatures)
161161
{
162-
const auto* Name = sign_it.first.GetStr();
163-
const auto& SrcSign = *sign_it.second;
162+
const char* Name = sign_it.first.GetStr();
163+
const SerializedResourceSignatureImpl& SrcSign = *sign_it.second;
164164
VERIFY_EXPR(SafeStrEqual(Name, SrcSign.GetDesc().Name));
165-
const auto& SrcCommonData = SrcSign.GetCommonData();
165+
const SerializedData& SrcCommonData = SrcSign.GetCommonData();
166166

167-
auto& DstData = Archive.GetResourceData(ResourceType::ResourceSignature, Name);
167+
ResourceData& DstData = Archive.GetResourceData(ResourceType::ResourceSignature, Name);
168168
// NB: since the Archive object is temporary, we do not need to copy the data
169169
DstData.Common = SerializedData{SrcCommonData.Ptr(), SrcCommonData.Size()};
170170

171171
for (size_t device_type = 0; device_type < static_cast<size_t>(DeviceType::Count); ++device_type)
172172
{
173-
if (const auto* pMem = SrcSign.GetDeviceData(static_cast<DeviceType>(device_type)))
173+
if (const SerializedData* pMem = SrcSign.GetDeviceData(static_cast<DeviceType>(device_type)))
174174
DstData.DeviceSpecific[device_type] = SerializedData{pMem->Ptr(), pMem->Size()};
175175
}
176176
}
177177

178178
// Add render passes
179179
for (const auto& rp_it : m_RenderPasses)
180180
{
181-
const auto* Name = rp_it.first.GetStr();
182-
const auto& SrcRP = *rp_it.second;
181+
const char* Name = rp_it.first.GetStr();
182+
const SerializedRenderPassImpl& SrcRP = *rp_it.second;
183183
VERIFY_EXPR(SafeStrEqual(Name, SrcRP.GetDesc().Name));
184-
const auto& SrcData = SrcRP.GetCommonData();
184+
const SerializedData& SrcData = SrcRP.GetCommonData();
185185

186-
auto& DstData = Archive.GetResourceData(ResourceType::RenderPass, Name);
187-
DstData.Common = SerializedData{SrcData.Ptr(), SrcData.Size()};
186+
ResourceData& DstData = Archive.GetResourceData(ResourceType::RenderPass, Name);
187+
DstData.Common = SerializedData{SrcData.Ptr(), SrcData.Size()};
188188
}
189189

190190
// Add standalone shaders
191191
for (const auto& shader_it : m_Shaders)
192192
{
193-
const auto* Name = shader_it.first.GetStr();
194-
auto& SrcShader = *shader_it.second;
193+
const char* Name = shader_it.first.GetStr();
194+
SerializedShaderImpl& SrcShader = *shader_it.second;
195195
{
196196
const SHADER_STATUS Status = SrcShader.GetStatus(/*WaitForCompletion = */ true);
197197
if (Status != SHADER_STATUS_READY)
@@ -204,12 +204,12 @@ Bool ArchiverImpl::SerializeToBlob(Uint32 ContentVersion, IDataBlob** ppBlob)
204204
}
205205
VERIFY_EXPR(SafeStrEqual(Name, SrcShader.GetDesc().Name));
206206

207-
auto& DstData = Archive.GetResourceData(ResourceType::StandaloneShader, Name);
208-
DstData.Common = SrcShader.GetCommonData();
207+
ResourceData& DstData = Archive.GetResourceData(ResourceType::StandaloneShader, Name);
208+
DstData.Common = SrcShader.GetCommonData();
209209

210210
for (size_t device_type = 0; device_type < static_cast<size_t>(DeviceType::Count); ++device_type)
211211
{
212-
auto DeviceData = SrcShader.GetDeviceData(static_cast<DeviceType>(device_type));
212+
SerializedData DeviceData = SrcShader.GetDeviceData(static_cast<DeviceType>(device_type));
213213
if (!DeviceData)
214214
continue;
215215

@@ -223,7 +223,7 @@ Bool ArchiverImpl::SerializeToBlob(Uint32 ContentVersion, IDataBlob** ppBlob)
223223
const Uint32 Index = it_inserted.first->second;
224224

225225
// For shaders, device-specific data is the serialized shader bytecode index
226-
auto& SerializedIndex = DstData.DeviceSpecific[device_type];
226+
SerializedData& SerializedIndex = DstData.DeviceSpecific[device_type];
227227

228228
Serializer<SerializerMode::Measure> MeasureSer;
229229
MeasureSer(Index);
@@ -272,7 +272,7 @@ bool AddObjectToArchive(IfaceType*
272272
UNEXPECTED(ObjectTypeStr, " '", pObject->GetDesc().Name, "' was not created by a serialization device.");
273273
return false;
274274
}
275-
const auto* Name = pSerializedObj->GetDesc().Name;
275+
const char* Name = pSerializedObj->GetDesc().Name;
276276

277277
std::lock_guard<std::mutex> Guard{Mtx};
278278

@@ -325,10 +325,10 @@ Bool ArchiverImpl::AddPipelineState(IPipelineState* pPSO)
325325
return false;
326326
}
327327

328-
const auto& Desc = pSerializedPSO->GetDesc();
329-
const auto* Name = Desc.Name;
328+
const PipelineStateDesc& Desc = pSerializedPSO->GetDesc();
329+
const char* Name = Desc.Name;
330330
// Mesh pipelines are serialized as graphics pipelines
331-
const auto ArchiveResType = PipelineTypeToArchiveResourceType(Desc.PipelineType);
331+
const ResourceType ArchiveResType = PipelineTypeToArchiveResourceType(Desc.PipelineType);
332332

333333
{
334334
std::lock_guard<std::mutex> Guard{m_PipelinesMtx};
@@ -342,7 +342,7 @@ Bool ArchiverImpl::AddPipelineState(IPipelineState* pPSO)
342342
}
343343

344344
bool Res = true;
345-
if (auto* pRenderPass = pSerializedPSO->GetRenderPass())
345+
if (IRenderPass* pRenderPass = pSerializedPSO->GetRenderPass())
346346
{
347347
if (!AddRenderPass(pRenderPass))
348348
Res = false;
@@ -412,7 +412,7 @@ IPipelineState* ArchiverImpl::GetPipelineState(PIPELINE_TYPE PSOType,
412412
{
413413
std::lock_guard<std::mutex> Guard{m_PipelinesMtx};
414414

415-
const auto ResType = PiplineTypeToArchiveResourceType(PSOType);
415+
const ResourceType ResType = PiplineTypeToArchiveResourceType(PSOType);
416416
if (ResType == ResourceType::Undefined)
417417
{
418418
UNEXPECTED("Unexpected pipeline type");

Graphics/Archiver/src/Archiver_D3D11.cpp

Lines changed: 20 additions & 19 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.
@@ -112,7 +112,7 @@ struct ShaderStageInfoD3D11
112112
private:
113113
static ShaderD3D11Impl* GetShaderD3D11(const SerializedShaderImpl* pShader)
114114
{
115-
auto* pCompiledShaderD3D11 = pShader->GetShader<CompiledShaderD3D11>(DeviceObjectArchive::DeviceType::Direct3D11);
115+
CompiledShaderD3D11* pCompiledShaderD3D11 = pShader->GetShader<CompiledShaderD3D11>(DeviceObjectArchive::DeviceType::Direct3D11);
116116
return pCompiledShaderD3D11 != nullptr ? &pCompiledShaderD3D11->ShaderD3D11 : nullptr;
117117
}
118118
};
@@ -146,8 +146,8 @@ void SerializedPipelineStateImpl::PatchShadersD3D11(const CreateInfoType& Create
146146
for (size_t i = 0; i < ShadersD3D11.size(); ++i)
147147
ShadersD3D11[i] = ShaderStages[i].pShader;
148148

149-
auto** ppSignatures = CreateInfo.ppResourceSignatures;
150-
auto SignaturesCount = CreateInfo.ResourceSignaturesCount;
149+
IPipelineResourceSignature** ppSignatures = CreateInfo.ppResourceSignatures;
150+
Uint32 SignaturesCount = CreateInfo.ResourceSignaturesCount;
151151

152152
IPipelineResourceSignature* DefaultSignatures[1] = {};
153153
if (CreateInfo.ResourceSignaturesCount == 0)
@@ -231,7 +231,7 @@ void SerializedShaderImpl::CreateShaderD3D11(IReferenceCounters* pRefCounter
231231
void SerializationDeviceImpl::GetPipelineResourceBindingsD3D11(const PipelineResourceBindingAttribs& Info,
232232
std::vector<PipelineResourceBinding>& ResourceBindings)
233233
{
234-
const auto ShaderStages = (Info.ShaderStages == SHADER_TYPE_UNKNOWN ? static_cast<SHADER_TYPE>(~0u) : Info.ShaderStages);
234+
const SHADER_TYPE ShaderStages = (Info.ShaderStages == SHADER_TYPE_UNKNOWN ? static_cast<SHADER_TYPE>(~0u) : Info.ShaderStages);
235235
constexpr SHADER_TYPE SupportedStagesMask = (SHADER_TYPE_ALL_GRAPHICS | SHADER_TYPE_COMPUTE);
236236

237237
SignatureArray<PipelineResourceSignatureD3D11Impl> Signatures = {};
@@ -250,39 +250,40 @@ void SerializationDeviceImpl::GetPipelineResourceBindingsD3D11(const PipelineRes
250250

251251
for (Uint32 r = 0; r < pSignature->GetTotalResourceCount(); ++r)
252252
{
253-
const auto& ResDesc = pSignature->GetResourceDesc(r);
254-
const auto& ResAttr = pSignature->GetResourceAttribs(r);
255-
const auto Range = PipelineResourceSignatureD3D11Impl::ShaderResourceTypeToRange(ResDesc.ResourceType);
253+
using ResourceAttribsD3D11 = PipelineResourceSignatureD3D11Impl::ResourceAttribs;
254+
const PipelineResourceDesc& ResDesc = pSignature->GetResourceDesc(r);
255+
const ResourceAttribsD3D11& ResAttr = pSignature->GetResourceAttribs(r);
256+
const D3D11_RESOURCE_RANGE Range = PipelineResourceSignatureD3D11Impl::ShaderResourceTypeToRange(ResDesc.ResourceType);
256257

257-
for (auto Stages = (ShaderStages & SupportedStagesMask); Stages != 0;)
258+
for (SHADER_TYPE Stages = (ShaderStages & SupportedStagesMask); Stages != 0;)
258259
{
259-
const auto ShaderStage = ExtractLSB(Stages);
260-
const auto ShaderInd = GetShaderTypeIndex(ShaderStage);
260+
const SHADER_TYPE ShaderStage = ExtractLSB(Stages);
261+
const Int32 ShaderInd = GetShaderTypeIndex(ShaderStage);
261262
if ((ResDesc.ShaderStages & ShaderStage) == 0)
262263
continue;
263264

264265
VERIFY_EXPR(ResAttr.BindPoints.IsStageActive(ShaderInd));
265-
const auto Register = Uint32{BaseBindings[Range][ShaderInd]} + Uint32{ResAttr.BindPoints[ShaderInd]};
266+
const Uint32 Register = Uint32{BaseBindings[Range][ShaderInd]} + Uint32{ResAttr.BindPoints[ShaderInd]};
266267
ResourceBindings.push_back(ResDescToPipelineResBinding(ResDesc, ShaderStage, Register, 0 /*space*/));
267268
}
268269
}
269270

270271
for (Uint32 samp = 0; samp < pSignature->GetImmutableSamplerCount(); ++samp)
271272
{
272-
const auto& ImtblSam = pSignature->GetImmutableSamplerDesc(samp);
273-
const auto& SampAttr = pSignature->GetImmutableSamplerAttribs(samp);
274-
const auto Range = D3D11_RESOURCE_RANGE_SAMPLER;
273+
const ImmutableSamplerDesc& ImtblSam = pSignature->GetImmutableSamplerDesc(samp);
274+
const ImmutableSamplerAttribsD3D11& SampAttr = pSignature->GetImmutableSamplerAttribs(samp);
275+
const D3D11_RESOURCE_RANGE Range = D3D11_RESOURCE_RANGE_SAMPLER;
275276

276-
for (auto Stages = (ShaderStages & SupportedStagesMask); Stages != 0;)
277+
for (SHADER_TYPE Stages = (ShaderStages & SupportedStagesMask); Stages != 0;)
277278
{
278-
const auto ShaderStage = ExtractLSB(Stages);
279-
const auto ShaderInd = GetShaderTypeIndex(ShaderStage);
279+
const SHADER_TYPE ShaderStage = ExtractLSB(Stages);
280+
const Int32 ShaderInd = GetShaderTypeIndex(ShaderStage);
280281

281282
if ((ImtblSam.ShaderStages & ShaderStage) == 0)
282283
continue;
283284

284285
VERIFY_EXPR(SampAttr.BindPoints.IsStageActive(ShaderInd));
285-
const auto Binding = Uint32{BaseBindings[Range][ShaderInd]} + Uint32{SampAttr.BindPoints[ShaderInd]};
286+
const Uint32 Binding = Uint32{BaseBindings[Range][ShaderInd]} + Uint32{SampAttr.BindPoints[ShaderInd]};
286287

287288
PipelineResourceBinding Dst{};
288289
Dst.Name = ImtblSam.SamplerOrTextureName;

0 commit comments

Comments
 (0)