Skip to content

Commit 200a58d

Browse files
GraphicsEngineD3DBase: don't use auto where unnecessary
1 parent ab49b88 commit 200a58d

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

Graphics/GraphicsEngineD3DBase/src/D3DShaderResourceValidation.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.
@@ -70,7 +70,7 @@ void ValidateShaderResourceBindings(const char* PSOName,
7070
"' is not present in the resource bindings map.");
7171
}
7272

73-
const auto& Bindings = it->second;
73+
const ResourceBinding::BindInfo& Bindings = it->second;
7474
if (Bindings.BindPoint != Attribs.BindPoint)
7575
{
7676
LOG_ERROR_AND_THROW("Resource '", Attribs.Name, "' in shader '", Resources.GetShaderName(), "' of PSO '", PSOName,

Graphics/GraphicsEngineD3DBase/src/DXGITypeConversions.cpp

Lines changed: 4 additions & 4 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");
@@ -413,7 +413,7 @@ DXGI_FORMAT TexFormatToDXGI_Format(TEXTURE_FORMAT TexFormat, Uint32 BindFlags)
413413

414414
if (TexFormat >= TEX_FORMAT_UNKNOWN && TexFormat < TEX_FORMAT_NUM_FORMATS)
415415
{
416-
auto DXGIFormat = FmtToDXGIFmtMap[TexFormat];
416+
DXGI_FORMAT DXGIFormat = FmtToDXGIFmtMap[TexFormat];
417417
VERIFY(TexFormat == TEX_FORMAT_UNKNOWN || TexFormat > TEX_FORMAT_BC7_UNORM_SRGB || DXGIFormat != DXGI_FORMAT_UNKNOWN, "Unsupported texture format");
418418
if (BindFlags != 0)
419419
DXGIFormat = CorrectDXGIFormat(DXGIFormat, BindFlags);
@@ -433,7 +433,7 @@ class DXGIFmtToFmtMapInitializer
433433
{
434434
for (TEXTURE_FORMAT fmt = TEX_FORMAT_UNKNOWN; fmt < TEX_FORMAT_NUM_FORMATS; fmt = static_cast<TEXTURE_FORMAT>(fmt + 1))
435435
{
436-
auto DXGIFmt = TexFormatToDXGI_Format(fmt);
436+
DXGI_FORMAT DXGIFmt = TexFormatToDXGI_Format(fmt);
437437
VERIFY_EXPR(DXGIFmt <= DXGI_FORMAT_B4G4R4A4_UNORM);
438438
DXGIFmtToFmtMap[DXGIFmt] = fmt;
439439
}
@@ -448,7 +448,7 @@ TEXTURE_FORMAT DXGI_FormatToTexFormat(DXGI_FORMAT DXGIFormat)
448448

449449
if (DXGIFormat >= DXGI_FORMAT_UNKNOWN && DXGIFormat <= DXGI_FORMAT_BC7_UNORM_SRGB)
450450
{
451-
auto Format = DXGIFmtToFmtMap[DXGIFormat];
451+
TEXTURE_FORMAT Format = DXGIFmtToFmtMap[DXGIFormat];
452452
VERIFY(DXGIFormat == DXGI_FORMAT_UNKNOWN || Format != TEX_FORMAT_UNKNOWN, "Unsupported texture format");
453453
VERIFY_EXPR(DXGIFormat == TexFormatToDXGI_Format(Format));
454454
return Format;

Graphics/GraphicsEngineD3DBase/src/ShaderResources.cpp

Lines changed: 23 additions & 23 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
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -132,13 +132,13 @@ void ShaderResources::AllocateMemory(IMemoryAllocator& Allocator,
132132
{
133133
constexpr Uint32 MaxOffset = std::numeric_limits<OffsetType>::max();
134134
VERIFY(CurrentOffset <= MaxOffset, "Current offset (", CurrentOffset, ") exceeds max allowed value (", MaxOffset, ")");
135-
auto Offset = static_cast<OffsetType>(CurrentOffset);
135+
OffsetType Offset = static_cast<OffsetType>(CurrentOffset);
136136
CurrentOffset += NumResources;
137137
return Offset;
138138
};
139139

140140
// clang-format off
141-
auto CBOffset = AdvanceOffset(ResCounters.NumCBs); (void)CBOffset; // To suppress warning
141+
OffsetType CBOffset = AdvanceOffset(ResCounters.NumCBs); (void)CBOffset; // To suppress warning
142142
m_TexSRVOffset = AdvanceOffset(ResCounters.NumTexSRVs);
143143
m_TexUAVOffset = AdvanceOffset(ResCounters.NumTexUAVs);
144144
m_BufSRVOffset = AdvanceOffset(ResCounters.NumBufSRVs);
@@ -147,8 +147,8 @@ void ShaderResources::AllocateMemory(IMemoryAllocator& Allocator,
147147
m_AccelStructsOffset = AdvanceOffset(ResCounters.NumAccelStructs);
148148
m_TotalResources = AdvanceOffset(0);
149149

150-
auto AlignedResourceNamesPoolSize = AlignUp(ResourceNamesPoolSize, sizeof(void*));
151-
auto MemorySize = m_TotalResources * sizeof(D3DShaderResourceAttribs) + AlignedResourceNamesPoolSize * sizeof(char);
150+
size_t AlignedResourceNamesPoolSize = AlignUp(ResourceNamesPoolSize, sizeof(void*));
151+
size_t MemorySize = m_TotalResources * sizeof(D3DShaderResourceAttribs) + AlignedResourceNamesPoolSize * sizeof(char);
152152

153153
VERIFY_EXPR(GetNumCBs() == ResCounters.NumCBs);
154154
VERIFY_EXPR(GetNumTexSRV() == ResCounters.NumTexSRVs);
@@ -161,7 +161,7 @@ void ShaderResources::AllocateMemory(IMemoryAllocator& Allocator,
161161

162162
if (MemorySize)
163163
{
164-
auto* pRawMem = ALLOCATE_RAW(Allocator, "Allocator for shader resources", MemorySize);
164+
void* pRawMem = ALLOCATE_RAW(Allocator, "Allocator for shader resources", MemorySize);
165165
m_MemoryBuffer = std::unique_ptr<void, STDDeleterRawMem<void>>(pRawMem, Allocator);
166166
char* NamesPool = reinterpret_cast<char*>(reinterpret_cast<D3DShaderResourceAttribs*>(pRawMem) + m_TotalResources);
167167
ResourceNamesPool.AssignMemory(NamesPool, ResourceNamesPoolSize);
@@ -180,11 +180,11 @@ void ShaderResources::DvpVerifyResourceLayout(const PipelineResourceLayoutDesc&
180180
std::string ShadersStr;
181181
while (ShaderStages != SHADER_TYPE_UNKNOWN)
182182
{
183-
const auto ShaderType = ShaderStages & static_cast<SHADER_TYPE>(~(static_cast<Uint32>(ShaderStages) - 1));
184-
String ShaderName;
183+
const SHADER_TYPE ShaderType = ShaderStages & static_cast<SHADER_TYPE>(~(static_cast<Uint32>(ShaderStages) - 1));
184+
String ShaderName;
185185
for (Uint32 s = 0; s < NumShaders; ++s)
186186
{
187-
const auto& Resources = *pShaderResources[s];
187+
const ShaderResources& Resources = *pShaderResources[s];
188188
if ((ShaderStages & Resources.GetShaderType()) != 0)
189189
{
190190
if (ShaderName.size())
@@ -218,7 +218,7 @@ void ShaderResources::DvpVerifyResourceLayout(const PipelineResourceLayoutDesc&
218218
{
219219
for (Uint32 v = 0; v < ResourceLayout.NumVariables; ++v)
220220
{
221-
const auto& VarDesc = ResourceLayout.Variables[v];
221+
const ShaderResourceVariableDesc& VarDesc = ResourceLayout.Variables[v];
222222
if (VarDesc.ShaderStages == SHADER_TYPE_UNKNOWN)
223223
{
224224
LOG_WARNING_MESSAGE("No allowed shader stages are specified for ", GetShaderVariableTypeLiteralName(VarDesc.Type), " variable '", VarDesc.Name, "'.");
@@ -228,14 +228,14 @@ void ShaderResources::DvpVerifyResourceLayout(const PipelineResourceLayoutDesc&
228228
bool VariableFound = false;
229229
for (Uint32 s = 0; s < NumShaders && !VariableFound; ++s)
230230
{
231-
const auto& Resources = *pShaderResources[s];
231+
const ShaderResources& Resources = *pShaderResources[s];
232232
if ((VarDesc.ShaderStages & Resources.GetShaderType()) == 0)
233233
continue;
234234

235-
const auto UseCombinedTextureSamplers = Resources.IsUsingCombinedTextureSamplers();
235+
const bool UseCombinedTextureSamplers = Resources.IsUsingCombinedTextureSamplers();
236236
for (Uint32 n = 0; n < Resources.m_TotalResources && !VariableFound; ++n)
237237
{
238-
const auto& Res = Resources.GetResAttribs(n, Resources.m_TotalResources, 0);
238+
const D3DShaderResourceAttribs& Res = Resources.GetResAttribs(n, Resources.m_TotalResources, 0);
239239

240240
// Skip samplers if combined texture samplers are used as
241241
// in this case they are not treated as independent variables
@@ -259,30 +259,30 @@ void ShaderResources::DvpVerifyResourceLayout(const PipelineResourceLayoutDesc&
259259
{
260260
for (Uint32 sam = 0; sam < ResourceLayout.NumImmutableSamplers; ++sam)
261261
{
262-
const auto& StSamDesc = ResourceLayout.ImmutableSamplers[sam];
262+
const ImmutableSamplerDesc& StSamDesc = ResourceLayout.ImmutableSamplers[sam];
263263
if (StSamDesc.ShaderStages == SHADER_TYPE_UNKNOWN)
264264
{
265265
LOG_WARNING_MESSAGE("No allowed shader stages are specified for immutable sampler '", StSamDesc.SamplerOrTextureName, "'.");
266266
continue;
267267
}
268268

269-
const auto* TexOrSamName = StSamDesc.SamplerOrTextureName;
269+
const char* TexOrSamName = StSamDesc.SamplerOrTextureName;
270270

271271
bool ImtblSamplerFound = false;
272272
for (Uint32 s = 0; s < NumShaders && !ImtblSamplerFound; ++s)
273273
{
274-
const auto& Resources = *pShaderResources[s];
274+
const ShaderResources& Resources = *pShaderResources[s];
275275
if ((StSamDesc.ShaderStages & Resources.GetShaderType()) == 0)
276276
continue;
277277

278278
// Look for immutable sampler.
279279
// In case HLSL-style combined image samplers are used, the condition is Sampler.Name == "g_Texture" + "_sampler".
280280
// Otherwise the condition is Sampler.Name == "g_Texture_sampler" + "".
281-
const auto* CombinedSamplerSuffix = Resources.GetCombinedSamplerSuffix();
281+
const char* CombinedSamplerSuffix = Resources.GetCombinedSamplerSuffix();
282282
for (Uint32 n = 0; n < Resources.GetNumSamplers() && !ImtblSamplerFound; ++n)
283283
{
284-
const auto& Sampler = Resources.GetSampler(n);
285-
ImtblSamplerFound = StreqSuff(Sampler.Name, TexOrSamName, CombinedSamplerSuffix);
284+
const D3DShaderResourceAttribs& Sampler = Resources.GetSampler(n);
285+
ImtblSamplerFound = StreqSuff(Sampler.Name, TexOrSamName, CombinedSamplerSuffix);
286286
}
287287
}
288288

@@ -301,10 +301,10 @@ Uint32 ShaderResources::FindAssignedSamplerId(const D3DShaderResourceAttribs& Te
301301
{
302302
VERIFY_EXPR(SamplerSuffix != nullptr && *SamplerSuffix != 0);
303303
VERIFY_EXPR(TexSRV.GetInputType() == D3D_SIT_TEXTURE && TexSRV.GetSRVDimension() != D3D_SRV_DIMENSION_BUFFER);
304-
auto NumSamplers = GetNumSamplers();
304+
Uint32 NumSamplers = GetNumSamplers();
305305
for (Uint32 s = 0; s < NumSamplers; ++s)
306306
{
307-
const auto& Sampler = GetSampler(s);
307+
const D3DShaderResourceAttribs& Sampler = GetSampler(s);
308308
if (StreqSuff(Sampler.Name, TexSRV.Name, SamplerSuffix))
309309
{
310310
DEV_CHECK_ERR(Sampler.BindCount == TexSRV.BindCount || Sampler.BindCount == 1, "Sampler '", Sampler.Name, "' assigned to texture '", TexSRV.Name, "' must be scalar or have the same array dimension (", TexSRV.BindCount, "). Actual sampler array dimension : ", Sampler.BindCount);
@@ -383,7 +383,7 @@ HLSLShaderResourceDesc ShaderResources::GetHLSLShaderResourceDesc(Uint32 Index)
383383
HLSLShaderResourceDesc HLSLResourceDesc = {};
384384
if (Index < m_TotalResources)
385385
{
386-
const auto& Res = GetResAttribs(Index, m_TotalResources, 0);
386+
const D3DShaderResourceAttribs& Res = GetResAttribs(Index, m_TotalResources, 0);
387387
return Res.GetHLSLResourceDesc();
388388
}
389389
return HLSLResourceDesc;
@@ -394,7 +394,7 @@ size_t ShaderResources::GetHash() const
394394
size_t hash = ComputeHash(GetNumCBs(), GetNumTexSRV(), GetNumTexUAV(), GetNumBufSRV(), GetNumBufUAV(), GetNumSamplers());
395395
for (Uint32 n = 0; n < m_TotalResources; ++n)
396396
{
397-
const auto& Res = GetResAttribs(n, m_TotalResources, 0);
397+
const D3DShaderResourceAttribs& Res = GetResAttribs(n, m_TotalResources, 0);
398398
HashCombine(hash, Res);
399399
}
400400

0 commit comments

Comments
 (0)