tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 71b4f75f6415d7d2bff005540cef8061c42ad0fd
parent 73481247ed635fdcb224f73545b7aab034c69967
Author: Jamie Nicol <jnicol@mozilla.com>
Date:   Thu, 16 Oct 2025 12:25:00 +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:
Mgfx/gl/GLContext.cpp | 10++++++++++
Mgfx/gl/GLContext.h | 17++++++++++++++++-
2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp @@ -885,6 +885,7 @@ bool GLContext::InitImpl() { raw_fGetIntegerv(LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE, &mMaxCubeMapTextureSize); raw_fGetIntegerv(LOCAL_GL_MAX_RENDERBUFFER_SIZE, &mMaxRenderbufferSize); raw_fGetIntegerv(LOCAL_GL_MAX_VIEWPORT_DIMS, mMaxViewportDims); + raw_fGetIntegerv(LOCAL_GL_MAX_VERTEX_ATTRIB_STRIDE, &mMaxVertexAttribStride); if (mWorkAroundDriverBugs) { int maxTexSize = INT32_MAX; @@ -942,6 +943,15 @@ 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. + mVertexBufferExtraPadding = Some(mMaxVertexAttribStride); + } +#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) { @@ -3909,10 +3920,14 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr { GLint mMaxCubeMapTextureSize = 0; GLint mMaxRenderbufferSize = 0; GLint mMaxViewportDims[2] = {}; + GLint mMaxVertexAttribStride = 0; GLsizei mMaxSamples = 0; 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;