[Perf] (MG_Backend/DirectGLES): Use glVertexAttribFormat to avoid redunant buffer binding.

This commit is contained in:
BZLZHH
2026-02-03 02:52:34 +08:00
parent 2fab6c5b0b
commit 1143c961b6
+16 -6
View File
@@ -264,12 +264,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
m_syncedAttributeVersions[attribIndex].BufferVersion; m_syncedAttributeVersions[attribIndex].BufferVersion;
if (!needsSyncFormat && !needsSyncBuffer) continue; if (!needsSyncFormat && !needsSyncBuffer) continue;
SyncAttributeBuffer(attribIndex, if (needsSyncBuffer) {
attrib); // Always need to bind VBO before setting glVertexAttribPointer SyncAttributeBuffer(attribIndex, attrib);
if (needsSyncFormat) {
MG_External::GLES::glVertexAttribDivisor(attribIndex, attrib.Divisor);
}
if (!attrib.IsInteger) { if (!attrib.IsInteger) {
MG_External::GLES::glVertexAttribPointer( MG_External::GLES::glVertexAttribPointer(
@@ -280,6 +276,20 @@ namespace MobileGL::MG_Backend::DirectGLES {
MG_Util::ConvertDataTypeToGLEnum(attrib.Type), MG_Util::ConvertDataTypeToGLEnum(attrib.Type),
attrib.Stride, (const void*)attrib.Offset); attrib.Stride, (const void*)attrib.Offset);
} }
continue; // No need to set format again
}
if (needsSyncFormat) {
MG_External::GLES::glVertexAttribDivisor(attribIndex, attrib.Divisor);
if (!attrib.IsInteger) {
MG_External::GLES::glVertexAttribFormat(attribIndex, attrib.Size,
MG_Util::ConvertDataTypeToGLEnum(attrib.Type),
attrib.Normalized ? GL_TRUE : GL_FALSE, attrib.Offset);
} else {
MG_External::GLES::glVertexAttribIFormat(
attribIndex, attrib.Size, MG_Util::ConvertDataTypeToGLEnum(attrib.Type), attrib.Offset);
}
}
} }
Uint16 currentIndexBufferVersion = stateVAOObject->GetIndexBufferBindingSlot().GetVersion(); Uint16 currentIndexBufferVersion = stateVAOObject->GetIndexBufferBindingSlot().GetVersion();