3434#include " BasicMath.hpp"
3535#include " Cast.hpp"
3636#include " StringTools.hpp"
37+ #include " HashUtils.hpp"
3738
3839namespace Diligent
3940{
@@ -427,7 +428,7 @@ const TextureFormatAttribs& GetTextureFormatAttribs(TEXTURE_FORMAT Format)
427428 {
428429 if (Format >= TEX_FORMAT_UNKNOWN && Format < TEX_FORMAT_NUM_FORMATS)
429430 {
430- const auto & Attribs = FmtAttribs[Format];
431+ const TextureFormatAttribs & Attribs = FmtAttribs[Format];
431432 VERIFY (Attribs.Format == Format, " Unexpected format" );
432433 return Attribs;
433434 }
@@ -1268,7 +1269,7 @@ String GetTextureDescString(const TextureDesc& Desc)
12681269 Str += ToString (Desc.ArraySize );
12691270 }
12701271
1271- auto FmtName = GetTextureFormatAttribs (Desc.Format ).Name ;
1272+ const char * FmtName = GetTextureFormatAttribs (Desc.Format ).Name ;
12721273 Str += " ; Format: " ;
12731274 Str += FmtName;
12741275
@@ -1443,9 +1444,9 @@ String GetResourceStateString(RESOURCE_STATE State)
14431444 if (!str.empty ())
14441445 str.push_back (' |' );
14451446
1446- auto lsb = State & ~(State - 1 );
1447+ Uint32 lsb = State & ~(State - 1 );
14471448
1448- const auto * StateFlagString = GetResourceStateFlagString (static_cast <RESOURCE_STATE>(lsb));
1449+ const char * StateFlagString = GetResourceStateFlagString (static_cast <RESOURCE_STATE>(lsb));
14491450 str.append (StateFlagString);
14501451 State = static_cast <RESOURCE_STATE>(State & ~lsb);
14511452 }
@@ -1726,7 +1727,7 @@ static void PrintShaderCodeVariables(std::stringstream& ss, size_t LevelIdent, s
17261727 int MaxBasicTypeLen = 0 ;
17271728 for (Uint32 i = 0 ; i < NumVars; ++i)
17281729 {
1729- const auto & Var = pVars[i];
1730+ const ShaderCodeVariableDesc & Var = pVars[i];
17301731 if (Var.Name != nullptr )
17311732 MaxNameLen = std::max (MaxNameLen, static_cast <int >(strlen (Var.Name )));
17321733 if (Var.TypeName != nullptr )
@@ -1739,7 +1740,7 @@ static void PrintShaderCodeVariables(std::stringstream& ss, size_t LevelIdent, s
17391740
17401741 for (Uint32 i = 0 ; i < NumVars; ++i)
17411742 {
1742- const auto & Var = pVars[i];
1743+ const ShaderCodeVariableDesc & Var = pVars[i];
17431744 ss << std::setw (static_cast <int >(LevelIdent) + MaxNameLen) << (Var.Name ? Var.Name : " ?" )
17441745 << " : " << std::setw (MaxTypeLen) << (Var.TypeName ? Var.TypeName : " " )
17451746 << ' ' << std::setw (MaxClassLen) << GetShaderCodeVariableClassString (Var.Class )
@@ -1864,7 +1865,7 @@ BIND_FLAGS SwapChainUsageFlagsToBindFlags(SWAP_CHAIN_USAGE_FLAGS SwapChainUsage)
18641865 static_assert (SWAP_CHAIN_USAGE_LAST == 8 , " Did you add a new swap chain usage flag? Please handle it here." );
18651866 while (SwapChainUsage != SWAP_CHAIN_USAGE_NONE)
18661867 {
1867- auto SCUsageBit = ExtractLSB (SwapChainUsage);
1868+ SWAP_CHAIN_USAGE_FLAGS SCUsageBit = ExtractLSB (SwapChainUsage);
18681869 switch (SCUsageBit)
18691870 {
18701871 case SWAP_CHAIN_USAGE_RENDER_TARGET:
@@ -2054,8 +2055,8 @@ if ( (State & ExclusiveState) != 0 && (State & ~ExclusiveState) != 0 )\
20542055
20552056MipLevelProperties GetMipLevelProperties (const TextureDesc& TexDesc, Uint32 MipLevel)
20562057{
2057- MipLevelProperties MipProps;
2058- const auto & FmtAttribs = GetTextureFormatAttribs (TexDesc.Format );
2058+ MipLevelProperties MipProps;
2059+ const TextureFormatAttribs& FmtAttribs = GetTextureFormatAttribs (TexDesc.Format );
20592060
20602061 MipProps.LogicalWidth = std::max (TexDesc.GetWidth () >> MipLevel, 1u );
20612062 MipProps.LogicalHeight = std::max (TexDesc.GetHeight () >> MipLevel, 1u );
@@ -2366,7 +2367,7 @@ Uint64 GetStagingTextureLocationOffset(const TextureDesc& TexDesc,
23662367 Uint64 ArraySliceSize = 0 ;
23672368 for (Uint32 mip = 0 ; mip < TexDesc.MipLevels ; ++mip)
23682369 {
2369- auto MipInfo = GetMipLevelProperties (TexDesc, mip);
2370+ MipLevelProperties MipInfo = GetMipLevelProperties (TexDesc, mip);
23702371 ArraySliceSize += AlignUp (MipInfo.MipSize , Alignment);
23712372 }
23722373
@@ -2377,7 +2378,7 @@ Uint64 GetStagingTextureLocationOffset(const TextureDesc& TexDesc,
23772378
23782379 for (Uint32 mip = 0 ; mip < MipLevel; ++mip)
23792380 {
2380- auto MipInfo = GetMipLevelProperties (TexDesc, mip);
2381+ MipLevelProperties MipInfo = GetMipLevelProperties (TexDesc, mip);
23812382 Offset += AlignUp (MipInfo.MipSize , Alignment);
23822383 }
23832384
@@ -2388,8 +2389,8 @@ Uint64 GetStagingTextureLocationOffset(const TextureDesc& TexDesc,
23882389 }
23892390 else if (LocationX != 0 || LocationY != 0 || LocationZ != 0 )
23902391 {
2391- const auto & MipLevelAttribs = GetMipLevelProperties (TexDesc, MipLevel);
2392- const auto & FmtAttribs = GetTextureFormatAttribs (TexDesc.Format );
2392+ const MipLevelProperties& MipLevelAttribs = GetMipLevelProperties (TexDesc, MipLevel);
2393+ const TextureFormatAttribs & FmtAttribs = GetTextureFormatAttribs (TexDesc.Format );
23932394 VERIFY (LocationX < MipLevelAttribs.LogicalWidth && LocationY < MipLevelAttribs.LogicalHeight && LocationZ < MipLevelAttribs.Depth ,
23942395 " Specified location is out of bounds" );
23952396 if (FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED)
@@ -2419,18 +2420,18 @@ BufferToTextureCopyInfo GetBufferToTextureCopyInfo(TEXTURE_FORMAT Format,
24192420{
24202421 BufferToTextureCopyInfo CopyInfo;
24212422
2422- const auto & FmtAttribs = GetTextureFormatAttribs (Format);
2423+ const TextureFormatAttribs & FmtAttribs = GetTextureFormatAttribs (Format);
24232424 VERIFY_EXPR (Region.IsValid ());
2424- const auto UpdateRegionWidth = Region.Width ();
2425- const auto UpdateRegionHeight = Region.Height ();
2426- const auto UpdateRegionDepth = Region.Depth ();
2425+ const Uint32 UpdateRegionWidth = Region.Width ();
2426+ const Uint32 UpdateRegionHeight = Region.Height ();
2427+ const Uint32 UpdateRegionDepth = Region.Depth ();
24272428 if (FmtAttribs.ComponentType == COMPONENT_TYPE_COMPRESSED)
24282429 {
24292430 // Align update region size by the block size
24302431 VERIFY_EXPR (IsPowerOfTwo (FmtAttribs.BlockWidth ));
24312432 VERIFY_EXPR (IsPowerOfTwo (FmtAttribs.BlockHeight ));
2432- const auto BlockAlignedRegionWidth = AlignUp (UpdateRegionWidth, Uint32{FmtAttribs.BlockWidth });
2433- const auto BlockAlignedRegionHeight = AlignUp (UpdateRegionHeight, Uint32{FmtAttribs.BlockHeight });
2433+ const Uint32 BlockAlignedRegionWidth = AlignUp (UpdateRegionWidth, Uint32{FmtAttribs.BlockWidth });
2434+ const Uint32 BlockAlignedRegionHeight = AlignUp (UpdateRegionHeight, Uint32{FmtAttribs.BlockHeight });
24342435
24352436 CopyInfo.RowSize = Uint64{BlockAlignedRegionWidth} / Uint32{FmtAttribs.BlockWidth } * Uint32{FmtAttribs.ComponentSize };
24362437 CopyInfo.RowCount = BlockAlignedRegionHeight / FmtAttribs.BlockHeight ;
@@ -2472,8 +2473,8 @@ void CopyTextureSubresource(const TextureSubResData& SrcSubres,
24722473 VERIFY (DstRowStride >= RowSize, " Dst data row stride (" , DstRowStride, " ) is smaller than the row size (" , RowSize, " )" );
24732474 for (Uint32 z = 0 ; z < NumDepthSlices; ++z)
24742475 {
2475- const auto * pSrcSlice = reinterpret_cast <const Uint8*>(SrcSubres.pData ) + SrcSubres.DepthStride * z;
2476- auto * pDstSlice = reinterpret_cast <Uint8*>(pDstData) + DstDepthStride * z;
2476+ const Uint8 * pSrcSlice = reinterpret_cast <const Uint8*>(SrcSubres.pData ) + SrcSubres.DepthStride * z;
2477+ Uint8 * pDstSlice = reinterpret_cast <Uint8*>(pDstData) + DstDepthStride * z;
24772478
24782479 for (Uint32 y = 0 ; y < NumRows; ++y)
24792480 {
@@ -2706,7 +2707,7 @@ String GetPipelineShadingRateFlagsString(PIPELINE_SHADING_RATE_FLAGS Flags)
27062707 String Result;
27072708 while (Flags != PIPELINE_SHADING_RATE_FLAG_NONE)
27082709 {
2709- auto Bit = ExtractLSB (Flags);
2710+ PIPELINE_SHADING_RATE_FLAGS Bit = ExtractLSB (Flags);
27102711
27112712 if (!Result.empty ())
27122713 Result += " | " ;
@@ -2756,7 +2757,7 @@ bool TextureComponentMappingFromString(const String& MappingStr, TextureComponen
27562757
27572758 for (size_t Comp = 0 ; Comp < MappingStr.length (); ++Comp)
27582759 {
2759- const auto Chr = MappingStr[Comp];
2760+ const char Chr = MappingStr[Comp];
27602761 if (Chr == ' r' || Chr == ' R' )
27612762 Mapping[Comp] = Comp == 0 ? TEXTURE_COMPONENT_SWIZZLE_IDENTITY : TEXTURE_COMPONENT_SWIZZLE_R;
27622763 else if (Chr == ' g' || Chr == ' G' )
@@ -2777,9 +2778,9 @@ bool TextureComponentMappingFromString(const String& MappingStr, TextureComponen
27772778
27782779SparseTextureProperties GetStandardSparseTextureProperties (const TextureDesc& TexDesc)
27792780{
2780- constexpr Uint32 SparseBlockSize = 64 << 10 ;
2781- const auto & FmtAttribs = GetTextureFormatAttribs (TexDesc.Format );
2782- const Uint32 TexelSize = FmtAttribs.GetElementSize ();
2781+ constexpr Uint32 SparseBlockSize = 64 << 10 ;
2782+ const TextureFormatAttribs& FmtAttribs = GetTextureFormatAttribs (TexDesc.Format );
2783+ const Uint32 TexelSize = FmtAttribs.GetElementSize ();
27832784 VERIFY_EXPR (IsPowerOfTwo (TexelSize));
27842785 VERIFY_EXPR (TexelSize >= 1 && TexelSize <= 16 );
27852786 VERIFY_EXPR (TexDesc.Is2D () || TexDesc.Is3D ());
@@ -2860,7 +2861,7 @@ SparseTextureProperties GetStandardSparseTextureProperties(const TextureDesc& Te
28602861 }
28612862 }
28622863
2863- const auto BytesPerTile =
2864+ const Uint32 BytesPerTile =
28642865 (Props.TileSize [0 ] / FmtAttribs.BlockWidth ) *
28652866 (Props.TileSize [1 ] / FmtAttribs.BlockHeight ) *
28662867 Props.TileSize [2 ] * TexDesc.SampleCount * TexelSize;
@@ -2870,14 +2871,14 @@ SparseTextureProperties GetStandardSparseTextureProperties(const TextureDesc& Te
28702871 Props.FirstMipInTail = ~0u ;
28712872 for (Uint32 Mip = 0 ; Mip < TexDesc.MipLevels ; ++Mip)
28722873 {
2873- const auto MipProps = GetMipLevelProperties (TexDesc, Mip);
2874- const auto MipWidth = MipProps.StorageWidth ;
2875- const auto MipHeight = MipProps.StorageHeight ;
2876- const auto MipDepth = MipProps.Depth ;
2874+ const MipLevelProperties MipProps = GetMipLevelProperties (TexDesc, Mip);
2875+ const Uint32 MipWidth = MipProps.StorageWidth ;
2876+ const Uint32 MipHeight = MipProps.StorageHeight ;
2877+ const Uint32 MipDepth = MipProps.Depth ;
28772878
28782879 // When the size of a texture mipmap level is at least one standard tile shape for its
28792880 // format, the mipmap level is guaranteed to be nonpacked.
2880- const auto IsUnpacked =
2881+ const bool IsUnpacked =
28812882 MipWidth >= Props.TileSize [0 ] &&
28822883 MipHeight >= Props.TileSize [1 ] &&
28832884 MipDepth >= Props.TileSize [2 ];
@@ -2894,7 +2895,7 @@ SparseTextureProperties GetStandardSparseTextureProperties(const TextureDesc& Te
28942895 }
28952896 else
28962897 {
2897- const auto NumTilesInMip = GetNumSparseTilesInBox (Box{0 , MipWidth, 0 , MipHeight, 0 , MipDepth}, Props.TileSize );
2898+ const uint3 NumTilesInMip = GetNumSparseTilesInBox (Box{0 , MipWidth, 0 , MipHeight, 0 , MipDepth}, Props.TileSize );
28982899 SliceSize += Uint64{NumTilesInMip.x } * NumTilesInMip.y * NumTilesInMip.z * SparseBlockSize;
28992900 }
29002901 }
@@ -2937,13 +2938,13 @@ std::vector<Uint32> ResolveInputLayoutAutoOffsetsAndStrides(LayoutElement* pLayo
29372938
29382939 for (Uint32 i = 0 ; i < NumElements; ++i)
29392940 {
2940- auto & LayoutElem = pLayoutElements[i];
2941+ LayoutElement & LayoutElem = pLayoutElements[i];
29412942
29422943 if (LayoutElem.ValueType == VT_FLOAT32 || LayoutElem.ValueType == VT_FLOAT16)
29432944 LayoutElem.IsNormalized = false ; // Floating point values cannot be normalized
29442945
2945- auto BuffSlot = LayoutElem.BufferSlot ;
2946- auto & CurrAutoStride = TightStrides[BuffSlot];
2946+ Uint32 BuffSlot = LayoutElem.BufferSlot ;
2947+ Uint32 & CurrAutoStride = TightStrides[BuffSlot];
29472948 // If offset is not explicitly specified, use current auto stride value
29482949 if (LayoutElem.RelativeOffset == LAYOUT_ELEMENT_AUTO_OFFSET)
29492950 {
@@ -2970,9 +2971,9 @@ std::vector<Uint32> ResolveInputLayoutAutoOffsetsAndStrides(LayoutElement* pLayo
29702971
29712972 for (Uint32 i = 0 ; i < NumElements; ++i)
29722973 {
2973- auto & LayoutElem = pLayoutElements[i];
2974+ LayoutElement & LayoutElem = pLayoutElements[i];
29742975
2975- auto BuffSlot = LayoutElem.BufferSlot ;
2976+ Uint32 BuffSlot = LayoutElem.BufferSlot ;
29762977 // If no input elements explicitly defined stride for this buffer slot, use automatic stride
29772978 if (Strides[BuffSlot] == LAYOUT_ELEMENT_AUTO_STRIDE)
29782979 {
@@ -2992,7 +2993,7 @@ std::vector<Uint32> ResolveInputLayoutAutoOffsetsAndStrides(LayoutElement* pLayo
29922993 }
29932994
29942995 // Set strides for all unused slots to 0
2995- for (auto & Stride : Strides)
2996+ for (Uint32 & Stride : Strides)
29962997 {
29972998 if (Stride == LAYOUT_ELEMENT_AUTO_STRIDE)
29982999 Stride = 0 ;
@@ -3001,4 +3002,13 @@ std::vector<Uint32> ResolveInputLayoutAutoOffsetsAndStrides(LayoutElement* pLayo
30013002 return Strides;
30023003}
30033004
3005+ size_t ComputeRenderTargetFormatsHash (Uint32 NumRenderTargets, const TEXTURE_FORMAT RTVFormats[], TEXTURE_FORMAT DSVFormat)
3006+ {
3007+ size_t Hash = ComputeHash (NumRenderTargets);
3008+ for (Uint32 rt = 0 ; rt < NumRenderTargets; ++rt)
3009+ HashCombine (Hash, RTVFormats[rt]);
3010+ HashCombine (Hash, DSVFormat);
3011+ return Hash;
3012+ }
3013+
30043014} // namespace Diligent
0 commit comments