1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 16:49:18 -05:00

chore: update wgpu and realign to spec (#9760)

This commit is contained in:
Luca Casonato 2021-05-06 16:48:45 +02:00 committed by GitHub
parent ce76f8c3a9
commit f208e6a26f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 684 additions and 632 deletions

121
Cargo.lock generated
View file

@ -83,12 +83,15 @@ name = "arrayvec"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
dependencies = [
"serde",
]
[[package]]
name = "ash"
version = "0.31.0"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c69a8137596e84c22d57f3da1b5de1d4230b1742a710091c85f4d7ce50f00f38"
checksum = "06063a002a77d2734631db74e8f4ce7148b77fe522e6bca46f2ae7774fd48112"
dependencies = [
"libloading",
]
@ -351,6 +354,16 @@ dependencies = [
"objc",
]
[[package]]
name = "codespan-reporting"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
dependencies = [
"termcolor",
"unicode-width",
]
[[package]]
name = "convert_case"
version = "0.4.0"
@ -438,9 +451,9 @@ dependencies = [
[[package]]
name = "d3d12"
version = "0.3.2"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0a60cceb22c7c53035f8980524fdc7f17cf49681a3c154e6757d30afbec6ec4"
checksum = "091ed1b25fe47c7ff129fc440c23650b6114f36aa00bc7212cc8041879294428"
dependencies = [
"bitflags",
"libloading",
@ -1271,9 +1284,9 @@ dependencies = [
[[package]]
name = "gfx-auxil"
version = "0.8.0"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7b33ecf067f2117668d91c9b0f2e5f223ebd1ffec314caa2f3de27bb580186d"
checksum = "9ccf8711c9994dfa34337466bee3ae1462e172874c432ce4eb120ab2e98d39cf"
dependencies = [
"fxhash",
"gfx-hal",
@ -1282,9 +1295,9 @@ dependencies = [
[[package]]
name = "gfx-backend-dx11"
version = "0.7.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f851d03c2e8f117e3702bf41201a4fafa447d5cb1276d5375870ae7573d069dd"
checksum = "6f839f27f8c8a6dc553ccca7f5b35a42009432bc25db9688bba7061cd394161f"
dependencies = [
"arrayvec",
"bitflags",
@ -1304,9 +1317,9 @@ dependencies = [
[[package]]
name = "gfx-backend-dx12"
version = "0.7.1"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5032d716a2a5f4dafb4675a794c5dc32081af8fbc7303c93ad93ff5413c6559f"
checksum = "3937738b0da5839bba4e33980d29f9a06dbce184d04a3a08c9a949e7953700e3"
dependencies = [
"arrayvec",
"bit-set",
@ -1326,9 +1339,9 @@ dependencies = [
[[package]]
name = "gfx-backend-empty"
version = "0.7.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f07ef26a65954cfdd7b4c587f485100d1bb3b0bd6a51b02d817d6c87cca7a91"
checksum = "2ac55ada4bfcd35479b3421eea324d36d7da5f724e2f66ecb36d4efdb7041a5e"
dependencies = [
"gfx-hal",
"log",
@ -1337,13 +1350,13 @@ dependencies = [
[[package]]
name = "gfx-backend-gl"
version = "0.7.1"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6717c50ab601efe4a669bfb44db615e3888695ac8263222aeaa702642b9fbc2"
checksum = "0caa03d6e0b7b4f202aea1f20c3f3288cfa06d92d24cea9d69c9a7627967244a"
dependencies = [
"arrayvec",
"bitflags",
"gfx-auxil",
"fxhash",
"gfx-hal",
"glow",
"js-sys",
@ -1353,16 +1366,15 @@ dependencies = [
"naga",
"parking_lot",
"raw-window-handle",
"spirv_cross",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "gfx-backend-metal"
version = "0.7.0"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dc54b456ece69ef49f8893269ebf24ac70969ed34ba2719c3f3abcc8fbff14e"
checksum = "96a809b746d8063ade971cfb3f188e2b0d655926979823d80be7590390f4b911"
dependencies = [
"arrayvec",
"bitflags",
@ -1370,24 +1382,24 @@ dependencies = [
"cocoa-foundation",
"copyless",
"foreign-types",
"gfx-auxil",
"fxhash",
"gfx-hal",
"log",
"metal",
"naga",
"objc",
"parking_lot",
"profiling",
"range-alloc",
"raw-window-handle",
"spirv_cross",
"storage-map",
]
[[package]]
name = "gfx-backend-vulkan"
version = "0.7.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dabe88b1a5c91e0f969b441cc57e70364858066e4ba937deeb62065654ef9bd9"
checksum = "a353fc6fdb42ec646de49bbb74e4870e37a7e680caf33f3ac0615c30b1146d94"
dependencies = [
"arrayvec",
"ash",
@ -1406,9 +1418,9 @@ dependencies = [
[[package]]
name = "gfx-hal"
version = "0.7.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1d9cc8d3b573dda62d0baca4f02e0209786e22c562caff001d77c389008781d"
checksum = "6d285bfd566f6b9134af908446ca350c0a1047495dfb9bbd826e701e8ee1d259"
dependencies = [
"bitflags",
"naga",
@ -1418,9 +1430,9 @@ dependencies = [
[[package]]
name = "glow"
version = "0.7.2"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "072136d2c3783f3a92f131acb227bc806d3886278e2a4dc1e9990ec89ef9e70b"
checksum = "4b80b98efaa8a34fce11d60dd2ce2760d5d83c373cbcc73bb87c2a3a84a54108"
dependencies = [
"js-sys",
"slotmap",
@ -1430,13 +1442,12 @@ dependencies = [
[[package]]
name = "gpu-alloc"
version = "0.3.0"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e7724b9aef57ea36d70faf54e0ee6265f86e41de16bed8333efdeab5b00e16b"
checksum = "bc76088804bb65a6f3b880bea9306fdaeffb25ebb453105fafa691282ee9fdba"
dependencies = [
"bitflags",
"gpu-alloc-types",
"tracing",
]
[[package]]
@ -1457,7 +1468,6 @@ dependencies = [
"bitflags",
"gpu-descriptor-types",
"hashbrown",
"tracing",
]
[[package]]
@ -1759,9 +1769,9 @@ dependencies = [
[[package]]
name = "khronos-egl"
version = "3.0.2"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b19cc4a81304db2a0ad69740e83cdc3a9364e3f9bd6d88a87288a4c2deec927b"
checksum = "8c2352bd1d0bceb871cb9d40f24360c8133c11d7486b68b5381c1dd1a32015e3"
dependencies = [
"libc",
"libloading",
@ -1781,9 +1791,9 @@ checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41"
[[package]]
name = "libloading"
version = "0.6.7"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883"
checksum = "6f84d96438c15fcd6c3f244c8fce01d1e2b9c6b5623e9c711dc9286d8fc92d6a"
dependencies = [
"cfg-if 1.0.0",
"winapi 0.3.9",
@ -1902,9 +1912,9 @@ checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
[[package]]
name = "metal"
version = "0.21.0"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4598d719460ade24c7d91f335daf055bf2a7eec030728ce751814c50cdd6a26c"
checksum = "1c12e48c737ee9a55e8bb2352bcde588f79ae308d3529ee888f7cc0f469b5777"
dependencies = [
"bitflags",
"block",
@ -1954,17 +1964,17 @@ dependencies = [
[[package]]
name = "naga"
version = "0.3.2"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05089b2acdf0e6a962cdbf5e328402345a27f59fcde1a59fe97a73e8149d416f"
checksum = "a462414ac6a74a8fcc2c6d235d9a92b288f22682c016cf725e75d0c9470fb515"
dependencies = [
"bit-set",
"bitflags",
"codespan-reporting",
"fxhash",
"log",
"num-traits",
"petgraph",
"serde",
"spirv_headers",
"thiserror",
]
@ -2318,6 +2328,12 @@ dependencies = [
"unicode-xid 0.2.1",
]
[[package]]
name = "profiling"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3a66d5e88679f2720126c11ee29da07a08f094eac52306b066edd7d393752d6"
[[package]]
name = "pty"
version = "0.2.2"
@ -3457,9 +3473,9 @@ dependencies = [
[[package]]
name = "thunderdome"
version = "0.3.0"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7572415bd688d401c52f6e36f4c8e805b9ae1622619303b9fa835d531db0acae"
checksum = "87b4947742c93ece24a0032141d9caa3d853752e694a57e35029dd2bd08673e0"
[[package]]
name = "time"
@ -3627,21 +3643,9 @@ checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f"
dependencies = [
"cfg-if 1.0.0",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2"
dependencies = [
"proc-macro2 1.0.26",
"quote 1.0.9",
"syn 1.0.65",
]
[[package]]
name = "tracing-core"
version = "0.1.17"
@ -4034,9 +4038,9 @@ dependencies = [
[[package]]
name = "wgpu-core"
version = "0.7.1"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c89fa2cc5d72236461ac09c5be967012663e29cb62f1a972654cbf35e49dffa8"
checksum = "59abd59fe91fe502fe2dd8777bcac414069199af22dd2a92a1bb635f9f251425"
dependencies = [
"arrayvec",
"bitflags",
@ -4052,21 +4056,22 @@ dependencies = [
"gfx-hal",
"gpu-alloc",
"gpu-descriptor",
"log",
"naga",
"parking_lot",
"profiling",
"ron",
"serde",
"smallvec",
"thiserror",
"tracing",
"wgpu-types",
]
[[package]]
name = "wgpu-types"
version = "0.7.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72fa9ba80626278fd87351555c363378d08122d7601e58319be3d6fa85a87747"
checksum = "aa248d90c8e6832269b8955bf800e8241f942c25e18a235b7752226804d21556"
dependencies = [
"bitflags",
"serde",

View file

@ -967,7 +967,8 @@ fn init_logger(maybe_level: Option<Level>) {
)
// https://github.com/denoland/deno/issues/6641
.filter_module("rustyline", LevelFilter::Off)
// wgpu backend crates (gfx_backend), have a lot of useless INFO and WARN logs
// wgpu crates (gfx_backend), have a lot of useless INFO and WARN logs
.filter_module("wgpu", LevelFilter::Error)
.filter_module("gfx", LevelFilter::Error)
.format(|buf, record| {
let mut target = record.target().to_string();

View file

@ -49,18 +49,13 @@ unitTest({
storageBuffer.unmap();
const bindGroupLayout = device.createBindGroupLayout({
entries: [
{
binding: 0,
visibility: 4,
buffer: {
type: "storage",
minBindingSize: 4,
const computePipeline = device.createComputePipeline({
compute: {
module: shaderModule,
entryPoint: "main",
},
},
],
});
const bindGroupLayout = computePipeline.getBindGroupLayout(0);
const bindGroup = device.createBindGroup({
layout: bindGroupLayout,
@ -74,18 +69,6 @@ unitTest({
],
});
const pipelineLayout = device.createPipelineLayout({
bindGroupLayouts: [bindGroupLayout],
});
const computePipeline = device.createComputePipeline({
layout: pipelineLayout,
compute: {
module: shaderModule,
entryPoint: "main",
},
});
const encoder = device.createCommandEncoder();
const computePass = encoder.beginComputePass();

View file

@ -1,14 +1,9 @@
[[builtin(global_invocation_id)]]
var global_id: vec3<u32>;
[[block]]
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;
// The Collatz Conjecture states that for any integer n:
// If n is even, n = n/2
// If n is odd, n = 3n+1
@ -26,14 +21,17 @@ fn collatz_iterations(n_base: u32) -> u32{
n = n / 2u;
}
else {
// Overflow? (i.e. 3*n + 1 > 0xffffffffu?)
if (n >= 1431655765u) { // 0x55555555u
return 4294967295u; // 0xffffffffu
}
n = 3u * n + 1u;
}
i = i + 1u;
}
return i;
}
[[stage(compute), workgroup_size(1)]]
fn main() {
fn main([[builtin(global_invocation_id)]] global_id: vec3<u32>) {
v_indices.data[global_id.x] = collatz_iterations(v_indices.data[global_id.x]);
}

View file

@ -1,19 +1,10 @@
[[builtin(vertex_index)]]
var<in> in_vertex_index: u32;
[[builtin(position)]]
var<out> out_pos: vec4<f32>;
[[stage(vertex)]]
fn vs_main() {
var x: f32 = f32(i32(in_vertex_index) - 1);
var y: f32 = f32(i32(in_vertex_index & 1) * 2 - 1);
out_pos = vec4<f32>(x, y, 0.0, 1.0);
fn vs_main([[builtin(vertex_index)]] in_vertex_index: u32) -> [[builtin(position)]] vec4<f32> {
let x = f32(i32(in_vertex_index) - 1);
let y = f32(i32(in_vertex_index & 1u) * 2 - 1);
return vec4<f32>(x, y, 0.0, 1.0);
}
[[location(0)]]
var<out> out_color: vec4<f32>;
[[stage(fragment)]]
fn fs_main() {
out_color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
fn fs_main() -> [[location(0)]] vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
}

View file

@ -79,7 +79,7 @@
return {
width: data[0],
height: data[1],
depth: data[2],
depthOrArrayLayers: data[2],
};
} else {
return data;
@ -179,7 +179,7 @@
/**
* @typedef InnerGPUAdapter
* @property {number} rid
* @property {GPUAdapterFeatures} features
* @property {GPUSupportedFeatures} features
* @property {GPUAdapterLimits} limits
*/
@ -194,7 +194,7 @@
adapter[_name] = name;
adapter[_adapter] = {
...inner,
features: createGPUAdapterFeatures(inner.features),
features: createGPUSupportedFeatures(inner.features),
limits: createGPUAdapterLimits(inner.limits),
};
return adapter;
@ -211,7 +211,7 @@
webidl.assertBranded(this, GPUAdapter);
return this[_name];
}
/** @returns {GPUAdapterFeatures} */
/** @returns {GPUSupportedFeatures} */
get features() {
webidl.assertBranded(this, GPUAdapter);
return this[_adapter].features;
@ -245,7 +245,7 @@
);
}
}
const nonGuaranteedLimits = descriptor.nonGuaranteedLimits ?? [];
const nonGuaranteedLimits = descriptor.nonGuaranteedLimits;
// TODO(lucacasonato): validate nonGuaranteedLimits
const { rid, features, limits } = await core.opAsync(
@ -320,16 +320,20 @@
}
get maxTextureDimension1D() {
throw new TypeError("Not yet implemented");
webidl.assertBranded(this, GPUAdapterLimits);
return this[_limits].maxTextureDimension1D;
}
get maxTextureDimension2D() {
throw new TypeError("Not yet implemented");
webidl.assertBranded(this, GPUAdapterLimits);
return this[_limits].maxTextureDimension2D;
}
get maxTextureDimension3D() {
throw new TypeError("Not yet implemented");
webidl.assertBranded(this, GPUAdapterLimits);
return this[_limits].maxTextureDimension3D;
}
get maxTextureArrayLayers() {
throw new TypeError("Not yet implemented");
webidl.assertBranded(this, GPUAdapterLimits);
return this[_limits].maxTextureArrayLayers;
}
get maxBindGroups() {
webidl.assertBranded(this, GPUAdapterLimits);
@ -368,16 +372,20 @@
return this[_limits].maxUniformBufferBindingSize;
}
get maxStorageBufferBindingSize() {
throw new TypeError("Not yet implemented");
webidl.assertBranded(this, GPUAdapterLimits);
return this[_limits].maxStorageBufferBindingSize;
}
get maxVertexBuffers() {
throw new TypeError("Not yet implemented");
webidl.assertBranded(this, GPUAdapterLimits);
return this[_limits].maxVertexBuffers;
}
get maxVertexAttributes() {
throw new TypeError("Not yet implemented");
webidl.assertBranded(this, GPUAdapterLimits);
return this[_limits].maxVertexAttributes;
}
get maxVertexBufferArrayStride() {
throw new TypeError("Not yet implemented");
webidl.assertBranded(this, GPUAdapterLimits);
return this[_limits].maxVertexBufferArrayStride;
}
[Symbol.for("Deno.customInspect")](inspect) {
@ -387,14 +395,14 @@
const _features = Symbol("[[features]]");
function createGPUAdapterFeatures(features) {
/** @type {GPUAdapterFeatures} */
const adapterFeatures = webidl.createBranded(GPUAdapterFeatures);
function createGPUSupportedFeatures(features) {
/** @type {GPUSupportedFeatures} */
const adapterFeatures = webidl.createBranded(GPUSupportedFeatures);
adapterFeatures[_features] = new Set(features);
return adapterFeatures;
}
class GPUAdapterFeatures {
class GPUSupportedFeatures {
/** @type {Set<string>} */
[_features];
@ -404,42 +412,42 @@
/** @return {IterableIterator<[string, string]>} */
entries() {
webidl.assertBranded(this, GPUAdapterFeatures);
webidl.assertBranded(this, GPUSupportedFeatures);
return this[_features].entries();
}
/** @return {void} */
forEach(callbackfn, thisArg) {
webidl.assertBranded(this, GPUAdapterFeatures);
webidl.assertBranded(this, GPUSupportedFeatures);
this[_features].forEach(callbackfn, thisArg);
}
/** @return {boolean} */
has(value) {
webidl.assertBranded(this, GPUAdapterFeatures);
webidl.assertBranded(this, GPUSupportedFeatures);
return this[_features].has(value);
}
/** @return {IterableIterator<string>} */
keys() {
webidl.assertBranded(this, GPUAdapterFeatures);
webidl.assertBranded(this, GPUSupportedFeatures);
return this[_features].keys();
}
/** @return {IterableIterator<string>} */
values() {
webidl.assertBranded(this, GPUAdapterFeatures);
webidl.assertBranded(this, GPUSupportedFeatures);
return this[_features].values();
}
/** @return {number} */
get size() {
webidl.assertBranded(this, GPUAdapterFeatures);
webidl.assertBranded(this, GPUSupportedFeatures);
return this[_features].size;
}
[Symbol.iterator]() {
webidl.assertBranded(this, GPUAdapterFeatures);
webidl.assertBranded(this, GPUSupportedFeatures);
return this[_features][Symbol.iterator]();
}
@ -661,10 +669,6 @@
}
}
get adapter() {
webidl.assertBranded(this, GPUDevice);
return this[_device].adapter;
}
get features() {
webidl.assertBranded(this, GPUDevice);
return this[_device].features;
@ -1291,7 +1295,6 @@
[Symbol.for("Deno.customInspect")](inspect) {
return `${this.constructor.name} ${
inspect({
adapter: this.adapter,
features: this.features,
label: this.label,
limits: this.limits,
@ -1693,41 +1696,7 @@
if (size === undefined) {
rangeSize = Math.max(0, this[_size] - offset);
} else {
rangeSize = this[_size];
}
if (this[_state] !== "mapped" && this[_state] !== "mapped at creation") {
throw new DOMException(
`${prefix}: buffer is not mapped.`,
"OperationError",
);
}
if ((offset % 8) !== 0) {
throw new DOMException(
`${prefix}: offset must be a multiple of 8.`,
"OperationError",
);
}
if ((rangeSize % 4) !== 0) {
throw new DOMException(
`${prefix}: rangeSize must be a multiple of 4.`,
"OperationError",
);
}
const mappingRange = this[_mappingRange];
if (!mappingRange) {
throw new DOMException(`${prefix}: invalid state.`, "OperationError");
}
if (offset < mappingRange[0]) {
throw new DOMException(
`${prefix}: offset is out of bounds.`,
"OperationError",
);
}
if ((offset + rangeSize) > mappingRange[1]) {
throw new DOMException(
`${prefix}: offset is out of bounds.`,
"OperationError",
);
rangeSize = size;
}
const mappedRanges = this[_mappedRanges];
if (!mappedRanges) {
@ -1752,8 +1721,8 @@
"op_webgpu_buffer_get_mapped_range",
{
bufferRid,
offset: offset - mappingRange[0],
size: rangeSize,
offset,
size,
},
new Uint8Array(buffer),
);
@ -3324,10 +3293,10 @@
/**
* @param {GPUColor} color
*/
setBlendColor(color) {
setBlendConstant(color) {
webidl.assertBranded(this, GPURenderPassEncoder);
const prefix =
"Failed to execute 'setBlendColor' on 'GPUComputePassEncoder'";
"Failed to execute 'setBlendConstant' on 'GPUComputePassEncoder'";
webidl.requiredArguments(arguments.length, 1, { prefix });
color = webidl.converters.GPUColor(color, {
prefix,
@ -3342,7 +3311,7 @@
context: "encoder referenced by this",
});
const renderPassRid = assertResource(this, { prefix, context: "this" });
core.opSync("op_webgpu_render_pass_set_blend_color", {
core.opSync("op_webgpu_render_pass_set_blend_constant", {
renderPassRid,
color: normalizeGPUColor(color),
});
@ -5017,7 +4986,7 @@
GPU,
GPUAdapter,
GPUAdapterLimits,
GPUAdapterFeatures,
GPUSupportedFeatures,
GPUDevice,
GPUQueue,
GPUBuffer,

View file

@ -11,7 +11,7 @@
GPU,
GPUAdapter,
GPUAdapterLimits,
GPUAdapterFeatures,
GPUSupportedFeatures,
GPUDevice,
GPUQueue,
GPUBuffer,
@ -58,10 +58,10 @@
GPUAdapterLimits,
);
// INTERFACE: GPUAdapterFeatures
webidl.converters.GPUAdapterFeatures = webidl.createInterfaceConverter(
"GPUAdapterFeatures",
GPUAdapterFeatures,
// INTERFACE: GPUSupportedFeatures
webidl.converters.GPUSupportedFeatures = webidl.createInterfaceConverter(
"GPUSupportedFeatures",
GPUSupportedFeatures,
);
// INTERFACE: GPU
@ -229,7 +229,7 @@
{
key: "width",
converter: webidl.converters["GPUIntegerCoordinate"],
defaultValue: 1,
required: true,
},
{
key: "height",
@ -835,28 +835,6 @@
dictMembersGPUPipelineLayoutDescriptor,
);
// ENUM: GPUCompilationMessageType
webidl.converters["GPUCompilationMessageType"] = webidl.createEnumConverter(
"GPUCompilationMessageType",
[
"error",
"warning",
"info",
],
);
// // INTERFACE: GPUCompilationMessage
// webidl.converters.GPUCompilationMessage = webidl.createInterfaceConverter(
// "GPUCompilationMessage",
// GPUCompilationMessage,
// );
// // INTERFACE: GPUCompilationInfo
// webidl.converters.GPUCompilationInfo = webidl.createInterfaceConverter(
// "GPUCompilationInfo",
// GPUCompilationInfo,
// );
// INTERFACE: GPUShaderModule
webidl.converters.GPUShaderModule = webidl.createInterfaceConverter(
"GPUShaderModule",
@ -891,6 +869,28 @@
dictMembersGPUShaderModuleDescriptor,
);
// // ENUM: GPUCompilationMessageType
// webidl.converters["GPUCompilationMessageType"] = webidl.createEnumConverter(
// "GPUCompilationMessageType",
// [
// "error",
// "warning",
// "info",
// ],
// );
// // INTERFACE: GPUCompilationMessage
// webidl.converters.GPUCompilationMessage = webidl.createInterfaceConverter(
// "GPUCompilationMessage",
// GPUCompilationMessage,
// );
// // INTERFACE: GPUCompilationInfo
// webidl.converters.GPUCompilationInfo = webidl.createInterfaceConverter(
// "GPUCompilationInfo",
// GPUCompilationInfo,
// );
// DICTIONARY: GPUPipelineDescriptorBase
const dictMembersGPUPipelineDescriptorBase = [
{ key: "layout", converter: webidl.converters["GPUPipelineLayout"] },
@ -960,36 +960,36 @@
webidl.converters["GPUVertexFormat"] = webidl.createEnumConverter(
"GPUVertexFormat",
[
"uchar2",
"uchar4",
"char2",
"char4",
"uchar2norm",
"uchar4norm",
"char2norm",
"char4norm",
"ushort2",
"ushort4",
"short2",
"short4",
"ushort2norm",
"ushort4norm",
"short2norm",
"short4norm",
"half2",
"half4",
"float",
"float2",
"float3",
"float4",
"uint",
"uint2",
"uint3",
"uint4",
"int",
"int2",
"int3",
"int4",
"uint8x2",
"uint8x4",
"sint8x2",
"sint8x4",
"unorm8x2",
"unorm8x4",
"snorm8x2",
"snorm8x4",
"uint16x2",
"uint16x4",
"sint16x2",
"sint16x4",
"unorm16x2",
"unorm16x4",
"snorm16x2",
"snorm16x4",
"float16x2",
"float16x4",
"float32",
"float32x2",
"float32x3",
"float32x4",
"uint32",
"uint32x2",
"uint32x3",
"uint32x4",
"sint32",
"sint32x2",
"sint32x3",
"sint32x4",
],
);
@ -1116,6 +1116,11 @@
converter: webidl.converters["GPUCullMode"],
defaultValue: "none",
},
{
key: "clampDepth",
converter: webidl.converters["boolean"],
defaultValue: false,
},
];
webidl.converters["GPUPrimitiveState"] = webidl.createDictionaryConverter(
"GPUPrimitiveState",
@ -1229,11 +1234,6 @@
converter: webidl.converters["float"],
defaultValue: 0,
},
{
key: "clampDepth",
converter: webidl.converters["boolean"],
defaultValue: false,
},
];
webidl.converters["GPUDepthStencilState"] = webidl.createDictionaryConverter(
"GPUDepthStencilState",
@ -1273,17 +1273,17 @@
[
"zero",
"one",
"src-color",
"one-minus-src-color",
"src",
"one-minus-src",
"src-alpha",
"one-minus-src-alpha",
"dst-color",
"one-minus-dst-color",
"dst",
"one-minus-dst",
"dst-alpha",
"one-minus-dst-alpha",
"src-alpha-saturated",
"blend-color",
"one-minus-blend-color",
"constant",
"one-minus-constant",
],
);
@ -1559,6 +1559,44 @@
dictMembersGPUImageCopyTexture,
);
// DICTIONARY: GPUOrigin2DDict
const dictMembersGPUOrigin2DDict = [
{
key: "x",
converter: webidl.converters["GPUIntegerCoordinate"],
defaultValue: 0,
},
{
key: "y",
converter: webidl.converters["GPUIntegerCoordinate"],
defaultValue: 0,
},
];
webidl.converters["GPUOrigin2DDict"] = webidl.createDictionaryConverter(
"GPUOrigin2DDict",
dictMembersGPUOrigin2DDict,
);
// TYPEDEF: GPUOrigin2D
webidl.converters["GPUOrigin2D"] = (V, opts) => {
// Union for (sequence<GPUIntegerCoordinate> or GPUOrigin2DDict)
if (V === null || V === undefined) {
return webidl.converters["GPUOrigin2DDict"](V, opts);
}
if (typeof V === "object") {
const method = V[Symbol.iterator];
if (method !== undefined) {
return webidl.converters["sequence<GPUIntegerCoordinate>"](V, opts);
}
return webidl.converters["GPUOrigin2DDict"](V, opts);
}
throw webidl.makeException(
TypeError,
"can not be converted to sequence<GPUIntegerCoordinate> or GPUOrigin2DDict.",
opts,
);
};
// INTERFACE: GPUComputePassEncoder
webidl.converters.GPUComputePassEncoder = webidl.createInterfaceConverter(
"GPUComputePassEncoder",
@ -1615,8 +1653,9 @@
"can not be converted to sequence<double> or GPUColorDict.",
opts,
);
}; // ENUM: GPUStoreOp
};
// ENUM: GPUStoreOp
webidl.converters["GPUStoreOp"] = webidl.createEnumConverter("GPUStoreOp", [
"store",
"clear",
@ -1638,7 +1677,7 @@
{
key: "storeOp",
converter: webidl.converters["GPUStoreOp"],
defaultValue: "store",
required: true,
},
];
webidl.converters["GPURenderPassColorAttachment"] = webidl
@ -1885,42 +1924,4 @@
// TYPEDEF: GPUFlagsConstant
webidl.converters["GPUFlagsConstant"] = webidl.converters["unsigned long"];
// DICTIONARY: GPUOrigin2DDict
const dictMembersGPUOrigin2DDict = [
{
key: "x",
converter: webidl.converters["GPUIntegerCoordinate"],
defaultValue: 0,
},
{
key: "y",
converter: webidl.converters["GPUIntegerCoordinate"],
defaultValue: 0,
},
];
webidl.converters["GPUOrigin2DDict"] = webidl.createDictionaryConverter(
"GPUOrigin2DDict",
dictMembersGPUOrigin2DDict,
);
// TYPEDEF: GPUOrigin2D
webidl.converters["GPUOrigin2D"] = (V, opts) => {
// Union for (sequence<GPUIntegerCoordinate> or GPUOrigin2DDict)
if (V === null || V === undefined) {
return webidl.converters["GPUOrigin2DDict"](V, opts);
}
if (typeof V === "object") {
const method = V[Symbol.iterator];
if (method !== undefined) {
return webidl.converters["sequence<GPUIntegerCoordinate>"](V, opts);
}
return webidl.converters["GPUOrigin2DDict"](V, opts);
}
throw webidl.makeException(
TypeError,
"can not be converted to sequence<GPUIntegerCoordinate> or GPUOrigin2DDict.",
opts,
);
};
})(this);

View file

@ -17,5 +17,5 @@ path = "lib.rs"
deno_core = { version = "0.86.0", path = "../../core" }
tokio = { version = "1.4.0", features = ["full"] }
serde = { version = "1.0.125", features = ["derive"] }
wgpu-core = { version = "0.7.0", features = ["trace"] }
wgpu-types = "0.7.0"
wgpu-core = { version = "0.8.0", features = ["trace"] }
wgpu-types = "0.8.0"

View file

@ -131,7 +131,7 @@ pub fn op_webgpu_create_bind_group_layout(
comparison: false,
},
"comparison" => wgpu_types::BindingType::Sampler {
filtering: false,
filtering: true,
comparison: true,
},
_ => unreachable!(),

View file

@ -163,7 +163,7 @@ pub async fn op_webgpu_buffer_get_map_async(
pub struct BufferGetMappedRangeArgs {
buffer_rid: ResourceId,
offset: u64,
size: u64,
size: Option<u64>,
}
pub fn op_webgpu_buffer_get_mapped_range(
@ -179,21 +179,22 @@ pub fn op_webgpu_buffer_get_mapped_range(
.ok_or_else(bad_resource_id)?;
let buffer = buffer_resource.0;
let slice_pointer = gfx_select!(buffer => instance.buffer_get_mapped_range(
let (slice_pointer, range_size) =
gfx_select!(buffer => instance.buffer_get_mapped_range(
buffer,
args.offset,
std::num::NonZeroU64::new(args.size)
std::num::NonZeroU64::new(args.size.unwrap_or(0))
))
.map_err(|e| DomExceptionOperationError::new(&e.to_string()))?;
let slice = unsafe {
std::slice::from_raw_parts_mut(slice_pointer, args.size as usize)
std::slice::from_raw_parts_mut(slice_pointer, range_size as usize)
};
zero_copy.copy_from_slice(slice);
let rid = state
.resource_table
.add(WebGpuBufferMapped(slice_pointer, args.size as usize));
.add(WebGpuBufferMapped(slice_pointer, range_size as usize));
Ok(WebGpuResult::rid(rid))
}

View file

@ -222,11 +222,9 @@ pub fn op_webgpu_render_bundle_encoder_pop_debug_group(
.get::<WebGpuRenderBundleEncoder>(args.render_bundle_encoder_rid)
.ok_or_else(bad_resource_id)?;
unsafe {
wgpu_core::command::bundle_ffi::wgpu_render_bundle_pop_debug_group(
&mut render_bundle_encoder_resource.0.borrow_mut(),
);
}
Ok(WebGpuResult::empty())
}

View file

@ -8,6 +8,7 @@ use deno_core::{OpState, Resource};
use serde::Deserialize;
use std::borrow::Cow;
use std::cell::RefCell;
use std::num::NonZeroU32;
use super::error::WebGpuResult;
@ -120,8 +121,8 @@ pub fn op_webgpu_command_encoder_begin_render_pass(
.get::<super::texture::WebGpuTextureView>(color_attachment.view)
.ok_or_else(bad_resource_id)?;
let attachment = wgpu_core::command::ColorAttachmentDescriptor {
attachment: texture_view_resource.0,
let attachment = wgpu_core::command::RenderPassColorAttachment {
view: texture_view_resource.0,
resolve_target: color_attachment
.resolve_target
.map(|rid| {
@ -173,8 +174,8 @@ pub fn op_webgpu_command_encoder_begin_render_pass(
.ok_or_else(bad_resource_id)?;
depth_stencil_attachment =
Some(wgpu_core::command::DepthStencilAttachmentDescriptor {
attachment: texture_view_resource.0,
Some(wgpu_core::command::RenderPassDepthStencilAttachment {
view: texture_view_resource.0,
depth: match attachment.depth_load_op.as_str() {
"load" => wgpu_core::command::PassChannel {
load_op: wgpu_core::command::LoadOp::Load,
@ -361,15 +362,15 @@ pub fn op_webgpu_command_encoder_copy_buffer_to_texture(
.get::<super::texture::WebGpuTexture>(args.destination.texture)
.ok_or_else(bad_resource_id)?;
let source = wgpu_core::command::BufferCopyView {
let source = wgpu_core::command::ImageCopyBuffer {
buffer: source_buffer_resource.0,
layout: wgpu_types::TextureDataLayout {
layout: wgpu_types::ImageDataLayout {
offset: args.source.offset.unwrap_or(0),
bytes_per_row: args.source.bytes_per_row.unwrap_or(0),
rows_per_image: args.source.rows_per_image.unwrap_or(0),
bytes_per_row: NonZeroU32::new(args.source.bytes_per_row.unwrap_or(0)),
rows_per_image: NonZeroU32::new(args.source.rows_per_image.unwrap_or(0)),
},
};
let destination = wgpu_core::command::TextureCopyView {
let destination = wgpu_core::command::ImageCopyTexture {
texture: destination_texture_resource.0,
mip_level: args.destination.mip_level.unwrap_or(0),
origin: args
@ -388,7 +389,7 @@ pub fn op_webgpu_command_encoder_copy_buffer_to_texture(
&wgpu_types::Extent3d {
width: args.copy_size.width.unwrap_or(1),
height: args.copy_size.height.unwrap_or(1),
depth: args.copy_size.depth.unwrap_or(1),
depth_or_array_layers: args.copy_size.depth_or_array_layers.unwrap_or(1),
}
))
}
@ -422,7 +423,7 @@ pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
.get::<super::buffer::WebGpuBuffer>(args.destination.buffer)
.ok_or_else(bad_resource_id)?;
let source = wgpu_core::command::TextureCopyView {
let source = wgpu_core::command::ImageCopyTexture {
texture: source_texture_resource.0,
mip_level: args.source.mip_level.unwrap_or(0),
origin: args.source.origin.map_or(Default::default(), |origin| {
@ -433,12 +434,16 @@ pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
}
}),
};
let destination = wgpu_core::command::BufferCopyView {
let destination = wgpu_core::command::ImageCopyBuffer {
buffer: destination_buffer_resource.0,
layout: wgpu_types::TextureDataLayout {
layout: wgpu_types::ImageDataLayout {
offset: args.destination.offset.unwrap_or(0),
bytes_per_row: args.destination.bytes_per_row.unwrap_or(0),
rows_per_image: args.destination.rows_per_image.unwrap_or(0),
bytes_per_row: NonZeroU32::new(
args.destination.bytes_per_row.unwrap_or(0),
),
rows_per_image: NonZeroU32::new(
args.destination.rows_per_image.unwrap_or(0),
),
},
};
gfx_ok!(command_encoder => instance.command_encoder_copy_texture_to_buffer(
@ -448,7 +453,7 @@ pub fn op_webgpu_command_encoder_copy_texture_to_buffer(
&wgpu_types::Extent3d {
width: args.copy_size.width.unwrap_or(1),
height: args.copy_size.height.unwrap_or(1),
depth: args.copy_size.depth.unwrap_or(1),
depth_or_array_layers: args.copy_size.depth_or_array_layers.unwrap_or(1),
}
))
}
@ -482,7 +487,7 @@ pub fn op_webgpu_command_encoder_copy_texture_to_texture(
.get::<super::texture::WebGpuTexture>(args.destination.texture)
.ok_or_else(bad_resource_id)?;
let source = wgpu_core::command::TextureCopyView {
let source = wgpu_core::command::ImageCopyTexture {
texture: source_texture_resource.0,
mip_level: args.source.mip_level.unwrap_or(0),
origin: args.source.origin.map_or(Default::default(), |origin| {
@ -493,7 +498,7 @@ pub fn op_webgpu_command_encoder_copy_texture_to_texture(
}
}),
};
let destination = wgpu_core::command::TextureCopyView {
let destination = wgpu_core::command::ImageCopyTexture {
texture: destination_texture_resource.0,
mip_level: args.destination.mip_level.unwrap_or(0),
origin: args
@ -512,7 +517,7 @@ pub fn op_webgpu_command_encoder_copy_texture_to_texture(
&wgpu_types::Extent3d {
width: args.copy_size.width.unwrap_or(1),
height: args.copy_size.height.unwrap_or(1),
depth: args.copy_size.depth.unwrap_or(1),
depth_or_array_layers: args.copy_size.depth_or_array_layers.unwrap_or(1),
}
))
}

View file

@ -132,13 +132,11 @@ pub fn op_webgpu_compute_pass_begin_pipeline_statistics_query(
.get::<super::WebGpuQuerySet>(args.query_set)
.ok_or_else(bad_resource_id)?;
unsafe {
wgpu_core::command::compute_ffi::wgpu_compute_pass_begin_pipeline_statistics_query(
&mut compute_pass_resource.0.borrow_mut(),
query_set_resource.0,
args.query_index,
);
}
Ok(WebGpuResult::empty())
}
@ -159,11 +157,9 @@ pub fn op_webgpu_compute_pass_end_pipeline_statistics_query(
.get::<WebGpuComputePass>(args.compute_pass_rid)
.ok_or_else(bad_resource_id)?;
unsafe {
wgpu_core::command::compute_ffi::wgpu_compute_pass_end_pipeline_statistics_query(
&mut compute_pass_resource.0.borrow_mut(),
);
}
Ok(WebGpuResult::empty())
}
@ -190,13 +186,11 @@ pub fn op_webgpu_compute_pass_write_timestamp(
.get::<super::WebGpuQuerySet>(args.query_set)
.ok_or_else(bad_resource_id)?;
unsafe {
wgpu_core::command::compute_ffi::wgpu_compute_pass_write_timestamp(
&mut compute_pass_resource.0.borrow_mut(),
query_set_resource.0,
args.query_index,
);
}
Ok(WebGpuResult::empty())
}

View file

@ -35,7 +35,7 @@ declare class GPUAdapterLimits {
maxVertexBufferArrayStride?: number;
}
declare class GPUAdapterFeatures {
declare class GPUSupportedFeatures {
forEach(
callbackfn: (
value: GPUFeatureName,
@ -69,10 +69,10 @@ declare type GPUPowerPreference = "low-power" | "high-performance";
declare class GPUAdapter {
readonly name: string;
readonly features: GPUAdapterFeatures;
readonly features: GPUSupportedFeatures;
readonly limits: GPUAdapterLimits;
requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice>;
}
declare interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
@ -114,7 +114,6 @@ declare class GPUDevice extends EventTarget implements GPUObjectBase {
| ((this: GPUDevice, ev: GPUUncapturedErrorEvent) => any)
| null;
readonly adapter: GPUAdapter;
readonly features: ReadonlyArray<GPUFeatureName>;
readonly limits: Record<string, number>;
readonly queue: GPUQueue;
@ -515,6 +514,7 @@ declare interface GPUPrimitiveState {
stripIndexFormat?: GPUIndexFormat;
frontFace?: GPUFrontFace;
cullMode?: GPUCullMode;
clampDepth?: boolean;
}
declare type GPUFrontFace = "ccw" | "cw";
@ -561,17 +561,17 @@ declare interface GPUBlendComponent {
declare type GPUBlendFactor =
| "zero"
| "one"
| "src-color"
| "one-minus-src-color"
| "src"
| "one-minus-src"
| "src-alpha"
| "one-minus-src-alpha"
| "dst-color"
| "one-minus-dst-color"
| "dst"
| "one-minus-dst"
| "dst-alpha"
| "one-minus-dst-alpha"
| "src-alpha-saturated"
| "blend-color"
| "one-minus-blend-color";
| "constant"
| "one-minus-constant";
declare type GPUBlendOperation =
| "add"
@ -595,8 +595,6 @@ declare interface GPUDepthStencilState {
depthBias?: number;
depthBiasSlopeScale?: number;
depthBiasClamp?: number;
clampDepth?: boolean;
}
declare interface GPUStencilFaceState {
@ -619,37 +617,36 @@ declare type GPUStencilOperation =
declare type GPUIndexFormat = "uint16" | "uint32";
declare type GPUVertexFormat =
| "uchar2"
| "uchar4"
| "char2"
| "char4"
| "uchar2norm"
| "uchar4norm"
| "char2norm"
| "char4norm"
| "ushort2"
| "ushort4"
| "short2"
| "short4"
| "ushort2norm"
| "ushort4norm"
| "short2norm"
| "short4norm"
| "half2"
| "half4"
| "float"
| "float2"
| "float3"
| "float4"
| "uint"
| "uint2"
| "uint3"
| "uint4"
| "int"
| "int2"
| "int3"
| "int4";
| "uint8x2"
| "uint8x4"
| "sint8x2"
| "sint8x4"
| "unorm8x2"
| "unorm8x4"
| "snorm8x2"
| "snorm8x4"
| "uint16x2"
| "uint16x4"
| "sint16x2"
| "sint16x4"
| "unorm16x2"
| "unorm16x4"
| "snorm16x2"
| "snorm16x4"
| "float16x2"
| "float16x4"
| "float32"
| "float32x2"
| "float32x3"
| "float32x4"
| "uint32"
| "uint32x2"
| "uint32x3"
| "uint32x4"
| "sint32"
| "sint32x2"
| "sint32x3"
| "sint32x4";
declare type GPUInputStepMode = "vertex" | "instance";
declare interface GPUVertexState extends GPUProgrammableStage {
@ -910,7 +907,7 @@ declare class GPURenderPassEncoder
height: number,
): undefined;
setBlendColor(color: GPUColor): undefined;
setBlendConstant(color: GPUColor): undefined;
setStencilReference(reference: number): undefined;
beginOcclusionQuery(queryIndex: number): undefined;
@ -1118,9 +1115,9 @@ declare interface GPUOrigin3DDict {
declare type GPUOrigin3D = number[] | GPUOrigin3DDict;
declare interface GPUExtent3DDict {
width?: number;
width: number;
height?: number;
depth?: number;
depthOrArrayLayers?: number;
}
declare type GPUExtent3D = number[] | GPUExtent3DDict;

View file

@ -291,10 +291,10 @@ pub async fn op_webgpu_request_adapter(
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct GpuLimits {
_max_texture_dimension1d: Option<u32>,
_max_texture_dimension2d: Option<u32>,
_max_texture_dimension3d: Option<u32>,
_max_texture_array_layers: Option<u32>,
max_texture_dimension_1d: Option<u32>,
max_texture_dimension_2d: Option<u32>,
max_texture_dimension_3d: Option<u32>,
max_texture_array_layers: Option<u32>,
max_bind_groups: Option<u32>,
max_dynamic_uniform_buffers_per_pipeline_layout: Option<u32>,
max_dynamic_storage_buffers_per_pipeline_layout: Option<u32>,
@ -304,10 +304,55 @@ struct GpuLimits {
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_vertex_buffers: Option<u32>,
_max_vertex_attributes: Option<u32>,
_max_vertex_buffer_array_stride: Option<u32>,
max_storage_buffer_binding_size: Option<u32>,
max_vertex_buffers: Option<u32>,
max_vertex_attributes: Option<u32>,
max_vertex_buffer_array_stride: Option<u32>,
}
impl From<GpuLimits> for wgpu_types::Limits {
fn from(limits: GpuLimits) -> wgpu_types::Limits {
wgpu_types::Limits {
max_texture_dimension_1d: limits.max_texture_dimension_1d.unwrap_or(8192),
max_texture_dimension_2d: limits.max_texture_dimension_2d.unwrap_or(8192),
max_texture_dimension_3d: limits.max_texture_dimension_3d.unwrap_or(2048),
max_texture_array_layers: limits.max_texture_array_layers.unwrap_or(2048),
max_bind_groups: limits.max_bind_groups.unwrap_or(4),
max_dynamic_uniform_buffers_per_pipeline_layout: limits
.max_dynamic_uniform_buffers_per_pipeline_layout
.unwrap_or(8),
max_dynamic_storage_buffers_per_pipeline_layout: limits
.max_dynamic_storage_buffers_per_pipeline_layout
.unwrap_or(4),
max_sampled_textures_per_shader_stage: limits
.max_sampled_textures_per_shader_stage
.unwrap_or(16),
max_samplers_per_shader_stage: limits
.max_samplers_per_shader_stage
.unwrap_or(16),
max_storage_buffers_per_shader_stage: limits
.max_storage_buffers_per_shader_stage
.unwrap_or(4),
max_storage_textures_per_shader_stage: limits
.max_storage_textures_per_shader_stage
.unwrap_or(4),
max_uniform_buffers_per_shader_stage: limits
.max_uniform_buffers_per_shader_stage
.unwrap_or(12),
max_uniform_buffer_binding_size: limits
.max_uniform_buffer_binding_size
.unwrap_or(16384),
max_storage_buffer_binding_size: limits
.max_storage_buffer_binding_size
.unwrap_or(134217728),
max_vertex_buffers: limits.max_vertex_buffers.unwrap_or(8),
max_vertex_attributes: limits.max_vertex_attributes.unwrap_or(16),
max_vertex_buffer_array_stride: limits
.max_vertex_buffer_array_stride
.unwrap_or(2048),
max_push_constant_size: 0,
}
}
}
#[derive(Deserialize)]
@ -416,34 +461,7 @@ pub async fn op_webgpu_request_device(
features,
limits: args
.non_guaranteed_limits
.map_or(Default::default(), |limits| wgpu_types::Limits {
max_bind_groups: limits.max_bind_groups.unwrap_or(4),
max_dynamic_uniform_buffers_per_pipeline_layout: limits
.max_dynamic_uniform_buffers_per_pipeline_layout
.unwrap_or(8),
max_dynamic_storage_buffers_per_pipeline_layout: limits
.max_dynamic_storage_buffers_per_pipeline_layout
.unwrap_or(4),
max_sampled_textures_per_shader_stage: limits
.max_sampled_textures_per_shader_stage
.unwrap_or(16),
max_samplers_per_shader_stage: limits
.max_samplers_per_shader_stage
.unwrap_or(16),
max_storage_buffers_per_shader_stage: limits
.max_storage_buffers_per_shader_stage
.unwrap_or(4),
max_storage_textures_per_shader_stage: limits
.max_storage_textures_per_shader_stage
.unwrap_or(4),
max_uniform_buffers_per_shader_stage: limits
.max_uniform_buffers_per_shader_stage
.unwrap_or(12),
max_uniform_buffer_binding_size: limits
.max_uniform_buffer_binding_size
.unwrap_or(16384),
max_push_constant_size: 0,
}),
.map_or(wgpu_types::Limits::default(), Into::into),
};
let (device, maybe_err) = gfx_select!(adapter => instance.adapter_request_device(
@ -705,8 +723,8 @@ fn declare_webgpu_ops() -> Vec<(&'static str, Box<OpFn>)> {
op_sync(render_pass::op_webgpu_render_pass_set_scissor_rect),
),
(
"op_webgpu_render_pass_set_blend_color",
op_sync(render_pass::op_webgpu_render_pass_set_blend_color),
"op_webgpu_render_pass_set_blend_constant",
op_sync(render_pass::op_webgpu_render_pass_set_blend_constant),
),
(
"op_webgpu_render_pass_set_stencil_reference",

View file

@ -97,25 +97,32 @@ fn serialize_blend_factor(blend_factor: &str) -> wgpu_types::BlendFactor {
match blend_factor {
"zero" => wgpu_types::BlendFactor::Zero,
"one" => wgpu_types::BlendFactor::One,
"src-color" => wgpu_types::BlendFactor::SrcColor,
"one-minus-src-color" => wgpu_types::BlendFactor::OneMinusSrcColor,
"src" => wgpu_types::BlendFactor::Src,
"one-minus-src" => wgpu_types::BlendFactor::OneMinusSrc,
"src-alpha" => wgpu_types::BlendFactor::SrcAlpha,
"one-minus-src-alpha" => wgpu_types::BlendFactor::OneMinusSrcAlpha,
"dst-color" => wgpu_types::BlendFactor::DstColor,
"one-minus-dst-color" => wgpu_types::BlendFactor::OneMinusDstColor,
"dst" => wgpu_types::BlendFactor::Dst,
"one-minus-dst" => wgpu_types::BlendFactor::OneMinusDst,
"dst-alpha" => wgpu_types::BlendFactor::DstAlpha,
"one-minus-dst-alpha" => wgpu_types::BlendFactor::OneMinusDstAlpha,
"src-alpha-saturated" => wgpu_types::BlendFactor::SrcAlphaSaturated,
"blend-color" => wgpu_types::BlendFactor::BlendColor,
"one-minus-blend-color" => wgpu_types::BlendFactor::OneMinusBlendColor,
"constant" => wgpu_types::BlendFactor::Constant,
"one-minus-constant" => wgpu_types::BlendFactor::OneMinusConstant,
_ => unreachable!(),
}
}
fn serialize_blend_state(state: GpuBlendState) -> wgpu_types::BlendState {
wgpu_types::BlendState {
alpha: serialize_blend_component(state.alpha),
color: serialize_blend_component(state.color),
}
}
fn serialize_blend_component(
blend: GpuBlendComponent,
) -> wgpu_types::BlendState {
wgpu_types::BlendState {
) -> wgpu_types::BlendComponent {
wgpu_types::BlendComponent {
src_factor: blend
.src_factor
.as_ref()
@ -201,7 +208,7 @@ pub fn op_webgpu_create_compute_pipeline(
}),
};
let (compute_pipeline, _, maybe_err) = gfx_select!(device => instance.device_create_compute_pipeline(
let (compute_pipeline, maybe_err) = gfx_select!(device => instance.device_create_compute_pipeline(
device,
&descriptor,
std::marker::PhantomData,
@ -264,6 +271,7 @@ struct GpuPrimitiveState {
strip_index_format: Option<String>,
front_face: Option<String>,
cull_mode: Option<String>,
clamp_depth: bool,
}
#[derive(Deserialize, Clone)]
@ -311,17 +319,97 @@ struct GpuDepthStencilState {
depth_bias: Option<i32>,
depth_bias_slope_scale: Option<f32>,
depth_bias_clamp: Option<f32>,
clamp_depth: Option<bool>,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct GpuVertexAttribute {
format: String,
format: GpuVertexFormat,
offset: u64,
shader_location: u32,
}
#[derive(Deserialize)]
#[serde(rename_all = "lowercase")]
enum GpuVertexFormat {
Uint8x2,
Uint8x4,
Sint8x2,
Sint8x4,
Unorm8x2,
Unorm8x4,
Snorm8x2,
Snorm8x4,
Uint16x2,
Uint16x4,
Sint16x2,
Sint16x4,
Unorm16x2,
Unorm16x4,
Snorm16x2,
Snorm16x4,
Float16x2,
Float16x4,
Float32,
Float32x2,
Float32x3,
Float32x4,
Uint32,
Uint32x2,
Uint32x3,
Uint32x4,
Sint32,
Sint32x2,
Sint32x3,
Sint32x4,
Float64,
Float64x2,
Float64x3,
Float64x4,
}
impl From<GpuVertexFormat> for wgpu_types::VertexFormat {
fn from(vf: GpuVertexFormat) -> wgpu_types::VertexFormat {
use wgpu_types::VertexFormat;
match vf {
GpuVertexFormat::Uint8x2 => VertexFormat::Uint8x2,
GpuVertexFormat::Uint8x4 => VertexFormat::Uint8x4,
GpuVertexFormat::Sint8x2 => VertexFormat::Sint8x2,
GpuVertexFormat::Sint8x4 => VertexFormat::Sint8x4,
GpuVertexFormat::Unorm8x2 => VertexFormat::Unorm8x2,
GpuVertexFormat::Unorm8x4 => VertexFormat::Unorm8x4,
GpuVertexFormat::Snorm8x2 => VertexFormat::Snorm8x2,
GpuVertexFormat::Snorm8x4 => VertexFormat::Snorm8x4,
GpuVertexFormat::Uint16x2 => VertexFormat::Uint16x2,
GpuVertexFormat::Uint16x4 => VertexFormat::Uint16x4,
GpuVertexFormat::Sint16x2 => VertexFormat::Sint16x2,
GpuVertexFormat::Sint16x4 => VertexFormat::Sint16x4,
GpuVertexFormat::Unorm16x2 => VertexFormat::Unorm16x2,
GpuVertexFormat::Unorm16x4 => VertexFormat::Unorm16x4,
GpuVertexFormat::Snorm16x2 => VertexFormat::Snorm16x2,
GpuVertexFormat::Snorm16x4 => VertexFormat::Snorm16x4,
GpuVertexFormat::Float16x2 => VertexFormat::Float16x2,
GpuVertexFormat::Float16x4 => VertexFormat::Float16x4,
GpuVertexFormat::Float32 => VertexFormat::Float32,
GpuVertexFormat::Float32x2 => VertexFormat::Float32x2,
GpuVertexFormat::Float32x3 => VertexFormat::Float32x3,
GpuVertexFormat::Float32x4 => VertexFormat::Float32x4,
GpuVertexFormat::Uint32 => VertexFormat::Uint32,
GpuVertexFormat::Uint32x2 => VertexFormat::Uint32x2,
GpuVertexFormat::Uint32x3 => VertexFormat::Uint32x3,
GpuVertexFormat::Uint32x4 => VertexFormat::Uint32x4,
GpuVertexFormat::Sint32 => VertexFormat::Sint32,
GpuVertexFormat::Sint32x2 => VertexFormat::Sint32x2,
GpuVertexFormat::Sint32x3 => VertexFormat::Sint32x3,
GpuVertexFormat::Sint32x4 => VertexFormat::Sint32x4,
GpuVertexFormat::Float64 => VertexFormat::Float64,
GpuVertexFormat::Float64x2 => VertexFormat::Float64x2,
GpuVertexFormat::Float64x3 => VertexFormat::Float64x3,
GpuVertexFormat::Float64x4 => VertexFormat::Float64x4,
}
}
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct GpuVertexBufferLayout {
@ -418,41 +506,9 @@ pub fn op_webgpu_create_render_pipeline(
attributes: Cow::from(
buffer
.attributes
.iter()
.into_iter()
.map(|attribute| wgpu_types::VertexAttribute {
format: match attribute.format.as_str() {
"uchar2" => wgpu_types::VertexFormat::Uchar2,
"uchar4" => wgpu_types::VertexFormat::Uchar4,
"char2" => wgpu_types::VertexFormat::Char2,
"char4" => wgpu_types::VertexFormat::Char4,
"uchar2norm" => wgpu_types::VertexFormat::Uchar2Norm,
"uchar4norm" => wgpu_types::VertexFormat::Uchar4,
"char2norm" => wgpu_types::VertexFormat::Char2Norm,
"char4norm" => wgpu_types::VertexFormat::Char4Norm,
"ushort2" => wgpu_types::VertexFormat::Ushort2,
"ushort4" => wgpu_types::VertexFormat::Ushort4,
"short2" => wgpu_types::VertexFormat::Short2,
"short4" => wgpu_types::VertexFormat::Short4,
"ushort2norm" => wgpu_types::VertexFormat::Ushort2Norm,
"ushort4norm" => wgpu_types::VertexFormat::Ushort4Norm,
"short2norm" => wgpu_types::VertexFormat::Short2Norm,
"short4norm" => wgpu_types::VertexFormat::Short4Norm,
"half2" => wgpu_types::VertexFormat::Half2,
"half4" => wgpu_types::VertexFormat::Half4,
"float" => wgpu_types::VertexFormat::Float,
"float2" => wgpu_types::VertexFormat::Float2,
"float3" => wgpu_types::VertexFormat::Float3,
"float4" => wgpu_types::VertexFormat::Float4,
"uint" => wgpu_types::VertexFormat::Uint,
"uint2" => wgpu_types::VertexFormat::Uint2,
"uint3" => wgpu_types::VertexFormat::Uint3,
"uint4" => wgpu_types::VertexFormat::Uint4,
"int" => wgpu_types::VertexFormat::Int,
"int2" => wgpu_types::VertexFormat::Int2,
"int3" => wgpu_types::VertexFormat::Int3,
"int4" => wgpu_types::VertexFormat::Int4,
_ => unreachable!(),
},
format: attribute.format.into(),
offset: attribute.offset,
shader_location: attribute.shader_location,
})
@ -491,14 +547,16 @@ pub fn op_webgpu_create_render_pipeline(
},
cull_mode: match primitive.cull_mode {
Some(cull_mode) => match cull_mode.as_str() {
"none" => wgpu_types::CullMode::None,
"front" => wgpu_types::CullMode::Front,
"back" => wgpu_types::CullMode::Back,
"none" => None,
"front" => Some(wgpu_types::Face::Front),
"back" => Some(wgpu_types::Face::Back),
_ => unreachable!(),
},
None => wgpu_types::CullMode::None,
None => None,
},
polygon_mode: Default::default(), // native-only
conservative: false, // native-only
clamp_depth: primitive.clamp_depth,
}
}),
depth_stencil: args.depth_stencil.map(|depth_stencil| {
@ -527,7 +585,6 @@ pub fn op_webgpu_create_render_pipeline(
slope_scale: depth_stencil.depth_bias_slope_scale.unwrap_or(0.0),
clamp: depth_stencil.depth_bias_clamp.unwrap_or(0.0),
},
clamp_depth: depth_stencil.clamp_depth.unwrap_or(false),
}
}),
multisample: args.multisample.map_or(Default::default(), |multisample| {
@ -554,31 +611,16 @@ pub fn op_webgpu_create_render_pipeline(
targets: Cow::from(
fragment
.targets
.iter()
.map(|target| {
let blends = target.blend.clone().map(|blend| {
(
serialize_blend_component(blend.alpha),
serialize_blend_component(blend.color),
)
});
wgpu_types::ColorTargetState {
format: super::texture::serialize_texture_format(
&target.format,
)
.into_iter()
.map(|target| wgpu_types::ColorTargetState {
format: super::texture::serialize_texture_format(&target.format)
.unwrap(),
alpha_blend: blends
.clone()
.map_or(Default::default(), |states| states.0),
color_blend: blends
.map_or(Default::default(), |states| states.1),
blend: target.blend.map(serialize_blend_state),
write_mask: target
.write_mask
.map_or(Default::default(), |mask| {
wgpu_types::ColorWrite::from_bits(mask).unwrap()
}),
}
})
.collect::<Vec<wgpu_types::ColorTargetState>>(),
),
@ -594,7 +636,7 @@ pub fn op_webgpu_create_render_pipeline(
}),
};
let (render_pipeline, _, maybe_err) = gfx_select!(device => instance.device_create_render_pipeline(
let (render_pipeline, maybe_err) = gfx_select!(device => instance.device_create_render_pipeline(
device,
&descriptor,
std::marker::PhantomData,

View file

@ -1,5 +1,7 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
use std::num::NonZeroU32;
use deno_core::error::bad_resource_id;
use deno_core::error::null_opbuf;
use deno_core::error::AnyError;
@ -124,7 +126,7 @@ pub fn op_webgpu_write_texture(
.ok_or_else(bad_resource_id)?;
let queue = queue_resource.0;
let destination = wgpu_core::command::TextureCopyView {
let destination = wgpu_core::command::ImageCopyTexture {
texture: texture_resource.0,
mip_level: args.destination.mip_level.unwrap_or(0),
origin: args
@ -136,10 +138,12 @@ pub fn op_webgpu_write_texture(
z: origin.z.unwrap_or(0),
}),
};
let data_layout = wgpu_types::TextureDataLayout {
let data_layout = wgpu_types::ImageDataLayout {
offset: args.data_layout.offset.unwrap_or(0),
bytes_per_row: args.data_layout.bytes_per_row.unwrap_or(0),
rows_per_image: args.data_layout.rows_per_image.unwrap_or(0),
bytes_per_row: NonZeroU32::new(args.data_layout.bytes_per_row.unwrap_or(0)),
rows_per_image: NonZeroU32::new(
args.data_layout.rows_per_image.unwrap_or(0),
),
};
gfx_ok!(queue => instance.queue_write_texture(
@ -150,7 +154,7 @@ pub fn op_webgpu_write_texture(
&wgpu_types::Extent3d {
width: args.size.width.unwrap_or(1),
height: args.size.height.unwrap_or(1),
depth: args.size.depth.unwrap_or(1),
depth_or_array_layers: args.size.depth_or_array_layers.unwrap_or(1),
}
))
}

View file

@ -98,14 +98,14 @@ pub struct GpuColor {
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RenderPassSetBlendColorArgs {
pub struct RenderPassSetBlendConstantArgs {
render_pass_rid: ResourceId,
color: GpuColor,
}
pub fn op_webgpu_render_pass_set_blend_color(
pub fn op_webgpu_render_pass_set_blend_constant(
state: &mut OpState,
args: RenderPassSetBlendColorArgs,
args: RenderPassSetBlendConstantArgs,
_zero_copy: Option<ZeroCopyBuf>,
) -> Result<WebGpuResult, AnyError> {
let render_pass_resource = state
@ -113,7 +113,7 @@ pub fn op_webgpu_render_pass_set_blend_color(
.get::<WebGpuRenderPass>(args.render_pass_rid)
.ok_or_else(bad_resource_id)?;
wgpu_core::command::render_ffi::wgpu_render_pass_set_blend_color(
wgpu_core::command::render_ffi::wgpu_render_pass_set_blend_constant(
&mut render_pass_resource.0.borrow_mut(),
&wgpu_types::Color {
r: args.color.r,
@ -173,13 +173,11 @@ pub fn op_webgpu_render_pass_begin_pipeline_statistics_query(
.get::<super::WebGpuQuerySet>(args.query_set)
.ok_or_else(bad_resource_id)?;
unsafe {
wgpu_core::command::render_ffi::wgpu_render_pass_begin_pipeline_statistics_query(
&mut render_pass_resource.0.borrow_mut(),
query_set_resource.0,
args.query_index,
);
}
Ok(WebGpuResult::empty())
}
@ -200,11 +198,9 @@ pub fn op_webgpu_render_pass_end_pipeline_statistics_query(
.get::<WebGpuRenderPass>(args.render_pass_rid)
.ok_or_else(bad_resource_id)?;
unsafe {
wgpu_core::command::render_ffi::wgpu_render_pass_end_pipeline_statistics_query(
&mut render_pass_resource.0.borrow_mut(),
);
}
Ok(WebGpuResult::empty())
}
@ -231,13 +227,11 @@ pub fn op_webgpu_render_pass_write_timestamp(
.get::<super::WebGpuQuerySet>(args.query_set)
.ok_or_else(bad_resource_id)?;
unsafe {
wgpu_core::command::render_ffi::wgpu_render_pass_write_timestamp(
&mut render_pass_resource.0.borrow_mut(),
query_set_resource.0,
args.query_index,
);
}
Ok(WebGpuResult::empty())
}

View file

@ -56,14 +56,9 @@ pub fn op_webgpu_create_shader_module(
})),
};
let mut flags = wgpu_types::ShaderFlags::default();
flags.set(wgpu_types::ShaderFlags::VALIDATION, true);
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
flags.set(wgpu_types::ShaderFlags::EXPERIMENTAL_TRANSLATION, true);
let descriptor = wgpu_core::pipeline::ShaderModuleDescriptor {
label: args.label.map(Cow::from),
flags,
flags: wgpu_types::ShaderFlags::all(),
};
gfx_put!(device => instance.device_create_shader_module(

View file

@ -126,7 +126,7 @@ pub fn serialize_dimension(
pub struct GpuExtent3D {
pub width: Option<u32>,
pub height: Option<u32>,
pub depth: Option<u32>,
pub depth_or_array_layers: Option<u32>,
}
#[derive(Deserialize)]
@ -159,7 +159,7 @@ pub fn op_webgpu_create_texture(
size: wgpu_types::Extent3d {
width: args.size.width.unwrap_or(1),
height: args.size.height.unwrap_or(1),
depth: args.size.depth.unwrap_or(1),
depth_or_array_layers: args.size.depth_or_array_layers.unwrap_or(1),
},
mip_level_count: args.mip_level_count.unwrap_or(1),
sample_count: args.sample_count.unwrap_or(1),
@ -226,7 +226,9 @@ pub fn op_webgpu_create_texture_view(
None => wgpu_types::TextureAspect::All,
},
base_mip_level: args.base_mip_level.unwrap_or(0),
level_count: std::num::NonZeroU32::new(args.mip_level_count.unwrap_or(0)),
mip_level_count: std::num::NonZeroU32::new(
args.mip_level_count.unwrap_or(0),
),
base_array_layer: args.base_array_layer.unwrap_or(0),
array_layer_count: std::num::NonZeroU32::new(
args.array_layer_count.unwrap_or(0),

View file

@ -6,39 +6,37 @@ dictionary GPUObjectDescriptorBase {
USVString label;
};
[Exposed=Window]
interface GPUAdapterLimits {
readonly attribute GPUSize32 maxTextureDimension1D;
readonly attribute GPUSize32 maxTextureDimension2D;
readonly attribute GPUSize32 maxTextureDimension3D;
readonly attribute GPUSize32 maxTextureArrayLayers;
readonly attribute GPUSize32 maxBindGroups;
readonly attribute GPUSize32 maxDynamicUniformBuffersPerPipelineLayout;
readonly attribute GPUSize32 maxDynamicStorageBuffersPerPipelineLayout;
readonly attribute GPUSize32 maxSampledTexturesPerShaderStage;
readonly attribute GPUSize32 maxSamplersPerShaderStage;
readonly attribute GPUSize32 maxStorageBuffersPerShaderStage;
readonly attribute GPUSize32 maxStorageTexturesPerShaderStage;
readonly attribute GPUSize32 maxUniformBuffersPerShaderStage;
readonly attribute GPUSize32 maxUniformBufferBindingSize;
readonly attribute GPUSize32 maxStorageBufferBindingSize;
readonly attribute GPUSize32 maxVertexBuffers;
readonly attribute GPUSize32 maxVertexAttributes;
readonly attribute GPUSize32 maxVertexBufferArrayStride;
};
interface GPUAdapterFeatures {
readonly setlike<GPUFeatureName>;
readonly attribute unsigned long maxTextureDimension1D;
readonly attribute unsigned long maxTextureDimension2D;
readonly attribute unsigned long maxTextureDimension3D;
readonly attribute unsigned long maxTextureArrayLayers;
readonly attribute unsigned long maxBindGroups;
readonly attribute unsigned long maxDynamicUniformBuffersPerPipelineLayout;
readonly attribute unsigned long maxDynamicStorageBuffersPerPipelineLayout;
readonly attribute unsigned long maxSampledTexturesPerShaderStage;
readonly attribute unsigned long maxSamplersPerShaderStage;
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 maxVertexBuffers;
readonly attribute unsigned long maxVertexAttributes;
readonly attribute unsigned long maxVertexBufferArrayStride;
};
[Exposed=Window]
partial interface Navigator {
[SameObject] readonly attribute GPU gpu;
interface GPUSupportedFeatures {
readonly setlike<DOMString>;
};
[Exposed=DedicatedWorker]
partial interface WorkerNavigator {
interface mixin NavigatorGPU {
[SameObject] readonly attribute GPU gpu;
};
Navigator includes NavigatorGPU;
WorkerNavigator includes NavigatorGPU;
[Exposed=(Window, DedicatedWorker)]
interface GPU {
@ -54,12 +52,13 @@ enum GPUPowerPreference {
"high-performance"
};
[Exposed=Window]
interface GPUAdapter {
readonly attribute DOMString name;
[SameObject] readonly attribute GPUAdapterFeatures features;
[SameObject] readonly attribute GPUSupportedFeatures features;
[SameObject] readonly attribute GPUAdapterLimits limits;
Promise<GPUDevice?> requestDevice(optional GPUDeviceDescriptor descriptor = {});
Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
};
dictionary GPUDeviceDescriptor : GPUObjectDescriptorBase {
@ -78,8 +77,7 @@ enum GPUFeatureName {
[Exposed=(Window, DedicatedWorker), Serializable]
interface GPUDevice : EventTarget {
[SameObject] readonly attribute GPUAdapter adapter;
readonly attribute FrozenArray<GPUFeatureName> features;
[SameObject] readonly attribute GPUSupportedFeatures features;
readonly attribute object limits;
[SameObject] readonly attribute GPUQueue queue;
@ -107,7 +105,7 @@ interface GPUDevice : EventTarget {
};
GPUDevice includes GPUObjectBase;
[Serializable]
[Exposed=Window, Serializable]
interface GPUBuffer {
Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
@ -124,6 +122,7 @@ dictionary GPUBufferDescriptor : GPUObjectDescriptorBase {
};
typedef [EnforceRange] unsigned long GPUBufferUsageFlags;
[Exposed=Window]
interface GPUBufferUsage {
const GPUFlagsConstant MAP_READ = 0x0001;
const GPUFlagsConstant MAP_WRITE = 0x0002;
@ -138,12 +137,13 @@ interface GPUBufferUsage {
};
typedef [EnforceRange] unsigned long GPUMapModeFlags;
[Exposed=Window]
interface GPUMapMode {
const GPUFlagsConstant READ = 0x0001;
const GPUFlagsConstant WRITE = 0x0002;
};
[Serializable]
[Exposed=Window, Serializable]
interface GPUTexture {
GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
@ -167,6 +167,7 @@ enum GPUTextureDimension {
};
typedef [EnforceRange] unsigned long GPUTextureUsageFlags;
[Exposed=Window]
interface GPUTextureUsage {
const GPUFlagsConstant COPY_SRC = 0x01;
const GPUFlagsConstant COPY_DST = 0x02;
@ -175,6 +176,7 @@ interface GPUTextureUsage {
const GPUFlagsConstant RENDER_ATTACHMENT = 0x10;
};
[Exposed=Window]
interface GPUTextureView {
};
GPUTextureView includes GPUObjectBase;
@ -283,6 +285,7 @@ enum GPUTextureFormat {
"depth32float-stencil8",
};
[Exposed=Window]
interface GPUSampler {
};
GPUSampler includes GPUObjectBase;
@ -322,7 +325,7 @@ enum GPUCompareFunction {
"always"
};
[Serializable]
[Exposed=Window, Serializable]
interface GPUBindGroupLayout {
};
GPUBindGroupLayout includes GPUObjectBase;
@ -332,6 +335,7 @@ dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {
};
typedef [EnforceRange] unsigned long GPUShaderStageFlags;
[Exposed=Window]
interface GPUShaderStage {
const GPUFlagsConstant VERTEX = 0x1;
const GPUFlagsConstant FRAGMENT = 0x2;
@ -395,6 +399,7 @@ dictionary GPUStorageTextureBindingLayout {
GPUTextureViewDimension viewDimension = "2d";
};
[Exposed=Window]
interface GPUBindGroup {
};
GPUBindGroup includes GPUObjectBase;
@ -417,7 +422,7 @@ dictionary GPUBufferBinding {
GPUSize64 size;
};
[Serializable]
[Exposed=Window, Serializable]
interface GPUPipelineLayout {
};
GPUPipelineLayout includes GPUObjectBase;
@ -426,26 +431,7 @@ dictionary GPUPipelineLayoutDescriptor : GPUObjectDescriptorBase {
required sequence<GPUBindGroupLayout> bindGroupLayouts;
};
enum GPUCompilationMessageType {
"error",
"warning",
"info"
};
[Serializable]
interface GPUCompilationMessage {
readonly attribute DOMString message;
readonly attribute GPUCompilationMessageType type;
readonly attribute unsigned long long lineNum;
readonly attribute unsigned long long linePos;
};
[Serializable]
interface GPUCompilationInfo {
readonly attribute FrozenArray<GPUCompilationMessage> messages;
};
[Serializable]
[Exposed=Window, Serializable]
interface GPUShaderModule {
Promise<GPUCompilationInfo> compilationInfo();
};
@ -456,6 +442,27 @@ dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase {
object sourceMap;
};
enum GPUCompilationMessageType {
"error",
"warning",
"info"
};
[Exposed=Window, Serializable]
interface GPUCompilationMessage {
readonly attribute DOMString message;
readonly attribute GPUCompilationMessageType type;
readonly attribute unsigned long long lineNum;
readonly attribute unsigned long long linePos;
readonly attribute unsigned long long offset;
readonly attribute unsigned long long length;
};
[Exposed=Window, Serializable]
interface GPUCompilationInfo {
readonly attribute FrozenArray<GPUCompilationMessage> messages;
};
dictionary GPUPipelineDescriptorBase : GPUObjectDescriptorBase {
GPUPipelineLayout layout;
};
@ -469,7 +476,7 @@ dictionary GPUProgrammableStage {
required USVString entryPoint;
};
[Serializable]
[Exposed=Window, Serializable]
interface GPUComputePipeline {
};
GPUComputePipeline includes GPUObjectBase;
@ -479,7 +486,7 @@ dictionary GPUComputePipelineDescriptor : GPUPipelineDescriptorBase {
required GPUProgrammableStage compute;
};
[Serializable]
[Exposed=Window, Serializable]
interface GPURenderPipeline {
};
GPURenderPipeline includes GPUObjectBase;
@ -506,6 +513,9 @@ dictionary GPUPrimitiveState {
GPUIndexFormat stripIndexFormat;
GPUFrontFace frontFace = "ccw";
GPUCullMode cullMode = "none";
// Enable depth clamping (requires "depth-clamping" feature)
boolean clampDepth = false;
};
enum GPUFrontFace {
@ -542,6 +552,7 @@ dictionary GPUBlendState {
};
typedef [EnforceRange] unsigned long GPUColorWriteFlags;
[Exposed=Window]
interface GPUColorWrite {
const GPUFlagsConstant RED = 0x1;
const GPUFlagsConstant GREEN = 0x2;
@ -559,17 +570,17 @@ dictionary GPUBlendComponent {
enum GPUBlendFactor {
"zero",
"one",
"src-color",
"one-minus-src-color",
"src",
"one-minus-src",
"src-alpha",
"one-minus-src-alpha",
"dst-color",
"one-minus-dst-color",
"dst",
"one-minus-dst",
"dst-alpha",
"one-minus-dst-alpha",
"src-alpha-saturated",
"blend-color",
"one-minus-blend-color"
"constant",
"one-minus-constant"
};
enum GPUBlendOperation {
@ -595,9 +606,6 @@ dictionary GPUDepthStencilState {
GPUDepthBias depthBias = 0;
float depthBiasSlopeScale = 0;
float depthBiasClamp = 0;
// Enable depth clamping (requires "depth-clamping" feature)
boolean clampDepth = false;
};
dictionary GPUStencilFaceState {
@ -624,36 +632,36 @@ enum GPUIndexFormat {
};
enum GPUVertexFormat {
"uchar2",
"uchar4",
"char2",
"char4",
"uchar2norm",
"uchar4norm",
"char2norm",
"char4norm",
"ushort2",
"ushort4",
"short2",
"short4",
"ushort2norm",
"ushort4norm",
"short2norm",
"short4norm",
"half2",
"half4",
"float",
"float2",
"float3",
"float4",
"uint",
"uint2",
"uint3",
"uint4",
"int",
"int2",
"int3",
"int4"
"uint8x2",
"uint8x4",
"sint8x2",
"sint8x4",
"unorm8x2",
"unorm8x4",
"snorm8x2",
"snorm8x4",
"uint16x2",
"uint16x4",
"sint16x2",
"sint16x4",
"unorm16x2",
"unorm16x4",
"snorm16x2",
"snorm16x4",
"float16x2",
"float16x4",
"float32",
"float32x2",
"float32x3",
"float32x4",
"uint32",
"uint32x2",
"uint32x3",
"uint32x4",
"sint32",
"sint32x2",
"sint32x3",
"sint32x4",
};
enum GPUInputStepMode {
@ -678,6 +686,7 @@ dictionary GPUVertexAttribute {
required GPUIndex32 shaderLocation;
};
[Exposed=Window]
interface GPUCommandBuffer {
readonly attribute Promise<double> executionTime;
};
@ -686,6 +695,7 @@ GPUCommandBuffer includes GPUObjectBase;
dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
};
[Exposed=Window]
interface GPUCommandEncoder {
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
@ -752,6 +762,11 @@ dictionary GPUImageCopyTexture {
GPUTextureAspect aspect = "all";
};
dictionary GPUImageCopyExternalImage {
required (ImageBitmap or HTMLCanvasElement or OffscreenCanvas) source;
GPUOrigin2D origin = {};
};
interface mixin GPUProgrammablePassEncoder {
undefined setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup,
optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []);
@ -766,6 +781,7 @@ interface mixin GPUProgrammablePassEncoder {
undefined insertDebugMarker(USVString markerLabel);
};
[Exposed=Window]
interface GPUComputePassEncoder {
undefined setPipeline(GPUComputePipeline pipeline);
undefined dispatch(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1);
@ -801,6 +817,7 @@ interface mixin GPURenderEncoderBase {
undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
};
[Exposed=Window]
interface GPURenderPassEncoder {
undefined setViewport(float x, float y,
float width, float height,
@ -809,7 +826,7 @@ interface GPURenderPassEncoder {
undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y,
GPUIntegerCoordinate width, GPUIntegerCoordinate height);
undefined setBlendColor(GPUColor color);
undefined setBlendConstant(GPUColor color);
undefined setStencilReference(GPUStencilValue reference);
undefined beginOcclusionQuery(GPUSize32 queryIndex);
@ -838,7 +855,7 @@ dictionary GPURenderPassColorAttachment {
GPUTextureView resolveTarget;
required (GPULoadOp or GPUColor) loadValue;
GPUStoreOp storeOp = "store";
required GPUStoreOp storeOp;
};
dictionary GPURenderPassDepthStencilAttachment {
@ -862,6 +879,7 @@ enum GPUStoreOp {
"clear"
};
[Exposed=Window]
interface GPURenderBundle {
};
GPURenderBundle includes GPUObjectBase;
@ -869,6 +887,7 @@ GPURenderBundle includes GPUObjectBase;
dictionary GPURenderBundleDescriptor : GPUObjectDescriptorBase {
};
[Exposed=Window]
interface GPURenderBundleEncoder {
GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
};
@ -882,6 +901,7 @@ dictionary GPURenderBundleEncoderDescriptor : GPUObjectDescriptorBase {
GPUSize32 sampleCount = 1;
};
[Exposed=Window]
interface GPUQueue {
undefined submit(sequence<GPUCommandBuffer> commandBuffers);
@ -899,9 +919,15 @@ interface GPUQueue {
[AllowShared] BufferSource data,
GPUImageDataLayout dataLayout,
GPUExtent3D size);
undefined copyExternalImageToTexture(
GPUImageCopyExternalImage source,
GPUImageCopyTexture destination,
GPUExtent3D copySize);
};
GPUQueue includes GPUObjectBase;
[Exposed=Window]
interface GPUQuerySet {
undefined destroy();
};
@ -927,10 +953,36 @@ enum GPUPipelineStatisticName {
"compute-shader-invocations"
};
[Exposed=Window]
interface GPUCanvasContext {
GPUSwapChain configureSwapChain(GPUSwapChainDescriptor descriptor);
GPUTextureFormat getSwapChainPreferredFormat(GPUAdapter adapter);
};
enum GPUCanvasCompositingAlphaMode {
"opaque",
"premultiplied",
};
dictionary GPUSwapChainDescriptor : GPUObjectDescriptorBase {
required GPUDevice device;
required GPUTextureFormat format;
GPUTextureUsageFlags usage = 0x10; // GPUTextureUsage.RENDER_ATTACHMENT
GPUCanvasCompositingAlphaMode compositingAlphaMode = "opaque";
};
[Exposed=Window]
interface GPUSwapChain {
GPUTexture getCurrentTexture();
};
GPUSwapChain includes GPUObjectBase;
enum GPUDeviceLostReason {
"destroyed",
};
[Exposed=Window]
interface GPUDeviceLostInfo {
readonly attribute (GPUDeviceLostReason or undefined) reason;
readonly attribute DOMString message;
@ -945,10 +997,12 @@ enum GPUErrorFilter {
"validation"
};
[Exposed=Window]
interface GPUOutOfMemoryError {
constructor();
};
[Exposed=Window]
interface GPUValidationError {
constructor(DOMString message);
readonly attribute DOMString message;
@ -1016,7 +1070,7 @@ dictionary GPUOrigin3DDict {
typedef (sequence<GPUIntegerCoordinate> or GPUOrigin3DDict) GPUOrigin3D;
dictionary GPUExtent3DDict {
GPUIntegerCoordinate width = 1;
required GPUIntegerCoordinate width;
GPUIntegerCoordinate height = 1;
GPUIntegerCoordinate depthOrArrayLayers = 1;
};

View file

@ -296,7 +296,7 @@ delete Object.prototype.__proto__;
GPU: util.nonEnumerable(webgpu.GPU),
GPUAdapter: util.nonEnumerable(webgpu.GPUAdapter),
GPUAdapterLimits: util.nonEnumerable(webgpu.GPUAdapterLimits),
GPUAdapterFeatures: util.nonEnumerable(webgpu.GPUAdapterFeatures),
GPUSupportedFeatures: util.nonEnumerable(webgpu.GPUSupportedFeatures),
GPUDevice: util.nonEnumerable(webgpu.GPUDevice),
GPUQueue: util.nonEnumerable(webgpu.GPUQueue),
GPUBuffer: util.nonEnumerable(webgpu.GPUBuffer),