Skip to content

Define WebGPU layer creation and texture lifecycle - #37

Open
cabanier wants to merge 8 commits into
immersive-web:mainfrom
cabanier:layers
Open

Define WebGPU layer creation and texture lifecycle#37
cabanier wants to merge 8 commits into
immersive-web:mainfrom
cabanier:layers

Conversation

@cabanier

@cabanier cabanier commented Jul 30, 2026

Copy link
Copy Markdown
Member
  • Specify projection and non-projection layer creation using the layer types defined by the WebXR Layers API.
  • Define user-agent-managed texture sets, frame-scoped GPUTexture acquisition and expiration, compositor synchronization, and WebGPU layer teardown.
  • Align XRGPUBinding method organization and validation with XRWebGLBinding, and remove the unstable API markup.

Preview | Diff

Specify projection and non-projection layer creation using the layer types defined by the WebXR Layers API.

Define user-agent-managed texture sets, frame-scoped GPUTexture acquisition and expiration, compositor synchronization, and WebGPU layer teardown.

Align XRGPUBinding method organization and validation with XRWebGLBinding, and remove the unstable API markup.
@cabanier

Copy link
Copy Markdown
Member Author

I know that this is a large change. @toji, would it help if I break it into at least 2 patches so the layer changes are more clear?

@AdaRoseCannon

Copy link
Copy Markdown
Member

@mwyrzykowski is probably better equipped to look at this than I

@mwyrzykowski
mwyrzykowski self-requested a review July 31, 2026 05:39
@cabanier

cabanier commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

I put an html version of the updated spec here: https://cabanier.github.io/WebXR-WebGPU-Binding
I also re-arranged a couple of sections so the spec more closely reflects the WebGL layers spec.

There's a fair number of changes that come from the destroy() method. I can remove those if needed.

@cabanier

cabanier commented Aug 3, 2026

Copy link
Copy Markdown
Member Author

/agenda discuss layer support for WebGPU

@probot-label probot-label Bot added the agenda label Aug 3, 2026

@toji toji left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a full review yet, but posting what I have so far. Will try and finish reviewing tomorrow.

Comment thread index.bs Outdated
Comment thread index.bs
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs
using |binding|'s [=XRGPUBinding/device=] with the storage properties described by
|motionVectorDescriptor|. Otherwise, set its motion vector resource to `null`.
1. If the user agent was unable to allocate any resource for |textureSet|, release every
resource allocated by these steps and throw an {{OperationError}} {{DOMException}}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is worth comparing to WebGPU's canvas context texture handling. https://gpuweb.github.io/gpuweb/#dom-gpucanvascontext-configure

In that case, if textures can't be allocated (do to OOM or a validation failure of the configuration) then error textures are returned. These are textures that have the right "shape" in that the set all the attributes as expected but any attempt to use them "dirties" the whole pass and you just get black output with a validation error.

Wether or not we want to carry that pattern into WebXR's integration with WebGPU is worth discussing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/agenda discuss error handling when textures can't be allocated

Replace the nonexistent GPUTexture size property with width, height, and depthOrArrayLayers for color, depth-stencil, and motion-vector textures.
@cabanier

cabanier commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

/agenda discuss error handling when textures can't be allocated (#37 (comment))

@toji toji left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got through createProjectionLayer() today. 😅 I'll wrap up the remainder soon! Thanks for your patience!

Comment thread index.bs
* {{GPUTextureDescriptor/dimension}} set to {{GPUTextureDimension/"2d"}}.
* {{GPUTextureDescriptor/format}} set to |format|.
* {{GPUTextureDescriptor/usage}} set to |usage|.
* {{GPUTextureDescriptor/viewFormats}} set to an empty sequence.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary to discuss as part of this change, but we might want to consider whether or not viewFormats should be exposed as part of the layer creation args? It's primary purpose is to make it easier to support sRGB rendering.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I file an issue?

Comment thread index.bs
Comment thread index.bs Outdated
Comment thread index.bs
<div class="algorithm" data-algorithm="destroy a WebGPU-backed layer">

### getViewDescriptor ### {#xrgpusubimage-getviewdescriptor}
When {{XRCompositionLayer/destroy()}} is invoked on a [=WebGPU-backed layer=] |layer|, the user

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I'm just missing it, but I went searching for some spec language either here or in the base layers spec that details how the session should deal with having a destroyed layer in it's layers array. I don't think we have anything about that? That's worth spelling out explicitly, but that probably also belongs in the based layers API.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. I'll file an issue in the layers spec.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread index.bs Outdated
Comment thread index.bs
The <dfn dict-member for="XRGPULayerInit">viewPixelHeight</dfn> member specifies the height, in pixels, of each view's texture.

The <dfn dict-member for="XRGPULayerInit">layout</dfn> member specifies the {{XRLayerLayout}} of the layer.
The <dfn dict-member for="XRGPULayerInit">layout</dfn> member specifies the {{XRLayerLayout}} of the layer. {{XRLayerLayout/"default"}} is not valid for non-projection layers created by an {{XRGPUBinding}}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a departure from WebGL, right? I don't recall if it was discussed prior to this or not, sorry, just want to make sure that we have the reasoning for it documented somewhere.

(Assuming that it is different than the WebGL layers behavior, maybe a note calling attention to that would be appropriate?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's the same in the layers spec.

Comment thread index.bs
Comment thread index.bs
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Co-authored-by: Brandon Jones <tojiro@gmail.com>
State that expiring color, depth-stencil, and motion-vector textures terminates write access without destroying their underlying storage.
Place projection layer creation and its texture sizing helper before the non-projection layer helpers to improve specification flow.
Allocate motion-vector textures only for projection layers with a usable depth aspect, keeping stencil-only and depthless layers on the normal rendering path.

Split ignoreDepthValues initialization between mandatory space-warp depth use and implementation-selected reprojection, and align the subimage, viewport, and Space Warp prose with those conditions.

@toji toji left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github is falling over apparently and won't let me review your latest changes? I can still see the correct prievew, though, so I can say that overall the rest of the changes looked good. Two more comments and then I'll re-review once you've resolved the outstanding issues and Github lets me see the diff. 😅

Comment thread index.bs
Comment thread index.bs Outdated
Document why quad and cylinder layers accept all XRSpace values while equirect and cube layers require non-viewer reference spaces.

Remove the redundant prose form of getSubImage's layers feature check while retaining the normative algorithm step.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants