commit 47a1818c6a30cb6192b2289993cf63c9bb419df7
parent eaa05d03ac167c6364984d22318fb4afe1c0c5d3
Author: Jamie Nicol <jnicol@mozilla.com>
Date: Thu, 16 Oct 2025 16:04:02 +0000
Bug 1983036 - Pad vertex buffers with space for an extra vertex on Xclipse GPUs. r=gfx-reviewers,nical
On devices with Samsung Xclipse GPUs running Android 15, we see broken
rendering due to attribute data residing at the end of a vertex buffer
not being read correctly. Ensuring we pad the size of vertex buffers
by an additional GL_MAX_VERTEX_ATTRIB_STRIDE bytes (i.e. definitely
enough space for one additional vertex) avoids the issue.
Differential Revision: https://phabricator.services.mozilla.com/D268727
Diffstat:
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp
@@ -942,6 +942,17 @@ bool GLContext::InitImpl() {
mMaxTexOrRbSize = std::min(mMaxTextureSize, mMaxRenderbufferSize);
+#ifdef MOZ_WIDGET_ANDROID
+ if (Renderer() == GLRenderer::SamsungXclipse && jni::GetAPIVersion() == 35) {
+ // On Samsung Xclipse GPUs on Android 15 attribute values for the final
+ // vertex in a buffer may be incorrect. Padding the buffer to contain
+ // enough space for an additional vertex avoids the issue. See bug 1983036.
+ GLint maxVertexAttribStride;
+ raw_fGetIntegerv(LOCAL_GL_MAX_VERTEX_ATTRIB_STRIDE, &maxVertexAttribStride);
+ mVertexBufferExtraPadding = Some(maxVertexAttribStride);
+ }
+#endif
+
////////////////////////////////////////////////////////////////////////////
// We're ready for final setup.
diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h
@@ -899,7 +899,18 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr {
public:
void fBufferData(GLenum target, GLsizeiptr size, const GLvoid* data,
GLenum usage) {
- raw_fBufferData(target, size, data, usage);
+ if (WorkAroundDriverBugs() && target == LOCAL_GL_ARRAY_BUFFER &&
+ mVertexBufferExtraPadding) {
+ // Some drivers require extra padding at the end of array buffers.
+ // See bug 1983036.
+ raw_fBufferData(target, size + *mVertexBufferExtraPadding, nullptr,
+ usage);
+ if (data) {
+ fBufferSubData(target, 0, size, data);
+ }
+ } else {
+ raw_fBufferData(target, size, data, usage);
+ }
// bug 744888
if (WorkAroundDriverBugs() && !data && Vendor() == GLVendor::NVIDIA) {
@@ -3913,6 +3924,9 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr {
bool mNeedsTextureSizeChecks = false;
bool mNeedsFlushBeforeDeleteFB = false;
bool mTextureAllocCrashesOnMapFailure = false;
+ // Amount of additional padding bytes that must be allocated for
+ // GL_ARRAY_BUFFER buffers to work around driver bugs. See bug 1983036.
+ Maybe<GLint> mVertexBufferExtraPadding;
const bool mWorkAroundDriverBugs;
mutable uint64_t mSyncGLCallCount = 0;