Skip to content

Commit 7773dc2

Browse files
TextureBase: don't use auto where not needed
1 parent fdda6ef commit 7773dc2

File tree

2 files changed

+43
-42
lines changed

2 files changed

+43
-42
lines changed

Graphics/GraphicsEngine/include/TextureBase.hpp

Lines changed: 12 additions & 12 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");
@@ -183,7 +183,7 @@ class TextureBase : public DeviceObjectBase<typename EngineImplTraits::TextureIn
183183
{
184184
VERIFY(m_pDefaultViews == nullptr, "Default views have already been initialized");
185185

186-
const auto& TexFmtAttribs = GetTextureFormatAttribs(this->m_Desc.Format);
186+
const TextureFormatAttribs& TexFmtAttribs = GetTextureFormatAttribs(this->m_Desc.Format);
187187
if (TexFmtAttribs.ComponentType == COMPONENT_TYPE_UNDEFINED)
188188
{
189189
// Cannot create default view for TYPELESS formats
@@ -199,7 +199,7 @@ class TextureBase : public DeviceObjectBase<typename EngineImplTraits::TextureIn
199199
m_pDefaultViews = ALLOCATE(GetRawAllocator(), "Default texture view array", TextureViewImplType*, NumDefaultViews);
200200
memset(m_pDefaultViews, 0, sizeof(TextureViewImplType*) * NumDefaultViews);
201201
}
202-
auto** ppDefaultViews = GetDefaultViewsArrayPtr();
202+
TextureViewImplType** ppDefaultViews = GetDefaultViewsArrayPtr();
203203

204204
Uint8 ViewIdx = 0;
205205

@@ -245,7 +245,7 @@ class TextureBase : public DeviceObjectBase<typename EngineImplTraits::TextureIn
245245
ViewDesc.Name = ViewName.c_str();
246246

247247
VERIFY_EXPR(ViewIdx < NumDefaultViews);
248-
auto& pView = ppDefaultViews[ViewIdx];
248+
TextureViewImplType*& pView = ppDefaultViews[ViewIdx];
249249
CreateViewInternal(ViewDesc, reinterpret_cast<ITextureView**>(&pView), true);
250250
DEV_CHECK_ERR(pView != nullptr, "Failed to create default view for texture '", this->m_Desc.Name, "'.");
251251
DEV_CHECK_ERR(pView->GetDesc().ViewType == ViewType, "Unexpected view type.");
@@ -312,12 +312,12 @@ class TextureBase : public DeviceObjectBase<typename EngineImplTraits::TextureIn
312312
/// Implementation of ITexture::GetDefaultView().
313313
virtual ITextureView* DILIGENT_CALL_TYPE GetDefaultView(TEXTURE_VIEW_TYPE ViewType) override
314314
{
315-
auto ViewIdx = m_ViewIndices[ViewType];
315+
Uint8 ViewIdx = m_ViewIndices[ViewType];
316316
if (ViewIdx == InvalidViewIndex)
317317
return nullptr;
318318

319319
VERIFY_EXPR(ViewIdx < GetNumDefaultViews());
320-
auto** ppDefaultViews = GetDefaultViewsArrayPtr();
320+
TextureViewImplType** ppDefaultViews = GetDefaultViewsArrayPtr();
321321
return ppDefaultViews[ViewIdx];
322322
}
323323

@@ -336,15 +336,15 @@ class TextureBase : public DeviceObjectBase<typename EngineImplTraits::TextureIn
336336
if (m_pDefaultViews == nullptr)
337337
return;
338338

339-
const auto NumViews = GetNumDefaultViews();
340-
auto** ppDefaultViews = GetDefaultViewsArrayPtr();
339+
const Uint32 NumViews = GetNumDefaultViews();
340+
TextureViewImplType** ppDefaultViews = GetDefaultViewsArrayPtr();
341341

342-
auto& TexViewAllocator = this->GetDevice()->GetTexViewObjAllocator();
342+
TexViewObjAllocatorType& TexViewAllocator = this->GetDevice()->GetTexViewObjAllocator();
343343
VERIFY(&TexViewAllocator == &m_dbgTexViewObjAllocator, "Texture view allocator does not match allocator provided during texture initialization");
344344

345345
for (Uint32 i = 0; i < NumViews; ++i)
346346
{
347-
if (auto* pView = ppDefaultViews[i])
347+
if (TextureViewImplType* pView = ppDefaultViews[i])
348348
{
349349
pView->~TextureViewImplType();
350350
TexViewAllocator.Free(pView);
@@ -364,7 +364,7 @@ class TextureBase : public DeviceObjectBase<typename EngineImplTraits::TextureIn
364364

365365
Uint32 GetNumDefaultViews() const
366366
{
367-
constexpr auto BindFlagsWithViews =
367+
constexpr BIND_FLAGS BindFlagsWithViews =
368368
BIND_SHADER_RESOURCE |
369369
BIND_RENDER_TARGET |
370370
BIND_DEPTH_STENCIL |
@@ -375,7 +375,7 @@ class TextureBase : public DeviceObjectBase<typename EngineImplTraits::TextureIn
375375

376376
TextureViewImplType** GetDefaultViewsArrayPtr()
377377
{
378-
const auto NumDefaultViews = GetNumDefaultViews();
378+
const Uint32 NumDefaultViews = GetNumDefaultViews();
379379
return NumDefaultViews > 1 ?
380380
reinterpret_cast<TextureViewImplType**>(m_pDefaultViews) :
381381
reinterpret_cast<TextureViewImplType**>(&m_pDefaultViews);

Graphics/GraphicsEngine/src/TextureBase.cpp

Lines changed: 31 additions & 30 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");
@@ -48,9 +48,9 @@ namespace Diligent
4848

4949
void ValidateTextureDesc(const TextureDesc& Desc, const IRenderDevice* pDevice) noexcept(false)
5050
{
51-
const auto& FmtAttribs = GetTextureFormatAttribs(Desc.Format);
52-
const auto& AdapterInfo = pDevice->GetAdapterInfo();
53-
const auto& DeviceInfo = pDevice->GetDeviceInfo();
51+
const TextureFormatAttribs& FmtAttribs = GetTextureFormatAttribs(Desc.Format);
52+
const GraphicsAdapterInfo& AdapterInfo = pDevice->GetAdapterInfo();
53+
const RenderDeviceInfo& DeviceInfo = pDevice->GetDeviceInfo();
5454

5555
if (Desc.Type == RESOURCE_DIM_UNDEFINED)
5656
{
@@ -141,15 +141,15 @@ void ValidateTextureDesc(const TextureDesc& Desc, const IRenderDevice* pDevice)
141141
(Desc.Format == TEX_FORMAT_R8_SNORM || Desc.Format == TEX_FORMAT_RG8_SNORM || Desc.Format == TEX_FORMAT_RGBA8_SNORM ||
142142
Desc.Format == TEX_FORMAT_R16_SNORM || Desc.Format == TEX_FORMAT_RG16_SNORM || Desc.Format == TEX_FORMAT_RGBA16_SNORM))
143143
{
144-
const auto* FmtName = GetTextureFormatAttribs(Desc.Format).Name;
144+
const char* FmtName = GetTextureFormatAttribs(Desc.Format).Name;
145145
LOG_WARNING_MESSAGE(FmtName, " texture is created with BIND_RENDER_TARGET flag set.\n"
146146
"There might be an issue in OpenGL driver on NVidia hardware: when rendering to SNORM textures, all negative values are clamped to zero.\n"
147147
"Use UNORM format instead.");
148148
}
149149

150150
if (Desc.MiscFlags & MISC_TEXTURE_FLAG_MEMORYLESS)
151151
{
152-
const auto& MemInfo = AdapterInfo.Memory;
152+
const AdapterMemoryInfo& MemInfo = AdapterInfo.Memory;
153153

154154
if (MemInfo.MemorylessTextureBindFlags == BIND_NONE)
155155
LOG_TEXTURE_ERROR_AND_THROW("Memoryless textures are not supported by device");
@@ -194,7 +194,7 @@ void ValidateTextureDesc(const TextureDesc& Desc, const IRenderDevice* pDevice)
194194
LOG_TEXTURE_ERROR_AND_THROW("USAGE_DYNAMIC textures may only be used in one immediate device context.");
195195
}
196196

197-
const auto& SRProps = pDevice->GetAdapterInfo().ShadingRate;
197+
const ShadingRateProperties& SRProps = pDevice->GetAdapterInfo().ShadingRate;
198198
if (Desc.MiscFlags & MISC_TEXTURE_FLAG_SUBSAMPLED)
199199
{
200200
if (!pDevice->GetDeviceInfo().Features.VariableRateShading)
@@ -269,7 +269,7 @@ void ValidateTextureDesc(const TextureDesc& Desc, const IRenderDevice* pDevice)
269269
{
270270
VERIFY_TEXTURE(DeviceInfo.Features.SparseResources, "sparse texture requires SparseResources feature");
271271

272-
const auto& SparseRes = AdapterInfo.SparseResources;
272+
const SparseResourceProperties& SparseRes = AdapterInfo.SparseResources;
273273

274274
if ((Desc.MiscFlags & MISC_TEXTURE_FLAG_SPARSE_ALIASING) != 0)
275275
VERIFY_TEXTURE((SparseRes.CapFlags & SPARSE_RESOURCE_CAP_FLAG_ALIASED) != 0, "MISC_TEXTURE_FLAG_SPARSE_ALIASING flag requires SPARSE_RESOURCE_CAP_FLAG_ALIASED capability");
@@ -290,8 +290,8 @@ void ValidateTextureDesc(const TextureDesc& Desc, const IRenderDevice* pDevice)
290290

291291
if ((SparseRes.CapFlags & SPARSE_RESOURCE_CAP_FLAG_TEXTURE_2D_ARRAY_MIP_TAIL) == 0)
292292
{
293-
const auto Props = GetStandardSparseTextureProperties(Desc);
294-
const uint2 MipSize{std::max(1u, Desc.Width >> Desc.MipLevels),
293+
const SparseTextureProperties Props = GetStandardSparseTextureProperties(Desc);
294+
const uint2 MipSize{std::max(1u, Desc.Width >> Desc.MipLevels),
295295
std::max(1u, Desc.Height >> Desc.MipLevels)};
296296
VERIFY_TEXTURE(MipSize.x >= Props.TileSize[0] && MipSize.y >= Props.TileSize[1],
297297
"2D array or Cube sparse texture with mip level count ", Desc.MipLevels,
@@ -348,7 +348,7 @@ void ValidateTextureRegion(const TextureDesc& TexDesc, Uint32 MipLevel, Uint32 S
348348
VERIFY_TEX_PARAMS(Slice == 0, "Array slice (", Slice, ") must be 0 for non-array textures.");
349349
}
350350

351-
const auto& FmtAttribs = GetTextureFormatAttribs(TexDesc.Format);
351+
const TextureFormatAttribs& FmtAttribs = GetTextureFormatAttribs(TexDesc.Format);
352352

353353
Uint32 MipWidth = std::max(TexDesc.Width >> MipLevel, 1U);
354354
if (FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED)
@@ -401,12 +401,12 @@ void ValidateUpdateTextureParams(const TextureDesc& TexDesc, Uint32 MipLevel, Ui
401401
VERIFY_TEX_PARAMS((SubresData.Stride & 0x03) == 0, "Texture data stride (", SubresData.Stride, ") must be at least 32-bit aligned.");
402402
VERIFY_TEX_PARAMS((SubresData.DepthStride & 0x03) == 0, "Texture data depth stride (", SubresData.DepthStride, ") must be at least 32-bit aligned.");
403403

404-
auto UpdateRegionWidth = DstBox.Width();
405-
auto UpdateRegionHeight = DstBox.Height();
406-
auto UpdateRegionDepth = DstBox.Depth();
407-
const auto& FmtAttribs = GetTextureFormatAttribs(TexDesc.Format);
408-
Uint32 RowSize = 0;
409-
Uint32 RowCount = 0;
404+
Uint32 UpdateRegionWidth = DstBox.Width();
405+
Uint32 UpdateRegionHeight = DstBox.Height();
406+
Uint32 UpdateRegionDepth = DstBox.Depth();
407+
const TextureFormatAttribs& FmtAttribs = GetTextureFormatAttribs(TexDesc.Format);
408+
Uint32 RowSize = 0;
409+
Uint32 RowCount = 0;
410410
if (FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED)
411411
{
412412
// Align update region size by the block size. This is only necessary when updating
@@ -424,25 +424,26 @@ void ValidateUpdateTextureParams(const TextureDesc& TexDesc, Uint32 MipLevel, Ui
424424
RowCount = UpdateRegionHeight;
425425
}
426426
DEV_CHECK_ERR(SubresData.Stride >= RowSize, "Source data stride (", SubresData.Stride, ") is below the image row size (", RowSize, ").");
427-
const auto PlaneSize = SubresData.Stride * RowCount;
427+
const Uint64 PlaneSize = SubresData.Stride * RowCount;
428428
DEV_CHECK_ERR(UpdateRegionDepth == 1 || SubresData.DepthStride >= PlaneSize, "Source data depth stride (", SubresData.DepthStride, ") is below the image plane size (", PlaneSize, ").");
429429
#endif
430430
}
431431

432432
void ValidateCopyTextureParams(const CopyTextureAttribs& CopyAttribs)
433433
{
434434
VERIFY_EXPR(CopyAttribs.pSrcTexture != nullptr && CopyAttribs.pDstTexture != nullptr);
435-
Box SrcBox;
436-
const auto& SrcTexDesc = CopyAttribs.pSrcTexture->GetDesc();
437-
const auto& DstTexDesc = CopyAttribs.pDstTexture->GetDesc();
438-
auto pSrcBox = CopyAttribs.pSrcBox;
435+
Box SrcBox;
436+
const TextureDesc& SrcTexDesc = CopyAttribs.pSrcTexture->GetDesc();
437+
const TextureDesc& DstTexDesc = CopyAttribs.pDstTexture->GetDesc();
438+
const Box* pSrcBox = CopyAttribs.pSrcBox;
439439
if (pSrcBox == nullptr)
440440
{
441-
auto MipLevelAttribs = GetMipLevelProperties(SrcTexDesc, CopyAttribs.SrcMipLevel);
442-
SrcBox.MaxX = MipLevelAttribs.LogicalWidth;
443-
SrcBox.MaxY = MipLevelAttribs.LogicalHeight;
444-
SrcBox.MaxZ = MipLevelAttribs.Depth;
445-
pSrcBox = &SrcBox;
441+
MipLevelProperties MipLevelAttribs = GetMipLevelProperties(SrcTexDesc, CopyAttribs.SrcMipLevel);
442+
443+
SrcBox.MaxX = MipLevelAttribs.LogicalWidth;
444+
SrcBox.MaxY = MipLevelAttribs.LogicalHeight;
445+
SrcBox.MaxZ = MipLevelAttribs.Depth;
446+
pSrcBox = &SrcBox;
446447
}
447448
ValidateTextureRegion(SrcTexDesc, CopyAttribs.SrcMipLevel, CopyAttribs.SrcSlice, *pSrcBox);
448449

@@ -650,7 +651,7 @@ void ValidatedAndCorrectTextureViewDesc(const TextureDesc& TexDesc, TextureViewD
650651

651652
case RESOURCE_DIM_TEX_3D:
652653
{
653-
auto MipDepth = std::max(TexDesc.Depth >> ViewDesc.MostDetailedMip, 1u);
654+
Uint32 MipDepth = std::max(TexDesc.Depth >> ViewDesc.MostDetailedMip, 1u);
654655
if (ViewDesc.FirstDepthSlice + ViewDesc.NumDepthSlices > MipDepth)
655656
TEX_VIEW_VALIDATION_ERROR("First slice (", ViewDesc.FirstDepthSlice, ") and number of slices in the view (", ViewDesc.NumDepthSlices, ") specify more slices than target 3D texture mip level has (", MipDepth, ").");
656657
break;
@@ -699,7 +700,7 @@ void ValidatedAndCorrectTextureViewDesc(const TextureDesc& TexDesc, TextureViewD
699700
ViewDesc.NumArraySlices = TexDesc.ArraySize - ViewDesc.FirstArraySlice;
700701
else if (TexDesc.Is3D())
701702
{
702-
auto MipDepth = std::max(TexDesc.Depth >> ViewDesc.MostDetailedMip, 1u);
703+
Uint32 MipDepth = std::max(TexDesc.Depth >> ViewDesc.MostDetailedMip, 1u);
703704
ViewDesc.NumDepthSlices = MipDepth - ViewDesc.FirstDepthSlice;
704705
}
705706
else
@@ -710,7 +711,7 @@ void ValidatedAndCorrectTextureViewDesc(const TextureDesc& TexDesc, TextureViewD
710711
(ViewDesc.Format == TEX_FORMAT_R8_SNORM || ViewDesc.Format == TEX_FORMAT_RG8_SNORM || ViewDesc.Format == TEX_FORMAT_RGBA8_SNORM ||
711712
ViewDesc.Format == TEX_FORMAT_R16_SNORM || ViewDesc.Format == TEX_FORMAT_RG16_SNORM || ViewDesc.Format == TEX_FORMAT_RGBA16_SNORM))
712713
{
713-
const auto* FmtName = GetTextureFormatAttribs(ViewDesc.Format).Name;
714+
const char* FmtName = GetTextureFormatAttribs(ViewDesc.Format).Name;
714715
LOG_WARNING_MESSAGE(FmtName, " render target view is created.\n"
715716
"There might be an issue in OpenGL driver on NVidia hardware: when rendering to SNORM textures, all negative values are clamped to zero.\n"
716717
"Use UNORM format instead.");

0 commit comments

Comments
 (0)