Skip to content

Commit e415791

Browse files
PipelineStateD3D11: don't use auto where unnecessary
1 parent ed773f5 commit e415791

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp

Lines changed: 31 additions & 30 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");
@@ -64,10 +64,10 @@ PipelineResourceSignatureDescWrapper PipelineStateD3D11Impl::GetDefaultResourceS
6464
PipelineResourceSignatureDescWrapper SignDesc{PSOName, ResourceLayout, SRBAllocationGranularity};
6565

6666
std::unordered_map<ShaderResourceHashKey, const D3DShaderResourceAttribs&, ShaderResourceHashKey::Hasher> UniqueResources;
67-
for (auto* pShader : Shaders)
67+
for (ShaderD3D11Impl* pShader : Shaders)
6868
{
69-
const auto& ShaderResources = *pShader->GetShaderResources();
70-
const auto ShaderType = ShaderResources.GetShaderType();
69+
const ShaderResourcesD3D11& ShaderResources = *pShader->GetShaderResources();
70+
const SHADER_TYPE ShaderType = ShaderResources.GetShaderType();
7171
VERIFY_EXPR(ShaderType == pShader->GetDesc().ShaderType);
7272

7373
ShaderResources.ProcessResources(
@@ -78,7 +78,7 @@ PipelineResourceSignatureDescWrapper PipelineStateD3D11Impl::GetDefaultResourceS
7878
ShaderResources.GetCombinedSamplerSuffix() :
7979
nullptr;
8080

81-
const auto VarDesc = FindPipelineResourceLayoutVariable(ResourceLayout, Attribs.Name, ShaderType, SamplerSuffix);
81+
const ShaderResourceVariableDesc VarDesc = FindPipelineResourceLayoutVariable(ResourceLayout, Attribs.Name, ShaderType, SamplerSuffix);
8282
// Note that Attribs.Name != VarDesc.Name for combined samplers
8383
const auto it_assigned = UniqueResources.emplace(ShaderResourceHashKey{VarDesc.ShaderStages, Attribs.Name}, Attribs);
8484
if (it_assigned.second)
@@ -89,8 +89,8 @@ PipelineResourceSignatureDescWrapper PipelineStateD3D11Impl::GetDefaultResourceS
8989
"Use explicit resource signature to specify the array size.");
9090
}
9191

92-
const auto ResType = Attribs.GetShaderResourceType();
93-
const auto ResFlags = Attribs.GetPipelineResourceFlags() | ShaderVariableFlagsToPipelineResourceFlags(VarDesc.Flags);
92+
const SHADER_RESOURCE_TYPE ResType = Attribs.GetShaderResourceType();
93+
const PIPELINE_RESOURCE_FLAGS ResFlags = Attribs.GetPipelineResourceFlags() | ShaderVariableFlagsToPipelineResourceFlags(VarDesc.Flags);
9494
SignDesc.AddResource(VarDesc.ShaderStages, Attribs.Name, Attribs.BindCount, ResType, VarDesc.Type, ResFlags);
9595
}
9696
else
@@ -121,9 +121,9 @@ void PipelineStateD3D11Impl::RemapOrVerifyShaderResources(const TShaderStages&
121121
// Verify that pipeline layout is compatible with shader resources and remap resource bindings.
122122
for (size_t s = 0; s < Shaders.size(); ++s)
123123
{
124-
auto* const pShader = Shaders[s];
125-
auto const ShaderType = pShader->GetDesc().ShaderType;
126-
const IDataBlob* pBytecode = Shaders[s]->GetD3DBytecode();
124+
ShaderD3D11Impl* const pShader = Shaders[s];
125+
SHADER_TYPE const ShaderType = pShader->GetDesc().ShaderType;
126+
const IDataBlob* pBytecode = Shaders[s]->GetD3DBytecode();
127127

128128
ResourceBinding::TMap ResourceMap;
129129
for (Uint32 sign = 0; sign < SignatureCount; ++sign)
@@ -160,10 +160,11 @@ void PipelineStateD3D11Impl::InitResourceLayouts(const PipelineStateCreateInfo&
160160
const std::vector<ShaderD3D11Impl*>& Shaders,
161161
RefCntAutoPtr<IDataBlob>& pVSByteCode)
162162
{
163-
const auto InternalFlags = GetInternalCreateFlags(CreateInfo);
163+
const PSO_CREATE_INTERNAL_FLAGS InternalFlags = GetInternalCreateFlags(CreateInfo);
164164
if (m_UsingImplicitSignature && (InternalFlags & PSO_CREATE_INTERNAL_FLAG_IMPLICIT_SIGNATURE0) == 0)
165165
{
166-
const auto SignDesc = GetDefaultResourceSignatureDesc(Shaders, m_Desc.Name, m_Desc.ResourceLayout, m_Desc.SRBAllocationGranularity);
166+
const PipelineResourceSignatureDescWrapper SignDesc =
167+
GetDefaultResourceSignatureDesc(Shaders, m_Desc.Name, m_Desc.ResourceLayout, m_Desc.SRBAllocationGranularity);
167168
InitDefaultSignature(SignDesc, GetActiveShaderStages(), false /*IsDeviceInternal*/);
168169
VERIFY_EXPR(m_Signatures[0]);
169170
}
@@ -191,7 +192,7 @@ void PipelineStateD3D11Impl::InitResourceLayouts(const PipelineStateCreateInfo&
191192
#ifdef DILIGENT_DEVELOPMENT
192193
for (Uint32 s = 0; s < D3D11ResourceBindPoints::NumShaderTypes; ++s)
193194
{
194-
const auto ShaderType = GetShaderTypeFromIndex(s);
195+
const SHADER_TYPE ShaderType = GetShaderTypeFromIndex(s);
195196
DEV_CHECK_ERR(ResCounters[D3D11_RESOURCE_RANGE_CBV][s] <= D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT,
196197
"Constant buffer count ", Uint32{ResCounters[D3D11_RESOURCE_RANGE_CBV][s]},
197198
" in ", GetShaderTypeLiteralName(ShaderType), " stage exceeds D3D11 limit ",
@@ -227,7 +228,7 @@ void PipelineStateD3D11Impl::InitResourceLayouts(const PipelineStateCreateInfo&
227228
{
228229
ValidateShaderResourceBindings(m_Desc.Name, *pShader->GetShaderResources(), BindingsMap);
229230
};
230-
const auto ValidateBindingsFn = !HandleRemappedBytecodeFn && (InternalFlags & PSO_CREATE_INTERNAL_FLAG_NO_SHADER_REFLECTION) == 0 ?
231+
const TValidateShaderBindingsFn ValidateBindingsFn = !HandleRemappedBytecodeFn && (InternalFlags & PSO_CREATE_INTERNAL_FLAG_NO_SHADER_REFLECTION) == 0 ?
231232
TValidateShaderBindingsFn{ValidateBindings} :
232233
TValidateShaderBindingsFn{nullptr};
233234

@@ -250,8 +251,8 @@ void PipelineStateD3D11Impl::InitResourceLayouts(const PipelineStateCreateInfo&
250251
{
251252
for (size_t s = 0; s < Shaders.size(); ++s)
252253
{
253-
auto* const pShader = Shaders[s];
254-
m_ppd3d11Shaders[s] = pShader->GetD3D11Shader();
254+
ShaderD3D11Impl* const pShader = Shaders[s];
255+
m_ppd3d11Shaders[s] = pShader->GetD3D11Shader();
255256
VERIFY_EXPR(m_ppd3d11Shaders[s]);
256257

257258
if (pShader->GetDesc().ShaderType == SHADER_TYPE_VERTEX)
@@ -272,8 +273,8 @@ void PipelineStateD3D11Impl::InitInternalObjects(const PSOCreateInfoType& Creat
272273
m_NumShaders = static_cast<Uint8>(Shaders.size());
273274
for (Uint32 s = 0; s < m_NumShaders; ++s)
274275
{
275-
const auto ShaderType = Shaders[s]->GetDesc().ShaderType;
276-
const auto ShaderTypeIdx = GetShaderTypeIndex(ShaderType);
276+
const SHADER_TYPE ShaderType = Shaders[s]->GetDesc().ShaderType;
277+
const Int32 ShaderTypeIdx = GetShaderTypeIndex(ShaderType);
277278
VERIFY_EXPR(m_ShaderIndices[ShaderTypeIdx] < 0);
278279
m_ShaderIndices[ShaderTypeIdx] = static_cast<Int8>(s);
279280
}
@@ -322,7 +323,7 @@ void PipelineStateD3D11Impl::InitializePipeline(const GraphicsPipelineStateCreat
322323
"Failed to create D3D11 depth stencil state");
323324

324325
// Create input layout
325-
const auto& InputLayout = GraphicsPipeline.InputLayout;
326+
const InputLayoutDesc& InputLayout = GraphicsPipeline.InputLayout;
326327
if (InputLayout.NumElements > 0)
327328
{
328329
std::vector<D3D11_INPUT_ELEMENT_DESC, STDAllocatorRawMem<D3D11_INPUT_ELEMENT_DESC>> d311InputElements(STD_ALLOCATOR_RAW_MEM(D3D11_INPUT_ELEMENT_DESC, GetRawAllocator(), "Allocator for vector<D3D11_INPUT_ELEMENT_DESC>"));
@@ -405,8 +406,8 @@ bool PipelineStateD3D11Impl::IsCompatibleWith(const IPipelineState* pPSO) const
405406

406407
void PipelineStateD3D11Impl::ValidateShaderResources(const ShaderD3D11Impl* pShader)
407408
{
408-
const auto& pShaderResources = pShader->GetShaderResources();
409-
const auto ShaderType = pShader->GetDesc().ShaderType;
409+
const auto& pShaderResources = pShader->GetShaderResources();
410+
const SHADER_TYPE ShaderType = pShader->GetDesc().ShaderType;
410411

411412
#ifdef DILIGENT_DEVELOPMENT
412413
m_ShaderResources.emplace_back(pShaderResources);
@@ -420,12 +421,12 @@ void PipelineStateD3D11Impl::ValidateShaderResources(const ShaderD3D11Impl* pSha
420421
m_ResourceAttibutions.emplace_back();
421422
#endif
422423

423-
const auto IsSampler = Attribs.GetInputType() == D3D_SIT_SAMPLER;
424+
const bool IsSampler = Attribs.GetInputType() == D3D_SIT_SAMPLER;
424425
if (IsSampler && pShaderResources->IsUsingCombinedTextureSamplers())
425426
return;
426427

427428
#ifdef DILIGENT_DEVELOPMENT
428-
auto& ResAttribution = m_ResourceAttibutions.back();
429+
ResourceAttribution& ResAttribution = m_ResourceAttibutions.back();
429430
#else
430431
ResourceAttribution ResAttribution;
431432
#endif
@@ -437,15 +438,15 @@ void PipelineStateD3D11Impl::ValidateShaderResources(const ShaderD3D11Impl* pSha
437438
m_Desc.Name, "'.");
438439
}
439440

440-
const auto ResType = Attribs.GetShaderResourceType();
441-
const auto ResFlags = Attribs.GetPipelineResourceFlags();
441+
const SHADER_RESOURCE_TYPE ResType = Attribs.GetShaderResourceType();
442+
const PIPELINE_RESOURCE_FLAGS ResFlags = Attribs.GetPipelineResourceFlags();
442443

443-
const auto* const pSignature = ResAttribution.pSignature;
444+
const PipelineResourceSignatureD3D11Impl* const pSignature = ResAttribution.pSignature;
444445
VERIFY_EXPR(pSignature != nullptr);
445446

446447
if (ResAttribution.ResourceIndex != ResourceAttribution::InvalidResourceIndex)
447448
{
448-
auto ResDesc = pSignature->GetResourceDesc(ResAttribution.ResourceIndex);
449+
PipelineResourceDesc ResDesc = pSignature->GetResourceDesc(ResAttribution.ResourceIndex);
449450
if (ResDesc.ResourceType == SHADER_RESOURCE_TYPE_INPUT_ATTACHMENT)
450451
ResDesc.ResourceType = SHADER_RESOURCE_TYPE_TEXTURE_SRV;
451452

@@ -479,10 +480,10 @@ void PipelineStateD3D11Impl::DvpVerifySRBResources(const ShaderResourceCacheArra
479480
const BaseBindingsArrayType& BaseBindings) const
480481
{
481482
// Verify base bindings
482-
const auto SignCount = GetResourceSignatureCount();
483+
const Uint32 SignCount = GetResourceSignatureCount();
483484
for (Uint32 sign = 0; sign < SignCount; ++sign)
484485
{
485-
const auto* pSignature = GetResourceSignature(sign);
486+
const PipelineResourceSignatureD3D11Impl* pSignature = GetResourceSignature(sign);
486487
if (pSignature == nullptr || pSignature->GetTotalResourceCount() == 0)
487488
continue; // Skip null and empty signatures
488489

@@ -498,7 +499,7 @@ void PipelineStateD3D11Impl::DvpVerifySRBResources(const ShaderResourceCacheArra
498499
{
499500
if (*attrib_it && !attrib_it->IsImmutableSampler())
500501
{
501-
const auto* pResourceCache = ResourceCaches[attrib_it->SignatureIndex];
502+
const ShaderResourceCacheD3D11* pResourceCache = ResourceCaches[attrib_it->SignatureIndex];
502503
DEV_CHECK_ERR(pResourceCache != nullptr, "No shader resource cache is set at index ", attrib_it->SignatureIndex);
503504
attrib_it->pSignature->DvpValidateCommittedResource(Attribs, attrib_it->ResourceIndex, *pResourceCache,
504505
pResources->GetShaderName(), m_Desc.Name);

0 commit comments

Comments
 (0)