Skip to content

Commit fae4e8d

Browse files
committed
Bootstrap the spec with IDL and some intro prose
1 parent aa86463 commit fae4e8d

File tree

2 files changed

+183
-8
lines changed

2 files changed

+183
-8
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
all: index.html
44

55
index.html: index.bs
6-
curl https://api.csswg.org/bikeshed/ -F file=@webxrlayers-1.bs -F output=err
7-
curl https://api.csswg.org/bikeshed/ -F file=@webxrlayers-1.bs -F force=1 > index.html | tee
6+
curl https://api.csswg.org/bikeshed/ -F file=@index.bs -F output=err
7+
curl https://api.csswg.org/bikeshed/ -F file=@index.bs -F force=1 > index.html | tee
88

99
local: index.bs
1010
bikeshed --die-on=everything spec index.bs

index.bs

+181-6
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,37 @@
22
Shortname: webxr-webgpu-binding
33
Title: WebXR/WebGPU Binding Module - Level 1
44
Group: immersivewebwg
5-
Status: ED
5+
Status: w3c/ED
66
TR: https://www.w3.org/TR/webxr-webgpu-binding-1/
77
ED: https://immersive-web.github.io/webxr-webgpu-binding/
88
Previous Version:
99
Repository: immersive-web/webxr-webgpu-binding
1010
Level: 1
1111
Mailing List Archives: https://lists.w3.org/Archives/Public/public-immersive-web/
1212
13-
Editor: Brandon Jones 87824, Google http://google.com/, [email protected]
13+
Editor: Brandon Jones, Google https://www.google.com, [email protected], w3cid 87824
1414
1515
Abstract: This specification describes support for rendering content for a WebXR session with WebGPU.
1616
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+
1723
Warning: custom
1824
Custom Warning Title: Unstable API
1925
Custom Warning Text:
2026
<b>The API represented in this document is under development and may change at any time.</b>
2127
<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>
2228
</pre>
2329

30+
<pre class="link-defaults">
31+
spec: webxr;
32+
type: dfn;
33+
text: feature descriptor
34+
</pre>
35+
2436
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
2537
<link rel="icon" type="image/png" sizes="96x96" href="favicon-96x96.png">
2638

@@ -79,13 +91,176 @@ Custom Warning Text:
7991
}
8092
</style>
8193

82-
Introduction {#intro}
83-
============
94+
# Introduction # {#intro}
8495

8596
<section class="non-normative">
8697

87-
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>.
8899

89100
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.
90101

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.
149+
150+
## GPUAdapter integration ## {#gpuadapter-integration}
151+
152+
<script type=idl>
153+
partial dictionary GPURequestAdapterOptions {
154+
boolean xrCompatible = false;
155+
};
156+
</script>
157+
158+
Note: There is no WebGPU equivalent to the {{WebGLRenderingContextBase/makeXRCompatible()}} method to make a {{GPUDevice}} XR-compatible after creation.
159+
160+
## XRGPUBinding ## {#xrgpubinding-interface}
161+
162+
<script type=idl>
163+
[Exposed=(Window), SecureContext]
164+
interface XRGPUBinding {
165+
constructor(XRSession session, GPUDevice device);
166+
167+
readonly attribute double nativeProjectionScaleFactor;
168+
169+
XRProjectionLayer createProjectionLayer(optional XRGPUProjectionLayerInit init);
170+
XRQuadLayer createQuadLayer(optional XRGPUQuadLayerInit init);
171+
XRCylinderLayer createCylinderLayer(optional XRGPUCylinderLayerInit init);
172+
XREquirectLayer createEquirectLayer(optional XRGPUEquirectLayerInit init);
173+
XRCubeLayer createCubeLayer(optional XRGPUCubeLayerInit init);
174+
175+
XRGPUSubImage getSubImage(XRCompositionLayer layer, XRFrame frame, optional XREye eye = "none");
176+
XRGPUSubImage getViewSubImage(XRProjectionLayer layer, XRView view);
177+
178+
GPUTextureFormat getPreferredColorFormat();
179+
};
180+
</script>
181+
182+
# Rendering # {#rendering}
183+
184+
## XRGPUSubImage ## {#xrgpusubimage-interface}
185+
186+
<script type=idl>
187+
[Exposed=(Window), SecureContext]
188+
interface XRGPUSubImage : XRSubImage {
189+
[SameObject] readonly attribute GPUTexture colorTexture;
190+
[SameObject] readonly attribute GPUTexture? depthStencilTexture;
191+
[SameObject] readonly attribute GPUTexture? motionVectorTexture;
192+
GPUTextureViewDescriptor getViewDescriptor();
193+
};
194+
</script>
195+
196+
# Layer Creation # {#layer-creation}
197+
198+
## XRGPUProjectionLayerInit ## {#xrgpuprojectionlayerinit}
199+
200+
<script type=idl>
201+
[Exposed=(Window), SecureContext]
202+
dictionary XRGPUProjectionLayerInit {
203+
required GPUTextureFormat colorFormat;
204+
GPUTextureFormat? depthStencilFormat;
205+
GPUTextureUsageFlags textureUsage = 0x10; // GPUTextureUsage.RENDER_ATTACHMENT
206+
double scaleFactor = 1.0;
207+
};
208+
</script>
209+
210+
## XRGPULayerInit ## {#xrgpulayerinit}
211+
212+
<script type=idl>
213+
[Exposed=(Window), SecureContext]
214+
dictionary XRGPULayerInit {
215+
required GPUTextureFormat colorFormat;
216+
GPUTextureFormat? depthStencilFormat;
217+
GPUTextureUsageFlags textureUsage = 0x10; // GPUTextureUsage.RENDER_ATTACHMENT
218+
required XRSpace space;
219+
unsigned long mipLevels = 1;
220+
required unsigned long viewPixelWidth;
221+
required unsigned long viewPixelHeight;
222+
XRLayerLayout layout = "mono";
223+
boolean isStatic = false;
224+
};
225+
</script>
226+
227+
## XRGPUQuadLayerInit ## {#xrgpuquadlayerinit}
228+
229+
<script type=idl>
230+
dictionary XRGPUQuadLayerInit : XRGPULayerInit {
231+
XRRigidTransform? transform;
232+
float width = 1.0;
233+
float height = 1.0;
234+
};
235+
</script>
236+
237+
## XRGPUCylinderLayerInit ## {#xrgpucylinderlayerinit}
238+
239+
<script type=idl>
240+
dictionary XRGPUCylinderLayerInit : XRGPULayerInit {
241+
XRRigidTransform? transform;
242+
float radius = 2.0;
243+
float centralAngle = 0.78539;
244+
float aspectRatio = 2.0;
245+
};
246+
</script>
247+
248+
## XRGPUEquirectLayerInit ## {#xrgpuequirectlayerinit}
249+
250+
<script type=idl>
251+
dictionary XRGPUEquirectLayerInit : XRGPULayerInit {
252+
XRRigidTransform? transform;
253+
float radius = 0;
254+
float centralHorizontalAngle = 6.28318;
255+
float upperVerticalAngle = 1.570795;
256+
float lowerVerticalAngle = -1.570795;
257+
};
258+
</script>
259+
260+
## XRGPUCubeLayerInit ## {#xrgpucubelayerinit}
261+
262+
<script type=idl>
263+
dictionary XRGPUCubeLayerInit : XRGPULayerInit {
264+
DOMPointReadOnly? orientation;
265+
};
266+
</script>

0 commit comments

Comments
 (0)