Skip to content

Commit 1a2163e

Browse files
Pipeline Resource Signature: updated documentation
Also, don't use auto where unnecessary
1 parent 96d7ead commit 1a2163e

File tree

3 files changed

+122
-117
lines changed

3 files changed

+122
-117
lines changed

Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp

Lines changed: 44 additions & 44 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");
@@ -219,7 +219,7 @@ class PipelineResourceSignatureDescWrapper
219219
m_Desc.NumResources = StaticCast<Uint32>(m_Resources.size());
220220
m_Desc.Resources = m_Resources.data();
221221

222-
auto& Res{m_Resources.back()};
222+
PipelineResourceDesc& Res{m_Resources.back()};
223223
Res.Name = m_StringPool.insert(Res.Name).first->c_str();
224224
}
225225

@@ -230,14 +230,14 @@ class PipelineResourceSignatureDescWrapper
230230
m_Desc.NumImmutableSamplers = StaticCast<Uint32>(m_ImmutableSamplers.size());
231231
m_Desc.ImmutableSamplers = m_ImmutableSamplers.data();
232232

233-
auto& ImtblSam{m_ImmutableSamplers.back()};
233+
ImmutableSamplerDesc& ImtblSam{m_ImmutableSamplers.back()};
234234
ImtblSam.SamplerOrTextureName = m_StringPool.insert(ImtblSam.SamplerOrTextureName).first->c_str();
235235
}
236236

237237
template <class HandlerType>
238238
void ProcessImmutableSamplers(HandlerType&& Handler)
239239
{
240-
for (auto& ImtblSam : m_ImmutableSamplers)
240+
for (ImmutableSamplerDesc& ImtblSam : m_ImmutableSamplers)
241241
{
242242
const char* OrigName = ImtblSam.SamplerOrTextureName;
243243
Handler(ImtblSam);
@@ -249,7 +249,7 @@ class PipelineResourceSignatureDescWrapper
249249
template <class HandlerType>
250250
void ProcessResources(HandlerType&& Handler)
251251
{
252-
for (auto& Res : m_Resources)
252+
for (PipelineResourceDesc& Res : m_Resources)
253253
{
254254
const char* OrigName = Res.Name;
255255
Handler(Res);
@@ -384,7 +384,7 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
384384
// shader stages that have static resources.
385385
for (Uint32 i = 0; i < Desc.NumResources; ++i)
386386
{
387-
const auto& ResDesc = Desc.Resources[i];
387+
const PipelineResourceDesc& ResDesc = Desc.Resources[i];
388388

389389
m_ShaderStages |= ResDesc.ShaderStages;
390390
if (ResDesc.VarType == SHADER_RESOURCE_VARIABLE_TYPE_STATIC)
@@ -399,10 +399,10 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
399399

400400
{
401401
Uint32 StaticVarStageIdx = 0;
402-
for (auto StaticResStages = m_StaticResShaderStages; StaticResStages != SHADER_TYPE_UNKNOWN; ++StaticVarStageIdx)
402+
for (SHADER_TYPE StaticResStages = m_StaticResShaderStages; StaticResStages != SHADER_TYPE_UNKNOWN; ++StaticVarStageIdx)
403403
{
404-
const auto StageBit = ExtractLSB(StaticResStages);
405-
const auto ShaderTypeInd = GetShaderTypePipelineIndex(StageBit, m_PipelineType);
404+
const SHADER_TYPE StageBit = ExtractLSB(StaticResStages);
405+
const Int32 ShaderTypeInd = GetShaderTypePipelineIndex(StageBit, m_PipelineType);
406406
m_StaticResStageIndex[ShaderTypeInd] = static_cast<Int8>(StaticVarStageIdx);
407407
}
408408
VERIFY_EXPR(StaticVarStageIdx == GetNumStaticResStages());
@@ -449,8 +449,8 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
449449
return 0;
450450
}
451451

452-
const auto ShaderTypeInd = GetShaderTypePipelineIndex(ShaderType, m_PipelineType);
453-
const auto VarMngrInd = m_StaticResStageIndex[ShaderTypeInd];
452+
const Int32 ShaderTypeInd = GetShaderTypePipelineIndex(ShaderType, m_PipelineType);
453+
const int VarMngrInd = m_StaticResStageIndex[ShaderTypeInd];
454454
if (VarMngrInd < 0)
455455
return 0;
456456

@@ -469,8 +469,8 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
469469
return nullptr;
470470
}
471471

472-
const auto ShaderTypeInd = GetShaderTypePipelineIndex(ShaderType, m_PipelineType);
473-
const auto VarMngrInd = m_StaticResStageIndex[ShaderTypeInd];
472+
const Int32 ShaderTypeInd = GetShaderTypePipelineIndex(ShaderType, m_PipelineType);
473+
const int VarMngrInd = m_StaticResStageIndex[ShaderTypeInd];
474474
if (VarMngrInd < 0)
475475
return nullptr;
476476

@@ -489,8 +489,8 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
489489
return nullptr;
490490
}
491491

492-
const auto ShaderTypeInd = GetShaderTypePipelineIndex(ShaderType, m_PipelineType);
493-
const auto VarMngrInd = m_StaticResStageIndex[ShaderTypeInd];
492+
const Int32 ShaderTypeInd = GetShaderTypePipelineIndex(ShaderType, m_PipelineType);
493+
const int VarMngrInd = m_StaticResStageIndex[ShaderTypeInd];
494494
if (VarMngrInd < 0)
495495
return nullptr;
496496

@@ -503,15 +503,15 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
503503
IResourceMapping* pResourceMapping,
504504
BIND_SHADER_RESOURCES_FLAGS Flags) override final
505505
{
506-
const auto PipelineType = GetPipelineType();
506+
const PIPELINE_TYPE PipelineType = GetPipelineType();
507507
for (Uint32 ShaderInd = 0; ShaderInd < m_StaticResStageIndex.size(); ++ShaderInd)
508508
{
509-
const auto VarMngrInd = m_StaticResStageIndex[ShaderInd];
509+
const int VarMngrInd = m_StaticResStageIndex[ShaderInd];
510510
if (VarMngrInd >= 0)
511511
{
512512
VERIFY_EXPR(static_cast<Uint32>(VarMngrInd) < GetNumStaticResStages());
513513
// ShaderInd is the shader type pipeline index here
514-
const auto ShaderType = GetShaderTypeFromPipelineIndex(ShaderInd, PipelineType);
514+
const SHADER_TYPE ShaderType = GetShaderTypeFromPipelineIndex(ShaderInd, PipelineType);
515515
if (ShaderStages & ShaderType)
516516
{
517517
m_StaticVarsMgrs[VarMngrInd].BindResources(pResourceMapping, Flags);
@@ -531,9 +531,9 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
531531
}
532532
DEV_CHECK_ERR(*ppShaderResourceBinding == nullptr, "Overwriting existing shader resource binding pointer may cause memory leaks.");
533533

534-
auto* pThisImpl{static_cast<PipelineResourceSignatureImplType*>(this)};
535-
auto& SRBAllocator{pThisImpl->GetDevice()->GetSRBAllocator()};
536-
auto* pResBindingImpl{NEW_RC_OBJ(SRBAllocator, "ShaderResourceBinding instance", ShaderResourceBindingImplType)(pThisImpl)};
534+
PipelineResourceSignatureImplType* pThisImpl{static_cast<PipelineResourceSignatureImplType*>(this)};
535+
FixedBlockMemoryAllocator& SRBAllocator{pThisImpl->GetDevice()->GetSRBAllocator()};
536+
ShaderResourceBindingImplType* pResBindingImpl{NEW_RC_OBJ(SRBAllocator, "ShaderResourceBinding instance", ShaderResourceBindingImplType)(pThisImpl)};
537537
if (InitStaticResources)
538538
pThisImpl->InitializeStaticSRBResources(pResBindingImpl);
539539
pResBindingImpl->QueryInterface(IID_ShaderResourceBinding, reinterpret_cast<IObject**>(ppShaderResourceBinding));
@@ -544,17 +544,17 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
544544
{
545545
DEV_CHECK_ERR(pSRB != nullptr, "SRB must not be null");
546546

547-
auto* const pSRBImpl = ClassPtrCast<ShaderResourceBindingImplType>(pSRB);
547+
ShaderResourceBindingImplType* const pSRBImpl = ClassPtrCast<ShaderResourceBindingImplType>(pSRB);
548548
if (pSRBImpl->StaticResourcesInitialized())
549549
{
550550
LOG_WARNING_MESSAGE("Static resources have already been initialized in this shader resource binding object.");
551551
return;
552552
}
553553

554-
const auto* const pThisImpl = static_cast<const PipelineResourceSignatureImplType*>(this);
554+
const PipelineResourceSignatureImplType* const pThisImpl = static_cast<const PipelineResourceSignatureImplType*>(this);
555555
#ifdef DILIGENT_DEVELOPMENT
556556
{
557-
const auto* pSRBSignature = pSRBImpl->GetPipelineResourceSignature();
557+
const IPipelineResourceSignature* pSRBSignature = pSRBImpl->GetPipelineResourceSignature();
558558
DEV_CHECK_ERR(pSRBSignature->IsCompatibleWith(pThisImpl), "Shader resource binding is not compatible with resource signature '", pThisImpl->m_Desc.Name, "'.");
559559
}
560560
#endif
@@ -580,8 +580,8 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
580580
return;
581581
}
582582

583-
const auto* const pThisImpl = static_cast<const PipelineResourceSignatureImplType*>(this);
584-
auto* const pDstSignImpl = static_cast<const PipelineResourceSignatureImplType*>(pDstSignature);
583+
const PipelineResourceSignatureImplType* const pThisImpl = static_cast<const PipelineResourceSignatureImplType*>(this);
584+
const PipelineResourceSignatureImplType* const pDstSignImpl = static_cast<const PipelineResourceSignatureImplType*>(pDstSignature);
585585
if (!pDstSignImpl->IsCompatibleWith(pThisImpl))
586586
{
587587
LOG_ERROR_MESSAGE("Can't copy static resources: destination pipeline resource signature '", pDstSignImpl->m_Desc.Name,
@@ -601,21 +601,21 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
601601
if (this == pPRS)
602602
return true;
603603

604-
const auto& This = *static_cast<const PipelineResourceSignatureImplType*>(this);
605-
const auto& Other = *ClassPtrCast<const PipelineResourceSignatureImplType>(pPRS);
604+
const PipelineResourceSignatureImplType& This = *static_cast<const PipelineResourceSignatureImplType*>(this);
605+
const PipelineResourceSignatureImplType& Other = *ClassPtrCast<const PipelineResourceSignatureImplType>(pPRS);
606606

607607
if (This.GetHash() != Other.GetHash())
608608
return false;
609609

610610
if (!PipelineResourceSignaturesCompatible(This.GetDesc(), Other.GetDesc()))
611611
return false;
612612

613-
const auto ResCount = This.GetTotalResourceCount();
613+
const Uint32 ResCount = This.GetTotalResourceCount();
614614
VERIFY_EXPR(ResCount == Other.GetTotalResourceCount());
615615
for (Uint32 r = 0; r < ResCount; ++r)
616616
{
617-
const auto& Res = This.GetResourceAttribs(r);
618-
const auto& OtherRes = Other.GetResourceAttribs(r);
617+
const PipelineResourceAttribsType& Res = This.GetResourceAttribs(r);
618+
const PipelineResourceAttribsType& OtherRes = Other.GetResourceAttribs(r);
619619
if (!Res.IsCompatibleWith(OtherRes))
620620
return false;
621621
}
@@ -665,7 +665,7 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
665665
SHADER_TYPE Stages = m_ShaderStages;
666666
for (Uint32 Index = 0; Stages != SHADER_TYPE_UNKNOWN; ++Index)
667667
{
668-
auto StageBit = ExtractLSB(Stages);
668+
SHADER_TYPE StageBit = ExtractLSB(Stages);
669669

670670
if (Index == StageIndex)
671671
return StageBit;
@@ -755,7 +755,7 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
755755
std::make_pair<Uint32, Uint32>(0, GetTotalResourceCount());
756756
for (Uint32 ResIdx = IdxRange.first; ResIdx < IdxRange.second; ++ResIdx)
757757
{
758-
const auto& ResDesc = GetResourceDesc(ResIdx);
758+
const PipelineResourceDesc& ResDesc = GetResourceDesc(ResIdx);
759759
VERIFY_EXPR(AllowedVarTypes == nullptr || ResDesc.VarType == AllowedVarTypes[TypeIdx]);
760760

761761
if ((ResDesc.ShaderStages & AllowedStages) != 0)
@@ -806,7 +806,7 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
806806

807807
Allocator.AddSpace<PipelineResourceAttribsType>(Desc.NumResources);
808808

809-
const auto NumStaticResStages = GetNumStaticResStages();
809+
const Uint32 NumStaticResStages = GetNumStaticResStages();
810810
if (NumStaticResStages > 0)
811811
{
812812
Allocator.AddSpace<ShaderResourceCacheImplType>(1);
@@ -829,7 +829,7 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
829829
VERIFY_EXPR(m_ResourceOffsets[SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES] == this->m_Desc.NumResources);
830830
for (Uint32 VarType = 0; VarType < SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES; ++VarType)
831831
{
832-
auto IdxRange = GetResourceIndexRange(static_cast<SHADER_RESOURCE_VARIABLE_TYPE>(VarType));
832+
const auto IdxRange = GetResourceIndexRange(static_cast<SHADER_RESOURCE_VARIABLE_TYPE>(VarType));
833833
for (Uint32 idx = IdxRange.first; idx < IdxRange.second; ++idx)
834834
VERIFY(this->m_Desc.Resources[idx].VarType == VarType, "Unexpected resource var type");
835835
}
@@ -872,7 +872,7 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
872872

873873
InitResourceLayout();
874874

875-
auto* const pThisImpl = static_cast<PipelineResourceSignatureImplType*>(this);
875+
PipelineResourceSignatureImplType* const pThisImpl = static_cast<PipelineResourceSignatureImplType*>(this);
876876

877877
if (NumStaticResStages > 0)
878878
{
@@ -883,7 +883,7 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
883883
if (Idx >= 0)
884884
{
885885
VERIFY_EXPR(static_cast<Uint32>(Idx) < NumStaticResStages);
886-
const auto ShaderType = GetShaderTypeFromPipelineIndex(i, GetPipelineType());
886+
const SHADER_TYPE ShaderType = GetShaderTypeFromPipelineIndex(i, GetPipelineType());
887887
m_StaticVarsMgrs[Idx].Initialize(*pThisImpl, RawAllocator, AllowedVarTypes, _countof(AllowedVarTypes), ShaderType);
888888
}
889889
}
@@ -936,7 +936,7 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
936936
bool HasCombinedSamplers = false;
937937
for (Uint32 r = 0; r < Desc.NumResources; ++r)
938938
{
939-
const auto& Res{Desc.Resources[r]};
939+
const PipelineResourceDesc& Res{Desc.Resources[r]};
940940
if ((Res.Flags & PIPELINE_RESOURCE_FLAG_COMBINED_SAMPLER) == 0)
941941
continue;
942942

@@ -948,7 +948,7 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
948948

949949
HasCombinedSamplers = true;
950950

951-
const auto SamplerName = std::string{Res.Name} + Desc.CombinedSamplerSuffix;
951+
const std::string SamplerName = std::string{Res.Name} + Desc.CombinedSamplerSuffix;
952952
// Check if the sampler is already defined.
953953
if (Diligent::FindResource(Desc.Resources, Desc.NumResources, Res.ShaderStages, SamplerName.c_str()) == InvalidPipelineResourceIndex)
954954
{
@@ -979,11 +979,11 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
979979
this->m_Desc.ImmutableSamplers = nullptr;
980980
this->m_Desc.CombinedSamplerSuffix = nullptr;
981981

982-
auto& RawAllocator = GetRawAllocator();
982+
IMemoryAllocator& RawAllocator = GetRawAllocator();
983983

984984
if (m_StaticVarsMgrs != nullptr)
985985
{
986-
for (auto Idx : m_StaticResStageIndex)
986+
for (int Idx : m_StaticResStageIndex)
987987
{
988988
if (Idx >= 0)
989989
{
@@ -1033,7 +1033,7 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
10331033

10341034
for (Uint32 i = IdxRange.first; i < IdxRange.second; ++i)
10351035
{
1036-
const auto& Res = this->m_Desc.Resources[i];
1036+
const PipelineResourceDesc& Res = this->m_Desc.Resources[i];
10371037
VERIFY_EXPR(Tex.VarType == Res.VarType);
10381038

10391039
if (Res.ResourceType == SHADER_RESOURCE_TYPE_SAMPLER &&
@@ -1051,12 +1051,12 @@ class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImp
10511051

10521052
void CalculateHash()
10531053
{
1054-
const auto* const pThisImpl = static_cast<const PipelineResourceSignatureImplType*>(this);
1054+
const PipelineResourceSignatureImplType* const pThisImpl = static_cast<const PipelineResourceSignatureImplType*>(this);
10551055

10561056
m_Hash = CalculatePipelineResourceSignatureDescHash(this->m_Desc);
10571057
for (Uint32 i = 0; i < this->m_Desc.NumResources; ++i)
10581058
{
1059-
const auto& Attr = pThisImpl->GetResourceAttribs(i);
1059+
const PipelineResourceAttribsType& Attr = pThisImpl->GetResourceAttribs(i);
10601060
HashCombine(m_Hash, Attr.GetHash());
10611061
}
10621062
}

0 commit comments

Comments
 (0)