Commit graph

127 commits

Author SHA1 Message Date
Andrew Osmond
34f04947f7 Bug 1781526 - Implement means to use VideoFrame with WebGL. r=webidl,smaug,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D181118
2023-09-20 22:40:24 +00:00
Peter Van der Beken
627ac90e0c Bug 1690111 - Use new TypedArray APIs for processing data. r=farre,media-playback-reviewers,padenot,chunmin,sfink
Depends on D152497

Differential Revision: https://phabricator.services.mozilla.com/D152498
2023-09-20 09:42:02 +00:00
Cosmin Sabou
680b4364c7 Backed out 13 changesets (bug 1690111) for causing fetch related crashes.
Backed out changeset 5f2c25d194ad (bug 1690111)
Backed out changeset 76c408bcd053 (bug 1690111)
Backed out changeset 6d0649fdafff (bug 1690111)
Backed out changeset c1330b5e8c43 (bug 1690111)
Backed out changeset 5fa36d8fd2a5 (bug 1690111)
Backed out changeset daf7d747853a (bug 1690111)
Backed out changeset f70e09a7f5c6 (bug 1690111)
Backed out changeset 40c6d6eed7f8 (bug 1690111)
Backed out changeset 692f2a759573 (bug 1690111)
Backed out changeset 7140866dd9f6 (bug 1690111)
Backed out changeset 2865fe682139 (bug 1690111)
Backed out changeset 9dcd2416f8a5 (bug 1690111)
Backed out changeset 9c411bf84079 (bug 1690111)
2023-09-11 17:55:24 +03:00
Peter Van der Beken
5738c01ba3 Bug 1690111 - Use new TypedArray APIs for processing data. r=farre,media-playback-reviewers,padenot,chunmin,sfink
Depends on D152497

Differential Revision: https://phabricator.services.mozilla.com/D152498
2023-09-11 12:52:20 +00:00
sotaro
50ab537300 Bug 1839314 - Force sync IPC if there are many flushed cmds without calling ClientWebGLContext::GetFrontBuffer() r=ipc-reviewers,nika,gfx-reviewers,lsalzman
There were cases that a lot of cmds messages were sent by WebGLChild::FlushPendingCmds() without calling ClientWebGLContext::GetFrontBuffer(). And the IPC messages were waiting to be handled by WebGLParent, since OpenGL handling could take longer. Then there were cases that pending IPC messages were accumulated and it caused out of file descriptor on Linux. The sync IPC could reduce the pending IPC messages if there are a lot of cmds flashes.

async Ping is used for checking if IPC message is congested at WebGLParent. If a count of flushes since last congestion check reaches maybeIPCMessageCongestion, we think that IPC message is congested at WebGLParent. Then send sync SyncPing message to flush pending IPC messages.

Differential Revision: https://phabricator.services.mozilla.com/D181484
2023-06-27 18:23:41 +00:00
sotaro
1ca2772206 Bug 1831548 - Force sync IPC if there are many flushed cmds between GetFrontBuffer() r=gfx-reviewers,lsalzman
Enabling async remote texture removes sync IPC PWebGLChild::SendGetFrontBuffer(). With the change, there are cases that pending IPC messages are accumulated and it caused out of file descriptor. The sync IPC SendGetFrontBuffer() could reduce the pending IPC messages if there are a lot of cmds flashes.

Differential Revision: https://phabricator.services.mozilla.com/D181033
2023-06-15 08:41:57 +00:00
Tim Huang
d72f344231 Bug 1816189 - Part 3: Moving ShouldResistFingerprinting() to nsICanvasRenderingContextInternal from ClientWebCLContext and add a RFPTarget as an input argument. r=tjr,lsalzman
This patch moves ShouldResistFingerprinting() and add a RFPTarget as
input argument. We will use this function to check if canvas
fingerprinting protection is enabled.

We also modify the caller to pass the right RFPTarget for Canvas image
data extraction prompt. Note that, we need to set the default argument
for the function to known because it's used for WebGL fingerprinting
protection too. However, We don't cut over this part in this patch and
will do it in a future bug.

Differential Revision: https://phabricator.services.mozilla.com/D175608
2023-05-08 14:04:34 +00:00
Kelsey Gilbert
1741f9c46a Bug 1829756 - E.g. DeleteTexture in ~WebGLTextureJS. r=gfx-reviewers,lsalzman
Otherwise GCing will not release them.

Differential Revision: https://phabricator.services.mozilla.com/D176828
2023-05-01 20:20:23 +00:00
Kelsey Gilbert
f11a202eea Bug 1826678 - Add webgpu CanvasContext.canvas backlink. r=gfx-reviewers,webidl,jimb,smaug,ErichDonGubler
Differential Revision: https://phabricator.services.mozilla.com/D174831
2023-04-13 19:15:00 +00:00
Jamie Nicol
942a3f5367 Bug 1826134 - Avoid interleaving glBufferSubData calls with draw calls in DrawTargetWebgl. r=gfx-reviewers,jgilbert,lsalzman
DrawTargetWebgl renders a path by uploading vertex data to the back of
a large VBO using glBufferSubData then issuing a draw call, orphaning
the buffer when it becomes full. This results in many glBufferSubData
calls being interleaved with draw calls. On Mali GPUs this causes
severe performance issues as the driver is unable to determine that
any pending draw calls do not reference the updated region of the
buffer, and therefore must create a copy of the buffer for each
update.

However, since *we* know that we never overwrite a region that is
referenced by a submitted draw call, we can force the driver to avoid
making these copies. We do so by adding a new function
UnsynchronizedBufferSubData(), which acts like BufferSubData so long
as this rule is followed. Internally, this uses glMapBufferRange with
GL_MAP_UNSYNCHRONIZED_BIT, allowing the driver to omit the extraneous
copies.

Differential Revision: https://phabricator.services.mozilla.com/D174685
2023-04-07 07:25:50 +00:00
Kelsey Gilbert
40d1327d04 Bug 1822867 - Only generate "ClientWaitSync not ready yet" warning after 100th time. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D172806
2023-04-03 21:23:30 +00:00
Kelsey Gilbert
7a17e909ef Bug 1825673 - Implement WEBGL_provoking_vertex. r=gfx-reviewers,webidl,lsalzman,saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D174197
2023-04-01 00:33:25 +00:00
Noemi Erli
c41e3f4330 Backed out changeset bc8c5f1973ff (bug 1825673) for causing mochitest failures in test_GridElementWidthResizer.html CLOSED TREE 2023-03-31 23:14:09 +03:00
Kelsey Gilbert
91a9368bb8 Bug 1825673 - Implement WEBGL_provoking_vertex. r=gfx-reviewers,webidl,lsalzman,saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D174197
2023-03-31 18:48:20 +00:00
Kelsey Gilbert
eaf3360db2 Bug 1812932 - Add size outvar to GetImageBuffer. r=gfx-reviewers,bradwerth
Differential Revision: https://phabricator.services.mozilla.com/D171764
2023-03-21 18:05:09 +00:00
Cristina Horotan
34c1361f96 Backed out changeset 7657d29cd872 (bug 1812932) for causing bc failures at browser_view_image.js CLOSED TREE 2023-03-07 09:26:40 +02:00
Kelsey Gilbert
0f88607820 Bug 1812932 - Add size outvar to GetImageBuffer. r=gfx-reviewers,bradwerth
Differential Revision: https://phabricator.services.mozilla.com/D171764
2023-03-07 04:52:04 +00:00
Jeff Muizelaar
3a46da3d80 Bug 1803375. Use different coordinates when running on AMD. r=lsalzman,jgilbert
This updates the version wpf-gpu-raster which adds support for
GPUs/drivers that use truncation instead of rounding when converting
vertices to fixed point.

It also adds the GL vendor to InitContextResult so that we can detect
AMD on macOS and tell wpf-gpu-raster that truncation is going to happen.

Differential Revision: https://phabricator.services.mozilla.com/D167503
2023-01-27 01:45:17 +00:00
Tom Schuster
ca628bdcc0 Bug 1810489 - Do more precise RFP checks in WebGL. r=gfx-reviewers,nical,tjr
Depends on D166897

Differential Revision: https://phabricator.services.mozilla.com/D166898
2023-01-18 08:19:49 +00:00
sotaro
02d18ed8c1 Bug 1776885 - Add capability of async remote texture on WebGL if CanvasRenderThread is used r=gfx-reviewers,lsalzman
The remote texture is processed asynchronously, but the WebGL rendering results are rendered synchronously with WebRender transaction by WebRender.

Async remote texture support is enabled only when CanvasRenderThread is used. This is to simplify implementation.

In async mode, remote texture of current RemoteTextureId might not be created yet when WebRenderImageHost::UseRemoteTexture() is called. In this case, RemoteTextureHostWrapper uses its own external image ID, otherwise the RemoteTextureHostWrapper uses compatible old remote texture for creating wr display list. RenderTextureHostWrapper calls RemoteTextureMap::GetExternalImageIdOfRemoteTextureSync() before is ussage. The GetExternalImageIdOfRemoteTextureSync() synchronously waits until remote texture becomes ready. The wait works since WebGL IPC handling is always done in CanvasRenderThread in async mode.

PWebGLChild::SendGetFrontBuffer() triggers sync IPC. It is called to ensure the compatible remote texture in RemoteTextureMap during RemoteTextureMap::GetRemoteTextureForDisplayList() call.

Differential Revision: https://phabricator.services.mozilla.com/D162971
2022-12-07 02:24:57 +00:00
Stanca Serban
d0ad6a0b22 Backed out changeset d78a41db7a82 (bug 1776885) for causing reftests failures in ReleaseCompositableRef. CLOSED TREE 2022-12-06 17:34:12 +02:00
sotaro
e23cea6ac1 Bug 1776885 - Add capability of async remote texture on WebGL if CanvasRenderThread is used r=gfx-reviewers,lsalzman
The remote texture is processed asynchronously, but the WebGL rendering results are rendered synchronously with WebRender transaction by WebRender.

Async remote texture support is enabled only when CanvasRenderThread is used. This is to simplify implementation.

In async mode, remote texture of current RemoteTextureId might not be created yet when WebRenderImageHost::UseRemoteTexture() is called. In this case, RemoteTextureHostWrapper uses its own external image ID, otherwise the RemoteTextureHostWrapper uses compatible old remote texture for creating wr display list. RenderTextureHostWrapper calls RemoteTextureMap::GetExternalImageIdOfRemoteTextureSync() before is ussage. The GetExternalImageIdOfRemoteTextureSync() synchronously waits until remote texture becomes ready. The wait works since WebGL IPC handling is always done in CanvasRenderThread in async mode.

PWebGLChild::SendGetFrontBuffer() triggers sync IPC. It is called to ensure the compatible remote texture in RemoteTextureMap during RemoteTextureMap::GetRemoteTextureForDisplayList() call.

Differential Revision: https://phabricator.services.mozilla.com/D162971
2022-12-06 13:56:19 +00:00
Lee Salzman
cb9096e766 Bug 1799402 - Use WGR to rasterize paths in DrawTargetWebgl. r=jrmuizel
This adds a path vertex buffer where triangle list output from WGR is stored.
Each PathCacheEntry can potentially reference a range of vertexes in this buffer
corresponding to triangles for that entry. When this buffer is full, it gets
orphaned and clears corresponding cache entries, so that it can start anew.

Differential Revision: https://phabricator.services.mozilla.com/D161479
2022-11-12 08:06:44 +00:00
Iulian Moraru
f838c68136 Backed out 3 changesets (bug 1799402) for causing windows build bustages. CLOSED TREE
Backed out changeset e51cd76008ef (bug 1799402)
Backed out changeset 3ff660b475ff (bug 1799402)
Backed out changeset 9cfa7581565e (bug 1799402)
2022-11-12 08:33:24 +02:00
Lee Salzman
bea9f37e42 Bug 1799402 - Use WGR to rasterize paths in DrawTargetWebgl. r=jrmuizel
This adds a path vertex buffer where triangle list output from WGR is stored.
Each PathCacheEntry can potentially reference a range of vertexes in this buffer
corresponding to triangles for that entry. When this buffer is full, it gets
orphaned and clears corresponding cache entries, so that it can start anew.

Differential Revision: https://phabricator.services.mozilla.com/D161479
2022-11-12 05:42:30 +00:00
sotaro
6b45a3fe5d Bug 1795050 - Set mResetLayer = true in ClientWebGLContext::Event_webglcontextrestored() r=gfx-reviewers,lsalzman
There was still a timing that hit the assert. When ClientWebGLContext::Event_webglcontextrestored() was called just before ClientWebGLContext::UpdateWebRenderCanvasData() the assert was failed.

Differential Revision: https://phabricator.services.mozilla.com/D161243
2022-11-05 04:14:31 +00:00
Kelsey Gilbert
4e7b4b5647 Bug 1794956 - TransferToImageBitmap should reset bitmap but not state. r=gfx-reviewers,lsalzman
s/Reset/ResetBitmap/ and implement for WebGL and WebGPU.

Differential Revision: https://phabricator.services.mozilla.com/D159346
2022-10-16 22:52:40 +00:00
Iulian Moraru
b3fd738eb1 Backed out 2 changesets (bug 1794956) for causing wpt failures on offscreencanvas.transfer.to.imagebitmap.html. CLOSED TREE
Backed out changeset 7b3067b086e6 (bug 1794956)
Backed out changeset 3abcf6ccf88a (bug 1794956)
2022-10-15 19:09:01 +03:00
Kelsey Gilbert
4253cbe5b3 Bug 1794956 - TransferToImageBitmap should reset bitmap but not state. r=gfx-reviewers,lsalzman
s/Reset/ResetBitmap/ and implement for WebGL and WebGPU.

Differential Revision: https://phabricator.services.mozilla.com/D159346
2022-10-15 09:01:46 +00:00
Kelsey Gilbert
2853c1d91c Bug 1795372 - Keepalive mNotLost within FuncScope. r=gfx-reviewers,lsalzman
Also remove unused FuncScopeId.

Differential Revision: https://phabricator.services.mozilla.com/D159428
2022-10-14 23:10:19 +00:00
Kelsey Gilbert
61dc37049b Bug 1795193 - Remove unused chrome-only API MozGetIPCContext. r=gfx-reviewers,jrmuizel,emilio
And also remove SetIsIPC.

Differential Revision: https://phabricator.services.mozilla.com/D159351
2022-10-14 18:02:28 +00:00
Olli Pettay
93acdfad59 Bug 1777574, automate CC zone handling, r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D155084
2022-09-07 11:22:51 +00:00
Lee Salzman
4a88a37cf6 Bug 1777872 - Use Shmem for backing DrawTargetWebgl's Skia target. r=jgilbert
When rendering large and/or fullscreen Canvas2Ds, excessive time can be spent
in calls to TexImage/ReadPixels copying into and out of Shmems to the separate
buffer for DrawTargetSkia. To alleviate this, we can make the DrawTargetSkia
directly wrap the Shmem, so that calls to TexImage/ReadPixels then directly
read or write to this without any separate copy. We modify RawTexImage to use
the IPDL SendTexImage path so that Shmems can be sent via SurfaceDescriptor.
Since SendTexImage is nominally async (which is beneficial), we rely on a
call to GetError later to verify that the Shmem processing is completely before
we further modify the DrawTargetSkia. We further add a ReadPixelsIntoShmem IPDL
call to allow sending the Shmem in the other direction directly.

Differential Revision: https://phabricator.services.mozilla.com/D151286
2022-07-12 09:25:35 +00:00
Bogdan Szekely
8702a09262 Backed out changeset 458aae4c5d0a (bug 1777872) for causing mochitest failures on Shmem.cpp CLOSED TREE 2022-07-12 12:03:35 +03:00
Lee Salzman
72406ec267 Bug 1777872 - Use Shmem for backing DrawTargetWebgl's Skia target. r=jgilbert
When rendering large and/or fullscreen Canvas2Ds, excessive time can be spent
in calls to TexImage/ReadPixels copying into and out of Shmems to the separate
buffer for DrawTargetSkia. To alleviate this, we can make the DrawTargetSkia
directly wrap the Shmem, so that calls to TexImage/ReadPixels then directly
read or write to this without any separate copy. We modify RawTexImage to use
the IPDL SendTexImage path so that Shmems can be sent via SurfaceDescriptor.
Since SendTexImage is nominally async (which is beneficial), we rely on a
call to GetError later to verify that the Shmem processing is completely before
we further modify the DrawTargetSkia. We further add a ReadPixelsIntoShmem IPDL
call to allow sending the Shmem in the other direction directly.

Differential Revision: https://phabricator.services.mozilla.com/D151286
2022-07-12 08:32:40 +00:00
Lee Salzman
2d7d1de46e Bug 1779010 - Rely on WebGL zero initializing buffers in DrawTargetWebgl. r=aosmond,gfx-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D151511
2022-07-12 08:11:06 +00:00
Cristian Tuns
452dd9b5cf Backed out changeset 2c17688069a7 (bug 1777872) for causing mochitest failures in browser_rules_flexbox-highlighter-on-mutation.js CLOSED TREE 2022-07-12 03:44:25 -04:00
Lee Salzman
0e9626ea47 Bug 1777872 - Use Shmem for backing DrawTargetWebgl's Skia target. r=jgilbert
When rendering large and/or fullscreen Canvas2Ds, excessive time can be spent
in calls to TexImage/ReadPixels copying into and out of Shmems to the separate
buffer for DrawTargetSkia. To alleviate this, we can make the DrawTargetSkia
directly wrap the Shmem, so that calls to TexImage/ReadPixels then directly
read or write to this without any separate copy. We modify RawTexImage to use
the IPDL SendTexImage path so that Shmems can be sent via SurfaceDescriptor.
Since SendTexImage is nominally async (which is beneficial), we rely on a
call to GetError later to verify that the Shmem processing is completely before
we further modify the DrawTargetSkia. We further add a ReadPixelsIntoShmem IPDL
call to allow sending the Shmem in the other direction directly.

Differential Revision: https://phabricator.services.mozilla.com/D151286
2022-07-12 07:00:05 +00:00
Lee Salzman
1d9820a99d Bug 1777426 - Support fast readbacks in CopyToSwapChain with async present. r=sotaro,jgilbert
Currently CopyToSwapChain creates spurious copies of the back buffer when SharedSurfaces aren't exportable (= ToSurfaceDescriptor returns Nothing from SharedSurface_Basic). These then later get read back into a CPU memory buffer when PresentFrontBufferToCompositor is used to send the buffer to RemoteTextureMap. This has associated performance and memory costs.

Conceptually, we want Present/CopyToSwapChain to just do the right thing and automatically push buffers to RemoteTextureMap, rather than secondarily needing a hidden call to PresentFrontBufferToCompositor. Then we can get rid of the need to create front buffers whose only purpose is to shuttle data to PresentFrontBufferToCompositor which then shuttles it RemoteTextureMap.

This patch achieves this by refactoring the guts of PresentFrontBufferToCompositor into Present/CopyToSwapChain. The remote texture ids are sent along inside SwapChainOptions if async present is enabled. Those remote texture ids are cached in ClientWebGLContext so that GetFrontBuffer can return them without any subsequent need for an IPDL call.

On the parent side, CopyToSwapChain will now notice if async present is to be used and if a SurfaceFactory does not generate SharedSurfaces that can be exported. In that case it cuts out the middle man and reads from the WebGLFramebuffer's back buffer directly into a CPU buffer to send to RemoteTextureMap.

This also adds a forceAsyncPresent option to SwapChainOptions so that in the future we can have a separate pref for Accelerated Canvas2D that will allow enabling async present independent of the global WebGL pref.

Differential Revision: https://phabricator.services.mozilla.com/D150720
2022-07-12 06:56:19 +00:00
sotaro
a807c798e9 Bug 1712486 - Add async front buffer posting for out-of-process WebGL r=jgilbert,lsalzman,gfx-reviewers
The async front buffer posting is going to be enabled by another bug.

Async IPC was added for async front buffer posting for out-of-process WebGL.
Client does not use TextureClient for storing SurfaceDescriptor.
It works basically same way as to in-process WebGL around nsDisplayCanvas, WebRenderCanvasData, WebRenderCommandBuilder and WebRenderBridgeParent.
SharedSurfaces of SurfaceDescriptorD3D10 are kept alive during their usage. It is for keeping a shread handle valid.
Copied data buffers of SharedShurface_Basics are kept alive during their usage. It is for keeping RenderBufferTextureHost valid.

Differential Revision: https://phabricator.services.mozilla.com/D150197
2022-06-29 09:32:29 +00:00
Norisz Fay
f70f5a4b0f Backed out changeset af98fb4ff148 (bug 1712486) for causing build bustages on LayersSurfaces CLOSED TREE 2022-06-29 09:06:45 +03:00
sotaro
8a8d04cce2 Bug 1712486 - Add async front buffer posting for out-of-process WebGL r=jgilbert,lsalzman,gfx-reviewers
The async front buffer posting is going to be enabled by another bug.

Async IPC was added for async front buffer posting for out-of-process WebGL.
Client does not use TextureClient for storing SurfaceDescriptor.
It works basically same way as to in-process WebGL around nsDisplayCanvas, WebRenderCanvasData, WebRenderCommandBuilder and WebRenderBridgeParent.
SharedSurfaces of SurfaceDescriptorD3D10 are kept alive during their usage. It is for keeping a shread handle valid.
Copied data buffers of SharedShurface_Basics are kept alive during their usage. It is for keeping RenderBufferTextureHost valid.

Differential Revision: https://phabricator.services.mozilla.com/D150197
2022-06-29 05:05:47 +00:00
Kagami Sascha Rosylight
6abe98f452 Bug 1769290 - Part 8: Apply mozilla-js-handle-rooted-typedef against dom/canvas,crypto,fetch,gamepad,geolocation,indexedDB,ipc r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D148281
2022-06-05 20:54:59 +00:00
sotaro
0bf1498ed8 Bug 1763503 - Hold layers::CanvasRenderer in ClientWebGLContext::mNotLost r=jgilbert,gfx-reviewers
bug 1733732 decreased the size of the display port on Android. When you scroll to the bottom of the page, the canvas leaves the display port. It triggers to destroy WebRenderCanvasData and WebRenderCanvasRendererAsync. And then RenderAndroidSurfaceTextureHost::NotifyNotUsed() is called and RenderAndroidSurfaceTextureHost is destroyed.

Then if scrolling makes the canvas into the display port again, WebRenderCanvasData, WebRenderCanvasRendererAsync and RenderAndroidSurfaceTextureHost are recreated again. But there is no rendering update at SharedSurface_SurfaceTexture. Since the page does WebGL rendering only once during page load.

It caused the problem to RenderAndroidSurfaceTextureHost. RenderAndroidSurfaceTextureHost::NotifyNotUsed() returns SurfaceTexture's buffer to client side. For using SurfaceTexture again in RenderAndroidSurfaceTextureHost, Client side needs to do re-rendering to SurfaceTexture. But SharedSurface_SurfaceTexture did nothing in this case.

To address the problem, we could hold layers::CanvasRenderer in ClientWebGLContext::mNotLost. If WebRenderCanvasRendererAsync is kept alive, RenderAndroidSurfaceTextureHost::NotifyNotUsed() and destruction of WebRenderCanvasRendererAsync do not happen.

Then if WebRenderCanvasData is re-created, the stored WebRenderCanvasRendererAsync is set in the new WebRenderCanvasData in ClientWebGLContext::UpdateWebRenderCanvasData().

Differential Revision: https://phabricator.services.mozilla.com/D143811
2022-05-13 00:17:42 +00:00
Andrew Osmond
cacb8be79b Bug 1759706 - Ensure we initialize TexImageSourceAdapter::mOut_error for OffscreenCanvas. r=gfx-reviewers,nical
The ErrorResult is actually used by FromOffscreenCanvas and setting this
properly will avoid a crash.

Differential Revision: https://phabricator.services.mozilla.com/D141103
2022-03-15 15:08:05 +00:00
Andrew Osmond
6eff3fa786 Bug 1691774 - Check shmem allocation/mapping failures in ClientWebGLContext. r=jgilbert
We use webgl::RaiiShmem in a few places to read in pixel buffers from a
call to the compositor process. Shmems might fail to be mapped into our
process, probably due to virtual memory constraints, and we should check
for that condition.

Depends on D136355

Differential Revision: https://phabricator.services.mozilla.com/D136365
2022-03-03 23:21:36 +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