From 8ae39bb25ae9639e086d3da2d71c8a2d5d011377 Mon Sep 17 00:00:00 2001 From: Joshua Groves Date: Tue, 10 Mar 2020 00:06:16 -0230 Subject: [PATCH] Update to latest WebGPU WebIDL --- crates/web-sys/Cargo.toml | 4 +- ...oupBinding.rs => gen_GpuBindGroupEntry.rs} | 18 ++--- ...ding.rs => gen_GpuBindGroupLayoutEntry.rs} | 66 ++++++++++++------- .../src/features/gen_GpuBindingType.rs | 4 +- .../src/features/gen_GpuBufferCopyView.rs | 3 +- .../features/gen_GpuShaderModuleDescriptor.rs | 4 +- crates/web-sys/src/features/mod.rs | 24 +++---- crates/web-sys/webidls/unstable/WebGPU.webidl | 23 +++---- 8 files changed, 85 insertions(+), 61 deletions(-) rename crates/web-sys/src/features/{gen_GpuBindGroupBinding.rs => gen_GpuBindGroupEntry.rs} (89%) rename crates/web-sys/src/features/{gen_GpuBindGroupLayoutBinding.rs => gen_GpuBindGroupLayoutEntry.rs} (79%) diff --git a/crates/web-sys/Cargo.toml b/crates/web-sys/Cargo.toml index 3499f408cd4..992154b0b44 100644 --- a/crates/web-sys/Cargo.toml +++ b/crates/web-sys/Cargo.toml @@ -381,11 +381,11 @@ Gpu = [] GpuAdapter = [] GpuAddressMode = [] GpuBindGroup = [] -GpuBindGroupBinding = [] GpuBindGroupDescriptor = [] +GpuBindGroupEntry = [] GpuBindGroupLayout = [] -GpuBindGroupLayoutBinding = [] GpuBindGroupLayoutDescriptor = [] +GpuBindGroupLayoutEntry = [] GpuBindingType = [] GpuBlendDescriptor = [] GpuBlendFactor = [] diff --git a/crates/web-sys/src/features/gen_GpuBindGroupBinding.rs b/crates/web-sys/src/features/gen_GpuBindGroupEntry.rs similarity index 89% rename from crates/web-sys/src/features/gen_GpuBindGroupBinding.rs rename to crates/web-sys/src/features/gen_GpuBindGroupEntry.rs index 9d4f360553a..538b0444f88 100644 --- a/crates/web-sys/src/features/gen_GpuBindGroupBinding.rs +++ b/crates/web-sys/src/features/gen_GpuBindGroupEntry.rs @@ -4,21 +4,21 @@ use wasm_bindgen::prelude::*; #[cfg(web_sys_unstable_apis)] #[wasm_bindgen] extern "C" { - # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = GPUBindGroupBinding ) ] + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = GPUBindGroupEntry ) ] #[derive(Debug, Clone, PartialEq, Eq)] - #[doc = "The `GpuBindGroupBinding` dictionary."] + #[doc = "The `GpuBindGroupEntry` dictionary."] #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupBinding`*"] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupEntry`*"] #[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 GpuBindGroupBinding; + pub type GpuBindGroupEntry; } #[cfg(web_sys_unstable_apis)] -impl GpuBindGroupBinding { - #[doc = "Construct a new `GpuBindGroupBinding`."] +impl GpuBindGroupEntry { + #[doc = "Construct a new `GpuBindGroupEntry`."] #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupBinding`*"] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupEntry`*"] #[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)*"] @@ -32,7 +32,7 @@ impl GpuBindGroupBinding { #[cfg(web_sys_unstable_apis)] #[doc = "Change the `binding` field of this object."] #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupBinding`*"] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupEntry`*"] #[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)*"] @@ -53,7 +53,7 @@ impl GpuBindGroupBinding { #[cfg(web_sys_unstable_apis)] #[doc = "Change the `resource` field of this object."] #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupBinding`*"] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupEntry`*"] #[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)*"] diff --git a/crates/web-sys/src/features/gen_GpuBindGroupLayoutBinding.rs b/crates/web-sys/src/features/gen_GpuBindGroupLayoutEntry.rs similarity index 79% rename from crates/web-sys/src/features/gen_GpuBindGroupLayoutBinding.rs rename to crates/web-sys/src/features/gen_GpuBindGroupLayoutEntry.rs index 99442e738e5..2963b876979 100644 --- a/crates/web-sys/src/features/gen_GpuBindGroupLayoutBinding.rs +++ b/crates/web-sys/src/features/gen_GpuBindGroupLayoutEntry.rs @@ -4,22 +4,22 @@ use wasm_bindgen::prelude::*; #[cfg(web_sys_unstable_apis)] #[wasm_bindgen] extern "C" { - # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = GPUBindGroupLayoutBinding ) ] + # [ wasm_bindgen ( extends = :: js_sys :: Object , js_name = GPUBindGroupLayoutEntry ) ] #[derive(Debug, Clone, PartialEq, Eq)] - #[doc = "The `GpuBindGroupLayoutBinding` dictionary."] + #[doc = "The `GpuBindGroupLayoutEntry` dictionary."] #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`*"] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`*"] #[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 GpuBindGroupLayoutBinding; + pub type GpuBindGroupLayoutEntry; } #[cfg(web_sys_unstable_apis)] -impl GpuBindGroupLayoutBinding { +impl GpuBindGroupLayoutEntry { #[cfg(feature = "GpuBindingType")] - #[doc = "Construct a new `GpuBindGroupLayoutBinding`."] + #[doc = "Construct a new `GpuBindGroupLayoutEntry`."] #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`, `GpuBindingType`*"] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuBindingType`*"] #[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)*"] @@ -34,7 +34,7 @@ impl GpuBindGroupLayoutBinding { #[cfg(web_sys_unstable_apis)] #[doc = "Change the `binding` field of this object."] #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`*"] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`*"] #[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)*"] @@ -55,7 +55,7 @@ impl GpuBindGroupLayoutBinding { #[cfg(web_sys_unstable_apis)] #[doc = "Change the `hasDynamicOffset` field of this object."] #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`*"] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`*"] #[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)*"] @@ -76,7 +76,7 @@ impl GpuBindGroupLayoutBinding { #[cfg(web_sys_unstable_apis)] #[doc = "Change the `multisampled` field of this object."] #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`*"] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`*"] #[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)*"] @@ -95,18 +95,18 @@ impl GpuBindGroupLayoutBinding { self } #[cfg(web_sys_unstable_apis)] - #[cfg(feature = "GpuTextureComponentType")] - #[doc = "Change the `textureComponentType` field of this object."] + #[cfg(feature = "GpuTextureFormat")] + #[doc = "Change the `storageTextureFormat` field of this object."] #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`, `GpuTextureComponentType`*"] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuTextureFormat`*"] #[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 texture_component_type(&mut self, val: GpuTextureComponentType) -> &mut Self { + pub fn storage_texture_format(&mut self, val: GpuTextureFormat) -> &mut Self { use wasm_bindgen::JsValue; let r = ::js_sys::Reflect::set( self.as_ref(), - &JsValue::from("textureComponentType"), + &JsValue::from("storageTextureFormat"), &JsValue::from(val), ); debug_assert!( @@ -117,18 +117,18 @@ impl GpuBindGroupLayoutBinding { self } #[cfg(web_sys_unstable_apis)] - #[cfg(feature = "GpuTextureViewDimension")] - #[doc = "Change the `textureDimension` field of this object."] + #[cfg(feature = "GpuTextureComponentType")] + #[doc = "Change the `textureComponentType` field of this object."] #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`, `GpuTextureViewDimension`*"] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuTextureComponentType`*"] #[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 texture_dimension(&mut self, val: GpuTextureViewDimension) -> &mut Self { + pub fn texture_component_type(&mut self, val: GpuTextureComponentType) -> &mut Self { use wasm_bindgen::JsValue; let r = ::js_sys::Reflect::set( self.as_ref(), - &JsValue::from("textureDimension"), + &JsValue::from("textureComponentType"), &JsValue::from(val), ); debug_assert!( @@ -142,7 +142,7 @@ impl GpuBindGroupLayoutBinding { #[cfg(feature = "GpuBindingType")] #[doc = "Change the `type` field of this object."] #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`, `GpuBindingType`*"] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuBindingType`*"] #[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)*"] @@ -157,9 +157,31 @@ impl GpuBindGroupLayoutBinding { self } #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "GpuTextureViewDimension")] + #[doc = "Change the `viewDimension` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuTextureViewDimension`*"] + #[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 view_dimension(&mut self, val: GpuTextureViewDimension) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("viewDimension"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] #[doc = "Change the `visibility` field of this object."] #[doc = ""] - #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutBinding`*"] + #[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`*"] #[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)*"] diff --git a/crates/web-sys/src/features/gen_GpuBindingType.rs b/crates/web-sys/src/features/gen_GpuBindingType.rs index 6b5aec7c218..72bcd3ac1f7 100644 --- a/crates/web-sys/src/features/gen_GpuBindingType.rs +++ b/crates/web-sys/src/features/gen_GpuBindingType.rs @@ -14,6 +14,8 @@ pub enum GpuBindingType { StorageBuffer = "storage-buffer", ReadonlyStorageBuffer = "readonly-storage-buffer", Sampler = "sampler", + ComparisonSampler = "comparison-sampler", SampledTexture = "sampled-texture", - StorageTexture = "storage-texture", + ReadonlyStorageTexture = "readonly-storage-texture", + WriteonlyStorageTexture = "writeonly-storage-texture", } diff --git a/crates/web-sys/src/features/gen_GpuBufferCopyView.rs b/crates/web-sys/src/features/gen_GpuBufferCopyView.rs index 0d445f4f60a..6d956dade43 100644 --- a/crates/web-sys/src/features/gen_GpuBufferCopyView.rs +++ b/crates/web-sys/src/features/gen_GpuBufferCopyView.rs @@ -23,11 +23,10 @@ impl GpuBufferCopyView { #[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(buffer: &GpuBuffer, image_height: u32, row_pitch: u32) -> Self { + pub fn new(buffer: &GpuBuffer, row_pitch: u32) -> Self { #[allow(unused_mut)] let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); ret.buffer(buffer); - ret.image_height(image_height); ret.row_pitch(row_pitch); ret } diff --git a/crates/web-sys/src/features/gen_GpuShaderModuleDescriptor.rs b/crates/web-sys/src/features/gen_GpuShaderModuleDescriptor.rs index 313707c8a57..bf6a4cfeff4 100644 --- a/crates/web-sys/src/features/gen_GpuShaderModuleDescriptor.rs +++ b/crates/web-sys/src/features/gen_GpuShaderModuleDescriptor.rs @@ -22,7 +22,7 @@ impl GpuShaderModuleDescriptor { #[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(code: &::wasm_bindgen::JsValue) -> Self { + pub fn new(code: &str) -> Self { #[allow(unused_mut)] let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); ret.code(code); @@ -52,7 +52,7 @@ impl GpuShaderModuleDescriptor { #[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 code(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + pub fn code(&mut self, val: &str) -> &mut Self { use wasm_bindgen::JsValue; let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("code"), &JsValue::from(val)); debug_assert!( diff --git a/crates/web-sys/src/features/mod.rs b/crates/web-sys/src/features/mod.rs index 98c701fec5f..183ec46ae3d 100644 --- a/crates/web-sys/src/features/mod.rs +++ b/crates/web-sys/src/features/mod.rs @@ -2104,36 +2104,36 @@ mod gen_GpuBindGroup; #[cfg(feature = "GpuBindGroup")] pub use gen_GpuBindGroup::*; -#[cfg(feature = "GpuBindGroupBinding")] -#[allow(non_snake_case)] -mod gen_GpuBindGroupBinding; -#[cfg(feature = "GpuBindGroupBinding")] -pub use gen_GpuBindGroupBinding::*; - #[cfg(feature = "GpuBindGroupDescriptor")] #[allow(non_snake_case)] mod gen_GpuBindGroupDescriptor; #[cfg(feature = "GpuBindGroupDescriptor")] pub use gen_GpuBindGroupDescriptor::*; +#[cfg(feature = "GpuBindGroupEntry")] +#[allow(non_snake_case)] +mod gen_GpuBindGroupEntry; +#[cfg(feature = "GpuBindGroupEntry")] +pub use gen_GpuBindGroupEntry::*; + #[cfg(feature = "GpuBindGroupLayout")] #[allow(non_snake_case)] mod gen_GpuBindGroupLayout; #[cfg(feature = "GpuBindGroupLayout")] pub use gen_GpuBindGroupLayout::*; -#[cfg(feature = "GpuBindGroupLayoutBinding")] -#[allow(non_snake_case)] -mod gen_GpuBindGroupLayoutBinding; -#[cfg(feature = "GpuBindGroupLayoutBinding")] -pub use gen_GpuBindGroupLayoutBinding::*; - #[cfg(feature = "GpuBindGroupLayoutDescriptor")] #[allow(non_snake_case)] mod gen_GpuBindGroupLayoutDescriptor; #[cfg(feature = "GpuBindGroupLayoutDescriptor")] pub use gen_GpuBindGroupLayoutDescriptor::*; +#[cfg(feature = "GpuBindGroupLayoutEntry")] +#[allow(non_snake_case)] +mod gen_GpuBindGroupLayoutEntry; +#[cfg(feature = "GpuBindGroupLayoutEntry")] +pub use gen_GpuBindGroupLayoutEntry::*; + #[cfg(feature = "GpuBindingType")] #[allow(non_snake_case)] mod gen_GpuBindingType; diff --git a/crates/web-sys/webidls/unstable/WebGPU.webidl b/crates/web-sys/webidls/unstable/WebGPU.webidl index b8fdf379f3c..b18b676de9e 100644 --- a/crates/web-sys/webidls/unstable/WebGPU.webidl +++ b/crates/web-sys/webidls/unstable/WebGPU.webidl @@ -246,7 +246,7 @@ dictionary GPUSamplerDescriptor : GPUObjectDescriptorBase { GPUFilterMode mipmapFilter = "nearest"; float lodMinClamp = 0; float lodMaxClamp = 0xffffffff; // TODO: What should this be? Was Number.MAX_VALUE. - GPUCompareFunction compare = "never"; + GPUCompareFunction compare; }; enum GPUAddressMode { @@ -277,17 +277,18 @@ interface GPUBindGroupLayout { GPUBindGroupLayout includes GPUObjectBase; dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase { - required sequence bindings; + required sequence bindings; }; -dictionary GPUBindGroupLayoutBinding { +dictionary GPUBindGroupLayoutEntry { required GPUIndex32 binding; required GPUShaderStageFlags visibility; required GPUBindingType type; - GPUTextureViewDimension textureDimension = "2d"; + GPUTextureViewDimension viewDimension = "2d"; GPUTextureComponentType textureComponentType = "float"; boolean multisampled = false; boolean hasDynamicOffset = false; + GPUTextureFormat storageTextureFormat; }; typedef [EnforceRange] unsigned long GPUShaderStageFlags; @@ -302,8 +303,10 @@ enum GPUBindingType { "storage-buffer", "readonly-storage-buffer", "sampler", + "comparison-sampler", "sampled-texture", - "storage-texture" + "readonly-storage-texture", + "writeonly-storage-texture" // TODO: other binding types }; @@ -313,12 +316,12 @@ GPUBindGroup includes GPUObjectBase; dictionary GPUBindGroupDescriptor : GPUObjectDescriptorBase { required GPUBindGroupLayout layout; - required sequence bindings; + required sequence bindings; }; typedef (GPUSampler or GPUTextureView or GPUBufferBinding) GPUBindingResource; -dictionary GPUBindGroupBinding { +dictionary GPUBindGroupEntry { required GPUIndex32 binding; required GPUBindingResource resource; }; @@ -342,10 +345,8 @@ interface GPUShaderModule { }; GPUShaderModule includes GPUObjectBase; -typedef (Uint32Array or DOMString) GPUShaderCode; - dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase { - required GPUShaderCode code; + required DOMString code; }; dictionary GPUPipelineDescriptorBase : GPUObjectDescriptorBase { @@ -604,7 +605,7 @@ dictionary GPUBufferCopyView { required GPUBuffer buffer; GPUSize64 offset = 0; required GPUSize32 rowPitch; - required GPUSize32 imageHeight; + GPUSize32 imageHeight = 0; }; dictionary GPUTextureCopyView {