Skip to content

Commit

Permalink
Update to latest WebGPU WebIDL (#2596)
Browse files Browse the repository at this point in the history
  • Loading branch information
grovesNL authored Jun 22, 2021
1 parent 80da105 commit b2caf83
Show file tree
Hide file tree
Showing 31 changed files with 916 additions and 389 deletions.
17 changes: 11 additions & 6 deletions crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,6 @@ GetRootNodeOptions = []
GetUserMediaRequest = []
Gpu = []
GpuAdapter = []
GpuAdapterFeatures = []
GpuAdapterLimits = []
GpuAddressMode = []
GpuBindGroup = []
GpuBindGroupDescriptor = []
Expand All @@ -422,7 +420,7 @@ GpuBufferBindingLayout = []
GpuBufferBindingType = []
GpuBufferDescriptor = []
GpuBufferUsage = []
GpuCanvasContext = []
GpuCanvasCompositingAlphaMode = []
GpuColorDict = []
GpuColorTargetState = []
GpuColorWrite = []
Expand All @@ -446,13 +444,17 @@ GpuDeviceLostInfo = []
GpuDeviceLostReason = []
GpuErrorFilter = []
GpuExtent3dDict = []
GpuExternalTexture = []
GpuExternalTextureBindingLayout = []
GpuExternalTextureDescriptor = []
GpuFeatureName = []
GpuFilterMode = []
GpuFragmentState = []
GpuFrontFace = []
GpuImageCopyBuffer = []
GpuImageCopyImageBitmap = []
GpuImageCopyExternalImage = []
GpuImageCopyTexture = []
GpuImageCopyTextureTagged = []
GpuImageDataLayout = []
GpuIndexFormat = []
GpuInputStepMode = []
Expand All @@ -468,6 +470,9 @@ GpuPipelineLayout = []
GpuPipelineLayoutDescriptor = []
GpuPipelineStatisticName = []
GpuPowerPreference = []
GpuPredefinedColorSpace = []
GpuPresentationConfiguration = []
GpuPresentationContext = []
GpuPrimitiveState = []
GpuPrimitiveTopology = []
GpuProgrammableStage = []
Expand Down Expand Up @@ -498,8 +503,8 @@ GpuStencilOperation = []
GpuStorageTextureAccess = []
GpuStorageTextureBindingLayout = []
GpuStoreOp = []
GpuSwapChain = []
GpuSwapChainDescriptor = []
GpuSupportedFeatures = []
GpuSupportedLimits = []
GpuTexture = []
GpuTextureAspect = []
GpuTextureBindingLayout = []
Expand Down
23 changes: 17 additions & 6 deletions crates/web-sys/src/features/gen_GpuAdapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,40 @@ extern "C" {
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn name(this: &GpuAdapter) -> String;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "GpuAdapterFeatures")]
#[cfg(feature = "GpuSupportedFeatures")]
# [wasm_bindgen (structural , method , getter , js_class = "GPUAdapter" , js_name = features)]
#[doc = "Getter for the `features` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUAdapter/features)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuAdapter`, `GpuAdapterFeatures`*"]
#[doc = "*This API requires the following crate features to be activated: `GpuAdapter`, `GpuSupportedFeatures`*"]
#[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 features(this: &GpuAdapter) -> GpuAdapterFeatures;
pub fn features(this: &GpuAdapter) -> GpuSupportedFeatures;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "GpuAdapterLimits")]
#[cfg(feature = "GpuSupportedLimits")]
# [wasm_bindgen (structural , method , getter , js_class = "GPUAdapter" , js_name = limits)]
#[doc = "Getter for the `limits` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUAdapter/limits)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuAdapter`, `GpuAdapterLimits`*"]
#[doc = "*This API requires the following crate features to be activated: `GpuAdapter`, `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 limits(this: &GpuAdapter) -> GpuAdapterLimits;
pub fn limits(this: &GpuAdapter) -> GpuSupportedLimits;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "GPUAdapter" , js_name = isSoftware)]
#[doc = "Getter for the `isSoftware` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUAdapter/isSoftware)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuAdapter`*"]
#[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 is_software(this: &GpuAdapter) -> bool;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "GPUAdapter" , js_name = requestDevice)]
#[doc = "The `requestDevice()` method."]
Expand Down
22 changes: 22 additions & 0 deletions crates/web-sys/src/features/gen_GpuBindGroupLayoutEntry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,28 @@ impl GpuBindGroupLayoutEntry {
self
}
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "GpuExternalTextureBindingLayout")]
#[doc = "Change the `externalTexture` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuBindGroupLayoutEntry`, `GpuExternalTextureBindingLayout`*"]
#[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 external_texture(&mut self, val: &GpuExternalTextureBindingLayout) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("externalTexture"),
&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)]
#[cfg(feature = "GpuSamplerBindingLayout")]
#[doc = "Change the `sampler` field of this object."]
#[doc = ""]
Expand Down
12 changes: 6 additions & 6 deletions crates/web-sys/src/features/gen_GpuBlendFactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ use wasm_bindgen::prelude::*;
pub enum GpuBlendFactor {
Zero = "zero",
One = "one",
SrcColor = "src-color",
OneMinusSrcColor = "one-minus-src-color",
Src = "src",
OneMinusSrc = "one-minus-src",
SrcAlpha = "src-alpha",
OneMinusSrcAlpha = "one-minus-src-alpha",
DstColor = "dst-color",
OneMinusDstColor = "one-minus-dst-color",
Dst = "dst",
OneMinusDst = "one-minus-dst",
DstAlpha = "dst-alpha",
OneMinusDstAlpha = "one-minus-dst-alpha",
SrcAlphaSaturated = "src-alpha-saturated",
BlendColor = "blend-color",
OneMinusBlendColor = "one-minus-blend-color",
Constant = "constant",
OneMinusConstant = "one-minus-constant",
}
15 changes: 15 additions & 0 deletions crates/web-sys/src/features/gen_GpuCanvasCompositingAlphaMode.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![allow(unused_imports)]
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
#[doc = "The `GpuCanvasCompositingAlphaMode` enum."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuCanvasCompositingAlphaMode`*"]
#[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 GpuCanvasCompositingAlphaMode {
Opaque = "opaque",
Premultiplied = "premultiplied",
}
48 changes: 0 additions & 48 deletions crates/web-sys/src/features/gen_GpuCanvasContext.rs

This file was deleted.

22 changes: 22 additions & 0 deletions crates/web-sys/src/features/gen_GpuCompilationMessage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,26 @@ extern "C" {
#[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 line_pos(this: &GpuCompilationMessage) -> f64;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "GPUCompilationMessage" , js_name = offset)]
#[doc = "Getter for the `offset` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCompilationMessage/offset)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuCompilationMessage`*"]
#[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 offset(this: &GpuCompilationMessage) -> f64;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "GPUCompilationMessage" , js_name = length)]
#[doc = "Getter for the `length` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUCompilationMessage/length)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuCompilationMessage`*"]
#[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 length(this: &GpuCompilationMessage) -> f64;
}
21 changes: 0 additions & 21 deletions crates/web-sys/src/features/gen_GpuDepthStencilState.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,6 @@ impl GpuDepthStencilState {
ret
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `clampDepth` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuDepthStencilState`*"]
#[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 clamp_depth(&mut self, val: bool) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("clampDepth"),
&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 `depthBias` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuDepthStencilState`*"]
Expand Down
40 changes: 24 additions & 16 deletions crates/web-sys/src/features/gen_GpuDevice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,29 @@ extern "C" {
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub type GpuDevice;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "GpuAdapter")]
# [wasm_bindgen (structural , method , getter , js_class = "GPUDevice" , js_name = adapter)]
#[doc = "Getter for the `adapter` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/adapter)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuAdapter`, `GpuDevice`*"]
#[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 adapter(this: &GpuDevice) -> GpuAdapter;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "GpuSupportedFeatures")]
# [wasm_bindgen (structural , method , getter , js_class = "GPUDevice" , js_name = features)]
#[doc = "Getter for the `features` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/features)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuDevice`*"]
#[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuSupportedFeatures`*"]
#[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 features(this: &GpuDevice) -> ::js_sys::Array;
pub fn features(this: &GpuDevice) -> GpuSupportedFeatures;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "GpuSupportedLimits")]
# [wasm_bindgen (structural , method , getter , js_class = "GPUDevice" , js_name = limits)]
#[doc = "Getter for the `limits` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/limits)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuDevice`*"]
#[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `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 limits(this: &GpuDevice) -> ::js_sys::Object;
pub fn limits(this: &GpuDevice) -> GpuSupportedLimits;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "GpuQueue")]
# [wasm_bindgen (structural , method , getter , js_class = "GPUDevice" , js_name = queue)]
Expand Down Expand Up @@ -360,6 +350,24 @@ extern "C" {
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn destroy(this: &GpuDevice);
#[cfg(web_sys_unstable_apis)]
#[cfg(all(
feature = "GpuExternalTexture",
feature = "GpuExternalTextureDescriptor",
))]
# [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = importExternalTexture)]
#[doc = "The `importExternalTexture()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/importExternalTexture)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuDevice`, `GpuExternalTexture`, `GpuExternalTextureDescriptor`*"]
#[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 import_external_texture(
this: &GpuDevice,
descriptor: &GpuExternalTextureDescriptor,
) -> GpuExternalTexture;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "GPUDevice" , js_name = popErrorScope)]
#[doc = "The `popErrorScope()` method."]
#[doc = ""]
Expand Down
6 changes: 3 additions & 3 deletions crates/web-sys/src/features/gen_GpuDeviceDescriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ impl GpuDeviceDescriptor {
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `nonGuaranteedFeatures` field of this object."]
#[doc = "Change the `requiredFeatures` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GpuDeviceDescriptor`*"]
#[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 non_guaranteed_features(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
pub fn required_features(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("nonGuaranteedFeatures"),
&JsValue::from("requiredFeatures"),
&JsValue::from(val),
);
debug_assert!(
Expand Down
Loading

1 comment on commit b2caf83

@525c1e21-bd67-4735-ac99-b4b0e5262290

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you @grovesNL

Please sign in to comment.