Bug 227245 - Add support for MTLSharedTextures in WebXR
Summary: Add support for MTLSharedTextures in WebXR
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-06-21 19:21 PDT by Dean Jackson
Modified: 2021-06-25 15:07 PDT (History)
5 users (show)

See Also:


Attachments
Patch (11.14 KB, patch)
2021-06-21 19:45 PDT, Dean Jackson
thorton: review+
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
EWS test (11.83 KB, patch)
2021-06-25 13:41 PDT, Dean Jackson
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
EWS test 2 (11.87 KB, patch)
2021-06-25 13:56 PDT, Dean Jackson
no flags 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-06-21 19:21:15 PDT
Sometimes the IOSurface sent for WebXR is a MTLSharedTexture, which means it can't be treated like a regular single-plane IOSurface. Using the fix for 226690, we should be able to create a MTLTexture object from the IOSurface and bind that to a GL texture.
Comment 1 Radar WebKit Bug Importer 2021-06-21 19:21:25 PDT
<rdar://problem/79591620>
Comment 2 Dean Jackson 2021-06-21 19:45:12 PDT
Created attachment 431940 [details]
Patch
Comment 3 Ada Chan 2021-06-21 20:58:47 PDT
Comment on attachment 431940 [details]
Patch

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

> Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp:143
> +        auto size = data.surface->size();

Should we still do the size check for the single plane IOSurface case?

> Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp:198
> +            gCGL->destroyPbufferAndDetachIOSurface(m_ioSurfaceTextureHandle);

Should we set m_ioSurfaceTextureHandle to null and m_ioSurfaceTextureHandleIsShared to false after?
Comment 4 Dean Jackson 2021-06-22 12:45:11 PDT
Comment on attachment 431940 [details]
Patch

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

>> Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp:143
>> +        auto size = data.surface->size();
> 
> Should we still do the size check for the single plane IOSurface case?

Yeah - good point. I'll put it back in.

>> Source/WebCore/Modules/webxr/WebXROpaqueFramebuffer.cpp:198
>> +            gCGL->destroyPbufferAndDetachIOSurface(m_ioSurfaceTextureHandle);
> 
> Should we set m_ioSurfaceTextureHandle to null and m_ioSurfaceTextureHandleIsShared to false after?

Agreed.

Ultimately we should have a class that wraps these handles and calls the correct destroyer. I started on that but got annoyed that I'd have to keep a reference to the GraphicsContextGL as well as the handle.
Comment 5 Dean Jackson 2021-06-25 13:41:18 PDT
Created attachment 432288 [details]
EWS test
Comment 6 Dean Jackson 2021-06-25 13:56:25 PDT
Created attachment 432289 [details]
EWS test 2
Comment 7 Dean Jackson 2021-06-25 15:07:09 PDT
Committed r279298 (239174@main): <https://commits.webkit.org/239174@main>