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
4949void 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
432432void 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