Skip to content

Commit 035902a

Browse files
authored
Update to latest WebGPU WebIDL (#2037)
1 parent 5534253 commit 035902a

8 files changed

+85
-61
lines changed

crates/web-sys/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,11 @@ Gpu = []
381381
GpuAdapter = []
382382
GpuAddressMode = []
383383
GpuBindGroup = []
384-
GpuBindGroupBinding = []
385384
GpuBindGroupDescriptor = []
385+
GpuBindGroupEntry = []
386386
GpuBindGroupLayout = []
387-
GpuBindGroupLayoutBinding = []
388387
GpuBindGroupLayoutDescriptor = []
388+
GpuBindGroupLayoutEntry = []
389389
GpuBindingType = []
390390
GpuBlendDescriptor = []
391391
GpuBlendFactor = []

crates/web-sys/src/features/gen_GpuBindGroupBinding.rs renamed to crates/web-sys/src/features/gen_GpuBindGroupEntry.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ use wasm_bindgen::prelude::*;
44
#[cfg(web_sys_unstable_apis)]
55
#[wasm_bindgen]
66
extern "C" {
7-
# [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = GPUBindGroupBinding ) ]
7+
# [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = GPUBindGroupEntry ) ]
88
#[derive(Debug, Clone, PartialEq, Eq)]
9-
#[doc = "The `GpuBindGroupBinding` dictionary."]
9+
#[doc = "The `GpuBindGroupEntry` dictionary."]
1010
#[doc = ""]
11-
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupBinding`*"]
11+
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupEntry`*"]
1212
#[doc = ""]
1313
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
1414
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
15-
pub type GpuBindGroupBinding;
15+
pub type GpuBindGroupEntry;
1616
}
1717
#[cfg(web_sys_unstable_apis)]
18-
impl GpuBindGroupBinding {
19-
#[doc = "Construct a new `GpuBindGroupBinding`."]
18+
impl GpuBindGroupEntry {
19+
#[doc = "Construct a new `GpuBindGroupEntry`."]
2020
#[doc = ""]
21-
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupBinding`*"]
21+
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupEntry`*"]
2222
#[doc = ""]
2323
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
2424
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
@@ -32,7 +32,7 @@ impl GpuBindGroupBinding {
3232
#[cfg(web_sys_unstable_apis)]
3333
#[doc = "Change the `binding` field of this object."]
3434
#[doc = ""]
35-
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupBinding`*"]
35+
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupEntry`*"]
3636
#[doc = ""]
3737
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
3838
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
@@ -53,7 +53,7 @@ impl GpuBindGroupBinding {
5353
#[cfg(web_sys_unstable_apis)]
5454
#[doc = "Change the `resource` field of this object."]
5555
#[doc = ""]
56-
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupBinding`*"]
56+
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupEntry`*"]
5757
#[doc = ""]
5858
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
5959
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]

crates/web-sys/src/features/gen_GpuBindGroupLayoutBinding.rs renamed to crates/web-sys/src/features/gen_GpuBindGroupLayoutEntry.rs

+44-22
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ use wasm_bindgen::prelude::*;
44
#[cfg(web_sys_unstable_apis)]
55
#[wasm_bindgen]
66
extern "C" {
7-
# [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = GPUBindGroupLayoutBinding ) ]
7+
# [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = GPUBindGroupLayoutEntry ) ]
88
#[derive(Debug, Clone, PartialEq, Eq)]
9-
#[doc = "The `GpuBindGroupLayoutBinding` dictionary."]
9+
#[doc = "The `GpuBindGroupLayoutEntry` dictionary."]
1010
#[doc = ""]
11-
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`*"]
11+
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`*"]
1212
#[doc = ""]
1313
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
1414
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
15-
pub type GpuBindGroupLayoutBinding;
15+
pub type GpuBindGroupLayoutEntry;
1616
}
1717
#[cfg(web_sys_unstable_apis)]
18-
impl GpuBindGroupLayoutBinding {
18+
impl GpuBindGroupLayoutEntry {
1919
#[cfg(feature = "GpuBindingType")]
20-
#[doc = "Construct a new `GpuBindGroupLayoutBinding`."]
20+
#[doc = "Construct a new `GpuBindGroupLayoutEntry`."]
2121
#[doc = ""]
22-
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`, `GpuBindingType`*"]
22+
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuBindingType`*"]
2323
#[doc = ""]
2424
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
2525
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
@@ -34,7 +34,7 @@ impl GpuBindGroupLayoutBinding {
3434
#[cfg(web_sys_unstable_apis)]
3535
#[doc = "Change the `binding` field of this object."]
3636
#[doc = ""]
37-
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`*"]
37+
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`*"]
3838
#[doc = ""]
3939
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
4040
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
@@ -55,7 +55,7 @@ impl GpuBindGroupLayoutBinding {
5555
#[cfg(web_sys_unstable_apis)]
5656
#[doc = "Change the `hasDynamicOffset` field of this object."]
5757
#[doc = ""]
58-
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`*"]
58+
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`*"]
5959
#[doc = ""]
6060
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
6161
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
@@ -76,7 +76,7 @@ impl GpuBindGroupLayoutBinding {
7676
#[cfg(web_sys_unstable_apis)]
7777
#[doc = "Change the `multisampled` field of this object."]
7878
#[doc = ""]
79-
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`*"]
79+
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`*"]
8080
#[doc = ""]
8181
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
8282
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
@@ -95,18 +95,18 @@ impl GpuBindGroupLayoutBinding {
9595
self
9696
}
9797
#[cfg(web_sys_unstable_apis)]
98-
#[cfg(feature = "GpuTextureComponentType")]
99-
#[doc = "Change the `textureComponentType` field of this object."]
98+
#[cfg(feature = "GpuTextureFormat")]
99+
#[doc = "Change the `storageTextureFormat` field of this object."]
100100
#[doc = ""]
101-
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`, `GpuTextureComponentType`*"]
101+
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuTextureFormat`*"]
102102
#[doc = ""]
103103
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
104104
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
105-
pub fn texture_component_type(&mut self, val: GpuTextureComponentType) -> &mut Self {
105+
pub fn storage_texture_format(&mut self, val: GpuTextureFormat) -> &mut Self {
106106
use wasm_bindgen::JsValue;
107107
let r = ::js_sys::Reflect::set(
108108
self.as_ref(),
109-
&JsValue::from("textureComponentType"),
109+
&JsValue::from("storageTextureFormat"),
110110
&JsValue::from(val),
111111
);
112112
debug_assert!(
@@ -117,18 +117,18 @@ impl GpuBindGroupLayoutBinding {
117117
self
118118
}
119119
#[cfg(web_sys_unstable_apis)]
120-
#[cfg(feature = "GpuTextureViewDimension")]
121-
#[doc = "Change the `textureDimension` field of this object."]
120+
#[cfg(feature = "GpuTextureComponentType")]
121+
#[doc = "Change the `textureComponentType` field of this object."]
122122
#[doc = ""]
123-
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`, `GpuTextureViewDimension`*"]
123+
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuTextureComponentType`*"]
124124
#[doc = ""]
125125
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
126126
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
127-
pub fn texture_dimension(&mut self, val: GpuTextureViewDimension) -> &mut Self {
127+
pub fn texture_component_type(&mut self, val: GpuTextureComponentType) -> &mut Self {
128128
use wasm_bindgen::JsValue;
129129
let r = ::js_sys::Reflect::set(
130130
self.as_ref(),
131-
&JsValue::from("textureDimension"),
131+
&JsValue::from("textureComponentType"),
132132
&JsValue::from(val),
133133
);
134134
debug_assert!(
@@ -142,7 +142,7 @@ impl GpuBindGroupLayoutBinding {
142142
#[cfg(feature = "GpuBindingType")]
143143
#[doc = "Change the `type` field of this object."]
144144
#[doc = ""]
145-
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`, `GpuBindingType`*"]
145+
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuBindingType`*"]
146146
#[doc = ""]
147147
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
148148
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
@@ -157,9 +157,31 @@ impl GpuBindGroupLayoutBinding {
157157
self
158158
}
159159
#[cfg(web_sys_unstable_apis)]
160+
#[cfg(feature = "GpuTextureViewDimension")]
161+
#[doc = "Change the `viewDimension` field of this object."]
162+
#[doc = ""]
163+
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuTextureViewDimension`*"]
164+
#[doc = ""]
165+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
166+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
167+
pub fn view_dimension(&mut self, val: GpuTextureViewDimension) -> &mut Self {
168+
use wasm_bindgen::JsValue;
169+
let r = ::js_sys::Reflect::set(
170+
self.as_ref(),
171+
&JsValue::from("viewDimension"),
172+
&JsValue::from(val),
173+
);
174+
debug_assert!(
175+
r.is_ok(),
176+
"setting properties should never fail on our dictionary objects"
177+
);
178+
let _ = r;
179+
self
180+
}
181+
#[cfg(web_sys_unstable_apis)]
160182
#[doc = "Change the `visibility` field of this object."]
161183
#[doc = ""]
162-
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`*"]
184+
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`*"]
163185
#[doc = ""]
164186
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
165187
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]

crates/web-sys/src/features/gen_GpuBindingType.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ pub enum GpuBindingType {
1414
StorageBuffer = "storage-buffer",
1515
ReadonlyStorageBuffer = "readonly-storage-buffer",
1616
Sampler = "sampler",
17+
ComparisonSampler = "comparison-sampler",
1718
SampledTexture = "sampled-texture",
18-
StorageTexture = "storage-texture",
19+
ReadonlyStorageTexture = "readonly-storage-texture",
20+
WriteonlyStorageTexture = "writeonly-storage-texture",
1921
}

crates/web-sys/src/features/gen_GpuBufferCopyView.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ impl GpuBufferCopyView {
2323
#[doc = ""]
2424
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
2525
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
26-
pub fn new(buffer: &GpuBuffer, image_height: u32, row_pitch: u32) -> Self {
26+
pub fn new(buffer: &GpuBuffer, row_pitch: u32) -> Self {
2727
#[allow(unused_mut)]
2828
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
2929
ret.buffer(buffer);
30-
ret.image_height(image_height);
3130
ret.row_pitch(row_pitch);
3231
ret
3332
}

crates/web-sys/src/features/gen_GpuShaderModuleDescriptor.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl GpuShaderModuleDescriptor {
2222
#[doc = ""]
2323
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
2424
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
25-
pub fn new(code: &::wasm_bindgen::JsValue) -> Self {
25+
pub fn new(code: &str) -> Self {
2626
#[allow(unused_mut)]
2727
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
2828
ret.code(code);
@@ -52,7 +52,7 @@ impl GpuShaderModuleDescriptor {
5252
#[doc = ""]
5353
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
5454
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
55-
pub fn code(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
55+
pub fn code(&mut self, val: &str) -> &mut Self {
5656
use wasm_bindgen::JsValue;
5757
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("code"), &JsValue::from(val));
5858
debug_assert!(

crates/web-sys/src/features/mod.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -2104,36 +2104,36 @@ mod gen_GpuBindGroup;
21042104
#[cfg(feature = "GpuBindGroup")]
21052105
pub use gen_GpuBindGroup::*;
21062106

2107-
#[cfg(feature = "GpuBindGroupBinding")]
2108-
#[allow(non_snake_case)]
2109-
mod gen_GpuBindGroupBinding;
2110-
#[cfg(feature = "GpuBindGroupBinding")]
2111-
pub use gen_GpuBindGroupBinding::*;
2112-
21132107
#[cfg(feature = "GpuBindGroupDescriptor")]
21142108
#[allow(non_snake_case)]
21152109
mod gen_GpuBindGroupDescriptor;
21162110
#[cfg(feature = "GpuBindGroupDescriptor")]
21172111
pub use gen_GpuBindGroupDescriptor::*;
21182112

2113+
#[cfg(feature = "GpuBindGroupEntry")]
2114+
#[allow(non_snake_case)]
2115+
mod gen_GpuBindGroupEntry;
2116+
#[cfg(feature = "GpuBindGroupEntry")]
2117+
pub use gen_GpuBindGroupEntry::*;
2118+
21192119
#[cfg(feature = "GpuBindGroupLayout")]
21202120
#[allow(non_snake_case)]
21212121
mod gen_GpuBindGroupLayout;
21222122
#[cfg(feature = "GpuBindGroupLayout")]
21232123
pub use gen_GpuBindGroupLayout::*;
21242124

2125-
#[cfg(feature = "GpuBindGroupLayoutBinding")]
2126-
#[allow(non_snake_case)]
2127-
mod gen_GpuBindGroupLayoutBinding;
2128-
#[cfg(feature = "GpuBindGroupLayoutBinding")]
2129-
pub use gen_GpuBindGroupLayoutBinding::*;
2130-
21312125
#[cfg(feature = "GpuBindGroupLayoutDescriptor")]
21322126
#[allow(non_snake_case)]
21332127
mod gen_GpuBindGroupLayoutDescriptor;
21342128
#[cfg(feature = "GpuBindGroupLayoutDescriptor")]
21352129
pub use gen_GpuBindGroupLayoutDescriptor::*;
21362130

2131+
#[cfg(feature = "GpuBindGroupLayoutEntry")]
2132+
#[allow(non_snake_case)]
2133+
mod gen_GpuBindGroupLayoutEntry;
2134+
#[cfg(feature = "GpuBindGroupLayoutEntry")]
2135+
pub use gen_GpuBindGroupLayoutEntry::*;
2136+
21372137
#[cfg(feature = "GpuBindingType")]
21382138
#[allow(non_snake_case)]
21392139
mod gen_GpuBindingType;

crates/web-sys/webidls/unstable/WebGPU.webidl

+12-11
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ dictionary GPUSamplerDescriptor : GPUObjectDescriptorBase {
246246
GPUFilterMode mipmapFilter = "nearest";
247247
float lodMinClamp = 0;
248248
float lodMaxClamp = 0xffffffff; // TODO: What should this be? Was Number.MAX_VALUE.
249-
GPUCompareFunction compare = "never";
249+
GPUCompareFunction compare;
250250
};
251251

252252
enum GPUAddressMode {
@@ -277,17 +277,18 @@ interface GPUBindGroupLayout {
277277
GPUBindGroupLayout includes GPUObjectBase;
278278

279279
dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {
280-
required sequence<GPUBindGroupLayoutBinding> bindings;
280+
required sequence<GPUBindGroupLayoutEntry> bindings;
281281
};
282282

283-
dictionary GPUBindGroupLayoutBinding {
283+
dictionary GPUBindGroupLayoutEntry {
284284
required GPUIndex32 binding;
285285
required GPUShaderStageFlags visibility;
286286
required GPUBindingType type;
287-
GPUTextureViewDimension textureDimension = "2d";
287+
GPUTextureViewDimension viewDimension = "2d";
288288
GPUTextureComponentType textureComponentType = "float";
289289
boolean multisampled = false;
290290
boolean hasDynamicOffset = false;
291+
GPUTextureFormat storageTextureFormat;
291292
};
292293

293294
typedef [EnforceRange] unsigned long GPUShaderStageFlags;
@@ -302,8 +303,10 @@ enum GPUBindingType {
302303
"storage-buffer",
303304
"readonly-storage-buffer",
304305
"sampler",
306+
"comparison-sampler",
305307
"sampled-texture",
306-
"storage-texture"
308+
"readonly-storage-texture",
309+
"writeonly-storage-texture"
307310
// TODO: other binding types
308311
};
309312

@@ -313,12 +316,12 @@ GPUBindGroup includes GPUObjectBase;
313316

314317
dictionary GPUBindGroupDescriptor : GPUObjectDescriptorBase {
315318
required GPUBindGroupLayout layout;
316-
required sequence<GPUBindGroupBinding> bindings;
319+
required sequence<GPUBindGroupEntry> bindings;
317320
};
318321

319322
typedef (GPUSampler or GPUTextureView or GPUBufferBinding) GPUBindingResource;
320323

321-
dictionary GPUBindGroupBinding {
324+
dictionary GPUBindGroupEntry {
322325
required GPUIndex32 binding;
323326
required GPUBindingResource resource;
324327
};
@@ -342,10 +345,8 @@ interface GPUShaderModule {
342345
};
343346
GPUShaderModule includes GPUObjectBase;
344347

345-
typedef (Uint32Array or DOMString) GPUShaderCode;
346-
347348
dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase {
348-
required GPUShaderCode code;
349+
required DOMString code;
349350
};
350351

351352
dictionary GPUPipelineDescriptorBase : GPUObjectDescriptorBase {
@@ -604,7 +605,7 @@ dictionary GPUBufferCopyView {
604605
required GPUBuffer buffer;
605606
GPUSize64 offset = 0;
606607
required GPUSize32 rowPitch;
607-
required GPUSize32 imageHeight;
608+
GPUSize32 imageHeight = 0;
608609
};
609610

610611
dictionary GPUTextureCopyView {

0 commit comments

Comments
 (0)