diff options
| author | Yong He <yonghe@outlook.com> | 2018-01-21 10:48:31 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-21 10:48:31 -0800 |
| commit | 4044a1d3a0605198465a7eb6e0e3c1f8b1a3c298 (patch) | |
| tree | 62927d4d2722b36c8e7eb4060e741b9032686835 /source/slang/parameter-binding.cpp | |
| parent | 2079b941bc5849b6ab33774fb90cefe9c2d624cb (diff) | |
| parent | f681a1505c98995683a7fbae7ce208dc5e444b9b (diff) | |
Merge pull request #372 from csyonghe/master
Allow type expression as type argument, fix global param enum order
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; } } |
