From 6dd64fd9d31f29b07fcf63e743066efabbc1b092 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 19 Jan 2018 22:20:29 -0500 Subject: Make specialization presserve global parameter enumeration order in reflection data --- source/slang/parameter-binding.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp index e5ea1d531..e1c5c1aca 100644 --- a/source/slang/parameter-binding.cpp +++ b/source/slang/parameter-binding.cpp @@ -2109,14 +2109,15 @@ RefPtr specializeProgramLayout( auto constantBufferRules = context.getRulesFamily()->getConstantBufferRules(); structLayout->rules = constantBufferRules; - + structLayout->fields.SetSize(globalStructLayout->fields.Count()); UniformLayoutInfo structLayoutInfo; structLayoutInfo.alignment = globalStructLayout->uniformAlignment; structLayoutInfo.size = 0; bool anyUniforms = false; Dictionary, RefPtr> varLayoutMapping; - for (auto & varLayout : globalStructLayout->fields) + for (uint32_t varId = 0; varId < globalStructLayout->fields.Count(); varId++) { + auto &varLayout = globalStructLayout->fields[varId]; // To recover layout context, we skip generic resources in the first pass if (varLayout->FindResourceInfo(LayoutResourceKind::GenericResource)) continue; @@ -2141,7 +2142,7 @@ RefPtr specializeProgramLayout( resInfo.index, resInfo.index + tresInfo.count); } - structLayout->fields.Add(varLayout); + structLayout->fields[varId] = varLayout; varLayoutMapping[varLayout] = varLayout; } auto originalGlobalCBufferInfo = programLayout->globalScopeLayout->FindResourceInfo(LayoutResourceKind::ConstantBuffer); @@ -2156,8 +2157,9 @@ RefPtr specializeProgramLayout( globalCBufferInfo.index = originalGlobalCBufferInfo->index; } // we have the context restored, can continue to layout the generic variables now - for (auto & varLayout : globalStructLayout->fields) + for (uint32_t varId = 0; varId < globalStructLayout->fields.Count(); varId++) { + auto &varLayout = globalStructLayout->fields[varId]; if (varLayout->typeLayout->FindResourceInfo(LayoutResourceKind::GenericResource)) { RefPtr newType = varLayout->typeLayout->type->Substitute(typeSubst).As(); @@ -2202,7 +2204,7 @@ RefPtr specializeProgramLayout( newVarLayout->findOrAddResourceInfo(LayoutResourceKind::Uniform)->index = uniformOffset; anyUniforms = true; } - structLayout->fields.Add(newVarLayout); + structLayout->fields[varId] = newVarLayout; varLayoutMapping[varLayout] = newVarLayout; } } -- cgit v1.2.3