From 984ae97579acbb11e7bbb8580636cb220e45fd7c Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Sat, 1 Nov 2025 21:42:05 +0800 Subject: [PATCH] [Improvement] (...): Better handling for enabling/disabling attribute in VAO. --- MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp | 1 + MobileGL/MG_Backend/DirectGLES/Managers.cpp | 9 ++++++++- MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp | 2 -- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp b/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp index 1537c8f3..65310acb 100644 --- a/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp +++ b/MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp @@ -23,6 +23,7 @@ namespace MobileGL::MG_Backend::DirectGLES { } for (const auto& attrib : currentVAOObject->GetAllAttributes()) { + if (!attrib.Enabled) return; const auto& bufferObject = attrib.Buffer; if (bufferObject) { buffersToSync.push_back(bufferObject); diff --git a/MobileGL/MG_Backend/DirectGLES/Managers.cpp b/MobileGL/MG_Backend/DirectGLES/Managers.cpp index 72a5a796..26684d18 100644 --- a/MobileGL/MG_Backend/DirectGLES/Managers.cpp +++ b/MobileGL/MG_Backend/DirectGLES/Managers.cpp @@ -162,6 +162,14 @@ namespace MobileGL::MG_Backend::DirectGLES { for (const auto& attribIndex : stateVAOObject->GetDirtyAttributeIndices()) { const auto& attrib = stateVAOObject->GetAttribute(attribIndex); + if (attrib.Enabled) { + MGLOG_D("Binding attribute index %u for VAO ID: %u", attribIndex, m_backendVAOId); + MG_External::GLES::glEnableVertexAttribArray(attribIndex); + } else { + MGLOG_D("Disabling attribute index %u for VAO ID: %u", attribIndex, m_backendVAOId); + MG_External::GLES::glDisableVertexAttribArray(attribIndex); + continue; + } const auto& bufferObject = attrib.Buffer; if (!bufferObject) { @@ -177,7 +185,6 @@ namespace MobileGL::MG_Backend::DirectGLES { const auto& backendBufferObject = backendBufferIt->second; backendBufferObject->Bind(GL_ARRAY_BUFFER); - MG_External::GLES::glEnableVertexAttribArray(attribIndex); if (!attrib.IsInteger) { MG_External::GLES::glVertexAttribPointer( attribIndex, attrib.Size, MG_Util::ConvertDataTypeToGLEnum(attrib.Type), diff --git a/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp b/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp index 738cb69c..4f9cd823 100644 --- a/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp +++ b/MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp @@ -99,8 +99,6 @@ namespace MobileGL { for (GLsizei y = 0; y < height; y++) { const SizeT destRowOffset = (yoffset + y) * destRowSize + xoffset * bytesPerPixel; const SizeT srcRowOffset = y * srcRowSize; - MGLOG_I("memcpy params: dst: %p, src: %p, size: %zu", destData + destRowOffset, srcData + srcRowOffset, - srcRowSize); Memcpy(destData + destRowOffset, srcData + srcRowOffset, srcRowSize); }