[Feat] (MG_State/ProgramObject, MG_Backend/DirectGLES): bind texture to uniform in backend

This commit is contained in:
2025-10-27 15:45:36 +08:00
parent 460b7a6eb3
commit 56c6d73185
4 changed files with 13 additions and 5 deletions
@@ -302,6 +302,17 @@ namespace MobileGL::MG_Backend::DirectGLES {
MG_External::GLES::glBindBufferBase(GL_UNIFORM_BUFFER, bindingPoint,
backendProgramIt->second->GetBackendGlobalUBOId());
// Sampler unit binding
auto maxUniformLoc = currentProgram->GetMaxUniformLocation();
for (int loc = 0; loc < maxUniformLoc; ++loc) {
auto unit = currentProgram->GetUniformSamplerOrImageUnitIndex(loc);
if (unit == -1)
continue;
auto& name = currentProgram->GetUniformName(loc);
auto locAtBackend = MG_External::GLES::glGetUniformLocation(backendProgramIt->second->GetBackendProgramId(), name.c_str());
MG_External::GLES::glUniform1i(locAtBackend, unit);
}
} else {
MG_External::GLES::glUseProgram(0);
}
@@ -530,9 +530,6 @@ namespace MobileGL::MG_Backend::DirectGLES {
GL_STREAM_DRAW);
MG_External::GLES::glBindBuffer(GL_UNIFORM_BUFFER, 0);
// Bind samplers
m_isInitialized = true;
MGLOG_D("Program sync completed. Backend ID: %u", m_backendProgramId);
}
@@ -92,7 +92,7 @@ namespace MobileGL {
// Be aware, there could be gaps in between these vectors
// Locations can be not sequential
m_uniformIndexInTProgram.resize(m_maxUniformLocation + 1, 4095);
m_uniformSamplerOrImageUnitIndex.resize(m_maxUniformLocation + 1, 0);
m_uniformSamplerOrImageUnitIndex.resize(m_maxUniformLocation + 1, -1);
Vector<int> unallocatedUniformIndex;
@@ -66,7 +66,7 @@ namespace MobileGL {
m_uniformSamplerOrImageUnitIndex[location] = unit;
}
Int SetUniformSamplerOrImageUnitIndex(Uint location) const {
Int GetUniformSamplerOrImageUnitIndex(Uint location) const {
return m_uniformSamplerOrImageUnitIndex[location];
}