From 537ec9e2b0189f75de0414a4c32f4fcfad17a07b Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Fri, 20 Jun 2025 23:42:38 +0800 Subject: [PATCH] [Fix] (Diligent/PSO): Try hashing bound texture ids for PSO. --- .../Implementations/EGL/Diligent/EGL_impl.cpp | 15 ++++++++++++++- 1 file changed, 14 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 5812168d..68818149 100644 --- a/MG/MG_GL/Implementations/EGL/Diligent/EGL_impl.cpp +++ b/MG/MG_GL/Implementations/EGL/Diligent/EGL_impl.cpp @@ -123,7 +123,7 @@ namespace MG_Diligent { hash_combine(hash, capabilities[GL_STENCIL_TEST]); auto *pVAO = vaState.GetCurrentVAO(); - // 保证顺序一致,按index排序 + std::vector attribIndices; for (const auto& [index, _] : pVAO->attribs) attribIndices.push_back(index); @@ -147,7 +147,20 @@ namespace MG_Diligent { } } hash_combine(hash, fbInfo.DepthStencilFormat); + auto& programObj = MG_State_T::programState->programs_[MG_State_T::programState->currentProgram_]; + for (auto& [name, uniform] : programObj.uniformValues) { + if (!MG_GL::GL::IsSamplerType(uniform.type)) continue; + + std::string textureIDStr; + if (!uniform.intData.empty()) { + auto textureUnit = static_cast(uniform.intData[0]); + auto unitState = &MG_State_T::textureState->textureUnits_[textureUnit]; + textureIDStr = "tex" + std::to_string(unitState->GetBoundTexture(unitState->activeTarget)); + hash_combine(hash, textureIDStr); + MG_Util::Debug::LogD("Hashing sampler: %s, texture: %s", name.c_str(), textureIDStr.c_str()); + } + } return hash; }