* 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
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
Now that each DrawTargetWebgl shares the same WebGL context, we can efficiently draw snapshots
of one DrawTargetWebgl to another without requiring any readback or error-prone driver-provided
shared context/resource mechanism. We just need to simply pass the WebGL texture from one target
to the other, and use it like any other texture.
This provides SourceSurfaceWebgl to store and pass along that WebGL texture. It is largely
modeled off of SourceSurfaceSkia in terms of its copy-on-write behavior. There are three
noteworthy state changes that it must track from DrawTargetWebgl - when the framebuffer
contents is changing, when the framebuffer is being destroyed, and when any cached texture
handle separate from a framebuffer is also being destroyed. It will copy, orphan, or read
back data as appropriate to handle each case.
If it needs to be mapped, it just forces a read back of the data into a CPU surface that
can be mapped as requested.
Differential Revision: https://phabricator.services.mozilla.com/D138118
Within DrawTargetWebgl, this implements a SharedContext class to store both the WebGL context and
also related resources for drawing with it. Not a lot of new code has actually been added as this
was mostly accomplished by refactoring as much drawing code as possible that touched the WebGL
context to be moved into SharedContext, while leaving any code that was only dealing with Skia
software rasterization still within DrawTargetWebgl itself as well as individual framebuffer state
that is unique to each DrawTargetWebgl instance.
Before DrawTargetWebgl can use SharedContext to draw, it must use SetTarget to install its framebuffer
as the one that the WebGL context will draw to as well as to learn details about the viewport and
other per-framebuffer state. All of the high-level cache state that was previously on DrawTargetWebgl
has now moved into SharedContext, so that SharedContext can easily access this for drawing as well
as to provide for the goal of simplifying resource limiting.
Differential Revision: https://phabricator.services.mozilla.com/D138117
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
Now that each DrawTargetWebgl shares the same WebGL context, we can efficiently draw snapshots
of one DrawTargetWebgl to another without requiring any readback or error-prone driver-provided
shared context/resource mechanism. We just need to simply pass the WebGL texture from one target
to the other, and use it like any other texture.
This provides SourceSurfaceWebgl to store and pass along that WebGL texture. It is largely
modeled off of SourceSurfaceSkia in terms of its copy-on-write behavior. There are three
noteworthy state changes that it must track from DrawTargetWebgl - when the framebuffer
contents is changing, when the framebuffer is being destroyed, and when any cached texture
handle separate from a framebuffer is also being destroyed. It will copy, orphan, or read
back data as appropriate to handle each case.
If it needs to be mapped, it just forces a read back of the data into a CPU surface that
can be mapped as requested.
Differential Revision: https://phabricator.services.mozilla.com/D138118
Within DrawTargetWebgl, this implements a SharedContext class to store both the WebGL context and
also related resources for drawing with it. Not a lot of new code has actually been added as this
was mostly accomplished by refactoring as much drawing code as possible that touched the WebGL
context to be moved into SharedContext, while leaving any code that was only dealing with Skia
software rasterization still within DrawTargetWebgl itself as well as individual framebuffer state
that is unique to each DrawTargetWebgl instance.
Before DrawTargetWebgl can use SharedContext to draw, it must use SetTarget to install its framebuffer
as the one that the WebGL context will draw to as well as to learn details about the viewport and
other per-framebuffer state. All of the high-level cache state that was previously on DrawTargetWebgl
has now moved into SharedContext, so that SharedContext can easily access this for drawing as well
as to provide for the goal of simplifying resource limiting.
Differential Revision: https://phabricator.services.mozilla.com/D138117
This simplifies the logic around descriptors significantly, which is
especially useful considering how few places use the type. There is a
small change required on Windows to create the NamedPipe directly and
transfer around each end's handle, rather than connecting between
processes after the fact.
A named pipe has to be used, rather than an anonymous pipe, as
bidirectional communication is required.
Differential Revision: https://phabricator.services.mozilla.com/D130381
Some versions of Mesa, including what we currently use on CI, need more
stack memory than what we currently provide on the compositor thread
order to pass the WebGL test suite in out-of-process mode. This patch
increases the limit and re-enables the previously broken tests.
(Testing on Try found that the threshold was somewhere between 384k and
448k, but because this depends on a third-party library and content
controlled input, I'm giving it 512k so we have some safety margin.)
Differential Revision: https://phabricator.services.mozilla.com/D137787
This patch adds a partial OffscreenCanvasRenderingContext2D
implementation. It is missing anything text and UI related, including
CanvasFilters, CanvasUserInterface, CanvasText, CanvasTextDrawingStyles,
and CanvasHitRegions.
Differential Revision: https://phabricator.services.mozilla.com/D135354
This patch is a non-functional change. It overloads some WebIDL methods
of CanvasRenderingContext2D to account for the difference between the
main thread and worker prototypes.
Differential Revision: https://phabricator.services.mozilla.com/D135353
This patch is a non-functional change which allows the shutdown observer
to be overridden (since workers have a different mechanism). It also
fixes a static counter to be atomic, and adds mOffscreenCanvas to the
cycle collection tracking.
Differential Revision: https://phabricator.services.mozilla.com/D135352
This patch adds a partial OffscreenCanvasRenderingContext2D
implementation. It is missing anything text and UI related, including
CanvasFilters, CanvasUserInterface, CanvasText, CanvasTextDrawingStyles,
and CanvasHitRegions.
Differential Revision: https://phabricator.services.mozilla.com/D135354
This patch is a non-functional change. It overloads some WebIDL methods
of CanvasRenderingContext2D to account for the difference between the
main thread and worker prototypes.
Differential Revision: https://phabricator.services.mozilla.com/D135353
This patch is a non-functional change which allows the shutdown observer
to be overridden (since workers have a different mechanism). It also
fixes a static counter to be atomic, and adds mOffscreenCanvas to the
cycle collection tracking.
Differential Revision: https://phabricator.services.mozilla.com/D135352
Turned out the refresh driver was not at all throttled in the test. rAF was
throttled but these are not always in sync.
This patch changes the approach to causing throttling by being closer to a real
scenario -- put the tab in the background by opening another tab in the
foreground.
This also meant that the method by which we were measuring the captured frame
rate became moot (videoElement.mozPaintedFrames), as the frames are not
composited in the background, and the compositor is what reports painted frames.
This patch changes the frame counting approach to a local peer connection and
the outbound-rtp stats' framesEncoded member.
Differential Revision: https://phabricator.services.mozilla.com/D137290
Turned out the refresh driver was not at all throttled in the test. rAF was
throttled but these are not always in sync.
This patch changes the approach to causing throttling by being closer to a real
scenario -- put the tab in the background by opening another tab in the
foreground.
This also meant that the method by which we were measuring the captured frame
rate became moot (videoElement.mozPaintedFrames), as the frames are not
composited in the background, and the compositor is what reports painted frames.
This patch changes the frame counting approach to a local peer connection and
the outbound-rtp stats' framesEncoded member.
Differential Revision: https://phabricator.services.mozilla.com/D137290
This patch adds a partial OffscreenCanvasRenderingContext2D
implementation. It is missing anything text and UI related, including
CanvasFilters, CanvasUserInterface, CanvasText, CanvasTextDrawingStyles,
and CanvasHitRegions.
Differential Revision: https://phabricator.services.mozilla.com/D135354
This patch is a non-functional change. It overloads some WebIDL methods
of CanvasRenderingContext2D to account for the difference between the
main thread and worker prototypes.
Differential Revision: https://phabricator.services.mozilla.com/D135353
This patch is a non-functional change which allows the shutdown observer
to be overridden (since workers have a different mechanism). It also
fixes a static counter to be atomic, and adds mOffscreenCanvas to the
cycle collection tracking.
Differential Revision: https://phabricator.services.mozilla.com/D135352
On the path that we need to read the pixels from the canvas for display
purposes, instead of using a platform buffer handle, we need to take
into account the need to y-flip for WebGL. This patch ensures that we do
so.
Differential Revision: https://phabricator.services.mozilla.com/D136504
This simplifies the logic around descriptors significantly, which is
especially useful considering how few places use the type. There is a
small change required on Windows to create the NamedPipe directly and
transfer around each end's handle, rather than connecting between
processes after the fact.
A named pipe has to be used, rather than an anonymous pipe, as
bidirectional communication is required.
Differential Revision: https://phabricator.services.mozilla.com/D130381
On the path that we need to read the pixels from the canvas for display
purposes, instead of using a platform buffer handle, we need to take
into account the need to y-flip for WebGL. This patch ensures that we do
so.
Differential Revision: https://phabricator.services.mozilla.com/D136504
When DeleteQuery is called, it uses mTarget to determine whether or not
BeginQuery has been called. This is an insufficient condition because
QueryCounter also sets mTarget without calling BeginQuery and occupying
a slot in current query map. This patch fixes the crash by checking if
the slot is empty first.
Differential Revision: https://phabricator.services.mozilla.com/D137070
This patch adds OffscreenCanvas as a texture source for texImage2D,
texSubImage2D and texSubImage2D. This applies to both
WebGLRenderingContext and WebGL2RenderingContext. This was causing
several test failures in the WebGL conformance suite with
OffscreenCanvas.
Differential Revision: https://phabricator.services.mozilla.com/D136924
On the path that we need to read the pixels from the canvas for display
purposes, instead of using a platform buffer handle, we need to take
into account the need to y-flip for WebGL. This patch ensures that we do
so.
Differential Revision: https://phabricator.services.mozilla.com/D136504
This patch adds several new prefs to control what happens with
OffscreenCanvas. gfx.offscreencanvas.enabled works as it did before.
- gfx.offscreencanvas.domain-enabled: Enables OffscreenCanvas for
domains on the allowlist.
- gfx.offscreencanvas.domain-allowlist: Comma separated allowlist
which controls which domains can access the OffscreenCanvas constructor
and HTMLCanvasElement.transferControlToOffscreen.
- dom.workers.requestAnimation: Controls whether or not
request/cancelAnimationFrame are accessible from dedicated workers.
Ideally this would have used the same decision process as
OffscreenCanvas but there were unrelated build/runtime issues around
using a Func directive with DedicatedWorkerGlobalScope.
Differential Revision: https://phabricator.services.mozilla.com/D135928
The intention of the if-clause in MatchesPath was was to early-out with false if
the path geometry doesn't actually match as an artifact of how earlier versions of
this code was written. Due to an accidental typo, the path comparison for this case
got inverted. This fixes that by just cleaning up the inverted mess to be easier to
read in the first place.
Differential Revision: https://phabricator.services.mozilla.com/D136694