Bug 226423

Summary: [WebXR] Provide a way to bind and unbind IOSurfaces to ANGLE Pbuffers
Product: WebKit Reporter: Dean Jackson <dino>
Component: WebXRAssignee: Dean Jackson <dino>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, graouts, kondapallykalyan, sam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch sam: review+, ews-feeder: commit-queue-

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>