diff --git a/webgpu/generate/webgpu-spec b/webgpu/generate/webgpu-spec index 21f95d5..532ffc2 160000 --- a/webgpu/generate/webgpu-spec +++ b/webgpu/generate/webgpu-spec @@ -1 +1 @@ -Subproject commit 21f95d56ced1f3887d7beb41c23d609926af60a9 +Subproject commit 532ffc26b181e6c67c76a28172905ea74b591069 diff --git a/webgpu/generate/webgpu-transforms.json b/webgpu/generate/webgpu-transforms.json index 41a4b35..57bbb02 100644 --- a/webgpu/generate/webgpu-transforms.json +++ b/webgpu/generate/webgpu-transforms.json @@ -221,7 +221,7 @@ { "operation": { "remove-variant-case": { - "variant": "gpu-buffer-binding-or-gpu-external-texture-or-gpu-sampler-or-gpu-texture-view", + "variant": "gpu-buffer-or-gpu-buffer-binding-or-gpu-external-texture-or-gpu-sampler-or-gpu-texture-or-gpu-texture-view", "case": "gpu-external-texture" } } @@ -229,8 +229,8 @@ { "operation": { "rename-type": { - "from": "gpu-buffer-binding-or-gpu-external-texture-or-gpu-sampler-or-gpu-texture-view", - "to": "gpu-buffer-binding-or-gpu-sampler-or-gpu-texture-view" + "from": "gpu-buffer-or-gpu-buffer-binding-or-gpu-external-texture-or-gpu-sampler-or-gpu-texture-or-gpu-texture-view", + "to": "gpu-buffer-or-gpu-buffer-binding-or-gpu-sampler-or-gpu-texture-or-gpu-texture-view" } } }, @@ -238,10 +238,10 @@ "operation": { "replace-type-usages": { "old": { - "named": "gpu-buffer-binding-or-gpu-external-texture-or-gpu-sampler-or-gpu-texture-view" + "named": "gpu-buffer-or-gpu-buffer-binding-or-gpu-external-texture-or-gpu-sampler-or-gpu-texture-or-gpu-texture-view" }, "new": { - "named": "gpu-buffer-binding-or-gpu-sampler-or-gpu-texture-view" + "named": "gpu-buffer-or-gpu-buffer-binding-or-gpu-sampler-or-gpu-texture-or-gpu-texture-view" } } } @@ -525,6 +525,90 @@ } ] }, + { + "reason": "Beautify gpu-command-encoder.copy-buffer-to-buffer, no tuple params. Using the more powerful variant with offsets and making the offsets optional", + "operations": [ + { + "vars": { + "$_SOURCE": { + "find-type": { + "variant-case": { + "variant": "gpu-command-encoder-copy-buffer-to-buffer-params", + "case": "source-source-offset-destination-destination-offset-size" + }, + "unwrap-t": [ + { "tuple": 0 } + ] + } + }, + "$_SOURCE_OFFSET": { + "find-type": { + "variant-case": { + "variant": "gpu-command-encoder-copy-buffer-to-buffer-params", + "case": "source-source-offset-destination-destination-offset-size" + }, + "unwrap-t": [ + { "tuple": 1 } + ] + } + }, + "$_DESTINATION": { + "find-type": { + "variant-case": { + "variant": "gpu-command-encoder-copy-buffer-to-buffer-params", + "case": "source-source-offset-destination-destination-offset-size" + }, + "unwrap-t": [ + { "tuple": 2 } + ] + } + }, + "$_DESTINATION_OFFSET": { + "find-type": { + "variant-case": { + "variant": "gpu-command-encoder-copy-buffer-to-buffer-params", + "case": "source-source-offset-destination-destination-offset-size" + }, + "unwrap-t": [ + { "tuple": 3 } + ] + } + }, + "$_SIZE": { + "find-type": { + "variant-case": { + "variant": "gpu-command-encoder-copy-buffer-to-buffer-params", + "case": "source-source-offset-destination-destination-offset-size" + }, + "unwrap-t": [ + { "tuple": 4 } + ] + } + } + }, + "operation": { + "retype-func-params": { + "resource": "gpu-command-encoder", + "func": "copy-buffer-to-buffer", + "new-params": { + "items": [ + ["source", "$_SOURCE"], + ["source-offset", { "option": "$_SOURCE_OFFSET" }], + ["destination", "$_DESTINATION"], + ["destination-offset", { "option": "$_DESTINATION_OFFSET" }], + ["size", "$_SIZE"] + ] + } + } + } + }, + { + "operation": { + "remove-type": "gpu-command-encoder-copy-buffer-to-buffer-params" + } + } + ] + }, { "reason": "Remove allow-shared-buffer-source as it's web related and temporarily replace it with list", "operations": [ @@ -830,7 +914,7 @@ { "operation": { "rename-type": { - "from" : "gpu-buffer-binding-or-gpu-sampler-or-gpu-texture-view", + "from" : "gpu-buffer-or-gpu-buffer-binding-or-gpu-sampler-or-gpu-texture-or-gpu-texture-view", "to" : "gpu-binding-resource" } } @@ -1037,6 +1121,36 @@ } ] }, + { + "reason": "Accepting a texture in place of a texture view is just shorthand for texture.createView() (https://www.w3.org/TR/webgpu/#abstract-opdef-get-as-texture-view), so it's unnecessary — callers can call create-view themselves. JS can hide this behind dynamic typing, but in WIT it would require a variant and complicate the API. webgpu.h also disallows it (https://github.com/gpuweb/gpuweb/pull/5228#issuecomment-3046161091).", + "operations": [ + { + "vars": { + "$_VIEW": { + "find-type": { + "variant-case": { + "variant": "gpu-texture-or-gpu-texture-view", + "case": "gpu-texture-view" + } + } + } + }, + "operation": { + "replace-type-usages": { + "old": { + "named": "gpu-texture-or-gpu-texture-view" + }, + "new": "$_VIEW" + } + } + }, + { + "operation": { + "remove-type": "gpu-texture-or-gpu-texture-view" + } + } + ] + }, { "reason": "Errors have the message field raised to the top level type so that they don't have to be taken out of the inner error. Important if we allow new error types in the future that the developer has not yet handled. They also get a `kind` to enable detecting the error type. `kind` is a variant and not an enum so that they can have fields inside like `pipeline-error.reason`. Note: not changing gpu-error to a record even though errors added by us are records, because GPUError is an interface in the spec, and might one day gain interface like properties", "operations": [ diff --git a/webgpu/webgpu.wit b/webgpu/webgpu.wit index e8a03c8..e6773e2 100644 --- a/webgpu/webgpu.wit +++ b/webgpu/webgpu.wit @@ -34,7 +34,6 @@ interface webgpu { features: func() -> gpu-supported-features; limits: func() -> gpu-supported-limits; info: func() -> gpu-adapter-info; - is-fallback-adapter: func() -> bool; request-device: func(descriptor: option) -> future>; } resource gpu-adapter-info { @@ -44,6 +43,7 @@ interface webgpu { description: func() -> string; subgroup-min-size: func() -> u32; subgroup-max-size: func() -> u32; + is-fallback-adapter: func() -> bool; } enum gpu-address-mode { clamp-to-edge, @@ -80,8 +80,10 @@ interface webgpu { storage-texture: option, } variant gpu-binding-resource { + gpu-buffer(borrow), gpu-buffer-binding(gpu-buffer-binding), gpu-sampler(borrow), + gpu-texture(borrow), gpu-texture-view(borrow), } record gpu-blend-component { @@ -235,7 +237,7 @@ interface webgpu { resource gpu-command-encoder { begin-render-pass: func(descriptor: gpu-render-pass-descriptor) -> gpu-render-pass-encoder; begin-compute-pass: func(descriptor: option) -> gpu-compute-pass-encoder; - copy-buffer-to-buffer: func(source: borrow, source-offset: gpu-size64, destination: borrow, destination-offset: gpu-size64, size: gpu-size64); + copy-buffer-to-buffer: func(source: borrow, source-offset: option, destination: borrow, destination-offset: option, size: option); copy-buffer-to-texture: func(source: gpu-texel-copy-buffer-info, destination: gpu-texel-copy-texture-info, copy-size: gpu-extent3-d); copy-texture-to-buffer: func(source: gpu-texel-copy-texture-info, destination: gpu-texel-copy-buffer-info, copy-size: gpu-extent3-d); copy-texture-to-texture: func(source: gpu-texel-copy-texture-info, destination: gpu-texel-copy-texture-info, copy-size: gpu-extent3-d); @@ -292,6 +294,7 @@ interface webgpu { pop-debug-group: func(); insert-debug-marker: func(marker-label: string); set-bind-group: func(index: gpu-index32, bind-group: option>, dynamic-offsets-data: option>, dynamic-offsets-data-start: option, dynamic-offsets-data-length: option) -> result<_, set-bind-group-error>; + set-immediates: func(range-offset: gpu-size32, data: list, data-offset: option, data-size: option); } record gpu-compute-pass-timestamp-writes { query-set: borrow, @@ -388,6 +391,7 @@ interface webgpu { depth-or-array-layers: option, } enum gpu-feature-name { + core-features-and-limits, depth-clip-control, depth32float-stencil8, texture-compression-bc, @@ -405,6 +409,10 @@ interface webgpu { clip-distances, dual-source-blending, subgroups, + texture-formats-tier1, + texture-formats-tier2, + primitive-index, + texture-component-swizzle, } enum gpu-filter-mode { nearest, @@ -466,6 +474,7 @@ interface webgpu { } record gpu-pipeline-layout-descriptor { bind-group-layouts: list>>, + immediate-size: option, label: option, } enum gpu-power-preference { @@ -533,6 +542,7 @@ interface webgpu { pop-debug-group: func(); insert-debug-marker: func(marker-label: string); set-bind-group: func(index: gpu-index32, bind-group: option>, dynamic-offsets-data: option>, dynamic-offsets-data-start: option, dynamic-offsets-data-length: option) -> result<_, set-bind-group-error>; + set-immediates: func(range-offset: gpu-size32, data: list, data-offset: option, data-size: option); set-pipeline: func(pipeline: borrow); set-index-buffer: func(buffer: borrow, index-format: gpu-index-format, offset: option, size: option); set-vertex-buffer: func(slot: gpu-index32, buffer: option>, offset: option, size: option); @@ -591,6 +601,7 @@ interface webgpu { pop-debug-group: func(); insert-debug-marker: func(marker-label: string); set-bind-group: func(index: gpu-index32, bind-group: option>, dynamic-offsets-data: option>, dynamic-offsets-data-start: option, dynamic-offsets-data-length: option) -> result<_, set-bind-group-error>; + set-immediates: func(range-offset: gpu-size32, data: list, data-offset: option, data-size: option); set-pipeline: func(pipeline: borrow); set-index-buffer: func(buffer: borrow, index-format: gpu-index-format, offset: option, size: option); set-vertex-buffer: func(slot: gpu-index32, buffer: option>, offset: option, size: option); @@ -716,13 +727,18 @@ interface webgpu { max-texture-array-layers: func() -> u32; max-bind-groups: func() -> u32; max-bind-groups-plus-vertex-buffers: func() -> u32; + max-immediate-size: func() -> u32; max-bindings-per-bind-group: func() -> u32; max-dynamic-uniform-buffers-per-pipeline-layout: func() -> u32; max-dynamic-storage-buffers-per-pipeline-layout: func() -> u32; max-sampled-textures-per-shader-stage: func() -> u32; max-samplers-per-shader-stage: func() -> u32; max-storage-buffers-per-shader-stage: func() -> u32; + max-storage-buffers-in-vertex-stage: func() -> u32; + max-storage-buffers-in-fragment-stage: func() -> u32; max-storage-textures-per-shader-stage: func() -> u32; + max-storage-textures-in-vertex-stage: func() -> u32; + max-storage-textures-in-fragment-stage: func() -> u32; max-uniform-buffers-per-shader-stage: func() -> u32; max-uniform-buffer-binding-size: func() -> u64; max-storage-buffer-binding-size: func() -> u64; @@ -770,6 +786,7 @@ interface webgpu { dimension: func() -> gpu-texture-dimension; format: func() -> gpu-texture-format; usage: func() -> gpu-flags-constant; + texture-binding-view-dimension: func() -> option; label: func() -> string; set-label: func(label: string); from-graphics-buffer: static func(buffer: abstract-buffer) -> gpu-texture; @@ -792,6 +809,7 @@ interface webgpu { format: gpu-texture-format, usage: gpu-texture-usage-flags, view-formats: option>, + texture-binding-view-dimension: option, label: option, } enum gpu-texture-dimension { @@ -804,6 +822,8 @@ interface webgpu { r8snorm, r8uint, r8sint, + r16unorm, + r16snorm, r16uint, r16sint, r16float, @@ -814,6 +834,8 @@ interface webgpu { r32uint, r32sint, r32float, + rg16unorm, + rg16snorm, rg16uint, rg16sint, rg16float, @@ -831,6 +853,8 @@ interface webgpu { rg32uint, rg32sint, rg32float, + rgba16unorm, + rgba16snorm, rgba16uint, rgba16sint, rgba16float, @@ -909,6 +933,7 @@ interface webgpu { TEXTURE-BINDING: static func() -> gpu-flags-constant; STORAGE-BINDING: static func() -> gpu-flags-constant; RENDER-ATTACHMENT: static func() -> gpu-flags-constant; + TRANSIENT-ATTACHMENT: static func() -> gpu-flags-constant; } type gpu-texture-usage-flags = u32; resource gpu-texture-view { @@ -924,6 +949,7 @@ interface webgpu { mip-level-count: option, base-array-layer: option, array-layer-count: option, + swizzle: option, label: option, } enum gpu-texture-view-dimension {