You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mailing List Archives: https://lists.w3.org/Archives/Public/public-immersive-web/
12
12
13
-
Editor: Brandon Jones 87824, Google http://google.com/, [email protected]
13
+
Editor: Brandon Jones, Google https://www.google.com, [email protected], w3cid 87824
14
14
15
15
Abstract: This specification describes support for rendering content for a WebXR session with WebGPU.
16
16
17
+
Markup Shorthands: markdown yes
18
+
Markup Shorthands: dfn yes
19
+
Markup Shorthands: idl yes
20
+
Markup Shorthands: css no
21
+
Assume Explicit For: yes
22
+
17
23
Warning: custom
18
24
Custom Warning Title: Unstable API
19
25
Custom Warning Text:
20
26
<b>The API represented in this document is under development and may change at any time.</b>
21
27
<p>For additional context on the use of this API please reference the <a href="https://github.com/immersive-web/webxr-webgpu-binding/blob/master/explainer.md">WebXR/WebGPU Binding Module Explainer</a>.</p>
This spec adds support for creation of {{XRCompositionLayers}}, as described in the <a href="https://immersive-web.github.io/layers/">WebXR Layers API</a>, which are rendered using the <a href="https://gpuweb.github.io/gpuweb/">WebGPU API</a>.
98
+
This spec adds support for creation of {{XRCompositionLayer}}s, as described in the <a href="https://immersive-web.github.io/layers/">WebXR Layers API</a>, which are rendered using the <a href="https://gpuweb.github.io/gpuweb/">WebGPU API</a>.
88
99
89
100
WebGPU is an API for utilizing the graphics and compute capabilities of a device's GPU more efficiently than WebGL allows, with an API that better matches both GPU hardware architecture and the modern native APIs that interface with them, such as Vulkan, Direct3D 12, and Metal.
90
101
91
-
</section>
102
+
</section>
103
+
104
+
## Application flow ## {#applicationflow}
105
+
106
+
<section class="non-normative">
107
+
108
+
If an author wants to use WebGPU to render content for a WebXR Session, they must perform the following steps:
109
+
110
+
In no particular order
111
+
1. Create a {{GPUDevice}} from an {{GPUAdapter}} which was requested with the {{GPURequestAdapterOptions/xrCompatible}} option set to `true`.
112
+
1. Create an {{XRSession}} with the [=feature descriptor/webgpu=] feature.
113
+
114
+
Then
115
+
1. Create an {{XRGPUBinding}} with both the XR-compatible {{GPUDevice}} and [=WebGPU-compatible session=].
116
+
1. Create one or more {{XRCompositionLayer}}s with the {{XRGPUBinding}}
117
+
1. Add the layers to {{XRRenderStateInit}} and call {{XRSession/updateRenderState()}}.
118
+
1. During {{XRSession/requestAnimationFrame()}} for each WebGPU layer:
119
+
1. For each {{XRGPUSubImage}} exposed by the layer:
120
+
1. Draw the contents of the subimage using the {{GPUDevice}} the {{XRGPUBinding}} was created with.
121
+
122
+
</section>
123
+
124
+
# Initialization # {#initialization}
125
+
126
+
## "webgpu" feature ## {#webgpu-feature}
127
+
128
+
If an application wants to use WebGPU for rendering during a session, the session MUST be requested with an appropriate [=feature descriptor=]. The string "<dfn for="feature descriptor">webgpu</dfn>" is introduced by this module as a new valid [=feature descriptor=] for the WebXR/WebGPU Bindings feature. {{XRSession}}s created with the [=feature descriptor/webgpu=] feature are considered [=WebGPU-compatible sessions=].
129
+
130
+
A <dfn>WebGPU-compatible session</dfn> MUST have the following behavioral from a WebGL-compatible session:
131
+
132
+
- {{XRSessionMode/"inline"}} sessions are not supported.
133
+
- {{XRWebGLBinding}} and {{XRWebGLLayer}} instances cannot be created with the session.
134
+
- {{XRGPUBinding}} instances can be created for the session.
135
+
- {{XRRenderStateInit/baseLayer}} cannot be be set in {{XRSession/updateRenderState()}}. {{XRRenderStateInit/layers}} must be used instead.
136
+
- The {{XRView/projectionMatrix}} attribute of any {{XRView}} associated with the session will return a matrix appropriate for a clip-space depth range of [0, 1] instead of [-1, 1].
137
+
138
+
<div class="example">
139
+
The following code creates a [=WebGPU-compatible session=].
140
+
141
+
<pre highlight="js">
142
+
navigator.xr.requestSession('immersive-vr', {
143
+
requiredFeatures: ['webgpu']
144
+
}
145
+
</pre>
146
+
</div>
147
+
148
+
Note: The [=feature descriptor/webgpu=] feature may be passed to either {{XRSessionInit/requiredFeatures}} or {{XRSessionInit/optionalFeatures}}, but if passed to {{XRSessionInit/optionalFeatures}} the author must check {{XRSession/enabledFeatures}} after the session is created and use either WebGPU or WebGL to render the session's content depending on if [=feature descriptor/webgpu=] is present.
Note: There is no WebGPU equivalent to the {{WebGLRenderingContextBase/makeXRCompatible()}} method to make a {{GPUDevice}} XR-compatible after creation.
0 commit comments