Skip to content

Commit

Permalink
Update deno (#2691)
Browse files Browse the repository at this point in the history
* update deno crates & align to IDL

* revert GPUAutoLayoutMode

* revert GPUAutoLayoutMode
  • Loading branch information
crowlKats authored May 24, 2022
1 parent 435188c commit dd6febe
Show file tree
Hide file tree
Showing 8 changed files with 247 additions and 98 deletions.
12 changes: 6 additions & 6 deletions cts_runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ publish = false
resolver = "2"

[dependencies]
deno_console = "0.43.0"
deno_core = "0.125.0"
deno_url = "0.43.0"
deno_web = "0.74.0"
deno_webidl = "0.43.0"
deno_console = "0.53.0"
deno_core = "0.135.0"
deno_url = "0.53.0"
deno_web = "0.84.0"
deno_webidl = "0.53.0"
deno_webgpu = { path = "../deno_webgpu" }
tokio = { version = "1.15.0", features = ["full"] }
tokio = { version = "1.17.0", features = ["full"] }
termcolor = "1.1.2"
2 changes: 1 addition & 1 deletion cts_runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn extension() -> deno_core::Extension {
])
.js(deno_core::include_js_files!(
prefix "deno:cts_runner",
"src/bootstrap.js",
"bootstrap.js",
))
.build()
}
Expand Down
6 changes: 3 additions & 3 deletions deno_webgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[package]
name = "deno_webgpu"
version = "0.44.0"
version = "0.54.0"
authors = ["the Deno authors"]
edition = "2018"
license = "MIT"
Expand All @@ -11,8 +11,8 @@ repository = "https://github.com/gfx-rs/wgpu"
description = "WebGPU implementation for Deno"

[dependencies]
deno_core = "0.125.0"
deno_core = "0.135.0"
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1.10", features = ["full"] }
tokio = { version = "1.17", features = ["full"] }
wgpu-core = { path = "../wgpu-core", features = ["trace", "replay", "serde"] }
wgpu-types = { path = "../wgpu-types", features = ["trace", "replay", "serde"] }
152 changes: 124 additions & 28 deletions deno_webgpu/01_webgpu.js → deno_webgpu/src/01_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,35 @@
}
}

class GPUOutOfMemoryError extends Error {
name = "GPUOutOfMemoryError";
class GPUError extends Error {
constructor() {
super("device out of memory");
super();
webidl.illegalConstructor();
}

[_message];
get message() {
webidl.assertBranded(this, GPUErrorPrototype);
return this[_message];
}
}
const GPUErrorPrototype = GPUError.prototype;

class GPUOutOfMemoryError extends GPUError {
name = "GPUOutOfMemoryError";
constructor(message) {
const prefix = "Failed to construct 'GPUOutOfMemoryError'";
webidl.requiredArguments(arguments.length, 1, { prefix });
message = webidl.converters.DOMString(message, {
prefix,
context: "Argument 1",
});
super(message);
}
}
const GPUOutOfMemoryErrorPrototype = GPUOutOfMemoryError.prototype;

class GPUValidationError extends Error {
class GPUValidationError extends GPUError {
name = "GPUValidationError";
/** @param {string} message */
constructor(message) {
Expand Down Expand Up @@ -203,7 +223,7 @@
if (err) {
return null;
} else {
return createGPUAdapter(data.name, data);
return createGPUAdapter(data);
}
}

Expand All @@ -213,7 +233,6 @@
}
const GPUPrototype = GPU.prototype;

const _name = Symbol("[[name]]");
const _adapter = Symbol("[[adapter]]");
const _cleanup = Symbol("[[cleanup]]");

Expand All @@ -226,14 +245,12 @@
*/

/**
* @param {string} name
* @param {InnerGPUAdapter} inner
* @returns {GPUAdapter}
*/
function createGPUAdapter(name, inner) {
function createGPUAdapter(inner) {
/** @type {GPUAdapter} */
const adapter = webidl.createBranded(GPUAdapter);
adapter[_name] = name;
adapter[_adapter] = {
...inner,
features: createGPUSupportedFeatures(inner.features),
Expand All @@ -243,16 +260,9 @@
}

class GPUAdapter {
/** @type {string} */
[_name];
/** @type {InnerGPUAdapter} */
[_adapter];

/** @returns {string} */
get name() {
webidl.assertBranded(this, GPUAdapterPrototype);
return this[_name];
}
/** @returns {GPUSupportedFeatures} */
get features() {
webidl.assertBranded(this, GPUAdapterPrototype);
Expand Down Expand Up @@ -315,10 +325,43 @@
);
}

/**
* @param {string[]} unmaskHints
* @returns {Promise<GPUAdapterInfo>}
*/
async requestAdapterInfo(unmaskHints = []) {
webidl.assertBranded(this, GPUAdapterPrototype);
const prefix = "Failed to execute 'requestAdapterInfo' on 'GPUAdapter'";
unmaskHints = webidl.converters["sequence<DOMString>"](unmaskHints, {
prefix,
context: "Argument 1",
});

const {
vendor,
architecture,
device,
description,
} = await core.opAsync(
"op_webgpu_request_adapter_info",
this[_adapter].rid,
);

const adapterInfo = webidl.createBranded(GPUAdapterInfo);
adapterInfo[_vendor] = unmaskHints.includes("vendor") ? vendor : "";
adapterInfo[_architecture] = unmaskHints.includes("architecture")
? architecture
: "";
adapterInfo[_device] = unmaskHints.includes("device") ? device : "";
adapterInfo[_description] = unmaskHints.includes("description")
? description
: "";
return adapterInfo;
}

[SymbolFor("Deno.privateCustomInspect")](inspect) {
return `${this.constructor.name} ${
inspect({
name: this.name,
features: this.features,
limits: this.limits,
})
Expand All @@ -327,6 +370,55 @@
}
const GPUAdapterPrototype = GPUAdapter.prototype;

const _vendor = Symbol("[[vendor]]");
const _architecture = Symbol("[[architecture]]");
const _description = Symbol("[[description]]");
class GPUAdapterInfo {
/** @type {string} */
[_vendor];
/** @returns {string} */
get vendor() {
webidl.assertBranded(this, GPUAdapterInfoPrototype);
return this[_vendor];
}

/** @type {string} */
[_architecture];
/** @returns {string} */
get architecture() {
webidl.assertBranded(this, GPUAdapterInfoPrototype);
return this[_architecture];
}

/** @type {string} */
[_device];
/** @returns {string} */
get device() {
webidl.assertBranded(this, GPUAdapterInfoPrototype);
return this[_device];
}

/** @type {string} */
[_description];
/** @returns {string} */
get description() {
webidl.assertBranded(this, GPUAdapterInfoPrototype);
return this[_description];
}

[SymbolFor("Deno.privateCustomInspect")](inspect) {
return `${this.constructor.name} ${
inspect({
vendor: this.vendor,
architecture: this.architecture,
device: this.device,
description: this.description,
})
}`;
}
}
const GPUAdapterInfoPrototype = GPUAdapterInfo.prototype;

const _limits = Symbol("[[limits]]");

function createGPUSupportedLimits(features) {
Expand Down Expand Up @@ -602,26 +694,24 @@
* @param {any} type
*/
function GPUObjectBaseMixin(name, type) {
type.prototype[_label] = undefined;
type.prototype[_label] = null;
ObjectDefineProperty(type.prototype, "label", {
/**
* @return {string | undefined}
* @return {string | null}
*/
get() {
webidl.assertBranded(this, type.prototype);
return this[_label];
},
/**
* @param {string | undefined} label
* @param {string | null} label
*/
set(label) {
webidl.assertBranded(this, type.prototype);
if (label !== undefined) {
label = webidl.converters["UVString"](label, {
prefix: `Failed to set 'label' on '${name}'`,
context: "Argument 1",
});
}
label = webidl.converters["UVString?"](label, {
prefix: `Failed to set 'label' on '${name}'`,
context: "Argument 1",
});
this[_label] = label;
},
});
Expand Down Expand Up @@ -4213,9 +4303,14 @@
* @param {number} workgroupCountY
* @param {number} workgroupCountZ
*/
dispatchWorkgroups(workgroupCountX, workgroupCountY = 1, workgroupCountZ = 1) {
dispatchWorkgroups(
workgroupCountX,
workgroupCountY = 1,
workgroupCountZ = 1,
) {
webidl.assertBranded(this, GPUComputePassEncoderPrototype);
const prefix = "Failed to execute 'dispatchWorkgroups' on 'GPUComputePassEncoder'";
const prefix =
"Failed to execute 'dispatchWorkgroups' on 'GPUComputePassEncoder'";
webidl.requiredArguments(arguments.length, 1, { prefix });
workgroupCountX = webidl.converters.GPUSize32(workgroupCountX, {
prefix,
Expand Down Expand Up @@ -5180,6 +5275,7 @@
GPURenderBundleEncoder,
GPURenderBundle,
GPUQuerySet,
GPUError,
GPUOutOfMemoryError,
GPUValidationError,
};
Expand Down
16 changes: 14 additions & 2 deletions deno_webgpu/02_idl_types.js → deno_webgpu/src/02_idl_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,15 @@
],
);

// ENUM: GPUMipmapFilterMode
webidl.converters["GPUMipmapFilterMode"] = webidl.createEnumConverter(
"GPUMipmapFilterMode",
[
"nearest",
"linear",
],
);

// ENUM: GPUCompareFunction
webidl.converters["GPUCompareFunction"] = webidl.createEnumConverter(
"GPUCompareFunction",
Expand Down Expand Up @@ -584,7 +593,7 @@
},
{
key: "mipmapFilter",
converter: webidl.converters["GPUFilterMode"],
converter: webidl.converters["GPUMipmapFilterMode"],
defaultValue: "nearest",
},
{
Expand Down Expand Up @@ -938,7 +947,10 @@

// DICTIONARY: GPUPipelineDescriptorBase
const dictMembersGPUPipelineDescriptorBase = [
{ key: "layout", converter: webidl.converters["GPUPipelineLayout"] },
{
key: "layout",
converter: webidl.converters["GPUPipelineLayout"],
},
];
webidl.converters["GPUPipelineDescriptorBase"] = webidl
.createDictionaryConverter(
Expand Down
Loading

0 comments on commit dd6febe

Please sign in to comment.