Skip to content

Commit a955368

Browse files
authored
Update WebGPU API to draft 2024-11-22 (#4290)
1 parent ee7a6b5 commit a955368

15 files changed

+332
-254
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
* Deprecated `#[wasm_bindgen(thread_local)]` in favor of `#[wasm_bindgen(thread_local_v2)]`, which creates a `wasm_bindgen::JsThreadLocal`. It is similar to `std::thread::LocalKey` but supports `no_std`.
5656
[#4277](https://github.com/rustwasm/wasm-bindgen/pull/4277)
5757

58+
* Updated the WebGPU API to the current draft as of 2024-11-22.
59+
[#4290](https://github.com/rustwasm/wasm-bindgen/pull/4290)
60+
5861
### Fixed
5962

6063
* Fixed methods with `self: &Self` consuming the object.

crates/web-sys/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,8 @@ GpuComputePassEncoder = []
520520
GpuComputePassTimestampWrites = []
521521
GpuComputePipeline = []
522522
GpuComputePipelineDescriptor = []
523+
GpuCopyExternalImageDestInfo = []
524+
GpuCopyExternalImageSourceInfo = []
523525
GpuCullMode = []
524526
GpuDepthStencilState = []
525527
GpuDevice = ["EventTarget"]
@@ -536,11 +538,6 @@ GpuFeatureName = []
536538
GpuFilterMode = []
537539
GpuFragmentState = []
538540
GpuFrontFace = []
539-
GpuImageCopyBuffer = []
540-
GpuImageCopyExternalImage = []
541-
GpuImageCopyTexture = []
542-
GpuImageCopyTextureTagged = []
543-
GpuImageDataLayout = []
544541
GpuIndexFormat = []
545542
GpuInternalError = ["GpuError"]
546543
GpuLoadOp = []
@@ -592,6 +589,9 @@ GpuStorageTextureBindingLayout = []
592589
GpuStoreOp = []
593590
GpuSupportedFeatures = []
594591
GpuSupportedLimits = []
592+
GpuTexelCopyBufferInfo = []
593+
GpuTexelCopyBufferLayout = []
594+
GpuTexelCopyTextureInfo = []
595595
GpuTexture = []
596596
GpuTextureAspect = []
597597
GpuTextureBindingLayout = []

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

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ extern "C" {
189189
);
190190
#[cfg(web_sys_unstable_apis)]
191191
#[cfg(feature = "GpuBuffer")]
192-
# [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
192+
# [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
193193
#[doc = "The `copyBufferToBuffer()` method."]
194194
#[doc = ""]
195195
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"]
@@ -205,10 +205,10 @@ extern "C" {
205205
destination: &GpuBuffer,
206206
destination_offset: u32,
207207
size: u32,
208-
);
208+
) -> Result<(), JsValue>;
209209
#[cfg(web_sys_unstable_apis)]
210210
#[cfg(feature = "GpuBuffer")]
211-
# [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
211+
# [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
212212
#[doc = "The `copyBufferToBuffer()` method."]
213213
#[doc = ""]
214214
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"]
@@ -224,10 +224,10 @@ extern "C" {
224224
destination: &GpuBuffer,
225225
destination_offset: u32,
226226
size: u32,
227-
);
227+
) -> Result<(), JsValue>;
228228
#[cfg(web_sys_unstable_apis)]
229229
#[cfg(feature = "GpuBuffer")]
230-
# [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
230+
# [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
231231
#[doc = "The `copyBufferToBuffer()` method."]
232232
#[doc = ""]
233233
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"]
@@ -243,10 +243,10 @@ extern "C" {
243243
destination: &GpuBuffer,
244244
destination_offset: f64,
245245
size: u32,
246-
);
246+
) -> Result<(), JsValue>;
247247
#[cfg(web_sys_unstable_apis)]
248248
#[cfg(feature = "GpuBuffer")]
249-
# [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
249+
# [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
250250
#[doc = "The `copyBufferToBuffer()` method."]
251251
#[doc = ""]
252252
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"]
@@ -262,10 +262,10 @@ extern "C" {
262262
destination: &GpuBuffer,
263263
destination_offset: f64,
264264
size: u32,
265-
);
265+
) -> Result<(), JsValue>;
266266
#[cfg(web_sys_unstable_apis)]
267267
#[cfg(feature = "GpuBuffer")]
268-
# [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
268+
# [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
269269
#[doc = "The `copyBufferToBuffer()` method."]
270270
#[doc = ""]
271271
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"]
@@ -281,10 +281,10 @@ extern "C" {
281281
destination: &GpuBuffer,
282282
destination_offset: u32,
283283
size: f64,
284-
);
284+
) -> Result<(), JsValue>;
285285
#[cfg(web_sys_unstable_apis)]
286286
#[cfg(feature = "GpuBuffer")]
287-
# [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
287+
# [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
288288
#[doc = "The `copyBufferToBuffer()` method."]
289289
#[doc = ""]
290290
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"]
@@ -300,10 +300,10 @@ extern "C" {
300300
destination: &GpuBuffer,
301301
destination_offset: u32,
302302
size: f64,
303-
);
303+
) -> Result<(), JsValue>;
304304
#[cfg(web_sys_unstable_apis)]
305305
#[cfg(feature = "GpuBuffer")]
306-
# [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
306+
# [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
307307
#[doc = "The `copyBufferToBuffer()` method."]
308308
#[doc = ""]
309309
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"]
@@ -319,10 +319,10 @@ extern "C" {
319319
destination: &GpuBuffer,
320320
destination_offset: f64,
321321
size: f64,
322-
);
322+
) -> Result<(), JsValue>;
323323
#[cfg(web_sys_unstable_apis)]
324324
#[cfg(feature = "GpuBuffer")]
325-
# [wasm_bindgen (method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
325+
# [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToBuffer)]
326326
#[doc = "The `copyBufferToBuffer()` method."]
327327
#[doc = ""]
328328
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToBuffer)"]
@@ -338,115 +338,121 @@ extern "C" {
338338
destination: &GpuBuffer,
339339
destination_offset: f64,
340340
size: f64,
341-
);
341+
) -> Result<(), JsValue>;
342342
#[cfg(web_sys_unstable_apis)]
343-
#[cfg(all(feature = "GpuImageCopyBuffer", feature = "GpuImageCopyTexture",))]
343+
#[cfg(all(
344+
feature = "GpuTexelCopyBufferInfo",
345+
feature = "GpuTexelCopyTextureInfo",
346+
))]
344347
# [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToTexture)]
345348
#[doc = "The `copyBufferToTexture()` method."]
346349
#[doc = ""]
347350
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToTexture)"]
348351
#[doc = ""]
349-
#[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuImageCopyBuffer`, `GpuImageCopyTexture`*"]
352+
#[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuTexelCopyBufferInfo`, `GpuTexelCopyTextureInfo`*"]
350353
#[doc = ""]
351354
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
352355
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
353356
pub fn copy_buffer_to_texture_with_u32_sequence(
354357
this: &GpuCommandEncoder,
355-
source: &GpuImageCopyBuffer,
356-
destination: &GpuImageCopyTexture,
358+
source: &GpuTexelCopyBufferInfo,
359+
destination: &GpuTexelCopyTextureInfo,
357360
copy_size: &::wasm_bindgen::JsValue,
358361
) -> Result<(), JsValue>;
359362
#[cfg(web_sys_unstable_apis)]
360363
#[cfg(all(
361364
feature = "GpuExtent3dDict",
362-
feature = "GpuImageCopyBuffer",
363-
feature = "GpuImageCopyTexture",
365+
feature = "GpuTexelCopyBufferInfo",
366+
feature = "GpuTexelCopyTextureInfo",
364367
))]
365368
# [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyBufferToTexture)]
366369
#[doc = "The `copyBufferToTexture()` method."]
367370
#[doc = ""]
368371
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyBufferToTexture)"]
369372
#[doc = ""]
370-
#[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuExtent3dDict`, `GpuImageCopyBuffer`, `GpuImageCopyTexture`*"]
373+
#[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuExtent3dDict`, `GpuTexelCopyBufferInfo`, `GpuTexelCopyTextureInfo`*"]
371374
#[doc = ""]
372375
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
373376
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
374377
pub fn copy_buffer_to_texture_with_gpu_extent_3d_dict(
375378
this: &GpuCommandEncoder,
376-
source: &GpuImageCopyBuffer,
377-
destination: &GpuImageCopyTexture,
379+
source: &GpuTexelCopyBufferInfo,
380+
destination: &GpuTexelCopyTextureInfo,
378381
copy_size: &GpuExtent3dDict,
379382
) -> Result<(), JsValue>;
380383
#[cfg(web_sys_unstable_apis)]
381-
#[cfg(all(feature = "GpuImageCopyBuffer", feature = "GpuImageCopyTexture",))]
384+
#[cfg(all(
385+
feature = "GpuTexelCopyBufferInfo",
386+
feature = "GpuTexelCopyTextureInfo",
387+
))]
382388
# [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToBuffer)]
383389
#[doc = "The `copyTextureToBuffer()` method."]
384390
#[doc = ""]
385391
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyTextureToBuffer)"]
386392
#[doc = ""]
387-
#[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuImageCopyBuffer`, `GpuImageCopyTexture`*"]
393+
#[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuTexelCopyBufferInfo`, `GpuTexelCopyTextureInfo`*"]
388394
#[doc = ""]
389395
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
390396
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
391397
pub fn copy_texture_to_buffer_with_u32_sequence(
392398
this: &GpuCommandEncoder,
393-
source: &GpuImageCopyTexture,
394-
destination: &GpuImageCopyBuffer,
399+
source: &GpuTexelCopyTextureInfo,
400+
destination: &GpuTexelCopyBufferInfo,
395401
copy_size: &::wasm_bindgen::JsValue,
396402
) -> Result<(), JsValue>;
397403
#[cfg(web_sys_unstable_apis)]
398404
#[cfg(all(
399405
feature = "GpuExtent3dDict",
400-
feature = "GpuImageCopyBuffer",
401-
feature = "GpuImageCopyTexture",
406+
feature = "GpuTexelCopyBufferInfo",
407+
feature = "GpuTexelCopyTextureInfo",
402408
))]
403409
# [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToBuffer)]
404410
#[doc = "The `copyTextureToBuffer()` method."]
405411
#[doc = ""]
406412
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyTextureToBuffer)"]
407413
#[doc = ""]
408-
#[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuExtent3dDict`, `GpuImageCopyBuffer`, `GpuImageCopyTexture`*"]
414+
#[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuExtent3dDict`, `GpuTexelCopyBufferInfo`, `GpuTexelCopyTextureInfo`*"]
409415
#[doc = ""]
410416
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
411417
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
412418
pub fn copy_texture_to_buffer_with_gpu_extent_3d_dict(
413419
this: &GpuCommandEncoder,
414-
source: &GpuImageCopyTexture,
415-
destination: &GpuImageCopyBuffer,
420+
source: &GpuTexelCopyTextureInfo,
421+
destination: &GpuTexelCopyBufferInfo,
416422
copy_size: &GpuExtent3dDict,
417423
) -> Result<(), JsValue>;
418424
#[cfg(web_sys_unstable_apis)]
419-
#[cfg(feature = "GpuImageCopyTexture")]
425+
#[cfg(feature = "GpuTexelCopyTextureInfo")]
420426
# [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToTexture)]
421427
#[doc = "The `copyTextureToTexture()` method."]
422428
#[doc = ""]
423429
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyTextureToTexture)"]
424430
#[doc = ""]
425-
#[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuImageCopyTexture`*"]
431+
#[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuTexelCopyTextureInfo`*"]
426432
#[doc = ""]
427433
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
428434
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
429435
pub fn copy_texture_to_texture_with_u32_sequence(
430436
this: &GpuCommandEncoder,
431-
source: &GpuImageCopyTexture,
432-
destination: &GpuImageCopyTexture,
437+
source: &GpuTexelCopyTextureInfo,
438+
destination: &GpuTexelCopyTextureInfo,
433439
copy_size: &::wasm_bindgen::JsValue,
434440
) -> Result<(), JsValue>;
435441
#[cfg(web_sys_unstable_apis)]
436-
#[cfg(all(feature = "GpuExtent3dDict", feature = "GpuImageCopyTexture",))]
442+
#[cfg(all(feature = "GpuExtent3dDict", feature = "GpuTexelCopyTextureInfo",))]
437443
# [wasm_bindgen (catch , method , structural , js_class = "GPUCommandEncoder" , js_name = copyTextureToTexture)]
438444
#[doc = "The `copyTextureToTexture()` method."]
439445
#[doc = ""]
440446
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCommandEncoder/copyTextureToTexture)"]
441447
#[doc = ""]
442-
#[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuExtent3dDict`, `GpuImageCopyTexture`*"]
448+
#[doc = "*This API requires the following crate features to be activated: `GpuCommandEncoder`, `GpuExtent3dDict`, `GpuTexelCopyTextureInfo`*"]
443449
#[doc = ""]
444450
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
445451
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
446452
pub fn copy_texture_to_texture_with_gpu_extent_3d_dict(
447453
this: &GpuCommandEncoder,
448-
source: &GpuImageCopyTexture,
449-
destination: &GpuImageCopyTexture,
454+
source: &GpuTexelCopyTextureInfo,
455+
destination: &GpuTexelCopyTextureInfo,
450456
copy_size: &GpuExtent3dDict,
451457
) -> Result<(), JsValue>;
452458
#[cfg(web_sys_unstable_apis)]

0 commit comments

Comments
 (0)