1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

chore(ext/webgpu): update wgpu to 0.10.0 (#11781)

Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
Leo K 2021-08-24 13:29:42 +02:00 committed by GitHub
parent 50f69a6996
commit f4a9db350f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 366 additions and 501 deletions

357
Cargo.lock generated
View file

@ -85,15 +85,21 @@ name = "arrayvec"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "arrayvec"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be4dc07131ffa69b8072d35f5007352af944213cde02545e2103680baed38fcd"
dependencies = [
"serde",
]
[[package]]
name = "ash"
version = "0.32.1"
version = "0.33.0+1.2.186"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06063a002a77d2734631db74e8f4ce7148b77fe522e6bca46f2ae7774fd48112"
checksum = "a2142f1fa77cc4d24ffd2f24dc84f88ce5b1e588d524f10fb473a04b93aef14f"
dependencies = [
"libloading",
]
@ -297,9 +303,6 @@ name = "cc"
version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787"
dependencies = [
"jobserver",
]
[[package]]
name = "cfg-if"
@ -358,21 +361,6 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "cocoa-foundation"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318"
dependencies = [
"bitflags",
"block",
"core-foundation",
"core-graphics-types",
"foreign-types",
"libc",
"objc",
]
[[package]]
name = "codespan-reporting"
version = "0.11.1"
@ -489,9 +477,9 @@ dependencies = [
[[package]]
name = "d3d12"
version = "0.4.0"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "091ed1b25fe47c7ff129fc440c23650b6114f36aa00bc7212cc8041879294428"
checksum = "2daefd788d1e96e0a9d66dee4b828b883509bc3ea9ce30665f04c3246372690c"
dependencies = [
"bitflags",
"libloading",
@ -1080,15 +1068,6 @@ dependencies = [
"swc_ecmascript",
]
[[package]]
name = "drm-fourcc"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebbf3a5ed4671aabffefce172ff43d69c1f27dd2c6aea28e5212a70f32ada0cf"
dependencies = [
"serde",
]
[[package]]
name = "either"
version = "1.6.1"
@ -1199,16 +1178,6 @@ dependencies = [
"libc",
]
[[package]]
name = "external-memory"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4dfe8d292b014422776a8c516862d2bff8a81b223a4461dfdc45f3862dc9d39"
dependencies = [
"bitflags",
"drm-fourcc",
]
[[package]]
name = "fallible-iterator"
version = "0.2.0"
@ -1495,173 +1464,11 @@ dependencies = [
"wasi 0.10.0+wasi-snapshot-preview1",
]
[[package]]
name = "gfx-auxil"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1694991b11d642680e82075a75c7c2bd75556b805efa7660b705689f05b1ab1c"
dependencies = [
"fxhash",
"gfx-hal",
"spirv_cross",
]
[[package]]
name = "gfx-backend-dx11"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f9e453baf3aaef2b0c354ce0b3d63d76402e406a59b64b7182d123cfa6635ae"
dependencies = [
"arrayvec",
"bitflags",
"gfx-auxil",
"gfx-hal",
"gfx-renderdoc",
"libloading",
"log",
"parking_lot",
"range-alloc",
"raw-window-handle",
"smallvec",
"spirv_cross",
"thunderdome",
"winapi 0.3.9",
"wio",
]
[[package]]
name = "gfx-backend-dx12"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21506399f64a3c4d389182a89a30073856ae33eb712315456b4fd8f39ee7682a"
dependencies = [
"arrayvec",
"bit-set",
"bitflags",
"d3d12",
"gfx-auxil",
"gfx-hal",
"gfx-renderdoc",
"log",
"parking_lot",
"range-alloc",
"raw-window-handle",
"smallvec",
"spirv_cross",
"thunderdome",
"winapi 0.3.9",
]
[[package]]
name = "gfx-backend-empty"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29c8f813c47791918aa00dc9c9ddf961d23fa8c2a5d869e6cb8ea84f944820f4"
dependencies = [
"gfx-hal",
"log",
"raw-window-handle",
]
[[package]]
name = "gfx-backend-gl"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bae057fc3a0ab23ecf97ae51d4017d27d5ddf0aab16ee6dcb58981af88c3152"
dependencies = [
"arrayvec",
"bitflags",
"fxhash",
"gfx-hal",
"glow",
"js-sys",
"khronos-egl",
"libloading",
"log",
"naga",
"parking_lot",
"raw-window-handle",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "gfx-backend-metal"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0de85808e2a98994c6af925253f8a9593bc57180ef1ea137deab6d35cc949517"
dependencies = [
"arrayvec",
"bitflags",
"block",
"cocoa-foundation",
"copyless",
"core-graphics-types",
"foreign-types",
"fxhash",
"gfx-hal",
"log",
"metal",
"naga",
"objc",
"parking_lot",
"profiling",
"range-alloc",
"raw-window-handle",
"storage-map",
]
[[package]]
name = "gfx-backend-vulkan"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9861ec855acbbc65c0e4f966d761224886e811dc2c6d413a4776e9293d0e5c0"
dependencies = [
"arrayvec",
"ash",
"byteorder",
"core-graphics-types",
"gfx-hal",
"gfx-renderdoc",
"inplace_it",
"log",
"naga",
"objc",
"parking_lot",
"raw-window-handle",
"smallvec",
"winapi 0.3.9",
]
[[package]]
name = "gfx-hal"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fbb575ea793dd0507b3082f4f2cde62dc9f3cebd98f5cd49ba2a4da97a976fd"
dependencies = [
"bitflags",
"external-memory",
"naga",
"raw-window-handle",
"thiserror",
]
[[package]]
name = "gfx-renderdoc"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8027995e247e2426d3a00d13f5191dd56c314bff02dc4b54cbf727f1ba9c40a"
dependencies = [
"libloading",
"log",
"renderdoc-sys",
]
[[package]]
name = "glow"
version = "0.9.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b80b98efaa8a34fce11d60dd2ce2760d5d83c373cbcc73bb87c2a3a84a54108"
checksum = "4f04649123493bc2483cbef4daddb45d40bbdae5adb221a63a23efdb0cc99520"
dependencies = [
"js-sys",
"slotmap",
@ -1671,9 +1478,9 @@ dependencies = [
[[package]]
name = "gpu-alloc"
version = "0.4.7"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbc1b6ca374e81862526786d9cb42357ce03706ed1b8761730caafd02ab91f3a"
checksum = "c481459c44304a1dfed23bd650bb3912e12c9f77d7871f86d7ed7c9730a52e79"
dependencies = [
"bitflags",
"gpu-alloc-types",
@ -1690,9 +1497,9 @@ dependencies = [
[[package]]
name = "gpu-descriptor"
version = "0.1.1"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8a70f1e87a3840ed6a3e99e02c2b861e4dbdf26f0d07e38f42ea5aff46cfce2"
checksum = "d7a237f0419ab10d17006d55c62ac4f689a6bf52c75d3f38b8361d249e8d4b0b"
dependencies = [
"bitflags",
"gpu-descriptor-types",
@ -1977,15 +1784,6 @@ version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
[[package]]
name = "jobserver"
version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "972f5ae5d1cb9c6ae417789196c803205313edde988685da5e3aae0827b9e7fd"
dependencies = [
"libc",
]
[[package]]
name = "js-sys"
version = "0.3.49"
@ -2049,7 +1847,7 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe"
dependencies = [
"arrayvec",
"arrayvec 0.5.2",
"bitflags",
"cfg-if 1.0.0",
"ryu",
@ -2260,9 +2058,9 @@ dependencies = [
[[package]]
name = "naga"
version = "0.5.0"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef670817eef03d356d5a509ea275e7dd3a78ea9e24261ea3cb2dfed1abb08f64"
checksum = "c70938c43114c164e8ef86e608b39e68d3e4c8bca25e105bf4a3e788042a804a"
dependencies = [
"bit-set",
"bitflags",
@ -2271,8 +2069,8 @@ dependencies = [
"log",
"num-traits",
"petgraph",
"rose_tree",
"spirv_headers",
"serde",
"spirv",
"thiserror",
]
@ -2987,15 +2785,6 @@ dependencies = [
"serde",
]
[[package]]
name = "rose_tree"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "284de9dae38774e2813aaabd7e947b4a6fe9b8c58c2309f754a487cdd50de1c2"
dependencies = [
"petgraph",
]
[[package]]
name = "rsa"
version = "0.5.0"
@ -3343,9 +3132,12 @@ checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527"
[[package]]
name = "slotmap"
version = "0.4.2"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d61b40583e0c1bd3100652ba8940939decc8808e7b2a07f4f4606c6a8a40035a"
checksum = "a952280edbecfb1d4bd3cf2dbc309dc6ab523e53487c438ae21a6df09fe84bc4"
dependencies = [
"version_check",
]
[[package]]
name = "smallvec"
@ -3397,21 +3189,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]]
name = "spirv_cross"
version = "0.23.1"
name = "spirv"
version = "0.2.0+1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60647fadbf83c4a72f0d7ea67a7ca3a81835cf442b8deae5c134c3e0055b2e14"
dependencies = [
"cc",
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "spirv_headers"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f5b132530b1ac069df335577e3581765995cba5a13995cdbbdbc8fb057c532c"
checksum = "246bfa38fe3db3f1dfc8ca5a2cdeb7348c78be2112740cc0ec8ef18b6d94f830"
dependencies = [
"bitflags",
"num-traits",
@ -3438,15 +3219,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "storage-map"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418bb14643aa55a7841d5303f72cf512cfb323b8cc221d51580500a1ca75206c"
dependencies = [
"lock_api",
]
[[package]]
name = "str-buf"
version = "1.0.5"
@ -4026,12 +3798,6 @@ dependencies = [
"once_cell",
]
[[package]]
name = "thunderdome"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87b4947742c93ece24a0032141d9caa3d853752e694a57e35029dd2bd08673e0"
[[package]]
name = "time"
version = "0.1.44"
@ -4599,24 +4365,15 @@ dependencies = [
[[package]]
name = "wgpu-core"
version = "0.9.0"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2af5c8acd3ae5781a277cdf65a17f3a7135de5ae782775620e74ea16c9d47770"
checksum = "2c035607b0c83c0d2c0afa84e786dea6b16ff6cb70dd986b7e33913be74d2a2a"
dependencies = [
"arrayvec",
"arrayvec 0.7.1",
"bitflags",
"cfg_aliases",
"copyless",
"fxhash",
"gfx-backend-dx11",
"gfx-backend-dx12",
"gfx-backend-empty",
"gfx-backend-gl",
"gfx-backend-metal",
"gfx-backend-vulkan",
"gfx-hal",
"gpu-alloc",
"gpu-descriptor",
"log",
"naga",
"parking_lot",
@ -4625,14 +4382,49 @@ dependencies = [
"serde",
"smallvec",
"thiserror",
"wgpu-hal",
"wgpu-types",
]
[[package]]
name = "wgpu-types"
version = "0.9.0"
name = "wgpu-hal"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f5c9678cd533558e28b416d66947b099742df1939307478db54f867137f1b60"
checksum = "90b2512ec9e1db82d0c8bc5fab77a4af507bc3723999681a46ff8a8a31fa5e94"
dependencies = [
"arrayvec 0.7.1",
"ash",
"bit-set",
"bitflags",
"block",
"core-graphics-types",
"d3d12",
"foreign-types",
"fxhash",
"glow",
"gpu-alloc",
"gpu-descriptor",
"inplace_it",
"khronos-egl",
"libloading",
"log",
"metal",
"naga",
"objc",
"parking_lot",
"range-alloc",
"raw-window-handle",
"renderdoc-sys",
"thiserror",
"wgpu-types",
"winapi 0.3.9",
]
[[package]]
name = "wgpu-types"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25feb2fbf24ab3219a9f10890ceb8e1ef02b13314ed89d64a9ae99dcad883e18"
dependencies = [
"bitflags",
"serde",
@ -4724,15 +4516,6 @@ dependencies = [
"toml",
]
[[package]]
name = "wio"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5"
dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "zeroize"
version = "1.3.0"

View file

@ -1,6 +1,7 @@
# Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
[workspace]
resolver = "2"
members = [
"bench_util",
"cli",
@ -40,7 +41,7 @@ lto = true
opt-level = 'z' # Optimize for size
# Key generation is too slow on `debug`
#
#
[profile.dev.package.num-bigint-dig]
opt-level = 3

View file

@ -3,7 +3,7 @@ struct PrimeIndices {
data: [[stride(4)]] array<u32>;
}; // this is used as both input and output for convenience
[[group(0), binding(0)]]
var<storage> v_indices: [[access(read_write)]] PrimeIndices;
var<storage, read_write> v_indices: PrimeIndices;
// The Collatz Conjecture states that for any integer n:
// If n is even, n = n/2
// If n is odd, n = 3n+1

View file

@ -215,7 +215,7 @@
* @property {number} rid
* @property {GPUSupportedFeatures} features
* @property {GPUSupportedLimits} limits
* @property {boolean} isSoftware
* @property {boolean} isFallbackAdapter
*/
/**
@ -257,8 +257,8 @@
return this[_adapter].limits;
}
/** @returns {boolean} */
get isSoftware() {
return this[_adapter].isSoftware;
get isFallbackAdapter() {
return this[_adapter].isFallbackAdapter;
}
constructor() {
@ -353,8 +353,11 @@
* @property {number} maxVertexBufferArrayStride
* @property {number} maxInterStageShaderComponents
* @property {number} maxComputeWorkgroupStorageSize
* @property {number} maxComputeWorkgroupInvocations
* @property {number} maxComputePerDimensionDispatchSize
* @property {number} maxComputeInvocationsPerWorkgroup
* @property {number} maxComputeWorkgroupSizeX
* @property {number} maxComputeWorkgroupSizeY
* @property {number} maxComputeWorkgroupSizeZ
* @property {number} maxComputeWorkgroupsPerDimension
*/
class GPUSupportedLimits {
@ -448,13 +451,25 @@
webidl.assertBranded(this, GPUSupportedLimits);
return this[_limits].maxComputeWorkgroupStorageSize;
}
get maxComputeWorkgroupInvocations() {
get maxComputeInvocationsPerWorkgroup() {
webidl.assertBranded(this, GPUSupportedLimits);
return this[_limits].maxComputeWorkgroupInvocations;
return this[_limits].maxComputeInvocationsPerWorkgroup;
}
get maxComputePerDimensionDispatchSize() {
get maxComputeWorkgroupSizeX() {
webidl.assertBranded(this, GPUSupportedLimits);
return this[_limits].maxComputePerDimensionDispatchSize;
return this[_limits].maxComputeWorkgroupSizeX;
}
get maxComputeWorkgroupSizeY() {
webidl.assertBranded(this, GPUSupportedLimits);
return this[_limits].maxComputeWorkgroupSizeY;
}
get maxComputeWorkgroupSizeZ() {
webidl.assertBranded(this, GPUSupportedLimits);
return this[_limits].maxComputeWorkgroupSizeZ;
}
get maxComputeWorkgroupsPerDimension() {
webidl.assertBranded(this, GPUSupportedLimits);
return this[_limits].maxComputeWorkgroupsPerDimension;
}
[SymbolFor("Deno.privateCustomInspect")](inspect) {
@ -1090,14 +1105,9 @@
{
deviceRid: device.rid,
label: descriptor.label,
code: (typeof descriptor.code === "string")
? descriptor.code
: undefined,
code: descriptor.code,
sourceMap: descriptor.sourceMap,
},
...(descriptor.code instanceof Uint32Array
? [new Uint8Array(descriptor.code.buffer)]
: []),
);
device.pushError(err);
@ -1575,6 +1585,7 @@
origin: destination.origin
? normalizeGPUOrigin3D(destination.origin)
: undefined,
aspect: destination.aspect,
},
dataLayout,
size: normalizeGPUExtent3D(size),
@ -2071,10 +2082,10 @@
static get COPY_DST() {
return 0x02;
}
static get SAMPLED() {
static get TEXTURE_BINDING() {
return 0x04;
}
static get STORAGE() {
static get STORAGE_BINDING() {
return 0x08;
}
static get RENDER_ATTACHMENT() {
@ -2906,6 +2917,7 @@
origin: destination.origin
? normalizeGPUOrigin3D(destination.origin)
: undefined,
aspect: destination.aspect,
},
copySize: normalizeGPUExtent3D(copySize),
},
@ -2968,6 +2980,7 @@
origin: source.origin
? normalizeGPUOrigin3D(source.origin)
: undefined,
aspect: source.aspect,
},
destination: {
...destination,
@ -3034,6 +3047,7 @@
origin: source.origin
? normalizeGPUOrigin3D(source.origin)
: undefined,
aspect: source.aspect,
},
destination: {
texture: destinationTextureRid,
@ -3041,6 +3055,7 @@
origin: destination.origin
? normalizeGPUOrigin3D(destination.origin)
: undefined,
aspect: source.aspect,
},
copySize: normalizeGPUExtent3D(copySize),
},

View file

@ -39,11 +39,7 @@
GPUOutOfMemoryError,
GPUValidationError,
} = window.__bootstrap.webgpu;
const {
SymbolIterator,
TypeError,
Uint32Array,
} = window.__bootstrap.primordials;
const { SymbolIterator, TypeError } = window.__bootstrap.primordials;
// This needs to be initalized after all of the base classes are implmented,
// otherwise their converters might not be available yet.
@ -94,7 +90,7 @@
converter: webidl.converters["GPUPowerPreference"],
},
{
key: "forceSoftware",
key: "forceFallbackAdapter",
converter: webidl.converters.boolean,
defaultValue: false,
},
@ -681,7 +677,6 @@
webidl.converters["GPUStorageTextureAccess"] = webidl.createEnumConverter(
"GPUStorageTextureAccess",
[
"read-only",
"write-only",
],
);
@ -691,7 +686,7 @@
{
key: "access",
converter: webidl.converters["GPUStorageTextureAccess"],
required: true,
defaultValue: "write-only",
},
{
key: "format",
@ -861,19 +856,7 @@
const dictMembersGPUShaderModuleDescriptor = [
{
key: "code",
converter: (V, opts) => {
if (V instanceof Uint32Array) {
return webidl.converters["Uint32Array"](V, opts);
}
if (typeof V === "string") {
return webidl.converters["DOMString"](V, opts);
}
throw webidl.makeException(
TypeError,
"can not be converted to Uint32Array or DOMString.",
opts,
);
},
converter: webidl.converters["DOMString"],
required: true,
},
{ key: "sourceMap", converter: webidl.converters["object"] },
@ -977,9 +960,9 @@
GPURenderPipeline,
);
// ENUM: GPUInputStepMode
webidl.converters["GPUInputStepMode"] = webidl.createEnumConverter(
"GPUInputStepMode",
// ENUM: GPUVertexStepMode
webidl.converters["GPUVertexStepMode"] = webidl.createEnumConverter(
"GPUVertexStepMode",
[
"vertex",
"instance",
@ -1055,7 +1038,7 @@
},
{
key: "stepMode",
converter: webidl.converters["GPUInputStepMode"],
converter: webidl.converters["GPUVertexStepMode"],
defaultValue: "vertex",
},
{
@ -1811,8 +1794,8 @@
GPURenderBundleEncoder,
);
// DICTIONARY: GPURenderBundleEncoderDescriptor
const dictMembersGPURenderBundleEncoderDescriptor = [
// DICTIONARY: GPURenderPassLayout
const dictMembersGPURenderPassLayout = [
{
key: "colorFormats",
converter: webidl.createSequenceConverter(
@ -1830,10 +1813,31 @@
defaultValue: 1,
},
];
webidl.converters["GPURenderPassLayout"] = webidl
.createDictionaryConverter(
"GPURenderPassLayout",
dictMembersGPUObjectDescriptorBase,
dictMembersGPURenderPassLayout,
);
// DICTIONARY: GPURenderBundleEncoderDescriptor
const dictMembersGPURenderBundleEncoderDescriptor = [
{
key: "depthReadOnly",
converter: webidl.converters.boolean,
defaultValue: false,
},
{
key: "stencilReadOnly",
converter: webidl.converters.boolean,
defaultValue: false,
},
];
webidl.converters["GPURenderBundleEncoderDescriptor"] = webidl
.createDictionaryConverter(
"GPURenderBundleEncoderDescriptor",
dictMembersGPUObjectDescriptorBase,
dictMembersGPURenderPassLayout,
dictMembersGPURenderBundleEncoderDescriptor,
);

View file

@ -17,5 +17,5 @@ path = "lib.rs"
deno_core = { version = "0.98.0", path = "../../core" }
serde = { version = "1.0.126", features = ["derive"] }
tokio = { version = "1.8.1", features = ["full"] }
wgpu-core = { version = "0.9.0", features = ["trace"] }
wgpu-types = "0.9.0"
wgpu-core = { version = "0.10.0", features = ["trace"] }
wgpu-types = "0.10.0"

View file

@ -91,7 +91,8 @@ pub fn op_webgpu_create_bind_group_layout(
for entry in &args.entries {
entries.push(wgpu_types::BindGroupLayoutEntry {
binding: entry.binding,
visibility: wgpu_types::ShaderStage::from_bits(entry.visibility).unwrap(),
visibility: wgpu_types::ShaderStages::from_bits(entry.visibility)
.unwrap(),
ty: if let Some(buffer) = &entry.buffer {
wgpu_types::BindingType::Buffer {
ty: match &buffer.kind {
@ -166,7 +167,6 @@ pub fn op_webgpu_create_bind_group_layout(
} else if let Some(storage_texture) = &entry.storage_texture {
wgpu_types::BindingType::StorageTexture {
access: match storage_texture.access.as_str() {
"read-only" => wgpu_types::StorageTextureAccess::ReadOnly,
"write-only" => wgpu_types::StorageTextureAccess::WriteOnly,
_ => unreachable!(),
},

View file

@ -55,7 +55,7 @@ pub fn op_webgpu_create_buffer(
let descriptor = wgpu_core::resource::BufferDescriptor {
label: args.label.map(Cow::from),
size: args.size,
usage: wgpu_types::BufferUsage::from_bits(args.usage)
usage: wgpu_types::BufferUsages::from_bits(args.usage)
.ok_or_else(|| type_error("usage is not valid"))?,
mapped_at_creation: args.mapped_at_creation.unwrap_or(false),
};

View file

@ -37,6 +37,8 @@ pub struct CreateRenderBundleEncoderArgs {
color_formats: Vec<String>,
depth_stencil_format: Option<String>,
sample_count: Option<u32>,
depth_read_only: bool,
stencil_read_only: bool,
}
pub fn op_webgpu_create_render_bundle_encoder(
@ -58,11 +60,17 @@ pub fn op_webgpu_create_render_bundle_encoder(
let descriptor = wgpu_core::command::RenderBundleEncoderDescriptor {
label: args.label.map(Cow::from),
color_formats: Cow::from(color_formats),
depth_stencil_format: args
.depth_stencil_format
.map(|s| serialize_texture_format(&s))
.transpose()?,
sample_count: args.sample_count.unwrap_or(1),
depth_stencil: if let Some(depth_stencil_format) = args.depth_stencil_format
{
Some(wgpu_types::RenderBundleDepthStencil {
format: serialize_texture_format(&depth_stencil_format)?,
depth_read_only: args.depth_read_only,
stencil_read_only: args.stencil_read_only,
})
} else {
None
},
};
let res =

View file

@ -31,7 +31,7 @@ impl Resource for WebGpuCommandBuffer {
fn serialize_store_op(store_op: String) -> wgpu_core::command::StoreOp {
match store_op.as_str() {
"store" => wgpu_core::command::StoreOp::Store,
"discard" => wgpu_core::command::StoreOp::Clear,
"discard" => wgpu_core::command::StoreOp::Discard,
_ => unreachable!(),
}
}
@ -323,7 +323,7 @@ pub struct GpuImageCopyTexture {
pub texture: u32,
pub mip_level: Option<u32>,
pub origin: Option<GpuOrigin3D>,
pub _aspect: Option<String>, // not yet implemented
pub aspect: String,
}
#[derive(Deserialize)]
@ -373,6 +373,12 @@ pub fn op_webgpu_command_encoder_copy_buffer_to_texture(
y: origin.y.unwrap_or(0),
z: origin.z.unwrap_or(0),
}),
aspect: match args.destination.aspect.as_str() {
"all" => wgpu_types::TextureAspect::All,
"stencil-only" => wgpu_types::TextureAspect::StencilOnly,
"depth-only" => wgpu_types::TextureAspect::DepthOnly,
_ => unreachable!(),
},
};
gfx_ok!(command_encoder => instance.command_encoder_copy_buffer_to_texture(
command_encoder,
@ -424,6 +430,12 @@ pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
z: origin.z.unwrap_or(0),
}
}),
aspect: match args.source.aspect.as_str() {
"all" => wgpu_types::TextureAspect::All,
"stencil-only" => wgpu_types::TextureAspect::StencilOnly,
"depth-only" => wgpu_types::TextureAspect::DepthOnly,
_ => unreachable!(),
},
};
let destination = wgpu_core::command::ImageCopyBuffer {
buffer: destination_buffer_resource.0,
@ -487,6 +499,12 @@ pub fn op_webgpu_command_encoder_copy_texture_to_texture(
z: origin.z.unwrap_or(0),
}
}),
aspect: match args.source.aspect.as_str() {
"all" => wgpu_types::TextureAspect::All,
"stencil-only" => wgpu_types::TextureAspect::StencilOnly,
"depth-only" => wgpu_types::TextureAspect::DepthOnly,
_ => unreachable!(),
},
};
let destination = wgpu_core::command::ImageCopyTexture {
texture: destination_texture_resource.0,
@ -499,6 +517,12 @@ pub fn op_webgpu_command_encoder_copy_texture_to_texture(
y: origin.y.unwrap_or(0),
z: origin.z.unwrap_or(0),
}),
aspect: match args.destination.aspect.as_str() {
"all" => wgpu_types::TextureAspect::All,
"stencil-only" => wgpu_types::TextureAspect::StencilOnly,
"depth-only" => wgpu_types::TextureAspect::DepthOnly,
_ => unreachable!(),
},
};
gfx_ok!(command_encoder => instance.command_encoder_copy_texture_to_texture(
command_encoder,

View file

@ -8,7 +8,6 @@ use wgpu_core::binding_model::CreateBindGroupError;
use wgpu_core::binding_model::CreateBindGroupLayoutError;
use wgpu_core::binding_model::CreatePipelineLayoutError;
use wgpu_core::binding_model::GetBindGroupLayoutError;
use wgpu_core::command::CommandAllocatorError;
use wgpu_core::command::CommandEncoderError;
use wgpu_core::command::ComputePassError;
use wgpu_core::command::CopyError;
@ -145,14 +144,6 @@ impl From<CreateRenderBundleError> for WebGpuError {
}
}
impl From<CommandAllocatorError> for WebGpuError {
fn from(err: CommandAllocatorError) -> Self {
match err {
CommandAllocatorError::Device(err) => err.into(),
}
}
}
impl From<CopyError> for WebGpuError {
fn from(err: CopyError) -> Self {
WebGpuError::Validation(err.to_string())

View file

@ -37,8 +37,11 @@ declare class GPUSupportedLimits {
maxVertexBufferArrayStride?: number;
maxInterStageShaderComponents?: number;
maxComputeWorkgroupStorageSize?: number;
maxComputeWorkgroupInvocations?: number;
maxComputePerDimensionDispatchSize?: number;
maxComputeInvocationsPerWorkgroup?: number;
maxComputeWorkgroupSizeX?: number;
maxComputeWorkgroupSizeY?: number;
maxComputeWorkgroupSizeZ?: number;
maxComputeWorkgroupsPerDimension?: number;
}
declare class GPUSupportedFeatures {
@ -69,7 +72,7 @@ declare class GPU {
declare interface GPURequestAdapterOptions {
powerPreference?: GPUPowerPreference;
forceSoftware?: boolean;
forceFallbackAdapter?: boolean;
}
declare type GPUPowerPreference = "low-power" | "high-performance";
@ -78,7 +81,7 @@ declare class GPUAdapter {
readonly name: string;
readonly features: GPUSupportedFeatures;
readonly limits: GPUSupportedLimits;
readonly isSoftware: boolean;
readonly isFallbackAdapter: boolean;
requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice>;
}
@ -226,8 +229,8 @@ declare type GPUTextureUsageFlags = number;
declare class GPUTextureUsage {
static COPY_SRC: 0x01;
static COPY_DST: 0x02;
static SAMPLED: 0x04;
static STORAGE: 0x08;
static TEXTURE_BINDING: 0x04;
static STORAGE_BINDING: 0x08;
static RENDER_ATTACHMENT: 0x10;
}
@ -400,13 +403,7 @@ declare type GPUTextureSampleType =
| "sint"
| "uint";
declare interface GPUTextureBindingLayout {
sampleType?: GPUTextureSampleType;
viewDimension?: GPUTextureViewDimension;
multisampled?: boolean;
}
declare type GPUStorageTextureAccess = "read-only" | "write-only";
declare type GPUStorageTextureAccess = "write-only";
declare interface GPUStorageTextureBindingLayout {
access: GPUStorageTextureAccess;
@ -467,7 +464,7 @@ declare class GPUShaderModule implements GPUObjectBase {
}
declare interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
code: string | Uint32Array;
code: string;
sourceMap?: any;
}
@ -655,7 +652,7 @@ declare type GPUVertexFormat =
| "sint32x2"
| "sint32x3"
| "sint32x4";
declare type GPUInputStepMode = "vertex" | "instance";
declare type GPUVertexStepMode = "vertex" | "instance";
declare interface GPUVertexState extends GPUProgrammableStage {
buffers?: (GPUVertexBufferLayout | null)[];
@ -663,7 +660,7 @@ declare interface GPUVertexState extends GPUProgrammableStage {
declare interface GPUVertexBufferLayout {
arrayStride: number;
stepMode?: GPUInputStepMode;
stepMode?: GPUVertexStepMode;
attributes: GPUVertexAttribute[];
}
@ -1022,13 +1019,17 @@ declare class GPURenderBundleEncoder
finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
}
declare interface GPURenderBundleEncoderDescriptor
extends GPUObjectDescriptorBase {
declare interface GPURenderPassLayout extends GPUObjectDescriptorBase {
colorFormats: GPUTextureFormat[];
depthStencilFormat?: GPUTextureFormat;
sampleCount?: number;
}
declare interface GPURenderBundleEncoderDescriptor extends GPURenderPassLayout {
depthReadOnly?: boolean;
stencilReadOnly?: boolean;
}
declare class GPUQueue implements GPUObjectBase {
label: string | null;

View file

@ -28,15 +28,13 @@ mod macros {
($id:expr => $global:ident.$method:ident( $($param:expr),* )) => {
match $id.backend() {
#[cfg(not(target_os = "macos"))]
wgpu_types::Backend::Vulkan => $global.$method::<wgpu_core::backend::Vulkan>( $($param),* ),
wgpu_types::Backend::Vulkan => $global.$method::<wgpu_core::api::Vulkan>( $($param),* ),
#[cfg(target_os = "macos")]
wgpu_types::Backend::Metal => $global.$method::<wgpu_core::backend::Metal>( $($param),* ),
wgpu_types::Backend::Metal => $global.$method::<wgpu_core::api::Metal>( $($param),* ),
#[cfg(windows)]
wgpu_types::Backend::Dx12 => $global.$method::<wgpu_core::backend::Dx12>( $($param),* ),
#[cfg(windows)]
wgpu_types::Backend::Dx11 => $global.$method::<wgpu_core::backend::Dx11>( $($param),* ),
wgpu_types::Backend::Dx12 => $global.$method::<wgpu_core::api::Dx12>( $($param),* ),
#[cfg(all(unix, not(target_os = "macos")))]
wgpu_types::Backend::Gl => $global.$method::<wgpu_core::backend::Gl>( $($param),+ ),
wgpu_types::Backend::Gl => $global.$method::<wgpu_core::api::Gles>( $($param),+ ),
other => panic!("Unexpected backend {:?}", other),
}
};
@ -75,7 +73,6 @@ pub struct Unstable(pub bool);
fn check_unstable(state: &OpState, api_name: &str) {
let unstable = state.borrow::<Unstable>();
if !unstable.0 {
eprintln!(
"Unstable API '{}'. The --unstable flag must be provided.",
@ -151,18 +148,20 @@ fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> {
if features.contains(wgpu_types::Features::MAPPABLE_PRIMARY_BUFFERS) {
return_features.push("mappable-primary-buffers");
}
if features.contains(wgpu_types::Features::SAMPLED_TEXTURE_BINDING_ARRAY) {
return_features.push("sampled-texture-binding-array");
if features.contains(wgpu_types::Features::TEXTURE_BINDING_ARRAY) {
return_features.push("texture-binding-array");
}
if features
.contains(wgpu_types::Features::SAMPLED_TEXTURE_ARRAY_DYNAMIC_INDEXING)
{
return_features.push("sampled-texture-array-dynamic-indexing");
if features.contains(wgpu_types::Features::BUFFER_BINDING_ARRAY) {
return_features.push("buffer-binding-array");
}
if features
.contains(wgpu_types::Features::SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING)
{
return_features.push("sampled-texture-array-non-uniform-indexing");
if features.contains(wgpu_types::Features::STORAGE_RESOURCE_BINDING_ARRAY) {
return_features.push("storage-resource-binding-array");
}
if features.contains(wgpu_types::Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING) {
return_features.push("sampled-texture-and-storage-buffer-array-non-uniform-indexing");
}
if features.contains(wgpu_types::Features::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING) {
return_features.push("uniform-buffer-and-storage-buffer-texture-non-uniform-indexing");
}
if features.contains(wgpu_types::Features::UNSIZED_BINDING_ARRAY) {
return_features.push("unsized-binding-array");
@ -199,6 +198,21 @@ fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> {
if features.contains(wgpu_types::Features::VERTEX_ATTRIBUTE_64BIT) {
return_features.push("vertex-attribute-64bit");
}
if features.contains(wgpu_types::Features::CONSERVATIVE_RASTERIZATION) {
return_features.push("conservative-rasterization");
}
if features.contains(wgpu_types::Features::VERTEX_WRITABLE_STORAGE) {
return_features.push("vertex-writable-storage");
}
if features.contains(wgpu_types::Features::CLEAR_COMMANDS) {
return_features.push("clear-commands");
}
if features.contains(wgpu_types::Features::SPIRV_SHADER_PASSTHROUGH) {
return_features.push("spirv-shader-passthrough");
}
if features.contains(wgpu_types::Features::SHADER_PRIMITIVE_INDEX) {
return_features.push("shader-primitive-index");
}
return_features
}
@ -239,7 +253,7 @@ pub async fn op_webgpu_request_adapter(
state.put(wgpu_core::hub::Global::new(
"webgpu",
wgpu_core::hub::IdentityManagerFactory,
wgpu_types::BackendBit::PRIMARY,
wgpu_types::Backends::PRIMARY,
));
state.borrow::<Instance>()
};
@ -253,13 +267,13 @@ pub async fn op_webgpu_request_adapter(
},
None => Default::default(),
},
// TODO(lucacasonato): respect forceSoftware
// TODO(lucacasonato): respect forceFallbackAdapter
compatible_surface: None, // windowless
};
let res = instance.request_adapter(
&descriptor,
wgpu_core::instance::AdapterInputs::Mask(
wgpu_types::BackendBit::PRIMARY,
wgpu_types::Backends::PRIMARY,
|_| std::marker::PhantomData,
),
);
@ -305,8 +319,8 @@ struct GpuLimits {
max_storage_buffers_per_shader_stage: Option<u32>,
max_storage_textures_per_shader_stage: Option<u32>,
max_uniform_buffers_per_shader_stage: Option<u32>,
max_uniform_buffer_binding_size: Option<u32>,
max_storage_buffer_binding_size: Option<u32>,
max_uniform_buffer_binding_size: Option<u32>, // TODO(@crowlkats): u64
max_storage_buffer_binding_size: Option<u32>, // TODO(@crowlkats): u64
// min_uniform_buffer_offset_alignment: Option<u32>,
// min_storage_buffer_offset_alignment: Option<u32>,
max_vertex_buffers: Option<u32>,
@ -314,8 +328,11 @@ struct GpuLimits {
max_vertex_buffer_array_stride: Option<u32>,
// max_inter_stage_shader_components: Option<u32>,
// max_compute_workgroup_storage_size: Option<u32>,
// max_compute_workgroup_invocations: Option<u32>,
// max_compute_per_dimension_dispatch_size: Option<u32>,
// max_compute_invocations_per_workgroup: Option<u32>,
// max_compute_workgroup_size_x: Option<u32>,
// max_compute_workgroup_size_y: Option<u32>,
// max_compute_workgroup_size_z: Option<u32>,
// max_compute_workgroups_per_dimension: Option<u32>,
}
impl From<GpuLimits> for wgpu_types::Limits {
@ -370,12 +387,21 @@ impl From<GpuLimits> for wgpu_types::Limits {
// max_compute_workgroup_storage_size: limits
// .max_compute_workgroup_storage_size
// .unwrap_or(default),
// max_compute_workgroup_invocations: limits
// .max_compute_workgroup_invocations
// .unwrap_or(default),
// max_compute_per_dimension_dispatch_size: limits
// .max_compute_per_dimension_dispatch_size
// .unwrap_or(default),
// max_compute_invocations_per_workgroup: limits
// .max_compute_invocations_per_workgroup
// .unwrap_or(default),
// max_compute_workgroup_size_x: limits
// .max_compute_workgroup_size_x
// .unwrap_or(default),
// max_compute_workgroup_size_y: limits
// .max_compute_workgroup_size_y
// .unwrap_or(default),
// max_compute_workgroup_size_z: limits
// .max_compute_workgroup_size_z
// .unwrap_or(default),
// max_compute_workgroups_per_dimension: limits
// .max_compute_workgroups_per_dimension
// .unwrap_or(default),
max_push_constant_size: 0,
}
}
@ -422,24 +448,26 @@ pub async fn op_webgpu_request_device(
if passed_features.contains(&"mappable-primary-buffers".to_string()) {
features.set(wgpu_types::Features::MAPPABLE_PRIMARY_BUFFERS, true);
}
if passed_features.contains(&"sampled-texture-binding-array".to_string()) {
features.set(wgpu_types::Features::SAMPLED_TEXTURE_BINDING_ARRAY, true);
if passed_features.contains(&"texture-binding-array".to_string()) {
features.set(wgpu_types::Features::TEXTURE_BINDING_ARRAY, true);
}
if passed_features
.contains(&"sampled-texture-array-dynamic-indexing".to_string())
{
features.set(
wgpu_types::Features::SAMPLED_TEXTURE_ARRAY_DYNAMIC_INDEXING,
true,
);
if passed_features.contains(&"buffer-binding-array".to_string()) {
features.set(wgpu_types::Features::BUFFER_BINDING_ARRAY, true);
}
if passed_features
.contains(&"sampled-texture-array-non-uniform-indexing".to_string())
{
features.set(
wgpu_types::Features::SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING,
true,
);
if passed_features.contains(&"storage-resource-binding-array".to_string()) {
features.set(wgpu_types::Features::STORAGE_RESOURCE_BINDING_ARRAY, true);
}
if passed_features.contains(
&"sampled-texture-and-storage-buffer-array-non-uniform-indexing"
.to_string(),
) {
features.set(wgpu_types::Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING, true);
}
if passed_features.contains(
&"uniform-buffer-and-storage-buffer-texture-non-uniform-indexing"
.to_string(),
) {
features.set(wgpu_types::Features::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING, true);
}
if passed_features.contains(&"unsized-binding-array".to_string()) {
features.set(wgpu_types::Features::UNSIZED_BINDING_ARRAY, true);
@ -479,6 +507,21 @@ pub async fn op_webgpu_request_device(
if passed_features.contains(&"vertex-attribute-64bit".to_string()) {
features.set(wgpu_types::Features::VERTEX_ATTRIBUTE_64BIT, true);
}
if passed_features.contains(&"conservative-rasterization".to_string()) {
features.set(wgpu_types::Features::CONSERVATIVE_RASTERIZATION, true);
}
if passed_features.contains(&"vertex-writable-storage".to_string()) {
features.set(wgpu_types::Features::VERTEX_WRITABLE_STORAGE, true);
}
if passed_features.contains(&"clear-commands".to_string()) {
features.set(wgpu_types::Features::CLEAR_COMMANDS, true);
}
if passed_features.contains(&"spirv-shader-passthrough".to_string()) {
features.set(wgpu_types::Features::SPIRV_SHADER_PASSTHROUGH, true);
}
if passed_features.contains(&"shader-primitive-index".to_string()) {
features.set(wgpu_types::Features::SHADER_PRIMITIVE_INDEX, true);
}
}
let descriptor = wgpu_types::DeviceDescriptor {
@ -520,7 +563,7 @@ pub async fn op_webgpu_request_device(
#[serde(rename_all = "camelCase")]
pub struct CreateQuerySetArgs {
device_rid: ResourceId,
_label: Option<String>, // not yet implemented
label: Option<String>,
#[serde(rename = "type")]
kind: String,
count: u32,
@ -538,6 +581,7 @@ pub fn op_webgpu_create_query_set(
let instance = &state.borrow::<Instance>();
let descriptor = wgpu_types::QuerySetDescriptor {
label: args.label.map(Cow::from),
ty: match args.kind.as_str() {
"pipeline-statistics" => {
let mut pipeline_statistics_names =

View file

@ -9,6 +9,8 @@ use std::borrow::Cow;
use super::error::{WebGpuError, WebGpuResult};
const MAX_BIND_GROUPS: usize = 8;
pub(crate) struct WebGpuPipelineLayout(
pub(crate) wgpu_core::id::PipelineLayoutId,
);
@ -200,7 +202,7 @@ pub fn op_webgpu_create_compute_pipeline(
Some(_) => None,
None => Some(wgpu_core::device::ImplicitPipelineIds {
root_id: std::marker::PhantomData,
group_ids: &[std::marker::PhantomData; wgpu_core::MAX_BIND_GROUPS],
group_ids: &[std::marker::PhantomData; MAX_BIND_GROUPS],
}),
};
@ -489,11 +491,11 @@ pub fn op_webgpu_create_render_pipeline(
array_stride: buffer.array_stride,
step_mode: match buffer.step_mode {
Some(step_mode) => match step_mode.as_str() {
"vertex" => wgpu_types::InputStepMode::Vertex,
"instance" => wgpu_types::InputStepMode::Instance,
"vertex" => wgpu_types::VertexStepMode::Vertex,
"instance" => wgpu_types::VertexStepMode::Instance,
_ => unreachable!(),
},
None => wgpu_types::InputStepMode::Vertex,
None => wgpu_types::VertexStepMode::Vertex,
},
attributes: Cow::from(
buffer
@ -610,7 +612,7 @@ pub fn op_webgpu_create_render_pipeline(
write_mask: target
.write_mask
.map_or(Default::default(), |mask| {
wgpu_types::ColorWrite::from_bits(mask).unwrap()
wgpu_types::ColorWrites::from_bits(mask).unwrap()
}),
})
.collect::<Vec<wgpu_types::ColorTargetState>>(),
@ -623,7 +625,7 @@ pub fn op_webgpu_create_render_pipeline(
Some(_) => None,
None => Some(wgpu_core::device::ImplicitPipelineIds {
root_id: std::marker::PhantomData,
group_ids: &[std::marker::PhantomData; wgpu_core::MAX_BIND_GROUPS],
group_ids: &[std::marker::PhantomData; MAX_BIND_GROUPS],
}),
};

View file

@ -128,6 +128,12 @@ pub fn op_webgpu_write_texture(
y: origin.y.unwrap_or(0),
z: origin.z.unwrap_or(0),
}),
aspect: match args.destination.aspect.as_str() {
"all" => wgpu_types::TextureAspect::All,
"stencil-only" => wgpu_types::TextureAspect::StencilOnly,
"depth-only" => wgpu_types::TextureAspect::DepthOnly,
_ => unreachable!(),
},
};
let data_layout = wgpu_types::ImageDataLayout {
offset: args.data_layout.offset.unwrap_or(0),

View file

@ -97,9 +97,7 @@ pub fn op_webgpu_create_sampler(
min_filter: serialize_filter_mode(args.min_filter),
mipmap_filter: serialize_filter_mode(args.mipmap_filter),
lod_min_clamp: args.lod_min_clamp.unwrap_or(0.0),
lod_max_clamp: args.lod_max_clamp.unwrap_or(
wgpu_core::resource::SamplerDescriptor::default().lod_max_clamp,
),
lod_max_clamp: args.lod_max_clamp.unwrap_or(32.0),
compare: args
.compare
.as_ref()

View file

@ -1,9 +1,7 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
use deno_core::error::null_opbuf;
use deno_core::error::AnyError;
use deno_core::ResourceId;
use deno_core::ZeroCopyBuf;
use deno_core::{OpState, Resource};
use serde::Deserialize;
use std::borrow::Cow;
@ -22,14 +20,14 @@ impl Resource for WebGpuShaderModule {
pub struct CreateShaderModuleArgs {
device_rid: ResourceId,
label: Option<String>,
code: Option<String>,
code: String,
_source_map: Option<()>, // not yet implemented
}
pub fn op_webgpu_create_shader_module(
state: &mut OpState,
args: CreateShaderModuleArgs,
zero_copy: Option<ZeroCopyBuf>,
_: (),
) -> Result<WebGpuResult, AnyError> {
let instance = state.borrow::<super::Instance>();
let device_resource = state
@ -37,26 +35,11 @@ pub fn op_webgpu_create_shader_module(
.get::<super::WebGpuDevice>(args.device_rid)?;
let device = device_resource.0;
let source = match args.code {
Some(code) => {
wgpu_core::pipeline::ShaderModuleSource::Wgsl(Cow::from(code))
}
None => wgpu_core::pipeline::ShaderModuleSource::SpirV(Cow::from(unsafe {
match &zero_copy {
Some(zero_copy) => {
let (prefix, data, suffix) = zero_copy.align_to::<u32>();
assert!(prefix.is_empty());
assert!(suffix.is_empty());
data
}
None => return Err(null_opbuf()),
}
})),
};
let source =
wgpu_core::pipeline::ShaderModuleSource::Wgsl(Cow::from(args.code));
let descriptor = wgpu_core::pipeline::ShaderModuleDescriptor {
label: args.label.map(Cow::from),
flags: wgpu_types::ShaderFlags::all(),
};
gfx_put!(device => instance.device_create_shader_module(

View file

@ -171,7 +171,7 @@ pub fn op_webgpu_create_texture(
None => wgpu_types::TextureDimension::D2,
},
format: serialize_texture_format(&args.format)?,
usage: wgpu_types::TextureUsage::from_bits(args.usage).unwrap(),
usage: wgpu_types::TextureUsages::from_bits(args.usage).unwrap(),
};
gfx_put!(device => instance.device_create_texture(

View file

@ -6,7 +6,7 @@ dictionary GPUObjectDescriptorBase {
USVString label;
};
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUSupportedLimits {
readonly attribute unsigned long maxTextureDimension1D;
readonly attribute unsigned long maxTextureDimension2D;
@ -20,8 +20,8 @@ interface GPUSupportedLimits {
readonly attribute unsigned long maxStorageBuffersPerShaderStage;
readonly attribute unsigned long maxStorageTexturesPerShaderStage;
readonly attribute unsigned long maxUniformBuffersPerShaderStage;
readonly attribute unsigned long maxUniformBufferBindingSize;
readonly attribute unsigned long maxStorageBufferBindingSize;
readonly attribute unsigned long long maxUniformBufferBindingSize;
readonly attribute unsigned long long maxStorageBufferBindingSize;
readonly attribute unsigned long minUniformBufferOffsetAlignment;
readonly attribute unsigned long minStorageBufferOffsetAlignment;
readonly attribute unsigned long maxVertexBuffers;
@ -29,11 +29,14 @@ interface GPUSupportedLimits {
readonly attribute unsigned long maxVertexBufferArrayStride;
readonly attribute unsigned long maxInterStageShaderComponents;
readonly attribute unsigned long maxComputeWorkgroupStorageSize;
readonly attribute unsigned long maxComputeWorkgroupInvocations;
readonly attribute unsigned long maxComputePerDimensionDispatchSize;
readonly attribute unsigned long maxComputeInvocationsPerWorkgroup;
readonly attribute unsigned long maxComputeWorkgroupSizeX;
readonly attribute unsigned long maxComputeWorkgroupSizeY;
readonly attribute unsigned long maxComputeWorkgroupSizeZ;
readonly attribute unsigned long maxComputeWorkgroupsPerDimension;
};
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUSupportedFeatures {
readonly setlike<DOMString>;
};
@ -55,7 +58,7 @@ interface GPU {
dictionary GPURequestAdapterOptions {
GPUPowerPreference powerPreference;
boolean forceSoftware = false;
boolean forceFallbackAdapter = false;
};
enum GPUPowerPreference {
@ -63,19 +66,19 @@ enum GPUPowerPreference {
"high-performance"
};
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUAdapter {
readonly attribute DOMString name;
[SameObject] readonly attribute GPUSupportedFeatures features;
[SameObject] readonly attribute GPUSupportedLimits limits;
readonly attribute boolean isSoftware;
readonly attribute boolean isFallbackAdapter;
Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
};
dictionary GPUDeviceDescriptor : GPUObjectDescriptorBase {
sequence<GPUFeatureName> requiredFeatures = [];
record<DOMString, GPUSize32> requiredLimits = {};
record<DOMString, GPUSize64> requiredLimits = {};
};
enum GPUFeatureName {
@ -87,7 +90,7 @@ enum GPUFeatureName {
"timestamp-query",
};
[Exposed=(Window, DedicatedWorker), Serializable]
[Exposed=(Window, DedicatedWorker)]
interface GPUDevice : EventTarget {
[SameObject] readonly attribute GPUSupportedFeatures features;
[SameObject] readonly attribute GPUSupportedLimits limits;
@ -117,7 +120,7 @@ interface GPUDevice : EventTarget {
};
GPUDevice includes GPUObjectBase;
[Exposed=Window, Serializable]
[Exposed=(Window, DedicatedWorker)]
interface GPUBuffer {
Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
@ -134,7 +137,7 @@ dictionary GPUBufferDescriptor : GPUObjectDescriptorBase {
};
typedef [EnforceRange] unsigned long GPUBufferUsageFlags;
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUBufferUsage {
const GPUFlagsConstant MAP_READ = 0x0001;
const GPUFlagsConstant MAP_WRITE = 0x0002;
@ -149,13 +152,13 @@ interface GPUBufferUsage {
};
typedef [EnforceRange] unsigned long GPUMapModeFlags;
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUMapMode {
const GPUFlagsConstant READ = 0x0001;
const GPUFlagsConstant WRITE = 0x0002;
};
[Exposed=Window, Serializable]
[Exposed=(Window, DedicatedWorker)]
interface GPUTexture {
GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
@ -179,16 +182,16 @@ enum GPUTextureDimension {
};
typedef [EnforceRange] unsigned long GPUTextureUsageFlags;
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUTextureUsage {
const GPUFlagsConstant COPY_SRC = 0x01;
const GPUFlagsConstant COPY_DST = 0x02;
const GPUFlagsConstant SAMPLED = 0x04;
const GPUFlagsConstant STORAGE = 0x08;
const GPUFlagsConstant TEXTURE_BINDING = 0x04;
const GPUFlagsConstant STORAGE_BINDING = 0x08;
const GPUFlagsConstant RENDER_ATTACHMENT = 0x10;
};
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUTextureView {
};
GPUTextureView includes GPUObjectBase;
@ -297,7 +300,7 @@ enum GPUTextureFormat {
"depth32float-stencil8",
};
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUSampler {
};
GPUSampler includes GPUObjectBase;
@ -310,7 +313,7 @@ dictionary GPUSamplerDescriptor : GPUObjectDescriptorBase {
GPUFilterMode minFilter = "nearest";
GPUFilterMode mipmapFilter = "nearest";
float lodMinClamp = 0;
float lodMaxClamp = 0xffffffff; // TODO: What should this be? Was Number.MAX_VALUE.
float lodMaxClamp = 32;
GPUCompareFunction compare;
[Clamp] unsigned short maxAnisotropy = 1;
};
@ -337,7 +340,7 @@ enum GPUCompareFunction {
"always"
};
[Exposed=Window, Serializable]
[Exposed=(Window, DedicatedWorker)]
interface GPUBindGroupLayout {
};
GPUBindGroupLayout includes GPUObjectBase;
@ -347,7 +350,7 @@ dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {
};
typedef [EnforceRange] unsigned long GPUShaderStageFlags;
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUShaderStage {
const GPUFlagsConstant VERTEX = 0x1;
const GPUFlagsConstant FRAGMENT = 0x2;
@ -401,17 +404,16 @@ dictionary GPUTextureBindingLayout {
};
enum GPUStorageTextureAccess {
"read-only",
"write-only",
};
dictionary GPUStorageTextureBindingLayout {
required GPUStorageTextureAccess access;
GPUStorageTextureAccess access = "write-only";
required GPUTextureFormat format;
GPUTextureViewDimension viewDimension = "2d";
};
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUBindGroup {
};
GPUBindGroup includes GPUObjectBase;
@ -434,7 +436,7 @@ dictionary GPUBufferBinding {
GPUSize64 size;
};
[Exposed=Window, Serializable]
[Exposed=(Window, DedicatedWorker)]
interface GPUPipelineLayout {
};
GPUPipelineLayout includes GPUObjectBase;
@ -443,7 +445,7 @@ dictionary GPUPipelineLayoutDescriptor : GPUObjectDescriptorBase {
required sequence<GPUBindGroupLayout> bindGroupLayouts;
};
[Exposed=Window, Serializable]
[Exposed=(Window, DedicatedWorker)]
interface GPUShaderModule {
Promise<GPUCompilationInfo> compilationInfo();
};
@ -460,7 +462,7 @@ enum GPUCompilationMessageType {
"info"
};
[Exposed=Window, Serializable]
[Exposed=(Window, DedicatedWorker), Serializable]
interface GPUCompilationMessage {
readonly attribute DOMString message;
readonly attribute GPUCompilationMessageType type;
@ -470,7 +472,7 @@ interface GPUCompilationMessage {
readonly attribute unsigned long long length;
};
[Exposed=Window, Serializable]
[Exposed=(Window, DedicatedWorker), Serializable]
interface GPUCompilationInfo {
readonly attribute FrozenArray<GPUCompilationMessage> messages;
};
@ -491,7 +493,7 @@ dictionary GPUProgrammableStage {
typedef double GPUPipelineConstantValue; // May represent WGSLs bool, f32, i32, u32.
[Exposed=Window, Serializable]
[Exposed=(Window, DedicatedWorker)]
interface GPUComputePipeline {
};
GPUComputePipeline includes GPUObjectBase;
@ -501,7 +503,7 @@ dictionary GPUComputePipelineDescriptor : GPUPipelineDescriptorBase {
required GPUProgrammableStage compute;
};
[Exposed=Window, Serializable]
[Exposed=(Window, DedicatedWorker)]
interface GPURenderPipeline {
};
GPURenderPipeline includes GPUObjectBase;
@ -567,7 +569,7 @@ dictionary GPUBlendState {
};
typedef [EnforceRange] unsigned long GPUColorWriteFlags;
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUColorWrite {
const GPUFlagsConstant RED = 0x1;
const GPUFlagsConstant GREEN = 0x2;
@ -679,7 +681,7 @@ enum GPUVertexFormat {
"sint32x4",
};
enum GPUInputStepMode {
enum GPUVertexStepMode {
"vertex",
"instance"
};
@ -690,7 +692,7 @@ dictionary GPUVertexState: GPUProgrammableStage {
dictionary GPUVertexBufferLayout {
required GPUSize64 arrayStride;
GPUInputStepMode stepMode = "vertex";
GPUVertexStepMode stepMode = "vertex";
required sequence<GPUVertexAttribute> attributes;
};
@ -701,7 +703,7 @@ dictionary GPUVertexAttribute {
required GPUIndex32 shaderLocation;
};
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUCommandBuffer {
readonly attribute Promise<double> executionTime;
};
@ -710,7 +712,7 @@ GPUCommandBuffer includes GPUObjectBase;
dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
};
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUCommandEncoder {
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
@ -756,8 +758,6 @@ GPUCommandEncoder includes GPUObjectBase;
dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
boolean measureExecutionTime = false;
// TODO: reusability flag?
};
dictionary GPUImageDataLayout {
@ -791,7 +791,7 @@ interface mixin GPUProgrammablePassEncoder {
undefined insertDebugMarker(USVString markerLabel);
};
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUComputePassEncoder {
undefined setPipeline(GPUComputePipeline pipeline);
undefined dispatch(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1);
@ -827,7 +827,7 @@ interface mixin GPURenderEncoderBase {
undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
};
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPURenderPassEncoder {
undefined setViewport(float x, float y,
float width, float height,
@ -889,7 +889,13 @@ enum GPUStoreOp {
"discard"
};
[Exposed=Window]
dictionary GPURenderPassLayout: GPUObjectDescriptorBase {
required sequence<GPUTextureFormat> colorFormats;
GPUTextureFormat depthStencilFormat;
GPUSize32 sampleCount = 1;
};
[Exposed=(Window, DedicatedWorker)]
interface GPURenderBundle {
};
GPURenderBundle includes GPUObjectBase;
@ -897,7 +903,7 @@ GPURenderBundle includes GPUObjectBase;
dictionary GPURenderBundleDescriptor : GPUObjectDescriptorBase {
};
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPURenderBundleEncoder {
GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
};
@ -905,13 +911,12 @@ GPURenderBundleEncoder includes GPUObjectBase;
GPURenderBundleEncoder includes GPUProgrammablePassEncoder;
GPURenderBundleEncoder includes GPURenderEncoderBase;
dictionary GPURenderBundleEncoderDescriptor : GPUObjectDescriptorBase {
required sequence<GPUTextureFormat> colorFormats;
GPUTextureFormat depthStencilFormat;
GPUSize32 sampleCount = 1;
dictionary GPURenderBundleEncoderDescriptor : GPURenderPassLayout {
boolean depthReadOnly = false;
boolean stencilReadOnly = false;
};
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUQueue {
undefined submit(sequence<GPUCommandBuffer> commandBuffers);
@ -932,7 +937,7 @@ interface GPUQueue {
};
GPUQueue includes GPUObjectBase;
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUQuerySet {
undefined destroy();
};
@ -962,7 +967,7 @@ enum GPUDeviceLostReason {
"destroyed",
};
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUDeviceLostInfo {
readonly attribute (GPUDeviceLostReason or undefined) reason;
readonly attribute DOMString message;
@ -977,12 +982,12 @@ enum GPUErrorFilter {
"validation"
};
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUOutOfMemoryError {
constructor();
};
[Exposed=Window]
[Exposed=(Window, DedicatedWorker)]
interface GPUValidationError {
constructor(DOMString message);
readonly attribute DOMString message;