From 9d6a6548e89b50ec22ff6a3e699c064af5116ee7 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Sat, 31 Jan 2026 11:49:55 +0800 Subject: [PATCH] [Fix] (MG_Impl/Buffer): wrong range set in `BindBufferBase_State` --- MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp | 12 ++++++++++-- MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp index 131a619c..3e06d5a6 100644 --- a/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp +++ b/MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp @@ -386,6 +386,8 @@ namespace MobileGL { } void BufferSubData_State(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { + MGLOG_D("%s: target = %s, offset = %d, size = %d, data = %p", __func__, + MG_Util::ConvertGLEnumToString(target).c_str(), offset, size, data); if (!data) { MG_State::pGLContext->RecordError( ErrorCode::NoError, // somehow OpenGL does not generate an error for this @@ -488,7 +490,7 @@ namespace MobileGL { auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget); bindingSlot.Bind(bufferObject); - MGLOG_D("%s: bind buffer object %p -> %s", __func__, bufferObject.get(), + MGLOG_D("%s: bind buffer object %d -> %s", __func__, bufferObject->GetExternalIndex(), MG_Util::ConvertGLEnumToString(target).c_str()); } @@ -509,6 +511,8 @@ namespace MobileGL { } void BindBufferBase_State(GLenum target, GLuint pointIndex, GLuint buffer) { + MGLOG_D("%s: target = %s, pointIndex = %u, buffer = %u", __func__, + MG_Util::ConvertGLEnumToString(target).c_str(), pointIndex, buffer); BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); if (!BufferImpl::ValidateBufferBindingPointTarget(bufferTarget)) return; @@ -520,10 +524,14 @@ namespace MobileGL { auto& point = MG_State::pGLContext->GetBufferBindingPoint(bufferTarget, pointIndex); point.Bind(bufferObject); - point.ClearRange(); + point.SetRange(Range1D(0, bufferObject->GetSize())); + MGLOG_D("%s: set range (0, %d)", __func__, + bufferObject->GetSize()); } void BindBufferRange_State(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) { + MGLOG_D("%s: target = %s, index = %u, buffer = %u, offset = %d, size = %d", __func__, + MG_Util::ConvertGLEnumToString(target).c_str(), index, buffer, offset, size); BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target); if (!BufferImpl::ValidateBufferBindingPointTarget(bufferTarget)) return; diff --git a/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp b/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp index 913c02bf..6c15d1ad 100644 --- a/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp +++ b/MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp @@ -821,7 +821,7 @@ namespace MobileGL { break; case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: #if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES - *params = MG_External::GLES::g_glesCaps.uniformBufferOffsetAlignment; // TODO: get real value from backend + *params = MG_External::GLES::g_glesCaps.uniformBufferOffsetAlignment; #else *params = 256; #endif