[Fix]: save order of uniform names, and apply it at linking and buffer mapping

This commit is contained in:
2025-06-08 20:19:06 +08:00
parent c183203264
commit 40a458b743
6 changed files with 18 additions and 8 deletions
+5 -1
View File
@@ -324,9 +324,11 @@ namespace MG_Util::Program {
}
void GenerateDefaultUBOForGLSL_Multi(
MG_Global::unordered_map<GLuint, std::string> &shaderSources) {
MG_Global::unordered_map<GLuint, std::string> &shaderSources, std::vector<std::string>& outUniformBufferNames) {
if (shaderSources.empty()) return;
outUniformBufferNames.clear();
std::unordered_map<GLuint, std::vector<bool>> commentMasks;
for (auto const& [id, source] : shaderSources) {
commentMasks[id] = buildCommentMask(source);
@@ -405,6 +407,8 @@ namespace MG_Util::Program {
if (allUniformNames.find(varName) == allUniformNames.end()) {
mergedUniforms.push_back(declaration);
allUniformNames.insert(varName);
// save the uniform names in order
outUniformBufferNames.emplace_back(varName);
}
size_t removeStart = declStart;