[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
@@ -86,7 +86,8 @@ namespace MG_GL::GL {
size_t offset = 0;
programInfo.uniformOffsets.clear();
for (auto& [name, uniform] : programInfo.programObj.uniformValues) {
for (auto& name: programInfo.uniformBufferNames) {
auto& uniform = programInfo.programObj.uniformValues[name];
if (IsSamplerType(uniform.type)) continue;
size_t size = GetUniformSize(uniform.type);
@@ -255,7 +256,7 @@ namespace MG_GL::GL {
shaderSources[shaderId] = shaderObj.source;
}
MG_Util::Program::GenerateDefaultUBOForGLSL_Multi(shaderSources);
MG_Util::Program::GenerateDefaultUBOForGLSL_Multi(shaderSources, programInfo.uniformBufferNames);
// Compile attached shaders
for (GLuint shaderId : programInfo.AttachedShadersID) {