Skip to content

Commit

Permalink
chore: update webgpu (denoland#17534)
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlKats authored and jbatez committed Jan 31, 2023
1 parent 5b0d35c commit 08b9100
Show file tree
Hide file tree
Showing 24 changed files with 1,370 additions and 1,243 deletions.
1,060 changes: 569 additions & 491 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ url = { version = "2.3.1", features = ["serde", "expose_internals"] }
uuid = { version = "=1.1.2", features = ["v4"] }
zstd = "=0.11.2"

# webgpu
raw-window-handle = "0.5.0"
wgpu-core = "0.15"
wgpu-types = "0.15"

# macros
proc-macro2 = "1"
quote = "1"
Expand Down
87 changes: 30 additions & 57 deletions cli/tsc/dts/lib.deno_webgpu.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// Copyright 2023 Jo Bates. All rights reserved. MIT license.

// deno-lint-ignore-file no-explicit-any no-empty-interface

Expand All @@ -23,6 +22,7 @@ declare class GPUSupportedLimits {
maxTextureDimension3D?: number;
maxTextureArrayLayers?: number;
maxBindGroups?: number;
maxBindingsPerBindGroup?: number;
maxDynamicUniformBuffersPerPipelineLayout?: number;
maxDynamicStorageBuffersPerPipelineLayout?: number;
maxSampledTexturesPerShaderStage?: number;
Expand All @@ -35,6 +35,7 @@ declare class GPUSupportedLimits {
minUniformBufferOffsetAlignment?: number;
minStorageBufferOffsetAlignment?: number;
maxVertexBuffers?: number;
maxBufferSize?: number;
maxVertexAttributes?: number;
maxVertexBufferArrayStride?: number;
maxInterStageShaderComponents?: number;
Expand Down Expand Up @@ -86,7 +87,6 @@ declare class GPU {
declare interface GPURequestAdapterOptions {
powerPreference?: GPUPowerPreference;
forceFallbackAdapter?: boolean;
compatibleSurface?: GPUSurface;
}

/** @category WebGPU */
Expand All @@ -111,7 +111,6 @@ declare interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
/** @category WebGPU */
declare type GPUFeatureName =
| "depth-clip-control"
| "depth24unorm-stencil8"
| "depth32float-stencil8"
| "pipeline-statistics-query"
| "texture-compression-bc"
Expand Down Expand Up @@ -141,9 +140,6 @@ declare class GPUDevice extends EventTarget implements GPUObjectBase {
readonly lost: Promise<GPUDeviceLostInfo>;
pushErrorScope(filter: GPUErrorFilter): undefined;
popErrorScope(): Promise<GPUError | null>;
onuncapturederror:
| ((this: GPUDevice, ev: GPUUncapturedErrorEvent) => any)
| null;

readonly features: GPUSupportedFeatures;
readonly limits: GPUSupportedLimits;
Expand Down Expand Up @@ -191,6 +187,10 @@ declare class GPUDevice extends EventTarget implements GPUObjectBase {
declare class GPUBuffer implements GPUObjectBase {
label: string;

readonly size: number;
readonly usage: GPUBufferUsageFlags;
readonly mapState: GPUBufferMapState;

mapAsync(
mode: GPUMapModeFlags,
offset?: number,
Expand All @@ -202,6 +202,9 @@ declare class GPUBuffer implements GPUObjectBase {
destroy(): undefined;
}

/** @category WebGPU */
declare type GPUBufferMapState = "unmapped" | "pending" | "mapped";

/** @category WebGPU */
declare interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
size: number;
Expand Down Expand Up @@ -241,6 +244,15 @@ declare class GPUTexture implements GPUObjectBase {

createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
destroy(): undefined;

readonly width: number;
readonly height: number;
readonly depthOrArrayLayers: number;
readonly mipLevelCount: number;
readonly sampleCount: number;
readonly dimension: GPUTextureDimension;
readonly format: GPUTextureFormat;
readonly usage: GPUTextureUsageFlags;
}

/** @category WebGPU */
Expand All @@ -251,6 +263,7 @@ declare interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
dimension?: GPUTextureDimension;
format: GPUTextureFormat;
usage: GPUTextureUsageFlags;
viewFormats?: GPUTextureFormat[];
}

/** @category WebGPU */
Expand Down Expand Up @@ -339,7 +352,6 @@ declare type GPUTextureFormat =
| "depth24plus"
| "depth24plus-stencil8"
| "depth32float"
| "depth24unorm-stencil8"
| "depth32float-stencil8"
| "bc1-rgba-unorm"
| "bc1-rgba-unorm-srgb"
Expand Down Expand Up @@ -816,6 +828,13 @@ declare interface GPUVertexAttribute {
shaderLocation: number;
}

/** @category WebGPU */
declare interface GPUImageDataLayout {
offset?: number;
bytesPerRow?: number;
rowsPerImage?: number;
}

/** @category WebGPU */
declare class GPUCommandBuffer implements GPUObjectBase {
label: string;
Expand Down Expand Up @@ -885,13 +904,6 @@ declare class GPUCommandEncoder implements GPUObjectBase {
/** @category WebGPU */
declare interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {}

/** @category WebGPU */
declare interface GPUImageDataLayout {
offset?: number;
bytesPerRow?: number;
rowsPerImage?: number;
}

/** @category WebGPU */
declare interface GPUImageCopyBuffer extends GPUImageDataLayout {
buffer: GPUBuffer;
Expand Down Expand Up @@ -1093,7 +1105,6 @@ declare class GPURenderPassEncoder
declare interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
colorAttachments: (GPURenderPassColorAttachment | null)[];
depthStencilAttachment?: GPURenderPassDepthStencilAttachment;
occlusionQuerySet?: GPUQuerySet;
}

/** @category WebGPU */
Expand Down Expand Up @@ -1231,6 +1242,9 @@ declare class GPUQuerySet implements GPUObjectBase {
label: string;

destroy(): undefined;

readonly type: GPUQueryType;
readonly count: number;
}

/** @category WebGPU */
Expand Down Expand Up @@ -1265,9 +1279,6 @@ declare class GPUError {
readonly message: string;
}

/** @category WebGPU */
declare type GPUErrorFilter = "out-of-memory" | "validation";

/** @category WebGPU */
declare class GPUOutOfMemoryError extends GPUError {
constructor(message: string);
Expand All @@ -1279,18 +1290,7 @@ declare class GPUValidationError extends GPUError {
}

/** @category WebGPU */
declare class GPUUncapturedErrorEvent extends Event {
constructor(
type: string,
gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit,
);
readonly error: GPUError;
}

/** @category WebGPU */
declare interface GPUUncapturedErrorEventInit extends EventInit {
error?: GPUError;
}
declare type GPUErrorFilter = "out-of-memory" | "validation";

/** @category WebGPU */
declare interface GPUColorDict {
Expand Down Expand Up @@ -1322,30 +1322,3 @@ declare interface GPUExtent3DDict {

/** @category WebGPU */
declare type GPUExtent3D = number[] | GPUExtent3DDict;

/** @category WebGPU */
declare class GPUSurface {
getSupportedFormats(adapter: GPUAdapter): GPUTextureFormat[];
getSupportedModes(adapter: GPUAdapter): GPUPresentMode[];
configure(configuration: GPUSurfaceConfiguration): void;
getCurrentTexture(): GPUTexture;
present(): void;
}

/** @category WebGPU */
declare type GPUPresentMode =
| "auto-vsync"
| "auto-no-vsync"
| "fifo"
| "fifo-relaxed"
| "immediate"
| "mailbox";

/** @category WebGPU */
declare interface GPUSurfaceConfiguration {
device: GPUDevice;
usage?: GPUTextureUsageFlags;
format: GPUTextureFormat;
size: GPUExtent3D;
presentMode?: GPUPresentMode;
}
31 changes: 26 additions & 5 deletions ext/webgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,38 @@
[package]
name = "denox_webgpu"
version = "0.1.0"
authors.workspace = true
authors = ["the Deno authors", "Jo Bates"]
edition.workspace = true
license.workspace = true
license = "MIT"
readme = "README.md"
repository.workspace = true
description = "WebGPU implementation for Denox"

[features]
surface = ["wgpu-core/raw-window-handle", "dep:raw-window-handle"]

[dependencies]
deno_core.workspace = true
raw-window-handle = "0.4"
raw-window-handle = { workspace = true, optional = true }
serde.workspace = true
tokio.workspace = true
wgpu-core = { version = "0.13", features = ["trace", "replay", "serde", "raw-window-handle"] }
wgpu-types = { version = "0.13", features = ["trace", "replay", "serde"] }
wgpu-types = { workspace = true, features = ["trace", "replay", "serde"] }

[dependencies.wgpu-core]
workspace = true
features = ["trace", "replay", "serde", "strict_asserts", "wgsl", "gles"]

# We want the wgpu-core Metal backend on macOS and iOS.
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgpu-core]
workspace = true
features = ["metal"]

# We want the wgpu-core Direct3D backends on Windows.
[target.'cfg(windows)'.dependencies.wgpu-core]
workspace = true
features = ["dx11", "dx12"]

# We want the wgpu-core Vulkan backend on Unix (but not Emscripten) and Windows.
[target.'cfg(any(windows, all(unix, not(target_arch = "emscripten"))))'.dependencies.wgpu-core]
workspace = true
features = ["vulkan"]
Loading

0 comments on commit 08b9100

Please sign in to comment.