Skip to content

Commit 7993d2a

Browse files
PipelineStateD3D12: don't use auto where unnecessary
1 parent 278f5ad commit 7993d2a

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed

Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -245,21 +245,21 @@ void GetShaderIdentifiers(ID3D12DeviceChild* pSO,
245245
{
246246
CComPtr<ID3D12StateObjectProperties> pStateObjectProperties;
247247

248-
auto hr = pSO->QueryInterface(IID_PPV_ARGS(&pStateObjectProperties));
248+
HRESULT hr = pSO->QueryInterface(IID_PPV_ARGS(&pStateObjectProperties));
249249
if (FAILED(hr))
250250
LOG_ERROR_AND_THROW("Failed to get state object properties");
251251

252252
for (Uint32 i = 0; i < CreateInfo.GeneralShaderCount; ++i)
253253
{
254-
const auto& GeneralShader = CreateInfo.pGeneralShaders[i];
254+
const RayTracingGeneralShaderGroup& GeneralShader = CreateInfo.pGeneralShaders[i];
255255

256256
auto iter = NameToGroupIndex.find(GeneralShader.Name);
257257
VERIFY(iter != NameToGroupIndex.end(),
258258
"Can't find general shader '", GeneralShader.Name,
259259
"'. This looks to be a bug as NameToGroupIndex is initialized by "
260260
"CopyRTShaderGroupNames() that processes the same general shaders.");
261261

262-
const auto* ShaderID = pStateObjectProperties->GetShaderIdentifier(WidenString(GeneralShader.Name).c_str());
262+
const void* ShaderID = pStateObjectProperties->GetShaderIdentifier(WidenString(GeneralShader.Name).c_str());
263263
if (ShaderID == nullptr)
264264
LOG_ERROR_AND_THROW("Failed to get shader identifier for general shader group '", GeneralShader.Name, "'");
265265

@@ -268,15 +268,15 @@ void GetShaderIdentifiers(ID3D12DeviceChild* pSO,
268268

269269
for (Uint32 i = 0; i < CreateInfo.TriangleHitShaderCount; ++i)
270270
{
271-
const auto& TriHitShader = CreateInfo.pTriangleHitShaders[i];
271+
const RayTracingTriangleHitShaderGroup& TriHitShader = CreateInfo.pTriangleHitShaders[i];
272272

273273
auto iter = NameToGroupIndex.find(TriHitShader.Name);
274274
VERIFY(iter != NameToGroupIndex.end(),
275275
"Can't find triangle hit group '", TriHitShader.Name,
276276
"'. This looks to be a bug as NameToGroupIndex is initialized by "
277277
"CopyRTShaderGroupNames() that processes the same hit groups.");
278278

279-
const auto* ShaderID = pStateObjectProperties->GetShaderIdentifier(WidenString(TriHitShader.Name).c_str());
279+
const void* ShaderID = pStateObjectProperties->GetShaderIdentifier(WidenString(TriHitShader.Name).c_str());
280280
if (ShaderID == nullptr)
281281
LOG_ERROR_AND_THROW("Failed to get shader identifier for triangle hit group '", TriHitShader.Name, "'");
282282

@@ -285,15 +285,15 @@ void GetShaderIdentifiers(ID3D12DeviceChild* pSO,
285285

286286
for (Uint32 i = 0; i < CreateInfo.ProceduralHitShaderCount; ++i)
287287
{
288-
const auto& ProcHitShader = CreateInfo.pProceduralHitShaders[i];
288+
const RayTracingProceduralHitShaderGroup& ProcHitShader = CreateInfo.pProceduralHitShaders[i];
289289

290290
auto iter = NameToGroupIndex.find(ProcHitShader.Name);
291291
VERIFY(iter != NameToGroupIndex.end(),
292292
"Can't find procedural hit group '", ProcHitShader.Name,
293293
"'. This looks to be a bug as NameToGroupIndex is initialized by "
294294
"CopyRTShaderGroupNames() that processes the same hit groups.");
295295

296-
const auto* ShaderID = pStateObjectProperties->GetShaderIdentifier(WidenString(ProcHitShader.Name).c_str());
296+
const void* ShaderID = pStateObjectProperties->GetShaderIdentifier(WidenString(ProcHitShader.Name).c_str());
297297
if (ShaderID == nullptr)
298298
LOG_ERROR_AND_THROW("Failed to get shader identifier for procedural hit shader group '", ProcHitShader.Name, "'");
299299

@@ -316,7 +316,7 @@ void PipelineStateD3D12Impl::ShaderStageInfo::Append(const ShaderD3D12Impl* pSha
316316
VERIFY(std::find(Shaders.begin(), Shaders.end(), pShader) == Shaders.end(),
317317
"Shader '", pShader->GetDesc().Name, "' already exists in the stage. Shaders must be deduplicated.");
318318

319-
const auto NewShaderType = pShader->GetDesc().ShaderType;
319+
const SHADER_TYPE NewShaderType = pShader->GetDesc().ShaderType;
320320
if (Type == SHADER_TYPE_UNKNOWN)
321321
{
322322
VERIFY_EXPR(Shaders.empty());
@@ -352,9 +352,9 @@ PipelineResourceSignatureDescWrapper PipelineStateD3D12Impl::GetDefaultResourceS
352352
std::unordered_map<ShaderResourceHashKey, const D3DShaderResourceAttribs&, ShaderResourceHashKey::Hasher> UniqueResources;
353353
for (auto& Stage : ShaderStages)
354354
{
355-
for (auto* pShader : Stage.Shaders)
355+
for (const ShaderD3D12Impl* pShader : Stage.Shaders)
356356
{
357-
const auto& ShaderResources = *pShader->GetShaderResources();
357+
const ShaderResourcesD3D12& ShaderResources = *pShader->GetShaderResources();
358358

359359
ShaderResources.ProcessResources(
360360
[&](const D3DShaderResourceAttribs& Attribs, Uint32) //
@@ -367,7 +367,7 @@ PipelineResourceSignatureDescWrapper PipelineStateD3D12Impl::GetDefaultResourceS
367367
ShaderResources.GetCombinedSamplerSuffix() :
368368
nullptr;
369369

370-
const auto VarDesc = FindPipelineResourceLayoutVariable(ResourceLayout, Attribs.Name, Stage.Type, SamplerSuffix);
370+
const ShaderResourceVariableDesc VarDesc = FindPipelineResourceLayoutVariable(ResourceLayout, Attribs.Name, Stage.Type, SamplerSuffix);
371371
// Note that Attribs.Name != VarDesc.Name for combined samplers
372372
const auto it_assigned = UniqueResources.emplace(ShaderResourceHashKey{VarDesc.ShaderStages, Attribs.Name}, Attribs);
373373
if (it_assigned.second)
@@ -378,8 +378,8 @@ PipelineResourceSignatureDescWrapper PipelineStateD3D12Impl::GetDefaultResourceS
378378
"Use explicit resource signature to specify the array size.");
379379
}
380380

381-
const auto ResType = Attribs.GetShaderResourceType();
382-
const auto ResFlags = Attribs.GetPipelineResourceFlags() | ShaderVariableFlagsToPipelineResourceFlags(VarDesc.Flags);
381+
const SHADER_RESOURCE_TYPE ResType = Attribs.GetShaderResourceType();
382+
const PIPELINE_RESOURCE_FLAGS ResFlags = Attribs.GetPipelineResourceFlags() | ShaderVariableFlagsToPipelineResourceFlags(VarDesc.Flags);
383383
SignDesc.AddResource(VarDesc.ShaderStages, Attribs.Name, Attribs.BindCount, ResType, VarDesc.Type, ResFlags);
384384
}
385385
else
@@ -411,9 +411,9 @@ void PipelineStateD3D12Impl::RemapOrVerifyShaderResources(TShaderStages&
411411
{
412412
for (size_t s = 0; s < ShaderStages.size(); ++s)
413413
{
414-
const auto& Shaders = ShaderStages[s].Shaders;
415-
auto& ByteCodes = ShaderStages[s].ByteCodes;
416-
const auto ShaderType = ShaderStages[s].Type;
414+
const auto& Shaders = ShaderStages[s].Shaders;
415+
auto& ByteCodes = ShaderStages[s].ByteCodes;
416+
const SHADER_TYPE ShaderType = ShaderStages[s].Type;
417417

418418
bool HasImtblSamArray = false;
419419
ResourceBinding::TMap ResourceMap;
@@ -448,7 +448,7 @@ void PipelineStateD3D12Impl::RemapOrVerifyShaderResources(TShaderStages&
448448

449449
for (size_t i = 0; i < Shaders.size(); ++i)
450450
{
451-
const auto* const pShader = Shaders[i];
451+
const ShaderD3D12Impl* const pShader = Shaders[i];
452452

453453
Uint32 VerMajor, VerMinor;
454454
pShader->GetShaderResources()->GetShaderModel(VerMajor, VerMinor);
@@ -476,7 +476,7 @@ void PipelineStateD3D12Impl::RemapOrVerifyShaderResources(TShaderStages&
476476
}
477477
else
478478
{
479-
auto& pBytecode = ByteCodes[i];
479+
RefCntAutoPtr<IDataBlob>& pBytecode = ByteCodes[i];
480480
if (IsDXILBytecode(pBytecode->GetConstDataPtr(), pBytecode->GetSize()))
481481
{
482482
if (!pDxCompiler)
@@ -504,10 +504,11 @@ void PipelineStateD3D12Impl::InitRootSignature(const PipelineStateCreateInfo& Cr
504504
TShaderStages& ShaderStages,
505505
LocalRootSignatureD3D12* pLocalRootSig) noexcept(false)
506506
{
507-
const auto InternalFlags = GetInternalCreateFlags(CreateInfo);
507+
const PSO_CREATE_INTERNAL_FLAGS InternalFlags = GetInternalCreateFlags(CreateInfo);
508508
if (m_UsingImplicitSignature && (InternalFlags & PSO_CREATE_INTERNAL_FLAG_IMPLICIT_SIGNATURE0) == 0)
509509
{
510-
const auto SignDesc = GetDefaultResourceSignatureDesc(ShaderStages, m_Desc.Name, m_Desc.ResourceLayout, m_Desc.SRBAllocationGranularity, pLocalRootSig);
510+
const PipelineResourceSignatureDescWrapper SignDesc =
511+
GetDefaultResourceSignatureDesc(ShaderStages, m_Desc.Name, m_Desc.ResourceLayout, m_Desc.SRBAllocationGranularity, pLocalRootSig);
511512

512513
// Always initialize default resource signature as internal device object.
513514
// This is necessary to avoid cyclic references from GenerateMips.
@@ -527,13 +528,13 @@ void PipelineStateD3D12Impl::InitRootSignature(const PipelineStateCreateInfo& Cr
527528
LOG_ERROR_AND_THROW("Failed to create local root signature for pipeline '", m_Desc.Name, "'.");
528529
}
529530

530-
const auto RemapResources = (CreateInfo.Flags & PSO_CREATE_FLAG_DONT_REMAP_SHADER_RESOURCES) == 0;
531+
const bool RemapResources = (CreateInfo.Flags & PSO_CREATE_FLAG_DONT_REMAP_SHADER_RESOURCES) == 0;
531532

532533
const auto ValidateBindings = [this](const ShaderD3D12Impl* pShader, const ResourceBinding::TMap& BindingsMap) //
533534
{
534535
ValidateShaderResourceBindings(m_Desc.Name, *pShader->GetShaderResources(), BindingsMap);
535536
};
536-
const auto ValidateBindingsFn = !RemapResources && (InternalFlags & PSO_CREATE_INTERNAL_FLAG_NO_SHADER_REFLECTION) == 0 ?
537+
const TValidateShaderBindingsFn ValidateBindingsFn = !RemapResources && (InternalFlags & PSO_CREATE_INTERNAL_FLAG_NO_SHADER_REFLECTION) == 0 ?
537538
TValidateShaderBindingsFn{ValidateBindings} :
538539
TValidateShaderBindingsFn{nullptr};
539540

@@ -556,8 +557,8 @@ void PipelineStateD3D12Impl::InitRootSignature(const PipelineStateCreateInfo& Cr
556557

557558
void PipelineStateD3D12Impl::ValidateShaderResources(const ShaderD3D12Impl* pShader, const LocalRootSignatureD3D12* pLocalRootSig)
558559
{
559-
const auto& pShaderResources = pShader->GetShaderResources();
560-
const auto ShaderType = pShader->GetDesc().ShaderType;
560+
const auto& pShaderResources = pShader->GetShaderResources();
561+
const SHADER_TYPE ShaderType = pShader->GetDesc().ShaderType;
561562

562563
#ifdef DILIGENT_DEVELOPMENT
563564
m_ShaderResources.emplace_back(pShaderResources);
@@ -569,15 +570,15 @@ void PipelineStateD3D12Impl::ValidateShaderResources(const ShaderD3D12Impl* pSha
569570
{
570571
#ifdef DILIGENT_DEVELOPMENT
571572
m_ResourceAttibutions.emplace_back();
572-
auto& ResAttribution = m_ResourceAttibutions.back();
573+
ResourceAttribution& ResAttribution = m_ResourceAttibutions.back();
573574
#else
574575
ResourceAttribution ResAttribution;
575576
#endif
576577

577578
if (pLocalRootSig != nullptr && pLocalRootSig->IsShaderRecord(Attribs))
578579
return;
579580

580-
const auto IsSampler = Attribs.GetInputType() == D3D_SIT_SAMPLER;
581+
const bool IsSampler = Attribs.GetInputType() == D3D_SIT_SAMPLER;
581582
if (IsSampler && pShaderResources->IsUsingCombinedTextureSamplers())
582583
return;
583584

@@ -589,15 +590,15 @@ void PipelineStateD3D12Impl::ValidateShaderResources(const ShaderD3D12Impl* pSha
589590
m_Desc.Name, "'.");
590591
}
591592

592-
const auto ResType = Attribs.GetShaderResourceType();
593-
const auto ResFlags = Attribs.GetPipelineResourceFlags();
593+
const SHADER_RESOURCE_TYPE ResType = Attribs.GetShaderResourceType();
594+
const PIPELINE_RESOURCE_FLAGS ResFlags = Attribs.GetPipelineResourceFlags();
594595

595-
const auto* const pSignature = ResAttribution.pSignature;
596+
const PipelineResourceSignatureD3D12Impl* const pSignature = ResAttribution.pSignature;
596597
VERIFY_EXPR(pSignature != nullptr);
597598

598599
if (ResAttribution.ResourceIndex != ResourceAttribution::InvalidResourceIndex)
599600
{
600-
auto ResDesc = pSignature->GetResourceDesc(ResAttribution.ResourceIndex);
601+
PipelineResourceDesc ResDesc = pSignature->GetResourceDesc(ResAttribution.ResourceIndex);
601602
if (ResDesc.ResourceType == SHADER_RESOURCE_TYPE_INPUT_ATTACHMENT)
602603
ResDesc.ResourceType = SHADER_RESOURCE_TYPE_TEXTURE_SRV;
603604
ValidatePipelineResourceCompatibility(ResDesc, ResType, ResFlags, Attribs.BindCount,
@@ -635,7 +636,7 @@ void PipelineStateD3D12Impl::DvpVerifySRBResources(const DeviceContextD3D12Impl*
635636
{
636637
VERIFY_EXPR(attrib_it->pSignature != nullptr);
637638
VERIFY_EXPR(attrib_it->pSignature->GetDesc().BindingIndex == attrib_it->SignatureIndex);
638-
const auto* pResourceCache = ResourceCaches[attrib_it->SignatureIndex];
639+
const ShaderResourceCacheD3D12* pResourceCache = ResourceCaches[attrib_it->SignatureIndex];
639640
DEV_CHECK_ERR(pResourceCache != nullptr, "Resource cache at index ", attrib_it->SignatureIndex, " is null.");
640641
attrib_it->pSignature->DvpValidateCommittedResource(pDeviceCtx, Attribs, attrib_it->ResourceIndex, *pResourceCache,
641642
pResources->GetShaderName(), m_Desc.Name);
@@ -674,27 +675,27 @@ void PipelineStateD3D12Impl::InitInternalObjects(const PSOCreateInfoType& Create
674675

675676
void PipelineStateD3D12Impl::InitializePipeline(const GraphicsPipelineStateCreateInfo& CreateInfo)
676677
{
677-
const auto WName = WidenString(m_Desc.Name);
678+
const std::wstring WName = WidenString(m_Desc.Name);
678679

679680
TShaderStages ShaderStages;
680681
InitInternalObjects(CreateInfo, ShaderStages);
681682

682-
auto* pd3d12Device = m_pDevice->GetD3D12Device();
683+
ID3D12Device* pd3d12Device = m_pDevice->GetD3D12Device();
683684
if (m_Desc.PipelineType == PIPELINE_TYPE_GRAPHICS)
684685
{
685686
const GraphicsPipelineDesc& GraphicsPipeline = m_pGraphicsPipelineData->Desc;
686687

687688
D3D12_GRAPHICS_PIPELINE_STATE_DESC d3d12PSODesc = {};
688689

689-
for (const auto& Stage : ShaderStages)
690+
for (const ShaderStageInfo& Stage : ShaderStages)
690691
{
691692
VERIFY_EXPR(Stage.Count() == 1);
692693
const IDataBlob* pByteCode = Stage.ByteCodes[0];
693694

694695
D3D12_SHADER_BYTECODE* pd3d12ShaderBytecode = nullptr;
695696
switch (Stage.Type)
696697
{
697-
// clang-format off
698+
// clang-format off
698699
case SHADER_TYPE_VERTEX: pd3d12ShaderBytecode = &d3d12PSODesc.VS; break;
699700
case SHADER_TYPE_PIXEL: pd3d12ShaderBytecode = &d3d12PSODesc.PS; break;
700701
case SHADER_TYPE_GEOMETRY: pd3d12ShaderBytecode = &d3d12PSODesc.GS; break;
@@ -721,7 +722,7 @@ void PipelineStateD3D12Impl::InitializePipeline(const GraphicsPipelineStateCreat
721722

722723
std::vector<D3D12_INPUT_ELEMENT_DESC, STDAllocatorRawMem<D3D12_INPUT_ELEMENT_DESC>> d312InputElements(STD_ALLOCATOR_RAW_MEM(D3D12_INPUT_ELEMENT_DESC, GetRawAllocator(), "Allocator for vector<D3D12_INPUT_ELEMENT_DESC>"));
723724

724-
const auto& InputLayout = GraphicsPipeline.InputLayout;
725+
const InputLayoutDesc& InputLayout = GraphicsPipeline.InputLayout;
725726
if (InputLayout.NumElements > 0)
726727
{
727728
LayoutElements_To_D3D12_INPUT_ELEMENT_DESCs(InputLayout, d312InputElements);
@@ -765,7 +766,7 @@ void PipelineStateD3D12Impl::InitializePipeline(const GraphicsPipelineStateCreat
765766
d3d12PSODesc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE;
766767

767768
// Try to load from the cache
768-
auto* const pPSOCacheD3D12 = ClassPtrCast<PipelineStateCacheD3D12Impl>(CreateInfo.pPSOCache);
769+
PipelineStateCacheD3D12Impl* const pPSOCacheD3D12 = ClassPtrCast<PipelineStateCacheD3D12Impl>(CreateInfo.pPSOCache);
769770
if (pPSOCacheD3D12 != nullptr && !WName.empty())
770771
m_pd3d12PSO = pPSOCacheD3D12->LoadGraphicsPipeline(WName.c_str(), d3d12PSODesc);
771772
if (!m_pd3d12PSO)
@@ -804,15 +805,15 @@ void PipelineStateD3D12Impl::InitializePipeline(const GraphicsPipelineStateCreat
804805
};
805806
MESH_SHADER_PIPELINE_STATE_DESC d3d12PSODesc = {};
806807

807-
for (const auto& Stage : ShaderStages)
808+
for (const ShaderStageInfo& Stage : ShaderStages)
808809
{
809810
VERIFY_EXPR(Stage.Count() == 1);
810811
const IDataBlob* pByteCode = Stage.ByteCodes[0];
811812

812813
D3D12_SHADER_BYTECODE* pd3d12ShaderBytecode = nullptr;
813814
switch (Stage.Type)
814815
{
815-
// clang-format off
816+
// clang-format off
816817
case SHADER_TYPE_AMPLIFICATION: pd3d12ShaderBytecode = &d3d12PSODesc.AS; break;
817818
case SHADER_TYPE_MESH: pd3d12ShaderBytecode = &d3d12PSODesc.MS; break;
818819
case SHADER_TYPE_PIXEL: pd3d12ShaderBytecode = &d3d12PSODesc.PS; break;
@@ -857,7 +858,7 @@ void PipelineStateD3D12Impl::InitializePipeline(const GraphicsPipelineStateCreat
857858
streamDesc.SizeInBytes = sizeof(d3d12PSODesc);
858859
streamDesc.pPipelineStateSubobjectStream = &d3d12PSODesc;
859860

860-
auto* pd3d12Device2 = m_pDevice->GetD3D12Device2();
861+
ID3D12Device2* pd3d12Device2 = m_pDevice->GetD3D12Device2();
861862
// Note: renderdoc frame capture fails if any interface but IID_ID3D12PipelineState is requested
862863
HRESULT hr = pd3d12Device2->CreatePipelineState(&streamDesc, __uuidof(ID3D12PipelineState), IID_PPV_ARGS_Helper(&m_pd3d12PSO));
863864
if (FAILED(hr))
@@ -880,7 +881,7 @@ void PipelineStateD3D12Impl::InitializePipeline(const ComputePipelineStateCreate
880881
TShaderStages ShaderStages;
881882
InitInternalObjects(CreateInfo, ShaderStages);
882883

883-
auto* pd3d12Device = m_pDevice->GetD3D12Device();
884+
ID3D12Device* pd3d12Device = m_pDevice->GetD3D12Device();
884885

885886
D3D12_COMPUTE_PIPELINE_STATE_DESC d3d12PSODesc = {};
886887

@@ -904,8 +905,8 @@ void PipelineStateD3D12Impl::InitializePipeline(const ComputePipelineStateCreate
904905
d3d12PSODesc.pRootSignature = m_RootSig->GetD3D12RootSignature();
905906

906907
// Try to load from the cache
907-
const auto WName = WidenString(m_Desc.Name);
908-
auto* const pPSOCacheD3D12 = ClassPtrCast<PipelineStateCacheD3D12Impl>(CreateInfo.pPSOCache);
908+
const std::wstring WName = WidenString(m_Desc.Name);
909+
PipelineStateCacheD3D12Impl* const pPSOCacheD3D12 = ClassPtrCast<PipelineStateCacheD3D12Impl>(CreateInfo.pPSOCache);
909910
if (pPSOCacheD3D12 != nullptr && !WName.empty())
910911
m_pd3d12PSO = pPSOCacheD3D12->LoadComputePipeline(WName.c_str(), d3d12PSODesc);
911912
if (!m_pd3d12PSO)
@@ -932,7 +933,7 @@ void PipelineStateD3D12Impl::InitializePipeline(const RayTracingPipelineStateCre
932933
TShaderStages ShaderStages;
933934
InitInternalObjects(CreateInfo, ShaderStages, &LocalRootSig);
934935

935-
auto* pd3d12Device = m_pDevice->GetD3D12Device5();
936+
ID3D12Device5* pd3d12Device = m_pDevice->GetD3D12Device5();
936937

937938
DynamicLinearAllocator TempPool{GetRawAllocator(), 4 << 10};
938939
std::vector<D3D12_STATE_SUBOBJECT> Subobjects;

0 commit comments

Comments
 (0)