From 5c28993bec755386a92d635162cd5a17cad653f5 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Tue, 6 Sep 2022 08:38:25 +0200 Subject: [PATCH] Update WebGPU's webidl (#3067) --- crates/web-sys/src/features/gen_GpuBuffer.rs | 12 ++++ .../src/features/gen_GpuBufferMapState.rs | 16 +++++ .../src/features/gen_GpuErrorFilter.rs | 3 +- .../src/features/gen_GpuFeatureName.rs | 1 + .../src/features/gen_GpuInternalError.rs | 29 ++++++++ .../src/features/gen_GpuSupportedLimits.rs | 33 +++++++++ crates/web-sys/src/features/mod.rs | 12 ++++ crates/web-sys/webidls/unstable/WebGPU.webidl | 69 ++++++++++++------- 8 files changed, 149 insertions(+), 26 deletions(-) create mode 100644 crates/web-sys/src/features/gen_GpuBufferMapState.rs create mode 100644 crates/web-sys/src/features/gen_GpuInternalError.rs diff --git a/crates/web-sys/src/features/gen_GpuBuffer.rs b/crates/web-sys/src/features/gen_GpuBuffer.rs index 0536da1a77e..ce58b85dfd1 100644 --- a/crates/web-sys/src/features/gen_GpuBuffer.rs +++ b/crates/web-sys/src/features/gen_GpuBuffer.rs @@ -38,6 +38,18 @@ extern "C" { #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn usage(this: &GpuBuffer) -> u32; #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "GpuBufferMapState")] + # [wasm_bindgen (structural , method , getter , js_class = "GPUBuffer" , js_name = mapState)] + #[doc = "Getter for the `mapState` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer/mapState)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBuffer`, `GpuBufferMapState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn map_state(this: &GpuBuffer) -> GpuBufferMapState; + #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (structural , method , getter , js_class = "GPUBuffer" , js_name = label)] #[doc = "Getter for the `label` field of this object."] #[doc = ""] diff --git a/crates/web-sys/src/features/gen_GpuBufferMapState.rs b/crates/web-sys/src/features/gen_GpuBufferMapState.rs new file mode 100644 index 00000000000..26bb64a842d --- /dev/null +++ b/crates/web-sys/src/features/gen_GpuBufferMapState.rs @@ -0,0 +1,16 @@ +#![allow(unused_imports)] +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +#[doc = "The `GpuBufferMapState` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `GpuBufferMapState`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GpuBufferMapState { + Unmapped = "unmapped", + Pending = "pending", + Mapped = "mapped", +} diff --git a/crates/web-sys/src/features/gen_GpuErrorFilter.rs b/crates/web-sys/src/features/gen_GpuErrorFilter.rs index 9c84cc776ed..36244a057e1 100644 --- a/crates/web-sys/src/features/gen_GpuErrorFilter.rs +++ b/crates/web-sys/src/features/gen_GpuErrorFilter.rs @@ -10,6 +10,7 @@ use wasm_bindgen::prelude::*; #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum GpuErrorFilter { - OutOfMemory = "out-of-memory", Validation = "validation", + OutOfMemory = "out-of-memory", + Internal = "internal", } diff --git a/crates/web-sys/src/features/gen_GpuFeatureName.rs b/crates/web-sys/src/features/gen_GpuFeatureName.rs index 70537802bfc..9a34268bee1 100644 --- a/crates/web-sys/src/features/gen_GpuFeatureName.rs +++ b/crates/web-sys/src/features/gen_GpuFeatureName.rs @@ -19,4 +19,5 @@ pub enum GpuFeatureName { IndirectFirstInstance = "indirect-first-instance", ShaderF16 = "shader-f16", Bgra8unormStorage = "bgra8unorm-storage", + Rg11b10ufloatRenderable = "rg11b10ufloat-renderable", } diff --git a/crates/web-sys/src/features/gen_GpuInternalError.rs b/crates/web-sys/src/features/gen_GpuInternalError.rs new file mode 100644 index 00000000000..3625b54dda9 --- /dev/null +++ b/crates/web-sys/src/features/gen_GpuInternalError.rs @@ -0,0 +1,29 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = GpuError , extends = :: js_sys :: Object , js_name = GPUInternalError , typescript_type = "GPUInternalError")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `GpuInternalError` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUInternalError)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuInternalError`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type GpuInternalError; + #[cfg(web_sys_unstable_apis)] + #[wasm_bindgen(catch, constructor, js_class = "GPUInternalError")] + #[doc = "The `new GpuInternalError(..)` constructor, creating a new instance of `GpuInternalError`."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUInternalError/GPUInternalError)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuInternalError`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(message: &str) -> Result; +} diff --git a/crates/web-sys/src/features/gen_GpuSupportedLimits.rs b/crates/web-sys/src/features/gen_GpuSupportedLimits.rs index 80b94bb75b8..4751a20211e 100644 --- a/crates/web-sys/src/features/gen_GpuSupportedLimits.rs +++ b/crates/web-sys/src/features/gen_GpuSupportedLimits.rs @@ -71,6 +71,17 @@ extern "C" { #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn max_bind_groups(this: &GpuSupportedLimits) -> u32; #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxBindingsPerBindGroup)] + #[doc = "Getter for the `maxBindingsPerBindGroup` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxBindingsPerBindGroup)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_bindings_per_bind_group(this: &GpuSupportedLimits) -> u32; + #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxDynamicUniformBuffersPerPipelineLayout)] #[doc = "Getter for the `maxDynamicUniformBuffersPerPipelineLayout` field of this object."] #[doc = ""] @@ -203,6 +214,17 @@ extern "C" { #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn max_vertex_buffers(this: &GpuSupportedLimits) -> u32; #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxBufferSize)] + #[doc = "Getter for the `maxBufferSize` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxBufferSize)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_buffer_size(this: &GpuSupportedLimits) -> f64; + #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxVertexAttributes)] #[doc = "Getter for the `maxVertexAttributes` field of this object."] #[doc = ""] @@ -258,6 +280,17 @@ extern "C" { #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn max_color_attachments(this: &GpuSupportedLimits) -> u32; #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxColorAttachmentBytesPerPixel)] + #[doc = "Getter for the `maxColorAttachmentBytesPerPixel` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUSupportedLimits/maxColorAttachmentBytesPerPixel)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuSupportedLimits`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn max_color_attachment_bytes_per_pixel(this: &GpuSupportedLimits) -> u32; + #[cfg(web_sys_unstable_apis)] # [wasm_bindgen (structural , method , getter , js_class = "GPUSupportedLimits" , js_name = maxComputeWorkgroupStorageSize)] #[doc = "Getter for the `maxComputeWorkgroupStorageSize` field of this object."] #[doc = ""] diff --git a/crates/web-sys/src/features/mod.rs b/crates/web-sys/src/features/mod.rs index dfb2a94cac1..02b8f667c27 100644 --- a/crates/web-sys/src/features/mod.rs +++ b/crates/web-sys/src/features/mod.rs @@ -2488,6 +2488,12 @@ mod gen_GpuBufferDescriptor; #[cfg(feature = "GpuBufferDescriptor")] pub use gen_GpuBufferDescriptor::*; +#[cfg(feature = "GpuBufferMapState")] +#[allow(non_snake_case)] +mod gen_GpuBufferMapState; +#[cfg(feature = "GpuBufferMapState")] +pub use gen_GpuBufferMapState::*; + #[cfg(feature = "GpuCanvasAlphaMode")] #[allow(non_snake_case)] mod gen_GpuCanvasAlphaMode; @@ -2734,6 +2740,12 @@ mod gen_GpuIndexFormat; #[cfg(feature = "GpuIndexFormat")] pub use gen_GpuIndexFormat::*; +#[cfg(feature = "GpuInternalError")] +#[allow(non_snake_case)] +mod gen_GpuInternalError; +#[cfg(feature = "GpuInternalError")] +pub use gen_GpuInternalError::*; + #[cfg(feature = "GpuLoadOp")] #[allow(non_snake_case)] mod gen_GpuLoadOp; diff --git a/crates/web-sys/webidls/unstable/WebGPU.webidl b/crates/web-sys/webidls/unstable/WebGPU.webidl index 689d7fdbfcb..e481dd5d9c8 100644 --- a/crates/web-sys/webidls/unstable/WebGPU.webidl +++ b/crates/web-sys/webidls/unstable/WebGPU.webidl @@ -13,6 +13,7 @@ interface GPUSupportedLimits { readonly attribute unsigned long maxTextureDimension3D; readonly attribute unsigned long maxTextureArrayLayers; readonly attribute unsigned long maxBindGroups; + readonly attribute unsigned long maxBindingsPerBindGroup; readonly attribute unsigned long maxDynamicUniformBuffersPerPipelineLayout; readonly attribute unsigned long maxDynamicStorageBuffersPerPipelineLayout; readonly attribute unsigned long maxSampledTexturesPerShaderStage; @@ -25,11 +26,13 @@ interface GPUSupportedLimits { readonly attribute unsigned long minUniformBufferOffsetAlignment; readonly attribute unsigned long minStorageBufferOffsetAlignment; readonly attribute unsigned long maxVertexBuffers; + readonly attribute unsigned long long maxBufferSize; readonly attribute unsigned long maxVertexAttributes; readonly attribute unsigned long maxVertexBufferArrayStride; readonly attribute unsigned long maxInterStageShaderComponents; readonly attribute unsigned long maxInterStageShaderVariables; readonly attribute unsigned long maxColorAttachments; + readonly attribute unsigned long maxColorAttachmentBytesPerPixel; readonly attribute unsigned long maxComputeWorkgroupStorageSize; readonly attribute unsigned long maxComputeInvocationsPerWorkgroup; readonly attribute unsigned long maxComputeWorkgroupSizeX; @@ -45,10 +48,10 @@ interface GPUSupportedFeatures { [Exposed=(Window, DedicatedWorker), SecureContext] interface GPUAdapterInfo { - readonly attribute DOMString vendor; - readonly attribute DOMString architecture; - readonly attribute DOMString device; - readonly attribute DOMString description; + readonly attribute DOMString vendor; + readonly attribute DOMString architecture; + readonly attribute DOMString device; + readonly attribute DOMString description; }; interface mixin NavigatorGPU { @@ -98,7 +101,8 @@ enum GPUFeatureName { "timestamp-query", "indirect-first-instance", "shader-f16", - "bgra8unorm-storage" + "bgra8unorm-storage", + "rg11b10ufloat-renderable" }; [Exposed=(Window, DedicatedWorker), SecureContext] @@ -134,17 +138,25 @@ GPUDevice includes GPUObjectBase; [Exposed=(Window, DedicatedWorker), SecureContext] interface GPUBuffer { + readonly attribute GPUSize64 size; + readonly attribute GPUBufferUsageFlags usage; + + readonly attribute GPUBufferMapState mapState; + Promise mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size); ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size); undefined unmap(); undefined destroy(); - - readonly attribute GPUSize64 size; - readonly attribute GPUBufferUsageFlags usage; }; GPUBuffer includes GPUObjectBase; +enum GPUBufferMapState { + "unmapped", + "pending", + "mapped" +}; + dictionary GPUBufferDescriptor : GPUObjectDescriptorBase { required GPUSize64 size; required GPUBufferUsageFlags usage; @@ -889,12 +901,12 @@ dictionary GPUImageCopyExternalImage { interface mixin GPUBindingCommandsMixin { undefined setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup, - optional sequence dynamicOffsets = []); + optional sequence dynamicOffsets = []); undefined setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup, - Uint32Array dynamicOffsetsData, - GPUSize64 dynamicOffsetsDataStart, - GPUSize32 dynamicOffsetsDataLength); + Uint32Array dynamicOffsetsData, + GPUSize64 dynamicOffsetsDataStart, + GPUSize32 dynamicOffsetsDataLength); }; interface mixin GPUDebugCommandsMixin { @@ -936,8 +948,8 @@ dictionary GPUComputePassDescriptor : GPUObjectDescriptorBase { [Exposed=(Window, DedicatedWorker), SecureContext] interface GPURenderPassEncoder { undefined setViewport(float x, float y, - float width, float height, - float minDepth, float maxDepth); + float width, float height, + float minDepth, float maxDepth); undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y, GPUIntegerCoordinate width, GPUIntegerCoordinate height); @@ -1024,11 +1036,11 @@ interface mixin GPURenderCommandsMixin { undefined setVertexBuffer(GPUIndex32 slot, GPUBuffer buffer, optional GPUSize64 offset = 0, optional GPUSize64 size); undefined draw(GPUSize32 vertexCount, optional GPUSize32 instanceCount = 1, - optional GPUSize32 firstVertex = 0, optional GPUSize32 firstInstance = 0); + optional GPUSize32 firstVertex = 0, optional GPUSize32 firstInstance = 0); undefined drawIndexed(GPUSize32 indexCount, optional GPUSize32 instanceCount = 1, - optional GPUSize32 firstIndex = 0, - optional GPUSignedOffset32 baseVertex = 0, - optional GPUSize32 firstInstance = 0); + optional GPUSize32 firstIndex = 0, + optional GPUSignedOffset32 baseVertex = 0, + optional GPUSize32 firstInstance = 0); undefined drawIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); @@ -1143,26 +1155,32 @@ partial interface GPUDevice { readonly attribute Promise lost; }; -enum GPUErrorFilter { - "out-of-memory", - "validation" -}; - [Exposed=(Window, DedicatedWorker), SecureContext] interface GPUError { readonly attribute DOMString message; }; +[Exposed=(Window, DedicatedWorker), SecureContext] +interface GPUValidationError : GPUError { + constructor(DOMString message); +}; + [Exposed=(Window, DedicatedWorker), SecureContext] interface GPUOutOfMemoryError : GPUError { constructor(DOMString message); }; [Exposed=(Window, DedicatedWorker), SecureContext] -interface GPUValidationError : GPUError { +interface GPUInternalError : GPUError { constructor(DOMString message); }; +enum GPUErrorFilter { + "validation", + "out-of-memory", + "internal" +}; + partial interface GPUDevice { undefined pushErrorScope(GPUErrorFilter filter); Promise popErrorScope(); @@ -1174,7 +1192,7 @@ interface GPUUncapturedErrorEvent : Event { DOMString type, GPUUncapturedErrorEventInit gpuUncapturedErrorEventInitDict ); - readonly attribute GPUError error; + [SameObject] readonly attribute GPUError error; }; dictionary GPUUncapturedErrorEventInit : EventInit { @@ -1226,3 +1244,4 @@ dictionary GPUExtent3DDict { GPUIntegerCoordinate depthOrArrayLayers = 1; }; typedef (sequence or GPUExtent3DDict) GPUExtent3D; +