From 7cace3aaaf6c29c71c895c6513ff9a5f37608bbd Mon Sep 17 00:00:00 2001 From: Jamie Nicol Date: Tue, 11 Apr 2023 16:06:13 +0000 Subject: [PATCH] Bug 1827047 - Avoid unsynchronized BufferSubData fast-path on ANGLE. r=gfx-reviewers,lsalzman In bug 1826134 we added a fast-path to WebGLBuffer::BufferSubData used by DrawTargetWebgl, which under the hood uses glMapBufferRange with GL_MAP_UNSYNCHRONIZED_BIT. However, this causes performance issues on ANGLE. This patch therefore avoids the fast-path on ANGLE, falling back to a simple glBufferSubData instead. Differential Revision: https://phabricator.services.mozilla.com/D175135 --- dom/canvas/WebGLBuffer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dom/canvas/WebGLBuffer.cpp b/dom/canvas/WebGLBuffer.cpp index a73c5dc36942..3aeea871e24c 100644 --- a/dom/canvas/WebGLBuffer.cpp +++ b/dom/canvas/WebGLBuffer.cpp @@ -205,7 +205,10 @@ void WebGLBuffer::BufferSubData(GLenum target, uint64_t rawDstByteOffset, const ScopedLazyBind lazyBind(gl, target, this); void* mapping = nullptr; - if (unsynchronized && gl->IsSupported(gl::GLFeature::map_buffer_range)) { + // Repeated calls to glMapBufferRange is slow on ANGLE, so fall back to the + // glBufferSubData path. See bug 1827047. + if (unsynchronized && gl->IsSupported(gl::GLFeature::map_buffer_range) && + !gl->IsANGLE()) { GLbitfield access = LOCAL_GL_MAP_WRITE_BIT | LOCAL_GL_MAP_UNSYNCHRONIZED_BIT | LOCAL_GL_MAP_INVALIDATE_RANGE_BIT;