[webkit-changes] [WebKit/WebKit] 98794f: [WebGPU] Add CompositorIntegration object

Myles C. Maxfield noreply at github.com
Mon Jan 30 14:49:07 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 98794f128842c07c91cf7048e3a9e574d701f56a
      https://github.com/WebKit/WebKit/commit/98794f128842c07c91cf7048e3a9e574d701f56a
  Author: Myles C. Maxfield <mmaxfield at apple.com>
  Date:   2023-01-30 (Mon, 30 Jan 2023)

  Changed paths:
    A Source/WebCore/Modules/WebGPU/GPUCompositorIntegration.cpp
    A Source/WebCore/Modules/WebGPU/GPUCompositorIntegration.h
    M Source/WebCore/Modules/WebGPU/GPUPresentationContext.h
    M Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj
    M Source/WebCore/PAL/pal/CMakeLists.txt
    A Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUCompositorIntegrationImpl.cpp
    A Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUCompositorIntegrationImpl.h
    M Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUConvertToBackingContext.h
    M Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUDowncastConvertToBackingContext.cpp
    M Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUDowncastConvertToBackingContext.h
    A Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUCompositorIntegration.h
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebKit/CMakeLists.txt
    M Source/WebKit/DerivedSources-input.xcfilelist
    M Source/WebKit/DerivedSources-output.xcfilelist
    M Source/WebKit/DerivedSources.make
    A Source/WebKit/GPUProcess/graphics/WebGPU/RemoteCompositorIntegration.cpp
    A Source/WebKit/GPUProcess/graphics/WebGPU/RemoteCompositorIntegration.h
    A Source/WebKit/GPUProcess/graphics/WebGPU/RemoteCompositorIntegration.messages.in
    M Source/WebKit/GPUProcess/graphics/WebGPU/WebGPUObjectHeap.cpp
    M Source/WebKit/GPUProcess/graphics/WebGPU/WebGPUObjectHeap.h
    M Source/WebKit/Shared/WebGPU/WebGPUConvertFromBackingContext.h
    M Source/WebKit/Shared/WebGPU/WebGPUConvertToBackingContext.h
    M Source/WebKit/Sources.txt
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    A Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteCompositorIntegrationProxy.cpp
    A Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteCompositorIntegrationProxy.h
    M Source/WebKit/WebProcess/GPU/graphics/WebGPU/WebGPUDowncastConvertToBackingContext.cpp
    M Source/WebKit/WebProcess/GPU/graphics/WebGPU/WebGPUDowncastConvertToBackingContext.h

  Log Message:
  -----------
  [WebGPU] Add CompositorIntegration object
https://bugs.webkit.org/show_bug.cgi?id=250955
rdar://104517402

Reviewed by Tadeu Zagallo.

Right now, the data flow that WebGPU uses to interact with the compositor doesn't match either the
WebGPU spec's API nor WebGPU.h. Ideally, we'd align them, for conceptual simplicity and to make
future hacking on this system easier.

The way this is supposed to work is the Surface gets created with a reference to a compositor
integration object. In the simple case, that's a CAMetalLayer, but in WebKit we don't use CAMetalLayer.
Instead, this patch creates an analogue for CAMetalLayer that contains the functionality to
integrate WebGPU with WebKit's compositor. Having this object means we can (eventually) get rid of
the custom APIs added to WebGPU.framework which cause leaky abstractions.

Just like CAMetalLayer, this object, named CompositorIntegration, is the owner of multiple IOSurfaces
used for render destinations. It has an API to recreate its IOSurfaces, which is mean to be called
whenever their attributes need to be changed. (For WebGPU, the creation of a swap chain indicates that
the IOSurfaces' attributes need to be changed.) CompositorIntegration also has an IPC message receiver,
like almost all of the WebGPU types, and has one exposed message which returns the current IOSurfaces.
This is meant to be called just after they get recreated, so GPUSwapChain can get access to the
IOSurfaces, so GPUSwapChain can set them as the appropriate layer's contents.

There is no WGPU analog of CompositorIntegration; just like CAMetalLayer, it exists outside of
WebGPU.framework.

Other than the creation and retention of IOSurfaces, there's nothing really special about this object;
it's set up pretty much identically to every other WebGPU object.

The use of CompositorIntegration isn't hooked up yet; I made a megapatch at
https://github.com/WebKit/WebKit/pull/8931/files and I'm trying to split it up into smaller, more
reviewable patches. This patch is just one piece of that larger patch. CompositorIntegration will be
hooked up in a subsequent patch.

* Source/WebCore/Modules/WebGPU/GPUCompositorIntegration.cpp: Added.
(WebCore::GPUCompositorIntegration::getRenderBuffers const):
* Source/WebCore/Modules/WebGPU/GPUCompositorIntegration.h: Added.
(WebCore::GPUCompositorIntegration::create):
(WebCore::GPUCompositorIntegration::backing):
(WebCore::GPUCompositorIntegration::backing const):
(WebCore::GPUCompositorIntegration::GPUCompositorIntegration):
* Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj:
* Source/WebCore/PAL/pal/CMakeLists.txt:
* Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUCompositorIntegrationImpl.cpp: Added.
(PAL::WebGPU::CompositorIntegrationImpl::CompositorIntegrationImpl):
(PAL::WebGPU::CompositorIntegrationImpl::getRenderBuffers):
(PAL::WebGPU::toCFNumber):
(PAL::WebGPU::CompositorIntegrationImpl::recreateIOSurfaces):
* Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUCompositorIntegrationImpl.h: Added.
* Source/WebCore/PAL/pal/graphics/WebGPU/WebGPUCompositorIntegration.h: Added.
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebKit/CMakeLists.txt:
* Source/WebKit/DerivedSources-input.xcfilelist:
* Source/WebKit/DerivedSources-output.xcfilelist:
* Source/WebKit/DerivedSources.make:
* Source/WebKit/GPUProcess/graphics/WebGPU/RemoteCompositorIntegration.cpp: Added.
(WebKit::RemoteCompositorIntegration::RemoteCompositorIntegration):
(WebKit::RemoteCompositorIntegration::stopListeningForIPC):
(WebKit::RemoteCompositorIntegration::getRenderBuffers):
* Source/WebKit/GPUProcess/graphics/WebGPU/RemoteCompositorIntegration.h: Added.
* Source/WebKit/GPUProcess/graphics/WebGPU/RemoteCompositorIntegration.messages.in: Added.
* Source/WebKit/Sources.txt:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteCompositorIntegrationProxy.cpp: Added.
(WebKit::WebGPU::RemoteCompositorIntegrationProxy::RemoteCompositorIntegrationProxy):
(WebKit::WebGPU::RemoteCompositorIntegrationProxy::getRenderBuffers):
* Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteCompositorIntegrationProxy.h: Added.

Canonical link: https://commits.webkit.org/259588@main




More information about the webkit-changes mailing list