mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-09 04:38:30 +09:00
[Feat] (MG_State/ProgramObject, MG_Backend/DirectGLES): bind texture to uniform in backend
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user