[Feat] (MG_State/ProgramObject, MG_State/GL_Program): implement sampler unit in program state

This commit is contained in:
2025-10-27 13:17:42 +08:00
parent 8e5cc46577
commit 5b3d5c998a
3 changed files with 29 additions and 6 deletions
+11 -4
View File
@@ -455,10 +455,17 @@ namespace MobileGL {
template <GLsizei VecCount, typename T>
void Uniform_State(MG_State::GLState::ProgramObject& programObject, GLuint location, T* value) {
auto size = programObject.GetUniformSizesInBytes(location);
auto offset = programObject.GetUniformOffset(location);
assert(size >= VecCount * sizeof(T));
memcpy((char*)programObject.MapUBO() + offset, value, VecCount * sizeof(T));
if (!programObject.IsUniformOpaqueAtLocation(location)) {
auto size = programObject.GetUniformSizesInBytes(location);
auto offset = programObject.GetUniformOffset(location);
assert(size >= VecCount * sizeof(T));
memcpy((char*)programObject.MapUBO() + offset, value, VecCount * sizeof(T));
} else {
auto* ttype = programObject.GetUniformTType(location);
if (ttype->isTexture() || ttype->isImage()) {
programObject.SetUniformSamplerOrImageUnitIndex(location, *value);
}
}
}
template <GLsizei VecCount, typename T>