11/*
2- * Copyright 2019-2022 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");
@@ -874,8 +874,8 @@ void RemapShaderResources(const DXBCUtils::TResourceBindingMap& ResourceMap, con
874874{
875875 VERIFY_EXPR (RDEFHeader->Magic == RDEFFourCC);
876876
877- auto * Ptr = reinterpret_cast <char *>(RDEFHeader) + sizeof (ChunkHeader);
878- auto * ResBinding = reinterpret_cast <ResourceBindingInfoType*>(Ptr + RDEFHeader->ResBindingOffset );
877+ char * Ptr = reinterpret_cast <char *>(RDEFHeader) + sizeof (ChunkHeader);
878+ ResourceBindingInfoType * ResBinding = reinterpret_cast <ResourceBindingInfoType*>(Ptr + RDEFHeader->ResBindingOffset );
879879 if (ResBinding + RDEFHeader->ResBindingCount > EndPtr)
880880 {
881881 LOG_ERROR_AND_THROW (" Resource binding data is outside of the specified byte code range. The byte code may be corrupted." );
@@ -884,14 +884,14 @@ void RemapShaderResources(const DXBCUtils::TResourceBindingMap& ResourceMap, con
884884 String TempName;
885885 for (Uint32 r = 0 ; r < RDEFHeader->ResBindingCount ; ++r)
886886 {
887- auto & Res = ResBinding[r];
888- const char * Name = Ptr + Res.NameOffset ;
887+ ResourceBindingInfoType& Res = ResBinding[r];
888+ const char * Name = Ptr + Res.NameOffset ;
889889 if (Name + 1 > EndPtr)
890890 {
891891 LOG_ERROR_AND_THROW (" Resource name pointer is outside of the specified byte code range. The byte code may be corrupted." );
892892 }
893893
894- const auto ResType = ToResType (Res.ShaderInputType );
894+ const RES_TYPE ResType = ToResType (Res.ShaderInputType );
895895 if (ResType > BindingsPerType.size ())
896896 {
897897 LOG_ERROR_AND_THROW (" Invalid shader input type." );
@@ -924,8 +924,8 @@ void RemapShaderResources(const DXBCUtils::TResourceBindingMap& ResourceMap, con
924924 LOG_ERROR_AND_THROW (" Failed to find '" , TempName, " ' in the resource mapping." );
925925 }
926926
927- auto & Ext = ExtResMap[&Iter->second ];
928- auto & Binding = BindingsPerType[ResType];
927+ ResourceExtendedInfo & Ext = ExtResMap[&Iter->second ];
928+ auto & Binding = BindingsPerType[ResType];
929929 Binding.emplace_back (&Iter->second );
930930
931931 VERIFY_EXPR (ArrayInd < Iter->second .ArraySize );
@@ -1021,9 +1021,9 @@ void ShaderBytecodeRemapper::RemapResourceOperandSM50(const OperandToken& Operan
10211021 const auto FindResourceBindings = [this ](RES_TYPE Type, Uint32& Token) //
10221022 {
10231023 auto & Bindings = BindingsPerType[Type];
1024- for (auto & Info : Bindings)
1024+ for (const DXBCUtils::BindInfo* Info : Bindings)
10251025 {
1026- const auto & Ext = ExtResourceMap[Info];
1026+ const ResourceExtendedInfo & Ext = ExtResourceMap[Info];
10271027 if (Token >= Ext.SrcBindPoint && Token < Ext.SrcBindPoint + Info->ArraySize )
10281028 {
10291029 Token = Info->BindPoint + (Token - Ext.SrcBindPoint );
@@ -1104,8 +1104,8 @@ void ShaderBytecodeRemapper::RemapResourceOperandSM51_2(const OperandToken& Oper
11041104 if (Token[0 ] >= Bindings.size ())
11051105 LOG_ERROR_AND_THROW (" Invalid " , ResTypeToString (Type), " index (" , Token[0 ], " ), the number of resources is (" , Bindings.size (), " )." );
11061106
1107- const auto & Info = *Bindings[Token[0 ]];
1108- const auto & Ext = ExtResourceMap[&Info];
1107+ const DXBCUtils::BindInfo& Info = *Bindings[Token[0 ]];
1108+ const ResourceExtendedInfo & Ext = ExtResourceMap[&Info];
11091109 switch (Operand.OperandIndex2D )
11101110 {
11111111 case D3D10_SB_OPERAND_INDEX_IMMEDIATE32:
@@ -1119,7 +1119,7 @@ void ShaderBytecodeRemapper::RemapResourceOperandSM51_2(const OperandToken& Oper
11191119 }
11201120 case D3D10_SB_OPERAND_INDEX_RELATIVE:
11211121 {
1122- const auto Operand2 = reinterpret_cast <OperandToken&>(Token[1 ]);
1122+ const OperandToken& Operand2 = reinterpret_cast <const OperandToken&>(Token[1 ]);
11231123 VERIFY_EXPR (Operand2.OperandType == D3D10_SB_OPERAND_TYPE_TEMP);
11241124 VERIFY_EXPR (Operand2.IndexDim == D3D10_SB_OPERAND_INDEX_1D);
11251125 VERIFY_EXPR (Operand2.OperandIndex1D == D3D10_SB_OPERAND_INDEX_IMMEDIATE32);
@@ -1202,7 +1202,7 @@ void ShaderBytecodeRemapper::RemapResourceOperandSM51(const OperandToken& Operan
12021202
12031203void ShaderBytecodeRemapper::RemapResourceBindingSM51 (const OpcodeToken& Opcode, Uint32* Token, const void * Finish)
12041204{
1205- const auto & Operand = *reinterpret_cast <OperandToken*>(Token);
1205+ const OperandToken & Operand = *reinterpret_cast <OperandToken*>(Token);
12061206
12071207 switch (Opcode.OpcodeType )
12081208 {
@@ -1227,8 +1227,8 @@ void ShaderBytecodeRemapper::RemapResourceBindingSM51(const OpcodeToken& Opcode,
12271227 if (Token[1 ] >= Bindings.size ())
12281228 LOG_ERROR_AND_THROW (" Invalid cbuffer index (" , Token[1 ], " ), the number of constant buffers is (" , Bindings.size (), " )." );
12291229
1230- const auto & Info = *Bindings[Token[1 ]];
1231- const auto & Ext = ExtResourceMap[&Info];
1230+ const DXBCUtils::BindInfo& Info = *Bindings[Token[1 ]];
1231+ const ResourceExtendedInfo & Ext = ExtResourceMap[&Info];
12321232 VERIFY_EXPR (Info.BindPoint == Token[2 ]);
12331233 VERIFY_EXPR (Ext.Type == RES_TYPE_CBV);
12341234
@@ -1264,8 +1264,8 @@ void ShaderBytecodeRemapper::RemapResourceBindingSM51(const OpcodeToken& Opcode,
12641264 if (Token[1 ] >= Bindings.size ())
12651265 LOG_ERROR_AND_THROW (" Invalid sampler index (" , Token[1 ], " ), the number of samplers is (" , Bindings.size (), " )." );
12661266
1267- const auto & Info = *Bindings[Token[1 ]];
1268- const auto & Ext = ExtResourceMap[&Info];
1267+ const DXBCUtils::BindInfo& Info = *Bindings[Token[1 ]];
1268+ const ResourceExtendedInfo & Ext = ExtResourceMap[&Info];
12691269 VERIFY_EXPR (Info.BindPoint == Token[2 ]);
12701270 VERIFY_EXPR (Ext.Type == RES_TYPE_SAMPLER);
12711271
@@ -1304,8 +1304,8 @@ void ShaderBytecodeRemapper::RemapResourceBindingSM51(const OpcodeToken& Opcode,
13041304 if (Token[1 ] >= Bindings.size ())
13051305 LOG_ERROR_AND_THROW (" Invalid texture index (" , Token[1 ], " ), the number of textures is (" , Bindings.size (), " )." );
13061306
1307- const auto & Info = *Bindings[Token[1 ]];
1308- const auto & Ext = ExtResourceMap[&Info];
1307+ const DXBCUtils::BindInfo& Info = *Bindings[Token[1 ]];
1308+ const ResourceExtendedInfo & Ext = ExtResourceMap[&Info];
13091309 VERIFY_EXPR (Info.BindPoint == Token[2 ]);
13101310 VERIFY_EXPR (Ext.Type == RES_TYPE_SRV);
13111311
@@ -1340,8 +1340,8 @@ void ShaderBytecodeRemapper::RemapResourceBindingSM51(const OpcodeToken& Opcode,
13401340 if (Token[1 ] >= Bindings.size ())
13411341 LOG_ERROR_AND_THROW (" Invalid texture index (" , Token[1 ], " ), the number of textures is (" , Bindings.size (), " )." );
13421342
1343- const auto & Info = *Bindings[Token[1 ]];
1344- const auto & Ext = ExtResourceMap[&Info];
1343+ const DXBCUtils::BindInfo& Info = *Bindings[Token[1 ]];
1344+ const ResourceExtendedInfo & Ext = ExtResourceMap[&Info];
13451345 VERIFY_EXPR (Info.BindPoint == Token[2 ]);
13461346 VERIFY_EXPR (Ext.Type == RES_TYPE_SRV);
13471347
@@ -1380,8 +1380,8 @@ void ShaderBytecodeRemapper::RemapResourceBindingSM51(const OpcodeToken& Opcode,
13801380 if (Token[1 ] >= Bindings.size ())
13811381 LOG_ERROR_AND_THROW (" Invalid UAV index (" , Token[1 ], " ), the number of UAVs is (" , Bindings.size (), " )." );
13821382
1383- const auto & Info = *Bindings[Token[1 ]];
1384- const auto & Ext = ExtResourceMap[&Info];
1383+ const DXBCUtils::BindInfo& Info = *Bindings[Token[1 ]];
1384+ const ResourceExtendedInfo & Ext = ExtResourceMap[&Info];
13851385 VERIFY_EXPR (Info.BindPoint == Token[2 ]);
13861386 VERIFY_EXPR (Ext.Type == RES_TYPE_UAV);
13871387
@@ -1416,8 +1416,8 @@ void ShaderBytecodeRemapper::RemapResourceBindingSM51(const OpcodeToken& Opcode,
14161416 if (Token[1 ] >= Bindings.size ())
14171417 LOG_ERROR_AND_THROW (" Invalid UAV index (" , Token[1 ], " ), the number of UAVs is (" , Bindings.size (), " )." );
14181418
1419- const auto & Info = *Bindings[Token[1 ]];
1420- const auto & Ext = ExtResourceMap[&Info];
1419+ const DXBCUtils::BindInfo& Info = *Bindings[Token[1 ]];
1420+ const ResourceExtendedInfo & Ext = ExtResourceMap[&Info];
14211421 VERIFY_EXPR (Info.BindPoint == Token[2 ]);
14221422 VERIFY_EXPR (Ext.Type == RES_TYPE_UAV);
14231423
@@ -1476,7 +1476,7 @@ void ShaderBytecodeRemapper::ParseIndex(D3D10_SB_OPERAND_INDEX_REPRESENTATION In
14761476
14771477void ShaderBytecodeRemapper::ParseOperand (Uint32*& Token, const void * Finish)
14781478{
1479- const auto & Operand = *reinterpret_cast <OperandToken*>(Token++);
1479+ const OperandToken & Operand = *reinterpret_cast <OperandToken*>(Token++);
14801480
14811481 Uint32 NumComponents = 0 ;
14821482 switch (Operand.NumComponents )
@@ -1590,10 +1590,10 @@ void ShaderBytecodeRemapper::ParseOpcode(Uint32*& Token, const void* Finish)
15901590 // Copyright (c) Microsoft Corporation.
15911591 // MIT License
15921592
1593- Uint32* StartToken = Token;
1594- const auto Opcode = reinterpret_cast <OpcodeToken&>(*Token++);
1595- const Uint32 NumOperands = GetNumOperands (Opcode.OpcodeType );
1596- Uint32 InstructionLength = Opcode.OpcodeLength ;
1593+ Uint32* StartToken = Token;
1594+ const OpcodeToken Opcode = reinterpret_cast <OpcodeToken&>(*Token++);
1595+ const Uint32 NumOperands = GetNumOperands (Opcode.OpcodeType );
1596+ Uint32 InstructionLength = Opcode.OpcodeLength ;
15971597
15981598 VERIFY_EXPR (Opcode.OpcodeType < D3D10_SB_NUM_OPCODES);
15991599
@@ -1620,8 +1620,8 @@ void ShaderBytecodeRemapper::ParseOpcode(Uint32*& Token, const void* Finish)
16201620 {
16211621 case D3D10_SB_OPCODE_CUSTOMDATA:
16221622 {
1623- const auto Type = static_cast <D3D10_SB_CUSTOMDATA_CLASS>((*(Token - 1 ) & 0xfffff800 ) >> 11 );
1624- InstructionLength = *Token;
1623+ const D3D10_SB_CUSTOMDATA_CLASS Type = static_cast <D3D10_SB_CUSTOMDATA_CLASS>((*(Token - 1 ) & 0xfffff800 ) >> 11 );
1624+ InstructionLength = *Token;
16251625 VERIFY_EXPR (InstructionLength >= 2 );
16261626
16271627 ParseCustomData (Token, Finish, Type);
@@ -1669,7 +1669,7 @@ void ShaderBytecodeRemapper::ParseOpcode(Uint32*& Token, const void* Finish)
16691669
16701670 if (Token < Finish)
16711671 {
1672- const auto NextOpcode = reinterpret_cast <OpcodeToken&>(*Token);
1672+ const OpcodeToken& NextOpcode = reinterpret_cast <const OpcodeToken&>(*Token);
16731673 VERIFY_EXPR (NextOpcode.OpcodeType < D3D10_SB_NUM_OPCODES);
16741674 }
16751675}
@@ -1710,7 +1710,7 @@ bool RemapResourceBindings(const TResourceBindingMap& ResourceMap,
17101710 return false ;
17111711 }
17121712
1713- auto * const Ptr = static_cast <char *>(pBytecode);
1713+ char * const Ptr = static_cast <char *>(pBytecode);
17141714 const void * const EndPtr = Ptr + Size;
17151715
17161716 if (Size < sizeof (DXBCHeader))
@@ -1719,7 +1719,7 @@ bool RemapResourceBindings(const TResourceBindingMap& ResourceMap,
17191719 return false ;
17201720 }
17211721
1722- auto & Header = *reinterpret_cast <DXBCHeader*>(Ptr);
1722+ DXBCHeader & Header = *reinterpret_cast <DXBCHeader*>(Ptr);
17231723 if (Header.TotalSize != Size)
17241724 {
17251725 LOG_ERROR_MESSAGE (" The byte code size (" , Header.TotalSize , " ) specified in the header does not match the actual size (" , Size,
@@ -1756,7 +1756,7 @@ bool RemapResourceBindings(const TResourceBindingMap& ResourceMap,
17561756 {
17571757 for (Uint32 i = 0 ; i < Header.ChunkCount ; ++i)
17581758 {
1759- auto * pChunk = reinterpret_cast <ChunkHeader*>(Ptr + Chunks[i]);
1759+ ChunkHeader * pChunk = reinterpret_cast <ChunkHeader*>(Ptr + Chunks[i]);
17601760 if (pChunk + 1 > EndPtr)
17611761 {
17621762 LOG_ERROR_MESSAGE (" Not enough space for the chunk header. The byte code may be corrupted." );
@@ -1770,7 +1770,7 @@ bool RemapResourceBindings(const TResourceBindingMap& ResourceMap,
17701770
17711771 if (pChunk->Magic == RDEFFourCC)
17721772 {
1773- auto * RDEFHeader = reinterpret_cast <ResourceDefChunkHeader*>(pChunk);
1773+ ResourceDefChunkHeader * RDEFHeader = reinterpret_cast <ResourceDefChunkHeader*>(pChunk);
17741774
17751775 if (RDEFHeader->MajorVersion == 5 && RDEFHeader->MinorVersion == 1 )
17761776 {
@@ -1790,9 +1790,9 @@ bool RemapResourceBindings(const TResourceBindingMap& ResourceMap,
17901790
17911791 if (pChunk->Magic == SHDRFourCC || pChunk->Magic == SHEXFourCC)
17921792 {
1793- Uint32* Token = reinterpret_cast <Uint32*>(Ptr + Chunks[i] + sizeof (ShaderChunkHeader));
1794- const auto & SBHeader = *reinterpret_cast <ShaderChunkHeader*>(pChunk);
1795- ShaderBytecodeRemapper Remapper{SBHeader, ExtResourceMap, BindingsPerType};
1793+ Uint32* Token = reinterpret_cast <Uint32*>(Ptr + Chunks[i] + sizeof (ShaderChunkHeader));
1794+ const ShaderChunkHeader& SBHeader = *reinterpret_cast <ShaderChunkHeader*>(pChunk);
1795+ ShaderBytecodeRemapper Remapper{SBHeader, ExtResourceMap, BindingsPerType};
17961796
17971797 Remapper.PatchBytecode (Token, EndPtr);
17981798 RemapBytecode = true ;
0 commit comments