Skip to content

Commit 6dd64fd

Browse files
committed
Make specialization presserve global parameter enumeration order in reflection data
1 parent 9d515dd commit 6dd64fd

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

source/slang/parameter-binding.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -2109,14 +2109,15 @@ RefPtr<ProgramLayout> specializeProgramLayout(
21092109

21102110
auto constantBufferRules = context.getRulesFamily()->getConstantBufferRules();
21112111
structLayout->rules = constantBufferRules;
2112-
2112+
structLayout->fields.SetSize(globalStructLayout->fields.Count());
21132113
UniformLayoutInfo structLayoutInfo;
21142114
structLayoutInfo.alignment = globalStructLayout->uniformAlignment;
21152115
structLayoutInfo.size = 0;
21162116
bool anyUniforms = false;
21172117
Dictionary<RefPtr<VarLayout>, RefPtr<VarLayout>> varLayoutMapping;
2118-
for (auto & varLayout : globalStructLayout->fields)
2118+
for (uint32_t varId = 0; varId < globalStructLayout->fields.Count(); varId++)
21192119
{
2120+
auto &varLayout = globalStructLayout->fields[varId];
21202121
// To recover layout context, we skip generic resources in the first pass
21212122
if (varLayout->FindResourceInfo(LayoutResourceKind::GenericResource))
21222123
continue;
@@ -2141,7 +2142,7 @@ RefPtr<ProgramLayout> specializeProgramLayout(
21412142
resInfo.index,
21422143
resInfo.index + tresInfo.count);
21432144
}
2144-
structLayout->fields.Add(varLayout);
2145+
structLayout->fields[varId] = varLayout;
21452146
varLayoutMapping[varLayout] = varLayout;
21462147
}
21472148
auto originalGlobalCBufferInfo = programLayout->globalScopeLayout->FindResourceInfo(LayoutResourceKind::ConstantBuffer);
@@ -2156,8 +2157,9 @@ RefPtr<ProgramLayout> specializeProgramLayout(
21562157
globalCBufferInfo.index = originalGlobalCBufferInfo->index;
21572158
}
21582159
// 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++)
21602161
{
2162+
auto &varLayout = globalStructLayout->fields[varId];
21612163
if (varLayout->typeLayout->FindResourceInfo(LayoutResourceKind::GenericResource))
21622164
{
21632165
RefPtr<Type> newType = varLayout->typeLayout->type->Substitute(typeSubst).As<Type>();
@@ -2202,7 +2204,7 @@ RefPtr<ProgramLayout> specializeProgramLayout(
22022204
newVarLayout->findOrAddResourceInfo(LayoutResourceKind::Uniform)->index = uniformOffset;
22032205
anyUniforms = true;
22042206
}
2205-
structLayout->fields.Add(newVarLayout);
2207+
structLayout->fields[varId] = newVarLayout;
22062208
varLayoutMapping[varLayout] = newVarLayout;
22072209
}
22082210
}

0 commit comments

Comments
 (0)