[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
@@ -286,7 +286,7 @@ namespace MG_Diligent {
void PipelineStateManager::ConfigureResourceLayout(
Diligent::GraphicsPipelineStateCreateInfo& PSOCreateInfo,
const GLProgramInfo& programInfo)
GLProgramInfo& programInfo)
{
MG_Util::Debug::LogD("Begin configuring resource layout for pipeline");
@@ -308,7 +308,7 @@ namespace MG_Diligent {
}
}
MG_Util::Program::GenerateDefaultUBOForGLSL_Multi(shaderSourcesMap);
MG_Util::Program::GenerateDefaultUBOForGLSL_Multi(shaderSourcesMap, programInfo.uniformBufferNames);
for (auto shader : programInfo.AttachedShaders) {
GLuint shaderId = 0;
@@ -43,6 +43,10 @@ namespace MG_Diligent {
std::vector<Diligent::LayoutElement> inputLayout;
GLuint DefaultFBO = 0;
ProgramObject programObj;
// Uniform names, in the order of their index in uniform buffer
std::vector<std::string> uniformBufferNames;
Diligent::IBuffer* pDefaultUBO = nullptr;
std::unordered_map<std::string, Diligent::SHADER_TYPE> uniformStages;
@@ -239,7 +243,7 @@ namespace MG_Diligent {
void ConfigureResourceLayout(
Diligent::GraphicsPipelineStateCreateInfo& PSOCreateInfo,
const GLProgramInfo& programInfo);
GLProgramInfo& programInfo);
};
extern PipelineStateManager g_PSOManager;