diff options
| author | Yong He <yonghe@outlook.com> | 2018-01-19 22:20:29 -0500 |
|---|---|---|
| committer | Yong He <yonghe@outlook.com> | 2018-01-19 22:21:29 -0500 |
| commit | 6dd64fd9d31f29b07fcf63e743066efabbc1b092 (patch) | |
| tree | e2687f76f9e212b3bd80cefb2474eab0f2960fdc /source/slang/parameter-binding.cpp | |
| parent | 9d515dd257498cba9144dd31f2f3219e997e03d0 (diff) | |
Make specialization presserve global parameter enumeration order in reflection data
Diffstat (limited to 'source/slang/parameter-binding.cpp')
| -rw-r--r-- | source/slang/parameter-binding.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
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<ProgramLayout> 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<VarLayout>, RefPtr<VarLayout>> 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<ProgramLayout> 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<ProgramLayout> 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<Type> newType = varLayout->typeLayout->type->Substitute(typeSubst).As<Type>(); @@ -2202,7 +2204,7 @@ RefPtr<ProgramLayout> specializeProgramLayout( newVarLayout->findOrAddResourceInfo(LayoutResourceKind::Uniform)->index = uniformOffset; anyUniforms = true; } - structLayout->fields.Add(newVarLayout); + structLayout->fields[varId] = newVarLayout; varLayoutMapping[varLayout] = newVarLayout; } } |
