Skip to content

Commit 7e4b2e0

Browse files
Shader D3D12/Vk/WebGPU: don't use auto where unnecessary
1 parent d7c5d04 commit 7e4b2e0

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp

Lines changed: 6 additions & 6 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");
@@ -45,15 +45,15 @@ static ShaderVersion GetD3D12ShaderModel(const ShaderCreateInfo& ShaderCI,
4545
IDXCompiler* pDXCompiler,
4646
const ShaderVersion& DeviceSM)
4747
{
48-
auto HLSLVersion = ShaderCI.HLSLVersion;
48+
ShaderVersion HLSLVersion = ShaderCI.HLSLVersion;
4949
if (HLSLVersion > DeviceSM)
5050
{
5151
LOG_WARNING_MESSAGE("Requested shader model ", Uint32{HLSLVersion.Major}, '_', Uint32{HLSLVersion.Minor},
5252
" exceeds maximum version supported by device (",
5353
Uint32{DeviceSM.Major}, '_', Uint32{DeviceSM.Minor}, ").");
5454
}
5555

56-
auto MaxSupportedSM = DeviceSM;
56+
ShaderVersion MaxSupportedSM = DeviceSM;
5757
if (ShaderCI.Source != nullptr || ShaderCI.FilePath != nullptr)
5858
{
5959
ShaderVersion CompilerSM;
@@ -117,9 +117,9 @@ ShaderD3D12Impl::ShaderD3D12Impl(IReferenceCounters* pRefCounters,
117117
GetD3D12ShaderModel(ShaderCI, D3D12ShaderCI.pDXCompiler, D3D12ShaderCI.MaxShaderVersion),
118118
[pDXCompiler = D3D12ShaderCI.pDXCompiler,
119119
LoadCBReflection = ShaderCI.LoadConstantBufferReflection](const ShaderDesc& Desc, IDataBlob* pShaderByteCode) {
120-
auto& Allocator = GetRawAllocator();
121-
auto* pRawMem = ALLOCATE(Allocator, "Allocator for ShaderResources", ShaderResourcesD3D12, 1);
122-
auto* pResources = new (pRawMem) ShaderResourcesD3D12 //
120+
IMemoryAllocator& Allocator = GetRawAllocator();
121+
ShaderResourcesD3D12* pRawMem = ALLOCATE(Allocator, "Allocator for ShaderResources", ShaderResourcesD3D12, 1);
122+
ShaderResourcesD3D12* pResources = new (pRawMem) ShaderResourcesD3D12 //
123123
{
124124
pShaderByteCode,
125125
Desc,

Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp

Lines changed: 11 additions & 11 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");
@@ -68,7 +68,7 @@ static constexpr char VulkanDefine[] =
6868
std::vector<uint32_t> CompileShaderDXC(const ShaderCreateInfo& ShaderCI,
6969
const ShaderVkImpl::CreateInfo& VkShaderCI)
7070
{
71-
auto* pDXCompiler = VkShaderCI.pDXCompiler;
71+
IDXCompiler* pDXCompiler = VkShaderCI.pDXCompiler;
7272
VERIFY_EXPR(pDXCompiler != nullptr && pDXCompiler->IsLoaded());
7373
std::vector<uint32_t> SPIRV;
7474
pDXCompiler->Compile(ShaderCI, ShaderCI.HLSLVersion, VulkanDefine, nullptr, &SPIRV, VkShaderCI.ppCompilerOutput);
@@ -78,7 +78,7 @@ std::vector<uint32_t> CompileShaderDXC(const ShaderCreateInfo& ShaderCI,
7878
{
7979
// SPIR-V bytecode generated from HLSL must be legalized to
8080
// turn it into a valid vulkan SPIR-V shader.
81-
auto LegalizedSPIRV = OptimizeSPIRV(SPIRV, SPV_ENV_MAX, SPIRV_OPTIMIZATION_FLAG_LEGALIZATION);
81+
std::vector<uint32_t> LegalizedSPIRV = OptimizeSPIRV(SPIRV, SPV_ENV_MAX, SPIRV_OPTIMIZATION_FLAG_LEGALIZATION);
8282
if (!LegalizedSPIRV.empty())
8383
SPIRV = std::move(LegalizedSPIRV);
8484
else
@@ -168,10 +168,10 @@ void ShaderVkImpl::Initialize(const ShaderCreateInfo& ShaderCI,
168168
{
169169
DEV_CHECK_ERR(ShaderCI.ByteCode == nullptr, "'ByteCode' must be null when shader is created from source code or a file");
170170

171-
auto ShaderCompiler = ShaderCI.ShaderCompiler;
171+
SHADER_COMPILER ShaderCompiler = ShaderCI.ShaderCompiler;
172172
if (ShaderCompiler == SHADER_COMPILER_DXC)
173173
{
174-
auto* pDXCompiler = VkShaderCI.pDXCompiler;
174+
IDXCompiler* pDXCompiler = VkShaderCI.pDXCompiler;
175175
if (pDXCompiler == nullptr || !pDXCompiler->IsLoaded())
176176
{
177177
LOG_WARNING_MESSAGE("DX Compiler is not loaded. Using default shader compiler");
@@ -219,13 +219,13 @@ void ShaderVkImpl::Initialize(const ShaderCreateInfo& ShaderCI,
219219
{
220220
if ((ShaderCI.CompileFlags & SHADER_COMPILE_FLAG_SKIP_REFLECTION) == 0)
221221
{
222-
auto& Allocator = GetRawAllocator();
222+
IMemoryAllocator& Allocator = GetRawAllocator();
223223

224224
std::unique_ptr<void, STDDeleterRawMem<void>> pRawMem{
225225
ALLOCATE(Allocator, "Memory for SPIRVShaderResources", SPIRVShaderResources, 1),
226226
STDDeleterRawMem<void>(Allocator),
227227
};
228-
auto LoadShaderInputs = m_Desc.ShaderType == SHADER_TYPE_VERTEX;
228+
const bool LoadShaderInputs = m_Desc.ShaderType == SHADER_TYPE_VERTEX;
229229
new (pRawMem.get()) SPIRVShaderResources // May throw
230230
{
231231
Allocator,
@@ -322,20 +322,20 @@ void ShaderVkImpl::GetResourceDesc(Uint32 Index, ShaderResourceDesc& ResourceDes
322322
{
323323
DEV_CHECK_ERR(!IsCompiling(), "Shader resources are not available until the shader is compiled. Use GetStatus() to check the shader status.");
324324

325-
auto ResCount = GetResourceCount();
325+
const Uint32 ResCount = GetResourceCount();
326326
DEV_CHECK_ERR(Index < ResCount, "Resource index (", Index, ") is out of range");
327327
if (Index < ResCount)
328328
{
329-
const auto& SPIRVResource = m_pShaderResources->GetResource(Index);
330-
ResourceDesc = SPIRVResource.GetResourceDesc();
329+
const SPIRVShaderResourceAttribs& SPIRVResource = m_pShaderResources->GetResource(Index);
330+
ResourceDesc = SPIRVResource.GetResourceDesc();
331331
}
332332
}
333333

334334
const ShaderCodeBufferDesc* ShaderVkImpl::GetConstantBufferDesc(Uint32 Index) const
335335
{
336336
DEV_CHECK_ERR(!IsCompiling(), "Shader resources are not available until the shader is compiled. Use GetStatus() to check the shader status.");
337337

338-
auto ResCount = GetResourceCount();
338+
const Uint32 ResCount = GetResourceCount();
339339
if (Index >= ResCount)
340340
{
341341
UNEXPECTED("Resource index (", Index, ") is out of range");

Graphics/GraphicsEngineWebGPU/src/ShaderWebGPUImpl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 Diligent Graphics LLC
2+
* Copyright 2023-2025 Diligent Graphics LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -229,7 +229,7 @@ void ShaderWebGPUImpl::Initialize(const ShaderCreateInfo& ShaderCI,
229229
// Load shader resources
230230
if ((ShaderCI.CompileFlags & SHADER_COMPILE_FLAG_SKIP_REFLECTION) == 0)
231231
{
232-
auto& Allocator = GetRawAllocator();
232+
IMemoryAllocator& Allocator = GetRawAllocator();
233233

234234
std::unique_ptr<void, STDDeleterRawMem<void>> pRawMem{
235235
ALLOCATE(Allocator, "Memory for WGSLShaderResources", WGSLShaderResources, 1),

0 commit comments

Comments
 (0)