From 1c16bd06c066273c76875afcd6d3d71d120b6b46 Mon Sep 17 00:00:00 2001 From: Kelsey Gilbert Date: Fri, 31 Dec 2021 00:56:07 +0000 Subject: [PATCH] Bug 1748019 - Add GRAPHICS profile markers to WebGLParent. r=gfx-reviewers,lsalzman Also: * Add label for WebGLContext::Create. * *Remove* label for WebGLContext::Draw*, since the labels for these are showing up in draw-call-heavy profiles. (~1.5%) * WebGLContext::UniformData continues to not have a label, since that would likely add another 2-3% labelling overhead. * Add missing !mHost check to RecvTexImage. Differential Revision: https://phabricator.services.mozilla.com/D134883 --- dom/canvas/WebGLContext.cpp | 1 + dom/canvas/WebGLContextDraw.cpp | 6 ++---- dom/canvas/WebGLParent.cpp | 10 ++++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index 10876ecc121f..19f9fd79def7 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -485,6 +485,7 @@ UniquePtr WebGLContext::CreateFormatUsage( RefPtr WebGLContext::Create(HostWebGLContext& host, const webgl::InitContextDesc& desc, webgl::InitContextResult* const out) { + AUTO_PROFILER_LABEL("WebGLContext::Create", GRAPHICS); nsCString failureId = "FEATURE_FAILURE_WEBGL_UNKOWN"_ns; const bool forceEnabled = StaticPrefs::webgl_force_enabled(); ScopedGfxFeatureReporter reporter("WebGL", forceEnabled); diff --git a/dom/canvas/WebGLContextDraw.cpp b/dom/canvas/WebGLContextDraw.cpp index 951daedff871..8bc7cf9907e9 100644 --- a/dom/canvas/WebGLContextDraw.cpp +++ b/dom/canvas/WebGLContextDraw.cpp @@ -653,7 +653,7 @@ void WebGLContext::DrawArraysInstanced(GLenum mode, GLint first, GLsizei vertCount, GLsizei instanceCount) { const FuncScope funcScope(*this, "drawArraysInstanced"); - AUTO_PROFILER_LABEL("WebGLContext::DrawArraysInstanced", GRAPHICS); + // AUTO_PROFILER_LABEL("WebGLContext::DrawArraysInstanced", GRAPHICS); if (IsContextLost()) return; const gl::GLContext::TlsScope inTls(gl); @@ -712,7 +712,6 @@ void WebGLContext::DrawArraysInstanced(GLenum mode, GLint first, { ScopedDrawCallWrapper wrapper(*this); if (vertCount && instanceCount) { - AUTO_PROFILER_LABEL("glDrawArraysInstanced", GRAPHICS); if (HasInstancedDrawing(*this)) { gl->fDrawArraysInstanced(mode, first, vertCount, instanceCount); } else { @@ -830,7 +829,7 @@ void WebGLContext::DrawElementsInstanced(GLenum mode, GLsizei indexCount, GLenum type, WebGLintptr byteOffset, GLsizei instanceCount) { const FuncScope funcScope(*this, "drawElementsInstanced"); - AUTO_PROFILER_LABEL("WebGLContext::DrawElementsInstanced", GRAPHICS); + // AUTO_PROFILER_LABEL("WebGLContext::DrawElementsInstanced", GRAPHICS); if (IsContextLost()) return; const gl::GLContext::TlsScope inTls(gl); @@ -912,7 +911,6 @@ void WebGLContext::DrawElementsInstanced(GLenum mode, GLsizei indexCount, } if (indexCount && instanceCount) { - AUTO_PROFILER_LABEL("glDrawElementsInstanced", GRAPHICS); if (HasInstancedDrawing(*this)) { if (MOZ_UNLIKELY(collapseToDrawArrays)) { gl->fDrawArraysInstanced(mode, 0, 1, instanceCount); diff --git a/dom/canvas/WebGLParent.cpp b/dom/canvas/WebGLParent.cpp index acf741fa8215..ef907653cd1f 100644 --- a/dom/canvas/WebGLParent.cpp +++ b/dom/canvas/WebGLParent.cpp @@ -33,6 +33,7 @@ using IPCResult = mozilla::ipc::IPCResult; IPCResult WebGLParent::RecvDispatchCommands(Shmem&& rawShmem, const uint64_t cmdsByteSize) { + AUTO_PROFILER_LABEL("WebGLParent::RecvDispatchCommands", GRAPHICS); if (!mHost) { return IPC_FAIL(this, "HostWebGLContext is not initialized."); } @@ -80,6 +81,10 @@ IPCResult WebGLParent::RecvTexImage(const uint32_t level, const uvec3& offset, const webgl::PackingInfo& pi, webgl::TexUnpackBlobDesc&& desc) { + if (!mHost) { + return IPC_FAIL(this, "HostWebGLContext is not initialized."); + } + mHost->TexImage(level, respecFormat, offset, pi, desc); return IPC_OK(); } @@ -102,8 +107,8 @@ IPCResult WebGLParent::RecvGetFrontBufferSnapshot( IPCResult WebGLParent::GetFrontBufferSnapshot( webgl::FrontBufferSnapshotIpc* const ret, IProtocol* aProtocol) { + AUTO_PROFILER_LABEL("WebGLParent::GetFrontBufferSnapshot", GRAPHICS); *ret = {}; - if (!mHost) { return IPC_FAIL(aProtocol, "HostWebGLContext is not initialized."); } @@ -138,6 +143,7 @@ IPCResult WebGLParent::RecvGetBufferSubData(const GLenum target, const uint64_t srcByteOffset, const uint64_t byteSize, Shmem* const ret) { + AUTO_PROFILER_LABEL("WebGLParent::RecvGetBufferSubData", GRAPHICS); if (!mHost) { return IPC_FAIL(this, "HostWebGLContext is not initialized."); } @@ -166,8 +172,8 @@ IPCResult WebGLParent::RecvGetBufferSubData(const GLenum target, IPCResult WebGLParent::RecvReadPixels(const webgl::ReadPixelsDesc& desc, const uint64_t byteSize, webgl::ReadPixelsResultIpc* const ret) { + AUTO_PROFILER_LABEL("WebGLParent::RecvReadPixels", GRAPHICS); *ret = {}; - if (!mHost) { return IPC_FAIL(this, "HostWebGLContext is not initialized."); }