Commit graph

494 commits

Author SHA1 Message Date
Molnar Sandor
68045e3d85 Backed out changeset 071aa43a0419 (bug 1703654) for causing build bustages in SharedSurfaceDMABUF. CLOSED TREE 2022-04-26 20:14:48 +03:00
Kelsey Gilbert
9f7815a9e2 Bug 1703654 - Prototype display-p3 for WebGL canvas. r=lsalzman,emilio
Enable (direct) external surface compositing for MacIOSurfaces.
Works on Mac.

Differential Revision: https://phabricator.services.mozilla.com/D144073
2022-04-26 16:54:17 +00:00
Iulian Moraru
92b62b9e23 Bug 1449575 - fix file-whitespace lint failures on WebGLContext.cpp. r=fix CLOSED TREE 2022-03-24 22:35:57 +02:00
Kelsey Gilbert
5362a1dd62 Bug 1449575 - Don't attempt ColorMask elision in WebGL. r=gfx-reviewers,aosmond
* Always use DoColorMask(u32?, u8) in webgl code.
* Handle OES_draw_buffers_indexed ColorMaski in GLBlitHelper.

Differential Revision: https://phabricator.services.mozilla.com/D141543
2022-03-24 19:39:06 +00:00
Lee Salzman
46a74c07ea Bug 1755780 - Support CopyToSwapChain on WebGLContext. r=jgilbert
For use within accelerated Canvas2D, it is expedient to have a variant of Present
that explicitly acknowledges that there is a copy from a supplied WebGL framebuffer
into the swap chain back buffer, as is usually the case when remoting, so that it
can be relied upon for format conversions or other concerns. This allows Present
to remain simple and assume rendering happened directly to the back buffer, without
need of a copy.

This backs out some of the earlier changes to Present in 1754130 in favor of
separating the new copy behavior into an explicit CopyToSwapChain interface,
which supports a format swizzle that is useful for converting between Canvas2D
and WebGL swap chain formats. The behavior of CopyToSwapChain, as noted,
assumes that there is a supplied WebGL framebuffer that must be copied to the
swap chain back buffer before any compositing should occur.

Differential Revision: https://phabricator.services.mozilla.com/D138954
2022-02-21 17:33:09 +00:00
Kelsey Gilbert
aeeb1e199d Bug 1750310 - Centralize and reuse pixelstorei pack/unpack handling. r=lsalzman
* Accept that finding an explicit unpack for a given stride might fail.
* Directly use the logic from the GLES spec for unpacking stride calculations.
* Use structuredSrcSize member.
* Calc explicit unpack based on dstStride, not srcStride.

Differential Revision: https://phabricator.services.mozilla.com/D136052
2022-02-12 02:20:42 +00:00
Lee Salzman
5c61fe02e5 Bug 1754130 - Support presenting a WebGLFramebuffer to its own swap chain without opaque FB. r=aosmond,jgilbert
Most of the support for presenting a WebGLFramebuffer to a swap chain existed as part of the
mechanism for opaque WebXR framebuffer support. However, such "opaque" framebuffer are meant
to be opaque in the sense that their attachments can't be inspected or changed, which does
not provide the requisite level of control for efficiently implementing Canvas2D snapshots.

To this end, the existing Present mechanism is slightly extended to allow presenting to the
swap chain already present in WebGLFramebuffer without the existence of a corresponding
MozFramebuffer.

This also fixes a bug in that AsWebgl() was no longer being utilized in CanvasRenderer, such
that a new mechanism that routed GetFrontBuffer() was needed to fix the code rot.

There are also some efforts to remove a couple redundant copies I noticed in profiles along
the way.

Differential Revision: https://phabricator.services.mozilla.com/D138119
2022-02-11 19:49:56 +00:00
Marian-Vasile Laza
610558649b Backed out 3 changesets (bug 1754130) for causing mochitest failures. CLOSED TREE
Backed out changeset 7fea32057b92 (bug 1754130)
Backed out changeset 1ac8f10e0025 (bug 1754130)
Backed out changeset 3d56b847ddf9 (bug 1754130)
2022-02-11 18:30:11 +02:00
Lee Salzman
4fb52bf9bc Bug 1754130 - Support presenting a WebGLFramebuffer to its own swap chain without opaque FB. r=aosmond,jgilbert
Most of the support for presenting a WebGLFramebuffer to a swap chain existed as part of the
mechanism for opaque WebXR framebuffer support. However, such "opaque" framebuffer are meant
to be opaque in the sense that their attachments can't be inspected or changed, which does
not provide the requisite level of control for efficiently implementing Canvas2D snapshots.

To this end, the existing Present mechanism is slightly extended to allow presenting to the
swap chain already present in WebGLFramebuffer without the existence of a corresponding
MozFramebuffer.

This also fixes a bug in that AsWebgl() was no longer being utilized in CanvasRenderer, such
that a new mechanism that routed GetFrontBuffer() was needed to fix the code rot.

There are also some efforts to remove a couple redundant copies I noticed in profiles along
the way.

Differential Revision: https://phabricator.services.mozilla.com/D138119
2022-02-11 15:36:30 +00:00
Andreas Pehrson
077549e08e Bug 1344524 - Change ContextCleanForFrameCapture flag to a Watchable FrameCaptureState. r=jgilbert
This allows the canvas element to be notified when a draw that would trigger
a captureStream-frame to be captured.

Differential Revision: https://phabricator.services.mozilla.com/D136003
2022-01-24 15:31:14 +00:00
sotaro
7a437cab43 Bug 1736793 - Add SurfaceTexture support to GLBlitHelper::BlitSdToFramebuffer() r=jgilbert,gfx-reviewers
Blit support of android SurfaceTexture was removed by Bug 1640607.

Differential Revision: https://phabricator.services.mozilla.com/D128992
2022-01-19 02:13:48 +00:00
Kelsey Gilbert
1c16bd06c0 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
2021-12-31 00:56:07 +00:00
msub2
46842b1f8b Bug 1596921 - Use nsICanvasRenderingContextInternal::GetParentObject in WebGLContext::MakeXRCompatible. r=jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D133824
2021-12-23 23:52:08 +00:00
Andrew Osmond
25fe6561f6 Bug 1740127 - Combine copy/swizzle/premultiply operations in ClientWebGLContext::GetFrontBufferSnapshot. r=jgilbert
The swizzling operations were showing up in talos profiles on Linux with
GLX and using OOP WebGL. If DMABuf has been disabled, similar performance
should be observed with EGL as well. This patch combines the necessary
copies, swizzling between RGBA and BGRA, and premultiplication operations
as much as possible for GetFrontBufferSnapshot.

It also has the advantage of unblocking the WebGL thread in the
compositor process sooner since it is a sync IPC call and moving that
work to the caller which would be blocked anyways.

Differential Revision: https://phabricator.services.mozilla.com/D130690
2021-12-15 12:15:36 +00:00
Kelsey Gilbert
c3603037db Bug 1746111 - (Re)serialize WebRTC frame SurfaceDescriptorBuffers for convert-and-upload on WebGLParent. r=gfx-reviewers,nika,lsalzman
Also generally de-inline (WebGLParent::TexImage not DispatchCommand)
TexImage(SurfaceDescriptor).

Differential Revision: https://phabricator.services.mozilla.com/D132851
2021-12-15 01:54:21 +00:00
Andrew Osmond
878275c3b6 Bug 1736177 - Part 11. Plumb in OffscreenCanvasDisplayHelper. r=jgilbert
This patch integrates OffscreenCanvasDisplayHelper with
HTMLCanvasElement, OffscreenCanvas and nsDisplayCanvas to allow
asynchronous display of an OffscreenCanvas.

Differential Revision: https://phabricator.services.mozilla.com/D130787
2021-12-10 02:57:55 +00:00
Andrew Osmond
3eaa48c8bb Bug 1736177 - Part 7. Remove some main thread dependencies from (Client)WebGLContext. r=jgilbert
Workers require all runnables to implement nsIDiscardableRunnable. This
is because the worker may want to terminate after going out of scope,
and want to discard any pending events. It should be safe to simply drop
any WebGL related events since we are going to tear down the context /
actors as well.

Also ensure that we record dirty events even without an associated
HTMLCanvasElement so that the OffscreenCanvas is notified properly.

Differential Revision: https://phabricator.services.mozilla.com/D130783
2021-12-10 02:57:54 +00:00
Csoregi Natalia
1c7cae16d7 Backed out 17 changesets (bug 1738971, bug 1736177) for bp-hybrid failures and others. CLOSED TREE
Backed out changeset 828633114de2 (bug 1736177)
Backed out changeset 5be8557c4721 (bug 1736177)
Backed out changeset 49f8b4205a46 (bug 1736177)
Backed out changeset 2610d4464ad5 (bug 1736177)
Backed out changeset 6d6c78c31c28 (bug 1736177)
Backed out changeset d55f1ee88bb9 (bug 1736177)
Backed out changeset bf588f8ffcf1 (bug 1736177)
Backed out changeset 86f6f6d86c6c (bug 1736177)
Backed out changeset f400c75c5829 (bug 1736177)
Backed out changeset 4a34124d5f4e (bug 1736177)
Backed out changeset 70aff7fcd001 (bug 1736177)
Backed out changeset db2347ee8147 (bug 1736177)
Backed out changeset 3dde5ddb65e5 (bug 1738971)
Backed out changeset 894ba6b7b68f (bug 1738971)
Backed out changeset dc4503052cf1 (bug 1738971)
Backed out changeset d9aef3e9797e (bug 1738971)
Backed out changeset 562a1e8e5ac3 (bug 1738971)
2021-12-10 01:13:23 +02:00
Andrew Osmond
8e0ebe8c37 Bug 1736177 - Part 11. Plumb in OffscreenCanvasDisplayHelper. r=jgilbert
This patch integrates OffscreenCanvasDisplayHelper with
HTMLCanvasElement, OffscreenCanvas and nsDisplayCanvas to allow
asynchronous display of an OffscreenCanvas.

Differential Revision: https://phabricator.services.mozilla.com/D130787
2021-12-09 19:25:28 +00:00
Andrew Osmond
a832f71083 Bug 1736177 - Part 7. Remove some main thread dependencies from (Client)WebGLContext. r=jgilbert
Workers require all runnables to implement nsIDiscardableRunnable. This
is because the worker may want to terminate after going out of scope,
and want to discard any pending events. It should be safe to simply drop
any WebGL related events since we are going to tear down the context /
actors as well.

Also ensure that we record dirty events even without an associated
HTMLCanvasElement so that the OffscreenCanvas is notified properly.

Differential Revision: https://phabricator.services.mozilla.com/D130783
2021-12-09 19:25:27 +00:00
Andi-Bogdan Postelnicu
c8e0f87391 Bug 1519636 - First reformat with clang-format 13.0.0. r=firefox-build-system-reviewers,sylvestre,mhentges
Updated with clang-format version 13.0.0 (taskcluster-OgjH5lasS5K_fvefdRcJVg)

Depends on D131114

Differential Revision: https://phabricator.services.mozilla.com/D129119
2021-11-16 08:07:30 +00:00
Jeff Gilbert
4d36916392 Bug 1661869 - Fix screenshotting of WebGL canvases. r=gfx-reviewers,lsalzman
For WebGL canvases with preserveDrawingBuffer:false, frontbuffer
snapshotting was not working properly.
If the frontbuffer had no user-fb associated with it,
was inexplicably calling BindDefaultFBForRead, which binds
*webgl*'s default FB, not *gl*'s default FB 0.
This caused frontbuffer snappshotting to actually snapshot the (cleared)
backbuffer instead of the visible frontbuffer contents.

Differential Revision: https://phabricator.services.mozilla.com/D126024
2021-09-18 01:23:58 +00:00
Jeff Gilbert
67e6fce4dd Bug 1730282 - Cleanup IPC WebGL code. r=gfx-reviewers,lsalzman
* Replace QueueStatus with bool
* Remove unused structs and code
* Add some MOZ_LIKELY to (de)serialization branches

Differential Revision: https://phabricator.services.mozilla.com/D125295
2021-09-11 02:11:11 +00:00
Jeff Gilbert
fa284e5717 Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio,webidl
Differential Revision: https://phabricator.services.mozilla.com/D122916
2021-08-27 01:47:14 +00:00
Jeff Gilbert
0d6f7f1c2b Bug 1726863 - Cache/elide GLContext::BindFramebuffer calls. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D123275
2021-08-23 23:59:26 +00:00
Csoregi Natalia
8d7a78b944 Backed out changeset fd92f897de07 (bug 1726863) for causing assertion failures on ContentCompositorBridgeParent.cpp. CLOSED TREE 2021-08-24 01:34:22 +03:00
Jeff Gilbert
16b629d8de Bug 1726863 - Cache/elide GLContext::BindFramebuffer calls. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D123275
2021-08-23 21:54:29 +00:00
Butkovits Atila
477919f37c Backed out changeset a4a346ecefd7 (bug 1726265) for causing failures at test_2_conformance2__extensions__oes-draw-buffers-indexed.html. CLOSED TREE 2021-08-21 01:46:52 +03:00
Jeff Gilbert
28e862be2d Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio
Differential Revision: https://phabricator.services.mozilla.com/D122916
2021-08-20 20:59:54 +00:00
Cosmin Sabou
135d55cd7e Backed out changeset 24e0d3aa4ada (bug 1726265) for causing non-unified build bustage. CLOSED TREE 2021-08-20 04:29:04 +03:00
Jeff Gilbert
df78036187 Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio
Differential Revision: https://phabricator.services.mozilla.com/D122916
2021-08-20 00:05:06 +00:00
Jeff Gilbert
1ab2048d63 Bug 1657189 - Avoid GetFragDataLocation('gl_*') on Mesa. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D122406
2021-08-12 01:35:15 +00:00
Kagami Sascha Rosylight
d994ae6124 Bug 1723050 - Part 6: Replace typedef by using in dom/canvas/ r=jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D121298
2021-07-30 15:30:52 +00:00
Jed Davis
a8d8e90b70 Bug 1635451 - Attempt to start WebGL even in headless mode. r=jgilbert
Currently we return an error when creating a WebGL context in headless
mode, but our WebGL implementation renders to an offscreen context, so
in theory it could work normally in a headless browser, and in practice
it already does work on some OSes.  This patch removes that check; the
attempt to use GL may fail, in which case we'll return an error to
content.

The main purpose of this patch is to run content processes with headless
mode set in an otherwise non-headless browser, but it should also be
useful for fully headless mode.  Comments in bug NNNNNNN indicate that
this change should be sufficient for headless WebGL on Windows and MacOS,
although it may not have been extensively tested.

Linux is more complicated.  The EGL/X11 backend manages its own
connection to the X server (indirectly via the EGL library); a later
patch in this series allows doing that in GLX mode as well.  Our Wayland
support can't do this yet, but it should be possible.

This patch also modifies the Linux sandbox policy so that content
processes can connect to a local X server (via the file broker) even when
the parent process is in headless mode.

Differential Revision: https://phabricator.services.mozilla.com/D118721
2021-07-06 07:42:41 +00:00
Jeff Gilbert
4a8c88c707 Bug 1655000 - Use same function for getting size as reading into buffer. r=lsalzman
Previously we called GetFrontBufferSize, alloc'd a buffer, and called
FrontBufferSnapshotInto to read into the buffer.
Now, call FrontBufferSnapshotInto({}) to get size, and then alloc and
pass pointer to newly alloc'd data into
FrontBufferSnapshotInto(Some(ptr)).
Using the same function for both means that logic can't diverge and
cause mismatch bugs.

Differential Revision: https://phabricator.services.mozilla.com/D113611
2021-05-06 00:22:42 +00:00
Alexandru Michis
2460ffe976 Backed out changeset 1331f134a250 (bug 1655000) for causing bustages in WebGLContext.cpp
CLOSED TREE
2021-04-29 00:44:19 +03:00
Jeff Gilbert
9317ccff9a Bug 1655000 - Use same function for getting size as reading into buffer. r=lsalzman
Previously we called GetFrontBufferSize, alloc'd a buffer, and called
FrontBufferSnapshotInto to read into the buffer.
Now, call FrontBufferSnapshotInto({}) to get size, and then alloc and
pass pointer to newly alloc'd data into
FrontBufferSnapshotInto(Some(ptr)).
Using the same function for both means that logic can't diverge and
cause mismatch bugs.

Differential Revision: https://phabricator.services.mozilla.com/D113611
2021-04-28 20:38:23 +00:00
Jeff Gilbert
2ec500123f Bug 1706510 - If no frontbuffer, reuse BindDefaultFBForRead. r=lsalzman
Don't bind mDefaultFB->mFB directly, since it might be multisampled.

Differential Revision: https://phabricator.services.mozilla.com/D112881
2021-04-21 01:03:32 +00:00
Jeff Gilbert
7a1619f7c2 Bug 1700799 - Better WebGL context creation failure messages. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D110166
2021-03-29 23:35:29 +00:00
Alexandru Michis
a6b034109b Backed out changeset 1bde1bcafcf1 (bug 1700799) for causing webgl crashes.
CLOSED TREE
2021-03-27 11:59:07 +02:00
Jeff Gilbert
615878e7ce Bug 1700799 - For GLContextGLX creation, add fallback if robustness fails. r=lsalzman
Also trim out unused code/vars.
Also give better WebGL context creation errors.

Differential Revision: https://phabricator.services.mozilla.com/D109679
2021-03-27 08:26:35 +00:00
Jeff Gilbert
a8926ffa47 Bug 1640607 - Send SurfaceDescriptors for GPU blitting for video-to-webgl. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D101061
2021-01-14 01:23:06 +00:00
Jeff Gilbert
77070731a2 Bug 1680595 - Point users towards "webgl.disable-fail-if-major-performance-caveat" if failIfMajorPerformanceCaveat: true causes failure. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D98824
2020-12-07 05:35:57 +00:00
Simon Giesecke
971b645fe3 Bug 1660470 - Add missing include directives/forward declarations. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D87865
2020-11-23 16:21:38 +00:00
Jeff Gilbert
449098b7b4 Bug 1668144 - Add blocklisting for OOP WebGL. r=mattwoodrow
* Add FEATURE_THREADSAFE_GL and FEATURE_ALLOW_WEBGL_OUT_OF_PROCESS
* Add gfxVars::AllowWebglOop()
* Blocklist THREADSAFE_GL on mesa/nouveau

Differential Revision: https://phabricator.services.mozilla.com/D91879
2020-10-01 08:14:12 +00:00
Jeff Gilbert
fe9cac8ce8 Bug 1664905 - Use gfxVars instead of GfxInfo in WebGL code. r=mattwoodrow
GfxInfo generally wants to be main-thread, so WebGL (especially
out-of-process) runs into problems sometimes.

Also rename to UNUSED_FEATURE_WEBGL_MSAA, pending removal.

Differential Revision: https://phabricator.services.mozilla.com/D91208
2020-09-27 22:18:23 +00:00
Csoregi Natalia
fd1e86b487 Backed out changeset 3dcacf3ae5a1 (bug 1664905) for assertion failures on GfxInfoBase.cpp. CLOSED TREE 2020-09-25 09:33:40 +03:00
Jeff Gilbert
3fd329a969 Bug 1664905 - Use gfxVars instead of GfxInfo in WebGL code. r=mattwoodrow
GfxInfo generally wants to be main-thread, so WebGL (especially
out-of-process) runs into problems sometimes.

Also remove obsolete FEATURE_WEBGL_MSAA.

Differential Revision: https://phabricator.services.mozilla.com/D91208
2020-09-25 05:43:24 +00:00
Razvan Maries
92ac0ffaa7 Backed out changeset 3ea0c63fe8b8 (bug 1664905) for build bustages on ClientWebGLContext.cpp. CLOSED TREE 2020-09-25 03:26:17 +03:00
Jeff Gilbert
98e2fea926 Bug 1664905 - Use gfxVars instead of GfxInfo in WebGL code. r=mattwoodrow
GfxInfo generally wants to be main-thread, so WebGL (especially
out-of-process) runs into problems sometimes.

Also remove obsolete FEATURE_WEBGL_MSAA.

Differential Revision: https://phabricator.services.mozilla.com/D91208
2020-09-24 23:46:12 +00:00