Skip to content

Commit 2c205ba

Browse files
EngineFactoryD3D11/12: don't use auto where unnecessary
1 parent d59dc8e commit 2c205ba

File tree

4 files changed

+78
-76
lines changed

4 files changed

+78
-76
lines changed

Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp

Lines changed: 24 additions & 24 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");
@@ -54,7 +54,7 @@ namespace Diligent
5454

5555
bool CheckAdapterD3D11Compatibility(IDXGIAdapter1* pDXGIAdapter, D3D_FEATURE_LEVEL FeatureLevel)
5656
{
57-
auto hr = D3D11CreateDevice(
57+
HRESULT hr = D3D11CreateDevice(
5858
nullptr,
5959
D3D_DRIVER_TYPE_NULL, // There is no need to create a real hardware device.
6060
0,
@@ -188,10 +188,10 @@ void EngineFactoryD3D11Impl::CreateD3D11DeviceAndContextForAdapter(
188188
// If you provide a D3D_FEATURE_LEVEL array that contains D3D_FEATURE_LEVEL_11_1 on a computer that doesn't have the Direct3D 11.1
189189
// runtime installed, D3D11CreateDevice immediately fails with E_INVALIDARG.
190190
// To avoid failure in this case we will try one feature level at a time
191-
for (auto FeatureLevel : {Version{11, 1}, Version{11, 0}, Version{10, 1}, Version{10, 0}})
191+
for (Version FeatureLevel : {Version{11, 1}, Version{11, 0}, Version{10, 1}, Version{10, 0}})
192192
{
193-
auto d3dFeatureLevel = GetD3DFeatureLevel(FeatureLevel);
194-
auto hr = D3D11CreateDevice(
193+
D3D_FEATURE_LEVEL d3dFeatureLevel = GetD3DFeatureLevel(FeatureLevel);
194+
HRESULT hr = D3D11CreateDevice(
195195
pAdapter, // Specify nullptr to use the default adapter.
196196
DriverType, // If no adapter specified, request hardware graphics driver.
197197
0, // Should be 0 unless the driver is D3D_DRIVER_TYPE_SOFTWARE.
@@ -313,7 +313,7 @@ static CComPtr<IDXGIAdapter1> DXGIAdapterFromD3D11Device(ID3D11Device* pd3d11Dev
313313
{
314314
CComPtr<IDXGIDevice> pDXGIDevice;
315315

316-
auto hr = pd3d11Device->QueryInterface(__uuidof(pDXGIDevice), reinterpret_cast<void**>(static_cast<IDXGIDevice**>(&pDXGIDevice)));
316+
HRESULT hr = pd3d11Device->QueryInterface(__uuidof(pDXGIDevice), reinterpret_cast<void**>(static_cast<IDXGIDevice**>(&pDXGIDevice)));
317317
if (SUCCEEDED(hr))
318318
{
319319
CComPtr<IDXGIAdapter> pDXGIAdapter;
@@ -354,7 +354,7 @@ void EngineFactoryD3D11Impl::AttachToD3D11Device(void* pd
354354
if (!ppDevice || !ppContexts)
355355
return;
356356

357-
const auto NumImmediateContexts = std::max(1u, EngineCI.NumImmediateContexts);
357+
const Uint32 NumImmediateContexts = std::max(1u, EngineCI.NumImmediateContexts);
358358

359359
*ppDevice = nullptr;
360360
memset(ppContexts, 0, sizeof(*ppContexts) * (size_t{NumImmediateContexts} + size_t{EngineCI.NumDeferredContexts}));
@@ -367,15 +367,15 @@ void EngineFactoryD3D11Impl::AttachToD3D11Device(void* pd
367367

368368
try
369369
{
370-
auto* pd3d11Device = reinterpret_cast<ID3D11Device*>(pd3d11NativeDevice);
371-
auto* pd3d11ImmediateCtx = reinterpret_cast<ID3D11DeviceContext*>(pd3d11ImmediateContext);
372-
auto pDXGIAdapter1 = DXGIAdapterFromD3D11Device(pd3d11Device);
370+
ID3D11Device* pd3d11Device = reinterpret_cast<ID3D11Device*>(pd3d11NativeDevice);
371+
ID3D11DeviceContext* pd3d11ImmediateCtx = reinterpret_cast<ID3D11DeviceContext*>(pd3d11ImmediateContext);
372+
CComPtr<IDXGIAdapter1> pDXGIAdapter1 = DXGIAdapterFromD3D11Device(pd3d11Device);
373373

374-
const auto AdapterInfo = GetGraphicsAdapterInfo(pd3d11NativeDevice, pDXGIAdapter1);
374+
const GraphicsAdapterInfo AdapterInfo = GetGraphicsAdapterInfo(pd3d11NativeDevice, pDXGIAdapter1);
375375
VerifyEngineCreateInfo(EngineCI, AdapterInfo);
376376

377377
SetRawAllocator(EngineCI.pRawMemAllocator);
378-
auto& RawAllocator = GetRawAllocator();
378+
IMemoryAllocator& RawAllocator = GetRawAllocator();
379379

380380
RenderDeviceD3D11Impl* pRenderDeviceD3D11{
381381
NEW_RC_OBJ(RawAllocator, "RenderDeviceD3D11Impl instance", RenderDeviceD3D11Impl)(
@@ -466,11 +466,11 @@ void EngineFactoryD3D11Impl::CreateSwapChainD3D11(IRenderDevice* pDev
466466

467467
try
468468
{
469-
auto* pDeviceD3D11 = ClassPtrCast<RenderDeviceD3D11Impl>(pDevice);
470-
auto* pDeviceContextD3D11 = ClassPtrCast<DeviceContextD3D11Impl>(pImmediateContext);
471-
auto& RawMemAllocator = GetRawAllocator();
469+
RenderDeviceD3D11Impl* pDeviceD3D11 = ClassPtrCast<RenderDeviceD3D11Impl>(pDevice);
470+
DeviceContextD3D11Impl* pDeviceContextD3D11 = ClassPtrCast<DeviceContextD3D11Impl>(pImmediateContext);
471+
IMemoryAllocator& RawMemAllocator = GetRawAllocator();
472472

473-
auto* pSwapChainD3D11 = NEW_RC_OBJ(RawMemAllocator, "SwapChainD3D11Impl instance", SwapChainD3D11Impl)(SCDesc, FSDesc, pDeviceD3D11, pDeviceContextD3D11, Window);
473+
SwapChainD3D11Impl* pSwapChainD3D11 = NEW_RC_OBJ(RawMemAllocator, "SwapChainD3D11Impl instance", SwapChainD3D11Impl)(SCDesc, FSDesc, pDeviceD3D11, pDeviceContextD3D11, Window);
474474
pSwapChainD3D11->QueryInterface(IID_SwapChain, reinterpret_cast<IObject**>(ppSwapChain));
475475
}
476476
catch (const std::runtime_error&)
@@ -489,7 +489,7 @@ void EngineFactoryD3D11Impl::CreateSwapChainD3D11(IRenderDevice* pDev
489489
GraphicsAdapterInfo EngineFactoryD3D11Impl::GetGraphicsAdapterInfo(void* pd3dDevice,
490490
IDXGIAdapter1* pDXIAdapter) const
491491
{
492-
auto AdapterInfo = TBase::GetGraphicsAdapterInfo(pd3dDevice, pDXIAdapter);
492+
GraphicsAdapterInfo AdapterInfo = TBase::GetGraphicsAdapterInfo(pd3dDevice, pDXIAdapter);
493493

494494
CComPtr<ID3D11Device> pd3d11Device{reinterpret_cast<ID3D11Device*>(pd3dDevice)};
495495
if (!pd3d11Device)
@@ -498,7 +498,7 @@ GraphicsAdapterInfo EngineFactoryD3D11Impl::GetGraphicsAdapterInfo(void*
498498
VERIFY_EXPR(pd3d11Device);
499499
}
500500

501-
auto& Features = AdapterInfo.Features;
501+
DeviceFeatures& Features = AdapterInfo.Features;
502502
{
503503
bool ShaderFloat16Supported = false;
504504

@@ -516,7 +516,7 @@ GraphicsAdapterInfo EngineFactoryD3D11Impl::GetGraphicsAdapterInfo(void*
516516

517517
// Texture properties
518518
{
519-
auto& TexProps{AdapterInfo.Texture};
519+
TextureProperties& TexProps{AdapterInfo.Texture};
520520
TexProps.MaxTexture1DDimension = D3D11_REQ_TEXTURE1D_U_DIMENSION;
521521
TexProps.MaxTexture1DArraySlices = D3D11_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION;
522522
TexProps.MaxTexture2DDimension = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION;
@@ -533,7 +533,7 @@ GraphicsAdapterInfo EngineFactoryD3D11Impl::GetGraphicsAdapterInfo(void*
533533

534534
// Sampler properties
535535
{
536-
auto& SamProps{AdapterInfo.Sampler};
536+
SamplerProperties& SamProps{AdapterInfo.Sampler};
537537
SamProps.BorderSamplingModeSupported = True;
538538
SamProps.MaxAnisotropy = D3D11_DEFAULT_MAX_ANISOTROPY;
539539
SamProps.LODBiasSupported = True;
@@ -542,7 +542,7 @@ GraphicsAdapterInfo EngineFactoryD3D11Impl::GetGraphicsAdapterInfo(void*
542542

543543
// Buffer properties
544544
{
545-
auto& BufferProps = AdapterInfo.Buffer;
545+
BufferProperties& BufferProps = AdapterInfo.Buffer;
546546
// Offsets passed to *SSetConstantBuffers1 are measured in shader constants, which are
547547
// 16 bytes (4*32-bit components). Each offset must be a multiple of 16 constants,
548548
// i.e. 256 bytes.
@@ -553,7 +553,7 @@ GraphicsAdapterInfo EngineFactoryD3D11Impl::GetGraphicsAdapterInfo(void*
553553

554554
// Compute shader properties
555555
{
556-
auto& CompProps{AdapterInfo.ComputeShader};
556+
ComputeShaderProperties& CompProps{AdapterInfo.ComputeShader};
557557
CompProps.SharedMemorySize = 32u << 10; // in specs: 32Kb in D3D11 and 16Kb on downlevel hardware
558558
CompProps.MaxThreadGroupInvocations = D3D11_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP;
559559
CompProps.MaxThreadGroupSizeX = D3D11_CS_THREAD_GROUP_MAX_X;
@@ -571,7 +571,7 @@ GraphicsAdapterInfo EngineFactoryD3D11Impl::GetGraphicsAdapterInfo(void*
571571

572572
// Draw command properties
573573
{
574-
auto& DrawCommandProps{AdapterInfo.DrawCommand};
574+
DrawCommandProperties& DrawCommandProps{AdapterInfo.DrawCommand};
575575
DrawCommandProps.CapFlags |= DRAW_COMMAND_CAP_FLAG_BASE_VERTEX;
576576
#if D3D11_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP >= 32
577577
DrawCommandProps.MaxIndexValue = ~0u;
@@ -596,7 +596,7 @@ GraphicsAdapterInfo EngineFactoryD3D11Impl::GetGraphicsAdapterInfo(void*
596596
{
597597
Features.SparseResources = DEVICE_FEATURE_STATE_ENABLED;
598598

599-
auto& SparseRes{AdapterInfo.SparseResources};
599+
SparseResourceProperties& SparseRes{AdapterInfo.SparseResources};
600600
// https://docs.microsoft.com/en-us/windows/win32/direct3d11/address-space-available-for-tiled-resources
601601
SparseRes.AddressSpaceSize = Uint64{1} << (sizeof(void*) > 4 ? 40 : 32);
602602
SparseRes.ResourceSpaceSize = std::numeric_limits<UINT>::max(); // buffer size limits to number of bits in UINT

0 commit comments

Comments
 (0)