Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a965fc6b218eb6f1808d3d7f11ff86cfee23faf0
      
https://github.com/WebKit/WebKit/commit/a965fc6b218eb6f1808d3d7f11ff86cfee23faf0
  Author: Sergio Villar Senin <[email protected]>
  Date:   2026-03-27 (Fri, 27 Mar 2026)

  Changed paths:
    M LayoutTests/platform/glib/TestExpectations
    M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
    M 
Source/WebCore/Modules/WebGPU/Implementation/WebGPUXRProjectionLayerImpl.cpp
    M Source/WebCore/Modules/WebGPU/Implementation/WebGPUXRProjectionLayerImpl.h
    A Source/WebCore/Modules/webxr/WebGLOpaqueTexture.cpp
    A Source/WebCore/Modules/webxr/WebGLOpaqueTexture.h
    M Source/WebCore/Modules/webxr/WebXRSession.cpp
    A Source/WebCore/Modules/webxr/WebXRSwapchain.h
    A Source/WebCore/Modules/webxr/WebXRWebGLSwapchain.cpp
    A Source/WebCore/Modules/webxr/WebXRWebGLSwapchain.h
    M Source/WebCore/Modules/webxr/XRCompositionLayer.cpp
    M Source/WebCore/Modules/webxr/XRCompositionLayer.h
    M Source/WebCore/Modules/webxr/XRGPUBinding.cpp
    M Source/WebCore/Modules/webxr/XRLayerBacking.h
    M Source/WebCore/Modules/webxr/XRProjectionLayer.cpp
    M Source/WebCore/Modules/webxr/XRProjectionLayer.h
    A Source/WebCore/Modules/webxr/XRSwapchain.h
    M Source/WebCore/Modules/webxr/XRWebGLBinding.cpp
    M Source/WebCore/Modules/webxr/XRWebGLBinding.h
    M Source/WebCore/Modules/webxr/XRWebGLBinding.idl
    A Source/WebCore/Modules/webxr/XRWebGLLayerBacking.cpp
    A Source/WebCore/Modules/webxr/XRWebGLLayerBacking.h
    A Source/WebCore/Modules/webxr/XRWebGLProjectionLayerBacking.cpp
    A Source/WebCore/Modules/webxr/XRWebGLProjectionLayerBacking.h
    M Source/WebCore/Modules/webxr/XRWebGLSubImage.cpp
    M Source/WebCore/Modules/webxr/XRWebGLSubImage.h
    M Source/WebCore/Sources.txt
    M Source/WebCore/html/canvas/WebGLTexture.h
    M Source/WebCore/html/canvas/WebGLTexture.idl
    M Source/WebKit/Shared/WebPreferencesDefaultValues.h
    M Source/WebKit/Shared/XR/XRSystem.serialization.in
    M Source/WebKit/UIProcess/XR/openxr/PlatformXROpenXR.cpp
    M 
Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteXRProjectionLayerProxy.cpp
    M 
Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteXRProjectionLayerProxy.h

  Log Message:
  -----------
  [WebXR Layers] Implement projection layer
https://bugs.webkit.org/show_bug.cgi?id=309063

Reviewed by Dan Glastonbury.

This provides an initial working implementation of WebXR projection
layer using the WebGL bindings. It's still far from being complete as
there are several parameters that are not obeyed but it works. So far we
are only providing an implementation for WPE and GTK ports although
migrating the COCOA ports should be quite straightforward as it uses
most of the concepts already in place for regular WebXR.

A new class called WebXROpaqueTexture was introduced to represent a
WebGL texture that is not managed by the GL context but the app. The
destruction code is run on purpose in this subclass to avoid the
superclass calls to the Graphics Context.

Those opaque textures are the objects that would be used in the web app
to render (regular WebXR uses framebuffers). The spec supports 3
different types of textures: color, depth and motion. So far we're only
adding support for the 2 first ones as proper rendering could not be
achieved without them.

Those opaque textures are managed by some new entities called the
XRSwapchains. As the name suggests their responsible for providing the
textures. The code will instance a different swapchain per texture type
(color, depth, motion). Swapchains are generic and could be eventually
extended to be used with the WebGPU bindings. So far we're only
providing an implementation for the WebGL bindings

There are 2 types of swapchains so far, shared and static. The former
use textures created by the XR compositor in the UIProcess (the
color textures) and those that are not shared with the UIProcess and
only used locally in the WebProcess ("static") for rendering (like the
depth/stencil textures). It should be possible to have also shared
textures for depth, and in fact, the current IPC already supports that
without further changes, but ports using DMABuf or GBM for texture
sharing could not benefit from that as there is no reliable way to share
those depth textures between processes.

A new WebXRSessionListener object was also added to listen to session
end events. We were already notifying the WebXRSystem about that but now
we do in a more generic way for those listeners (currently the
WebXRSystem and the XRWebGLBinding).

The creation of the XRProjectionLayer happens inside the XRWebGLBinding
object wich performs several validation steps and is the one that
eventually creates the projection layer and the backing object which is
the one that holds references to the swapchains.

It's important to mention that the spec is not fully supported. The
WebXR Layers spec allows multiple setups for the views (only left to
right stereo is supported right now) and multiple types of textures
(regular or texture arrays) but so far only regular textures can be used.

Apart from adding the feature this change allows us to unskip several WPT
tests that PASS now. Feature moved to testable state for those builds
with WEBXR_LAYERS enabled.

* LayoutTests/platform/glib/TestExpectations:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/Modules/WebGPU/Implementation/WebGPUXRProjectionLayerImpl.cpp:
(WebCore::WebGPU::XRProjectionLayerImpl::colorTextureWidth const):
(WebCore::WebGPU::XRProjectionLayerImpl::colorTextureHeight const):
(WebCore::WebGPU::XRProjectionLayerImpl::colorTextureArrayLength const):
(WebCore::WebGPU::XRProjectionLayerImpl::textureWidth const): Deleted.
(WebCore::WebGPU::XRProjectionLayerImpl::textureHeight const): Deleted.
(WebCore::WebGPU::XRProjectionLayerImpl::textureArrayLength const): Deleted.
* Source/WebCore/Modules/WebGPU/Implementation/WebGPUXRProjectionLayerImpl.h:
* Source/WebCore/Modules/webxr/WebGLOpaqueTexture.cpp:
(WebCore::WebGLOpaqueTexture::create):
(WebCore::WebGLOpaqueTexture::WebGLOpaqueTexture):
(WebCore::WebGLOpaqueTexture::deleteObjectImpl):
(WebCore::WebGLOpaqueTexture::~WebGLOpaqueTexture):
* Source/WebCore/Modules/webxr/WebGLOpaqueTexture.h:
* Source/WebCore/Modules/webxr/WebXRSession.cpp:
(WebCore::WebXRSession::onFrame):
* Source/WebCore/Modules/webxr/WebXRSwapchain.h:
(WebCore::WebXRSwapchain::WebXRSwapchain):
* Source/WebCore/Modules/webxr/WebXRWebGLSwapchain.cpp: Added.
(WebCore::WebXRWebGLSwapchain::WebXRWebGLSwapchain):
(WebCore::WebXRWebGLSwapchain::clearCurrentTexture):
(WebCore::WebXRWebGLSharedImageSwapchain::create):
(WebCore::WebXRWebGLSharedImageSwapchain::WebXRWebGLSharedImageSwapchain):
(WebCore::WebXRWebGLSharedImageSwapchain::~WebXRWebGLSharedImageSwapchain):
(WebCore::WebXRWebGLSharedImageSwapchain::currentTexture):
(WebCore::calcImagePhysicalSize):
(WebCore::toIntSize):
(WebCore::WebXRWebGLSharedImageSwapchain::setupExternalImage):
(WebCore::WebXRWebGLSharedImageSwapchain::reusableTextures const):
(WebCore::WebXRWebGLSharedImageSwapchain::releaseTexturesAtIndex):
(WebCore::createAndBindCompositorTexture):
(WebCore::makeExternalImageSource):
(WebCore::WebXRWebGLSharedImageSwapchain::bindCompositorTexturesForDisplay):
(WebCore::WebXRWebGLSharedImageSwapchain::startFrame):
(WebCore::WebXRWebGLSharedImageSwapchain::endFrame):
(WebCore::WebXRExternalImage::destroyImage):
(WebCore::WebXRExternalImage::release):
(WebCore::WebXRExternalImage::leakObject):
(WebCore::WebXRWebGLStaticImageSwapchain::create):
(WebCore::WebXRWebGLStaticImageSwapchain::WebXRWebGLStaticImageSwapchain):
(WebCore::WebXRWebGLStaticImageSwapchain::~WebXRWebGLStaticImageSwapchain):
(WebCore::WebXRWebGLStaticImageSwapchain::currentTexture):
(WebCore::WebXRWebGLStaticImageSwapchain::releaseDisplayImagesAtIndex):
(WebCore::WebXRWebGLStaticImageSwapchain::bindCompositorTexturesForDisplay):
(WebCore::WebXRWebGLStaticImageSwapchain::startFrame):
(WebCore::WebXRWebGLStaticImageSwapchain::endFrame):
* Source/WebCore/Modules/webxr/WebXRWebGLSwapchain.h: Added.
(WebCore::WebXRExternalImage::operator bool const):
(WebCore::WebXRImageSet::operator bool const):
(WebCore::WebXRImageSet::release):
(WebCore::WebXRImageSet::leakObject):
(WebCore::WebXRWebGLSwapchain::context):
(WebCore::WebXRWebGLSwapchain::size const):
* Source/WebCore/Modules/webxr/XRCompositionLayer.cpp:
(WebCore::XRCompositionLayer::XRCompositionLayer):
(WebCore::XRCompositionLayer::setColorTextures):
(WebCore::XRCompositionLayer::setDepthStencilTextures):
* Source/WebCore/Modules/webxr/XRCompositionLayer.h:
(WebCore::XRCompositionLayer::layout const):
(WebCore::XRCompositionLayer::setLayout):
(WebCore::XRCompositionLayer::needsRedraw const):
(WebCore::XRCompositionLayer::setNeedsRedraw):
(WebCore::XRCompositionLayer::isStatic const):
(WebCore::XRCompositionLayer::setIsStatic):
(WebCore::XRCompositionLayer::session const):
(WebCore::XRCompositionLayer::colorTextures const):
(WebCore::XRCompositionLayer::depthStencilTextures const):
* Source/WebCore/Modules/webxr/XRGPUBinding.cpp:
(WebCore::XRGPUBinding::createProjectionLayer):
* Source/WebCore/Modules/webxr/XRLayerBacking.h:
(WebCore::XRLayerBacking::depthTextureWidth const):
(WebCore::XRLayerBacking::depthTextureHeight const):
(WebCore::XRLayerBacking::handle):
(WebCore::XRLayerBacking::setHandle):
(WebCore::XRLayerBacking::startFrame): Deleted.
* Source/WebCore/Modules/webxr/XRProjectionLayer.cpp:
(WebCore::XRProjectionLayer::XRProjectionLayer):
(WebCore::XRProjectionLayer::startFrame):
(WebCore::XRProjectionLayer::computeViewports):
(WebCore::XRProjectionLayer::endFrame):
(WebCore::XRProjectionLayer::textureWidth const):
(WebCore::XRProjectionLayer::textureHeight const):
(WebCore::XRProjectionLayer::textureArrayLength const):
* Source/WebCore/Modules/webxr/XRProjectionLayer.h:
(WebCore::XRProjectionLayer::create):
(WebCore::XRProjectionLayer::setIgnoreDepthValues):
(WebCore::XRProjectionLayer::init const):
* Source/WebCore/Modules/webxr/XRSwapchain.h: Added.
* Source/WebCore/Modules/webxr/XRWebGLBinding.cpp:
(WebCore::XRWebGLBinding::initializeCompositionLayer):
(WebCore::XRWebGLBinding::determineLayout):
(WebCore::XRWebGLBinding::colorFormatIsSupportedForProjectionLayer const):
(WebCore::XRWebGLBinding::depthFormatIsSupportedForProjectionLayer const):
(WebCore::XRWebGLBinding::createProjectionLayer):
(WebCore::XRWebGLBinding::validateXRWebGLSubImageCreation const):
(WebCore::XRWebGLBinding::rectForView const):
(WebCore::XRWebGLBinding::allocateColorTexturesForProjectionLayer):
(WebCore::XRWebGLBinding::allocateDepthTexturesForProjectionLayer):
(WebCore::XRWebGLBinding::getViewSubImage):
* Source/WebCore/Modules/webxr/XRWebGLBinding.h:
(WebCore::XRWebGLBinding::createProjectionLayer): Deleted.
(WebCore::XRWebGLBinding::getViewSubImage): Deleted.
* Source/WebCore/Modules/webxr/XRWebGLBinding.idl:
* Source/WebCore/Modules/webxr/XRWebGLLayerBacking.cpp: Added.
(WebCore::XRWebGLLayerBacking::XRWebGLLayerBacking):
(WebCore::XRWebGLLayerBacking::colorTextureWidth const):
(WebCore::XRWebGLLayerBacking::colorTextureHeight const):
(WebCore::XRWebGLLayerBacking::colorTextureArrayLength const):
(WebCore::XRWebGLLayerBacking::depthTextureWidth const):
(WebCore::XRWebGLLayerBacking::depthTextureHeight const):
(WebCore::XRWebGLLayerBacking::startFrame):
(WebCore::XRWebGLLayerBacking::endFrame):
(WebCore::XRWebGLLayerBacking::currentColorTexture const):
(WebCore::XRWebGLLayerBacking::currentDepthTexture const):
(WebCore::XRWebGLLayerBacking::swapchainFormatsForLayerFormat):
(WebCore::XRWebGLLayerBacking::formatHasStencil):
* Source/WebCore/Modules/webxr/XRWebGLLayerBacking.h: Copied from 
Source/WebCore/Modules/webxr/XRCompositionLayer.h.
* Source/WebCore/Modules/webxr/XRWebGLProjectionLayerBacking.cpp: Added.
(WebCore::XRWebGLProjectionLayerBacking::create):
(WebCore::XRWebGLProjectionLayerBacking::XRWebGLProjectionLayerBacking):
* Source/WebCore/Modules/webxr/XRWebGLProjectionLayerBacking.h: Copied from 
Source/WebCore/Modules/webxr/XRWebGLSubImage.cpp.
* Source/WebCore/Modules/webxr/XRWebGLSubImage.cpp:
(WebCore::XRWebGLSubImage::XRWebGLSubImage):
(WebCore::XRWebGLSubImage::create):
(WebCore::XRWebGLSubImage::colorTexture const):
(WebCore::XRWebGLSubImage::depthStencilTexture const):
(WebCore::XRWebGLSubImage::depthStencilTextureWidth const):
(WebCore::XRWebGLSubImage::depthStencilTextureHeight const):
* Source/WebCore/Modules/webxr/XRWebGLSubImage.h:
(WebCore::XRWebGLSubImage::motionVectorTexture const):
(WebCore::XRWebGLSubImage::imageIndex const):
(WebCore::XRWebGLSubImage::colorTextureWidth const):
(WebCore::XRWebGLSubImage::colorTextureHeight const):
(WebCore::XRWebGLSubImage::motionVectorTextureWidth const):
(WebCore::XRWebGLSubImage::motionVectorTextureHeight const):
(WebCore::XRWebGLSubImage::colorTexture const): Deleted.
(WebCore::XRWebGLSubImage::depthStencilTexture const): Deleted.
(WebCore::XRWebGLSubImage::depthStencilTextureWidth const): Deleted.
(WebCore::XRWebGLSubImage::depthStencilTextureHeight const): Deleted.
* Source/WebCore/Sources.txt:
* Source/WebCore/html/canvas/WebGLTexture.h:
* Source/WebCore/html/canvas/WebGLTexture.idl:
* Source/WebKit/Shared/WebPreferencesDefaultValues.h:
* Source/WebKit/Shared/XR/XRSystem.serialization.in:
* Source/WebKit/UIProcess/XR/openxr/PlatformXROpenXR.cpp:
(WebKit::OpenXRCoordinator::scheduleAnimationFrame):
* Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteXRProjectionLayerProxy.cpp:
(WebKit::WebGPU::RemoteXRProjectionLayerProxy::endFrame):
(WebKit::WebGPU::RemoteXRProjectionLayerProxy::colorTextureWidth const):
(WebKit::WebGPU::RemoteXRProjectionLayerProxy::colorTextureHeight const):
(WebKit::WebGPU::RemoteXRProjectionLayerProxy::colorTextureArrayLength const):
(WebKit::WebGPU::RemoteXRProjectionLayerProxy::textureWidth const): Deleted.
(WebKit::WebGPU::RemoteXRProjectionLayerProxy::textureHeight const): Deleted.
(WebKit::WebGPU::RemoteXRProjectionLayerProxy::textureArrayLength const): 
Deleted.
* Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteXRProjectionLayerProxy.h:

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to