@@ -2109,14 +2109,15 @@ RefPtr<ProgramLayout> specializeProgramLayout(
2109
2109
2110
2110
auto constantBufferRules = context.getRulesFamily ()->getConstantBufferRules ();
2111
2111
structLayout->rules = constantBufferRules;
2112
-
2112
+ structLayout-> fields . SetSize (globalStructLayout-> fields . Count ());
2113
2113
UniformLayoutInfo structLayoutInfo;
2114
2114
structLayoutInfo.alignment = globalStructLayout->uniformAlignment ;
2115
2115
structLayoutInfo.size = 0 ;
2116
2116
bool anyUniforms = false ;
2117
2117
Dictionary<RefPtr<VarLayout>, RefPtr<VarLayout>> varLayoutMapping;
2118
- for (auto & varLayout : globalStructLayout->fields )
2118
+ for (uint32_t varId = 0 ; varId < globalStructLayout->fields . Count (); varId++ )
2119
2119
{
2120
+ auto &varLayout = globalStructLayout->fields [varId];
2120
2121
// To recover layout context, we skip generic resources in the first pass
2121
2122
if (varLayout->FindResourceInfo (LayoutResourceKind::GenericResource))
2122
2123
continue ;
@@ -2141,7 +2142,7 @@ RefPtr<ProgramLayout> specializeProgramLayout(
2141
2142
resInfo.index ,
2142
2143
resInfo.index + tresInfo.count );
2143
2144
}
2144
- structLayout->fields . Add ( varLayout) ;
2145
+ structLayout->fields [varId] = varLayout;
2145
2146
varLayoutMapping[varLayout] = varLayout;
2146
2147
}
2147
2148
auto originalGlobalCBufferInfo = programLayout->globalScopeLayout ->FindResourceInfo (LayoutResourceKind::ConstantBuffer);
@@ -2156,8 +2157,9 @@ RefPtr<ProgramLayout> specializeProgramLayout(
2156
2157
globalCBufferInfo.index = originalGlobalCBufferInfo->index ;
2157
2158
}
2158
2159
// we have the context restored, can continue to layout the generic variables now
2159
- for (auto & varLayout : globalStructLayout->fields )
2160
+ for (uint32_t varId = 0 ; varId < globalStructLayout->fields . Count (); varId++ )
2160
2161
{
2162
+ auto &varLayout = globalStructLayout->fields [varId];
2161
2163
if (varLayout->typeLayout ->FindResourceInfo (LayoutResourceKind::GenericResource))
2162
2164
{
2163
2165
RefPtr<Type> newType = varLayout->typeLayout ->type ->Substitute (typeSubst).As <Type>();
@@ -2202,7 +2204,7 @@ RefPtr<ProgramLayout> specializeProgramLayout(
2202
2204
newVarLayout->findOrAddResourceInfo (LayoutResourceKind::Uniform)->index = uniformOffset;
2203
2205
anyUniforms = true ;
2204
2206
}
2205
- structLayout->fields . Add ( newVarLayout) ;
2207
+ structLayout->fields [varId] = newVarLayout;
2206
2208
varLayoutMapping[varLayout] = newVarLayout;
2207
2209
}
2208
2210
}
0 commit comments