From 6e9f990eed3e8238c2ea8412b020a15e4b700d99 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Sun, 22 Jun 2025 21:59:20 +0800 Subject: [PATCH] [Fix] (Diligent/PSO,Program): get rid of phantom program 0 --- MG/MG_GL/Implementations/EGL/Diligent/EGL_impl.cpp | 8 ++++++++ MG/MG_GL/Implementations/GL/Program/GL_Program.cpp | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/MG/MG_GL/Implementations/EGL/Diligent/EGL_impl.cpp b/MG/MG_GL/Implementations/EGL/Diligent/EGL_impl.cpp index 8f977fa9..c144e503 100644 --- a/MG/MG_GL/Implementations/EGL/Diligent/EGL_impl.cpp +++ b/MG/MG_GL/Implementations/EGL/Diligent/EGL_impl.cpp @@ -291,6 +291,8 @@ namespace MG_Diligent { } void PipelineStateManager::ReleasePSO(GLuint program) { + if (program == 0) + return; auto &programInfo = g_ProgramMap[program]; if (programInfo.pPipelineState) { MG_Util::Debug::LogD("Releasing PSO for program %u", program); @@ -302,6 +304,8 @@ namespace MG_Diligent { } void PipelineStateManager::MarkPSODirty(GLuint program) { + if (program == 0) + return; auto &programInfo = g_ProgramMap[program]; programInfo.psoDirty = true; MG_Util::Debug::LogD("Marked PSO dirty for program %u", program); @@ -345,6 +349,9 @@ namespace MG_Diligent { assert(ConvertGLBlendFactor(commonState.blendDstRGB) == desc.BlendDesc.RenderTargets[0].DestBlend); assert(ConvertGLBlendFactor(commonState.blendSrcAlpha) == desc.BlendDesc.RenderTargets[0].SrcBlendAlpha); assert(ConvertGLBlendFactor(commonState.blendDstAlpha) == desc.BlendDesc.RenderTargets[0].DestBlendAlpha); + + assert(ConvertGLDepthFunc(commonState.depthFunc) == desc.DepthStencilDesc.DepthFunc); + assert(commonState.capabilities[GL_DEPTH_TEST] == desc.DepthStencilDesc.DepthEnable); // if ((ConvertGLBlendFactor(commonState.blendSrcRGB) == desc.BlendDesc.RenderTargets[0].SrcBlend) && // (ConvertGLBlendFactor(commonState.blendDstRGB) == desc.BlendDesc.RenderTargets[0].DestBlend) && // (ConvertGLBlendFactor(commonState.blendSrcAlpha) == desc.BlendDesc.RenderTargets[0].SrcBlendAlpha) && @@ -409,6 +416,7 @@ namespace MG_Diligent { MG_Util::Debug::LogD(" GraphicsPipeline.DSVFormat: %d", PSOCreateInfo.GraphicsPipeline.DSVFormat); MG_Util::Debug::LogD(" GraphicsPipeline.BlendDesc.IndependentBlendEnable: %s", PSOCreateInfo.GraphicsPipeline.BlendDesc.IndependentBlendEnable ? "true" : "false"); MG_Util::Debug::LogD(" GraphicsPipeline.DepthStencilDesc.DepthEnable: %s", PSOCreateInfo.GraphicsPipeline.DepthStencilDesc.DepthEnable ? "true" : "false"); + MG_Util::Debug::LogD(" GraphicsPipeline.DepthStencilDesc.DepthFunc: 0x%x", PSOCreateInfo.GraphicsPipeline.DepthStencilDesc.DepthFunc); MG_Util::Debug::LogD(" GraphicsPipeline.RasterizerDesc.CullMode: %d", PSOCreateInfo.GraphicsPipeline.RasterizerDesc.CullMode); MG_Util::Debug::LogD("Blend states: "); diff --git a/MG/MG_GL/Implementations/GL/Program/GL_Program.cpp b/MG/MG_GL/Implementations/GL/Program/GL_Program.cpp index 1b1eb033..eef2d54a 100644 --- a/MG/MG_GL/Implementations/GL/Program/GL_Program.cpp +++ b/MG/MG_GL/Implementations/GL/Program/GL_Program.cpp @@ -285,6 +285,8 @@ namespace MG_GL::GL { auto& programInfo = MG_Diligent::g_ProgramMap[program]; auto& programObj = MG_State_T::programState->programs_[program]; + programInfo.id = program; + for (const auto& shaderId : programObj.attachedShaders) { programInfo.AttachedShadersID.push_back(shaderId); } @@ -372,7 +374,6 @@ namespace MG_GL::GL { } } - programInfo.id = program; programInfo.inputLayout.clear(); auto* pVAO = MG_State_T::vertexArrayState->GetCurrentVAO();