From 93dacf53b5f30c3af566358d6411619a3386b90b Mon Sep 17 00:00:00 2001 From: Jeff Gilbert Date: Wed, 20 Dec 2017 16:31:58 -0800 Subject: [PATCH] Bug 1425488 - Reset last fenceId on write to buffers. - r=lenzak MozReview-Commit-ID: HwPpGWKNA9W --- dom/canvas/WebGL2ContextBuffers.cpp | 16 +++++++++------- dom/canvas/WebGLBuffer.cpp | 10 ++++++++++ dom/canvas/WebGLBuffer.h | 4 +++- dom/canvas/WebGLContextDraw.cpp | 4 ++++ dom/canvas/WebGLContextGL.cpp | 2 ++ 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/dom/canvas/WebGL2ContextBuffers.cpp b/dom/canvas/WebGL2ContextBuffers.cpp index 7ee14b5e4319..0c83644e3695 100644 --- a/dom/canvas/WebGL2ContextBuffers.cpp +++ b/dom/canvas/WebGL2ContextBuffers.cpp @@ -86,6 +86,8 @@ WebGL2Context::CopyBufferSubData(GLenum readTarget, GLenum writeTarget, const ScopedLazyBind readBind(gl, readTarget, readBuffer); const ScopedLazyBind writeBind(gl, writeTarget, writeBuffer); gl->fCopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size); + + writeBuffer->ResetLastUpdateFenceId(); } void @@ -132,16 +134,16 @@ WebGL2Context::GetBufferSubData(GLenum target, GLintptr srcByteOffset, case LOCAL_GL_STREAM_READ: case LOCAL_GL_DYNAMIC_READ: if (mCompletedFenceId < buffer->mLastUpdateFenceId) { - GeneratePerfWarning("%s: Reading from a buffer without checking for previous" - " command completion likely causes pipeline stalls." - " Please use FenceSync.", - funcName); + GenerateWarning("%s: Reading from a buffer without checking for previous" + " command completion likely causes pipeline stalls." + " Please use FenceSync.", + funcName); } break; default: - GeneratePerfWarning("%s: Reading from a buffer with usage other than *_READ" - " causes pipeline stalls. Copy through a STREAM_READ buffer.", - funcName); + GenerateWarning("%s: Reading from a buffer with usage other than *_READ" + " causes pipeline stalls. Copy through a STREAM_READ buffer.", + funcName); break; } diff --git a/dom/canvas/WebGLBuffer.cpp b/dom/canvas/WebGLBuffer.cpp index ae8dce16f22e..2086eab1e22d 100644 --- a/dom/canvas/WebGLBuffer.cpp +++ b/dom/canvas/WebGLBuffer.cpp @@ -166,6 +166,8 @@ WebGLBuffer::BufferData(GLenum target, size_t size, const void* data, GLenum usa mIndexRanges.clear(); } } + + ResetLastUpdateFenceId(); } void @@ -197,6 +199,8 @@ WebGLBuffer::BufferSubData(GLenum target, size_t dstByteOffset, size_t dataLen, const ScopedLazyBind lazyBind(gl, target, this); gl->fBufferSubData(target, dstByteOffset, dataLen, uploadData); + + ResetLastUpdateFenceId(); } bool @@ -409,6 +413,12 @@ WebGLBuffer::ValidateCanBindToTarget(const char* funcName, GLenum target) return false; } +void +WebGLBuffer::ResetLastUpdateFenceId() const +{ + mLastUpdateFenceId = mContext->mNextFenceId; +} + JSObject* WebGLBuffer::WrapObject(JSContext* cx, JS::Handle givenProto) { diff --git a/dom/canvas/WebGLBuffer.h b/dom/canvas/WebGLBuffer.h index 1e5be35cc4f4..db4bf7344aef 100644 --- a/dom/canvas/WebGLBuffer.h +++ b/dom/canvas/WebGLBuffer.h @@ -105,7 +105,7 @@ protected: size_t mByteLength; size_t mTFBindCount; size_t mNonTFBindCount; - uint64_t mLastUpdateFenceId = 0; + mutable uint64_t mLastUpdateFenceId = 0; struct IndexRange final { GLenum type; @@ -128,6 +128,8 @@ protected: public: CacheMapInvalidator mFetchInvalidator; + + void ResetLastUpdateFenceId() const; }; } // namespace mozilla diff --git a/dom/canvas/WebGLContextDraw.cpp b/dom/canvas/WebGLContextDraw.cpp index 22e114bfb5a5..410dc60e41ab 100644 --- a/dom/canvas/WebGLContextDraw.cpp +++ b/dom/canvas/WebGLContextDraw.cpp @@ -337,6 +337,10 @@ public: *out_error = true; return; } + + // Technically we don't know that this will be updated yet, but we can + // speculatively mark it. + buffer->ResetLastUpdateFenceId(); } } diff --git a/dom/canvas/WebGLContextGL.cpp b/dom/canvas/WebGLContextGL.cpp index 3de322654f62..73251ba8462b 100644 --- a/dom/canvas/WebGLContextGL.cpp +++ b/dom/canvas/WebGLContextGL.cpp @@ -1423,6 +1423,8 @@ WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum const ScopedLazyBind lazyBind(gl, LOCAL_GL_PIXEL_PACK_BUFFER, buffer); ReadPixelsImpl(x, y, width, height, format, type, (void*)offset, bytesAfterOffset); + + buffer->ResetLastUpdateFenceId(); } static webgl::PackingInfo