Skip to content

Commit ab49b88

Browse files
GraphicsEngineD3D12: don't use auto where unnecessary
1 parent 0a37ae9 commit ab49b88

24 files changed

+668
-669
lines changed

Graphics/GraphicsEngineD3D12/src/BottomLevelASD3D12Impl.cpp

Lines changed: 12 additions & 12 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");
@@ -43,9 +43,9 @@ BottomLevelASD3D12Impl::BottomLevelASD3D12Impl(IReferenceCounters* pRefCoun
4343
const BottomLevelASDesc& Desc) :
4444
TBottomLevelASBase{pRefCounters, pDeviceD3D12, Desc}
4545
{
46-
auto* pd3d12Device = pDeviceD3D12->GetD3D12Device5();
47-
const auto& RTProps = pDeviceD3D12->GetAdapterInfo().RayTracing;
48-
UINT64 ResultDataMaxSizeInBytes = 0;
46+
ID3D12Device5* pd3d12Device = pDeviceD3D12->GetD3D12Device5();
47+
const RayTracingProperties& RTProps = pDeviceD3D12->GetAdapterInfo().RayTracing;
48+
UINT64 ResultDataMaxSizeInBytes = 0;
4949

5050
if (m_Desc.CompactedSize)
5151
{
@@ -63,8 +63,8 @@ BottomLevelASD3D12Impl::BottomLevelASD3D12Impl(IReferenceCounters* pRefCoun
6363
Uint32 MaxPrimitiveCount = 0;
6464
for (uint32_t i = 0; i < m_Desc.TriangleCount; ++i)
6565
{
66-
auto& src = m_Desc.pTriangles[i];
67-
auto& dst = d3d12Geometries[i];
66+
const BLASTriangleDesc& src = m_Desc.pTriangles[i];
67+
D3D12_RAYTRACING_GEOMETRY_DESC& dst = d3d12Geometries[i];
6868

6969
dst.Type = D3D12_RAYTRACING_GEOMETRY_TYPE_TRIANGLES;
7070
dst.Flags = D3D12_RAYTRACING_GEOMETRY_FLAG_NONE;
@@ -90,8 +90,8 @@ BottomLevelASD3D12Impl::BottomLevelASD3D12Impl(IReferenceCounters* pRefCoun
9090
Uint32 MaxBoxCount = 0;
9191
for (uint32_t i = 0; i < m_Desc.BoxCount; ++i)
9292
{
93-
auto& src = m_Desc.pBoxes[i];
94-
auto& dst = d3d12Geometries[i];
93+
const BLASBoundingBoxDesc& src = m_Desc.pBoxes[i];
94+
D3D12_RAYTRACING_GEOMETRY_DESC& dst = d3d12Geometries[i];
9595

9696
dst.Type = D3D12_RAYTRACING_GEOMETRY_TYPE_PROCEDURAL_PRIMITIVE_AABBS;
9797
dst.Flags = D3D12_RAYTRACING_GEOMETRY_FLAG_NONE;
@@ -149,10 +149,10 @@ BottomLevelASD3D12Impl::BottomLevelASD3D12Impl(IReferenceCounters* pRefCoun
149149
ASDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
150150
ASDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
151151

152-
auto hr = pd3d12Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE,
153-
&ASDesc, D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE, nullptr,
154-
__uuidof(m_pd3d12Resource),
155-
reinterpret_cast<void**>(static_cast<ID3D12Resource**>(&m_pd3d12Resource)));
152+
HRESULT hr = pd3d12Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE,
153+
&ASDesc, D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE, nullptr,
154+
__uuidof(m_pd3d12Resource),
155+
reinterpret_cast<void**>(static_cast<ID3D12Resource**>(&m_pd3d12Resource)));
156156
if (FAILED(hr))
157157
LOG_ERROR_AND_THROW("Failed to create D3D12 Bottom-level acceleration structure");
158158

Graphics/GraphicsEngineD3D12/src/CommandContext.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2023 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");
@@ -103,7 +103,7 @@ ID3D12GraphicsCommandList* CommandContext::Close(CComPtr<ID3D12CommandAllocator>
103103
// EngineProfiling::EndBlock(this);
104104

105105
VERIFY_EXPR(m_pCurrentAllocator != nullptr);
106-
auto hr = m_pCommandList->Close();
106+
HRESULT hr = m_pCommandList->Close();
107107
DEV_CHECK_ERR(SUCCEEDED(hr), "Failed to close the command list");
108108

109109
pAllocator = std::move(m_pCurrentAllocator);
@@ -233,7 +233,7 @@ void StateTransitionHelper::DiscardIfAppropriate(const TextureDesc& TexDesc,
233233
if ((m_Barrier.Flags & STATE_TRANSITION_FLAG_DISCARD_CONTENT) == 0)
234234
return;
235235

236-
const auto d3d12CmdListType = m_CmdCtx.GetCommandListType();
236+
const D3D12_COMMAND_LIST_TYPE d3d12CmdListType = m_CmdCtx.GetCommandListType();
237237

238238
bool DiscardAllowed = false;
239239

@@ -303,7 +303,7 @@ void StateTransitionHelper::AddD3D12ResourceBarriers(TextureD3D12Impl& Tex, D3D1
303303
// D3D12_RESOURCE_STATE_COMMON == D3D12_RESOURCE_STATE_PRESENT
304304
if (d3d12Barrier.Transition.StateBefore != d3d12Barrier.Transition.StateAfter)
305305
{
306-
const auto& TexDesc = Tex.GetDesc();
306+
const TextureDesc& TexDesc = Tex.GetDesc();
307307
VERIFY(m_Barrier.FirstMipLevel < TexDesc.MipLevels, "First mip level is out of range");
308308
VERIFY(m_Barrier.MipLevelsCount == REMAINING_MIP_LEVELS || m_Barrier.FirstMipLevel + m_Barrier.MipLevelsCount <= TexDesc.MipLevels,
309309
"Invalid mip level range");
@@ -400,7 +400,7 @@ void StateTransitionHelper::operator()(ResourceType& Resource)
400400
// Check if required state is already set
401401
if ((m_OldState & m_Barrier.NewState) != m_Barrier.NewState)
402402
{
403-
auto NewState = m_Barrier.NewState;
403+
RESOURCE_STATE NewState = m_Barrier.NewState;
404404
// If both old state and new state are read-only states, combine the two
405405
if ((m_OldState & RESOURCE_STATE_GENERIC_READ) == m_OldState &&
406406
(NewState & RESOURCE_STATE_GENERIC_READ) == NewState)

Graphics/GraphicsEngineD3D12/src/CommandListManager.cpp

Lines changed: 5 additions & 5 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");
@@ -50,7 +50,7 @@ CommandListManager::~CommandListManager()
5050
void CommandListManager::CreateNewCommandList(ID3D12GraphicsCommandList** List, ID3D12CommandAllocator** Allocator, Uint32& IfaceVersion)
5151
{
5252
RequestAllocator(Allocator);
53-
auto* pd3d12Device = m_DeviceD3D12Impl.GetD3D12Device();
53+
ID3D12Device* pd3d12Device = m_DeviceD3D12Impl.GetD3D12Device();
5454

5555
const IID CmdListIIDs[] =
5656
{
@@ -91,16 +91,16 @@ void CommandListManager::RequestAllocator(ID3D12CommandAllocator** ppAllocator)
9191
if (!m_FreeAllocators.empty())
9292
{
9393
*ppAllocator = m_FreeAllocators.back().Detach();
94-
auto hr = (*ppAllocator)->Reset();
94+
HRESULT hr = (*ppAllocator)->Reset();
9595
DEV_CHECK_ERR(SUCCEEDED(hr), "Failed to reset command allocator");
9696
m_FreeAllocators.pop_back();
9797
}
9898

9999
// If no allocators were ready to be reused, create a new one
100100
if ((*ppAllocator) == nullptr)
101101
{
102-
auto* pd3d12Device = m_DeviceD3D12Impl.GetD3D12Device();
103-
auto hr = pd3d12Device->CreateCommandAllocator(m_CmdListType, __uuidof(*ppAllocator), reinterpret_cast<void**>(ppAllocator));
102+
ID3D12Device* pd3d12Device = m_DeviceD3D12Impl.GetD3D12Device();
103+
HRESULT hr = pd3d12Device->CreateCommandAllocator(m_CmdListType, __uuidof(*ppAllocator), reinterpret_cast<void**>(ppAllocator));
104104
VERIFY(SUCCEEDED(hr), "Failed to create command allocator");
105105
wchar_t AllocatorName[32];
106106
swprintf(AllocatorName, _countof(AllocatorName), L"Cmd list allocator %ld", m_NumAllocators.fetch_add(1));

Graphics/GraphicsEngineD3D12/src/CommandQueueD3D12Impl.cpp

Lines changed: 5 additions & 5 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");
@@ -64,7 +64,7 @@ Uint64 CommandQueueD3D12Impl::Submit(Uint32 NumCommandLists,
6464
std::lock_guard<std::mutex> Lock{m_QueueMtx};
6565

6666
// Increment the value before submitting the list
67-
auto FenceValue = m_NextFenceValue.fetch_add(1);
67+
Uint64 FenceValue = m_NextFenceValue.fetch_add(1);
6868

6969
// Render device submits null command list to signal the fence and
7070
// discard all resources.
@@ -104,10 +104,10 @@ Uint64 CommandQueueD3D12Impl::WaitForIdle()
104104

105105
Uint64 CommandQueueD3D12Impl::GetCompletedFenceValue()
106106
{
107-
auto CompletedFenceValue = m_d3d12Fence->GetCompletedValue();
107+
Uint64 CompletedFenceValue = m_d3d12Fence->GetCompletedValue();
108108
VERIFY(CompletedFenceValue != UINT64_MAX, "If the device has been removed, the return value will be UINT64_MAX");
109109

110-
auto CurrValue = m_LastCompletedFenceValue.load();
110+
Uint64 CurrValue = m_LastCompletedFenceValue.load();
111111
while (!m_LastCompletedFenceValue.compare_exchange_weak(CurrValue, std::max(CurrValue, CompletedFenceValue)))
112112
{
113113
// If exchange fails, CurrValue will hold the actual value of m_LastCompletedFenceValue
@@ -140,7 +140,7 @@ void CommandQueueD3D12Impl::UpdateTileMappings(ResourceTileMappingsD3D12* pMappi
140140

141141
for (Uint32 i = 0; i < Count; ++i)
142142
{
143-
const auto& Mapping = pMappings[i];
143+
const ResourceTileMappingsD3D12& Mapping = pMappings[i];
144144
if (Mapping.UseNVApi)
145145
{
146146
#ifdef DILIGENT_ENABLE_D3D_NVAPI

Graphics/GraphicsEngineD3D12/src/D3D12DynamicHeap.cpp

Lines changed: 13 additions & 13 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");
@@ -57,9 +57,9 @@ D3D12DynamicPage::D3D12DynamicPage(ID3D12Device* pd3d12Device, Uint64 Size)
5757
DefaultUsage = D3D12_RESOURCE_STATE_GENERIC_READ;
5858
ResourceDesc.Width = Size;
5959

60-
auto hr = pd3d12Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE, &ResourceDesc,
61-
DefaultUsage, nullptr, __uuidof(m_pd3d12Buffer),
62-
reinterpret_cast<void**>(static_cast<ID3D12Resource**>(&m_pd3d12Buffer)));
60+
HRESULT hr = pd3d12Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE, &ResourceDesc,
61+
DefaultUsage, nullptr, __uuidof(m_pd3d12Buffer),
62+
reinterpret_cast<void**>(static_cast<ID3D12Resource**>(&m_pd3d12Buffer)));
6363
if (FAILED(hr))
6464
{
6565
LOG_D3D_ERROR(hr, "Failed to create dynamic page");
@@ -85,7 +85,7 @@ D3D12DynamicMemoryManager::D3D12DynamicMemoryManager(IMemoryAllocator& Allo
8585
for (Uint32 i = 0; i < NumPagesToReserve; ++i)
8686
{
8787
D3D12DynamicPage Page(m_DeviceD3D12Impl.GetD3D12Device(), PageSize);
88-
auto Size = Page.GetSize();
88+
Uint64 Size = Page.GetSize();
8989
m_AvailablePages.emplace(Size, std::move(Page));
9090
}
9191
}
@@ -144,12 +144,12 @@ void D3D12DynamicMemoryManager::ReleasePages(std::vector<D3D12DynamicPage>& Page
144144
#ifdef DILIGENT_DEVELOPMENT
145145
--Mgr->m_AllocatedPageCounter;
146146
#endif
147-
auto PageSize = Page.GetSize();
147+
Uint64 PageSize = Page.GetSize();
148148
Mgr->m_AvailablePages.emplace(PageSize, std::move(Page));
149149
}
150150
}
151151
};
152-
for (auto& Page : Pages)
152+
for (D3D12DynamicPage& Page : Pages)
153153
{
154154
m_DeviceD3D12Impl.SafeReleaseDeviceObject(StalePage{std::move(Page), *this}, QueueMask);
155155
}
@@ -180,7 +180,7 @@ D3D12DynamicHeap::~D3D12DynamicHeap()
180180
{
181181
VERIFY(m_AllocatedPages.empty(), "Allocated pages have not been released which indicates FinishFrame() has not been called");
182182

183-
auto PeakAllocatedPages = m_PeakAllocatedSize / m_PageSize;
183+
Uint64 PeakAllocatedPages = m_PeakAllocatedSize / m_PageSize;
184184
LOG_INFO_MESSAGE(m_HeapName,
185185
" usage stats:\n"
186186
" Peak used/aligned/allocated size: ",
@@ -199,11 +199,11 @@ D3D12DynamicAllocation D3D12DynamicHeap::Allocate(Uint64 SizeInBytes, Uint64 Ali
199199

200200
if (m_CurrOffset == InvalidOffset || SizeInBytes + (AlignUp(m_CurrOffset, Alignment) - m_CurrOffset) > m_AvailableSize)
201201
{
202-
auto NewPageSize = m_PageSize;
202+
Uint64 NewPageSize = m_PageSize;
203203
while (NewPageSize < SizeInBytes)
204204
NewPageSize *= 2;
205205

206-
auto NewPage = m_GlobalDynamicMemMgr.AllocatePage(NewPageSize);
206+
D3D12DynamicPage NewPage = m_GlobalDynamicMemMgr.AllocatePage(NewPageSize);
207207
if (NewPage.IsValid())
208208
{
209209
m_CurrOffset = 0;
@@ -218,8 +218,8 @@ D3D12DynamicAllocation D3D12DynamicHeap::Allocate(Uint64 SizeInBytes, Uint64 Ali
218218

219219
if (m_CurrOffset != InvalidOffset && SizeInBytes + (AlignUp(m_CurrOffset, Alignment) - m_CurrOffset) <= m_AvailableSize)
220220
{
221-
auto AlignedOffset = AlignUp(m_CurrOffset, Alignment);
222-
auto AdjustedSize = SizeInBytes + (AlignedOffset - m_CurrOffset);
221+
Uint64 AlignedOffset = AlignUp(m_CurrOffset, Alignment);
222+
Uint64 AdjustedSize = SizeInBytes + (AlignedOffset - m_CurrOffset);
223223
VERIFY_EXPR(AdjustedSize <= m_AvailableSize);
224224
m_AvailableSize -= AdjustedSize;
225225
m_CurrOffset += AdjustedSize;
@@ -230,7 +230,7 @@ D3D12DynamicAllocation D3D12DynamicHeap::Allocate(Uint64 SizeInBytes, Uint64 Ali
230230
m_CurrAlignedSize += AdjustedSize;
231231
m_PeakAlignedSize = std::max(m_PeakAlignedSize, m_CurrAlignedSize);
232232

233-
auto& CurrPage = m_AllocatedPages.back();
233+
D3D12DynamicPage& CurrPage = m_AllocatedPages.back();
234234
// clang-format off
235235
return D3D12DynamicAllocation
236236
{

Graphics/GraphicsEngineD3D12/src/D3D12Loader.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
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -43,7 +43,7 @@ D3D12SerializeRootSignatureProcType D3D12SerializeRootSignature;
4343
HMODULE LoadD3D12Dll(const char* DLLPath)
4444
{
4545
#if PLATFORM_WIN32
46-
auto hModule = LoadLibraryA(DLLPath);
46+
HMODULE hModule = LoadLibraryA(DLLPath);
4747

4848
if (hModule == NULL)
4949
{

Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.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
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -113,7 +113,7 @@ D3D12_LOGIC_OP LogicOperationToD3D12LogicOp(LOGIC_OPERATION lo)
113113
}
114114
if (lo >= LOGIC_OP_CLEAR && lo < LOGIC_OP_NUM_OPERATIONS)
115115
{
116-
auto d3dlo = D3D12LogicOp[lo];
116+
D3D12_LOGIC_OP d3dlo = D3D12LogicOp[lo];
117117
return d3dlo;
118118
}
119119
else
@@ -130,8 +130,8 @@ void BlendStateDesc_To_D3D12_BLEND_DESC(const BlendStateDesc& BSDesc, D3D12_BLEN
130130

131131
for (int i = 0; i < 8; ++i)
132132
{
133-
const auto& SrcRTDesc = BSDesc.RenderTargets[i];
134-
auto& DstRTDesc = d3d12BlendDesc.RenderTarget[i];
133+
const RenderTargetBlendDesc& SrcRTDesc = BSDesc.RenderTargets[i];
134+
D3D12_RENDER_TARGET_BLEND_DESC& DstRTDesc = d3d12BlendDesc.RenderTarget[i];
135135

136136
// The following members only present in D3D_RENDER_TARGET_BLEND_DESC
137137
DstRTDesc.LogicOpEnable = SrcRTDesc.LogicOperationEnable ? TRUE : FALSE;
@@ -432,7 +432,7 @@ D3D12_RESOURCE_STATES ResourceStateFlagsToD3D12ResourceStates(RESOURCE_STATE Sta
432432
Uint32 Bits = StateFlags;
433433
while (Bits != 0)
434434
{
435-
auto lsb = PlatformMisc::GetLSB(Bits);
435+
Uint32 lsb = PlatformMisc::GetLSB(Bits);
436436
D3D12ResourceStates |= BitPosToD3D12ResState(lsb);
437437
Bits &= ~(1 << lsb);
438438
}
@@ -549,7 +549,7 @@ RESOURCE_STATE D3D12ResourceStatesToResourceStateFlags(D3D12_RESOURCE_STATES Sta
549549
Uint32 Bits = StateFlags;
550550
while (Bits != 0)
551551
{
552-
auto lsb = PlatformMisc::GetLSB(Bits);
552+
Uint32 lsb = PlatformMisc::GetLSB(Bits);
553553
ResourceStates |= BitPosToResState(lsb);
554554
Bits &= ~(1 << lsb);
555555
}
@@ -713,7 +713,7 @@ D3D12_RAYTRACING_GEOMETRY_FLAGS GeometryFlagsToD3D12RTGeometryFlags(RAYTRACING_G
713713
D3D12_RAYTRACING_GEOMETRY_FLAGS Result = D3D12_RAYTRACING_GEOMETRY_FLAG_NONE;
714714
while (Flags != RAYTRACING_GEOMETRY_FLAG_NONE)
715715
{
716-
auto FlagBit = static_cast<RAYTRACING_GEOMETRY_FLAGS>(1 << PlatformMisc::GetLSB(Uint32{Flags}));
716+
RAYTRACING_GEOMETRY_FLAGS FlagBit = static_cast<RAYTRACING_GEOMETRY_FLAGS>(1 << PlatformMisc::GetLSB(Uint32{Flags}));
717717
switch (FlagBit)
718718
{
719719
// clang-format off
@@ -735,7 +735,7 @@ D3D12_RAYTRACING_INSTANCE_FLAGS InstanceFlagsToD3D12RTInstanceFlags(RAYTRACING_I
735735
D3D12_RAYTRACING_INSTANCE_FLAGS Result = D3D12_RAYTRACING_INSTANCE_FLAG_NONE;
736736
while (Flags != RAYTRACING_INSTANCE_NONE)
737737
{
738-
auto FlagBit = static_cast<RAYTRACING_INSTANCE_FLAGS>(1 << PlatformMisc::GetLSB(Uint32{Flags}));
738+
RAYTRACING_INSTANCE_FLAGS FlagBit = static_cast<RAYTRACING_INSTANCE_FLAGS>(1 << PlatformMisc::GetLSB(Uint32{Flags}));
739739
switch (FlagBit)
740740
{
741741
// clang-format off
@@ -759,7 +759,7 @@ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS BuildASFlagsToD3D12ASBuildFl
759759
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS Result = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_NONE;
760760
while (Flags != RAYTRACING_BUILD_AS_NONE)
761761
{
762-
auto FlagBit = static_cast<RAYTRACING_BUILD_AS_FLAGS>(1 << PlatformMisc::GetLSB(Uint32{Flags}));
762+
RAYTRACING_BUILD_AS_FLAGS FlagBit = static_cast<RAYTRACING_BUILD_AS_FLAGS>(1 << PlatformMisc::GetLSB(Uint32{Flags}));
763763
switch (FlagBit)
764764
{
765765
// clang-format off

0 commit comments

Comments
 (0)