Closed Bug 2052522 Opened 2 months ago Closed 1 month ago

Support binding IOSurfaces to textures on ANGLE/EGL for webrender

Categories

(Core :: Graphics, task)

task

Tracking

()

RESOLVED FIXED
154 Branch
Tracking Status
firefox154 --- fixed

People

(Reporter: jnicol, Assigned: jnicol)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fxpe])

Attachments

(4 files)

Similar to bug 2048254, we must support binding IOSurfaces to textures using EGL/ANGLE for use with webrender. Specifically, in SurfacePoolCA, and RenderMacIOSurfaceTextureHost. The latter of these almost works already because it uses the MacIOSurface::BindTexImage() helper - we just need to stop hardcoding the target as GL_TEXTURE_RECTANGLE.

One wrinkle, however, is that the ImageBufferKind for a webrender external image is set by the TextureHost, not the RenderTextureHost, e.g. here. This must match the texture target used by the render texture host. Currently we just assume that MacIOSurfaceTextureHosts will always use TextureRect, but that will no longer be the case with Metal ANGLE. [MacIOSurface::GetTextureTarget()] can be used to query the target which should be used, but this needs a GL context, which we do not have access to in the texture host.

Moves the helper function for querying which GL texture target Mac
IOSurfaces should be bound to from a static helper in MacIOSurface to a
virtual method on GLContext.

This should have no functional change, but better mirrors the existing
GetPreferredEGLImageTextureTarget() helper.

It also avoids having to include MacIOSurface.h in order to query this
value, which avoids unified build errors in subsequent patches.

Assignee: nobody → jnicol
Status: NEW → ASSIGNED

Implement GLContext::GetPreferredMacIOSurfaceTextureTarget() for
GLContextEAGL, and use to query the target rather than using
constants.

In the macOS path in
SurfacePoolCA::LockedPool::GetFramebufferForSurface(), construct a
temporary MacIOSurface and call the BindTexImage() helper, which is
implemented for both CGL and EGL/ANGLE contexts, rather than directly
calling CGLTexImageIOSurface2D().

Note we purposefully do not implement MacIOSurface::BindTexImage() for
EAGL (iOS), and instead retain the separate iOS path in
GetFramebufferForSurface(). This is to avoid changing behaviour on iOS
for other callers of BindTexImage(), such as SharedSurface_IOSurface
and RenderMacIOSurfaceTextureHost, where we would currently
MOZ_CRASH("unimplemented"). Perhaps this should be done as a
follow-up, but whether they would work or not has not yet been tested.

Combines several of WebRenderAPI's various members and getters into a
single struct, and plumb through TransactionBuilder so they can all be
accessed by TextureHost::PushResourceUpdates().

This makes no functional change, but will allow the following patch to
neatly add a new capability that is required by PushResourceUpdates().

RenderMacIOSurfaceTextureHost already uses the
MacIOSurface::BindTexImage() helper, which is implemented for
EGL/ANGLE, so simply needs to query which texture target to use rather
than assuming GL_TEXTURE_RECTANGLE.

MacIOSurfaceTextureHostOGL::PushResourceUpdates() must set the correct
ImageBufferKind, which depends on which GL texture target should be
used, but has no access to a GL context from which to query that. We
therefore add a new mIOSurfaceImageKind field to
WebRenderCapabilities, which is initialized by querying the GL context
when the WebRenderAPI is created.

Pushed by jnicol@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/380b58bcbada https://hg.mozilla.org/integration/autoland/rev/5bf29304f9f9 Move MacIOSurface::GetTextureTarget to virtual GLContext method. r=gfx-reviewers,lsalzman https://github.com/mozilla-firefox/firefox/commit/9365f3b5caae https://hg.mozilla.org/integration/autoland/rev/ab80d7fe298d Support binding SurfacePoolCA's surfaces to framebuffers using EGL/ANGLE. r=gfx-reviewers,lsalzman https://github.com/mozilla-firefox/firefox/commit/d204d96487a2 https://hg.mozilla.org/integration/autoland/rev/5fd6257cd691 Combine WebRenderAPI's various capability flags into single struct member. r=gfx-reviewers,lsalzman https://github.com/mozilla-firefox/firefox/commit/c2b9d3951930 https://hg.mozilla.org/integration/autoland/rev/a1972c31ea5d Support binding MacIOSurfaceTextureHosts to textures on EGL/ANGLE. r=gfx-reviewers,lsalzman
QA Whiteboard: [qa-triage-done-c155/b154]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: