Bug 226423 - [WebXR] Provide a way to bind and unbind IOSurfaces to ANGLE Pbuffers
Summary: [WebXR] Provide a way to bind and unbind IOSurfaces to ANGLE Pbuffers
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebXR (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dean Jackson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-29 13:34 PDT by Dean Jackson
Modified: 2021-05-30 15:47 PDT (History)
5 users (show)

See Also:


Attachments
Patch (5.56 KB, patch)
2021-05-29 13:39 PDT, Dean Jackson
no flags Details | Formatted Diff | Diff
Patch (5.89 KB, patch)
2021-05-30 12:58 PDT, Dean Jackson
sam: review+
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dean Jackson 2021-05-29 13:34:34 PDT
WebXR on Cocoa platforms gets framebuffer texture targets via IOSurfaces. Those must be attached to ANGLE Pbuffers, which are then bound to GL textures. There is already some code in GraphicsContextGL (and in the CoreVideo classes) to do this, but this is an attempt to make a generic function that will handle all use cases.
Comment 1 Radar WebKit Bug Importer 2021-05-29 13:34:46 PDT
<rdar://problem/78652783>
Comment 2 Dean Jackson 2021-05-29 13:39:14 PDT
Created attachment 430106 [details]
Patch
Comment 3 Sam Weinig 2021-05-29 13:44:35 PDT
Comment on attachment 430106 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=430106&action=review

> Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:651
> +    auto usageHintAngle = [&] () -> EGLint {
> +        if (usage == PbufferAttachmentUsage::Read)
> +            return EGL_IOSURFACE_READ_HINT_ANGLE;
> +        return EGL_IOSURFACE_WRITE_HINT_ANGLE;
> +    }();

Never both?

> Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h:574
> +    friend class WebXROpaqueFramebuffer;

This is a layering violation. Platform level concepts should not be aware of things like WebXR. Why is this needed? Why not just make this public?

> Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h:578
> +    enum class PbufferAttachmentUsage {
> +        Read,
> +        Write
> +    };

I would put this all on one line.
Comment 4 Dean Jackson 2021-05-30 12:47:36 PDT
Comment on attachment 430106 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=430106&action=review

>> Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:651
>> +    }();
> 
> Never both?

Good point. I'll check if ANGLE handles that and add it if so.

>> Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h:574
>> +    friend class WebXROpaqueFramebuffer;
> 
> This is a layering violation. Platform level concepts should not be aware of things like WebXR. Why is this needed? Why not just make this public?

Duh, of course. Yeah, I'll make them public.

>> Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h:578
>> +    };
> 
> I would put this all on one line.

ok!
Comment 5 Dean Jackson 2021-05-30 12:58:31 PDT
Created attachment 430146 [details]
Patch
Comment 6 Dean Jackson 2021-05-30 15:47:13 PDT
Committed r278260 (238297@main): <https://commits.webkit.org/238297@main>