Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update WebGPU's webidl #3067

Merged
merged 3 commits into from Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions crates/web-sys/src/features/gen_GpuBuffer.rs
Expand Up @@ -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 = ""]
Expand Down
16 changes: 16 additions & 0 deletions 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",
}
3 changes: 2 additions & 1 deletion crates/web-sys/src/features/gen_GpuErrorFilter.rs
Expand Up @@ -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",
}
1 change: 1 addition & 0 deletions crates/web-sys/src/features/gen_GpuFeatureName.rs
Expand Up @@ -19,4 +19,5 @@ pub enum GpuFeatureName {
IndirectFirstInstance = "indirect-first-instance",
ShaderF16 = "shader-f16",
Bgra8unormStorage = "bgra8unorm-storage",
Rg11b10ufloatRenderable = "rg11b10ufloat-renderable",
}
29 changes: 29 additions & 0 deletions 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<GpuInternalError, JsValue>;
}
33 changes: 33 additions & 0 deletions crates/web-sys/src/features/gen_GpuSupportedLimits.rs
Expand Up @@ -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 = ""]
Expand Down Expand Up @@ -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 = ""]
Expand Down Expand Up @@ -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 = ""]
Expand Down
12 changes: 12 additions & 0 deletions crates/web-sys/src/features/mod.rs
Expand Up @@ -2476,6 +2476,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;
Expand Down Expand Up @@ -2722,6 +2728,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;
Expand Down
69 changes: 44 additions & 25 deletions crates/web-sys/webidls/unstable/WebGPU.webidl
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -98,7 +101,8 @@ enum GPUFeatureName {
"timestamp-query",
"indirect-first-instance",
"shader-f16",
"bgra8unorm-storage"
"bgra8unorm-storage",
"rg11b10ufloat-renderable"
};

[Exposed=(Window, DedicatedWorker), SecureContext]
Expand Down Expand Up @@ -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<undefined> 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;
Expand Down Expand Up @@ -889,12 +901,12 @@ dictionary GPUImageCopyExternalImage {

interface mixin GPUBindingCommandsMixin {
undefined setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup,
optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []);
optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []);

undefined setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup,
Uint32Array dynamicOffsetsData,
GPUSize64 dynamicOffsetsDataStart,
GPUSize32 dynamicOffsetsDataLength);
Uint32Array dynamicOffsetsData,
GPUSize64 dynamicOffsetsDataStart,
GPUSize32 dynamicOffsetsDataLength);
};

interface mixin GPUDebugCommandsMixin {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1143,26 +1155,32 @@ partial interface GPUDevice {
readonly attribute Promise<GPUDeviceLostInfo> 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<GPUError?> popErrorScope();
Expand All @@ -1174,7 +1192,7 @@ interface GPUUncapturedErrorEvent : Event {
DOMString type,
GPUUncapturedErrorEventInit gpuUncapturedErrorEventInitDict
);
readonly attribute GPUError error;
[SameObject] readonly attribute GPUError error;
};

dictionary GPUUncapturedErrorEventInit : EventInit {
Expand Down Expand Up @@ -1226,3 +1244,4 @@ dictionary GPUExtent3DDict {
GPUIntegerCoordinate depthOrArrayLayers = 1;
};
typedef (sequence<GPUIntegerCoordinate> or GPUExtent3DDict) GPUExtent3D;