summaryrefslogtreecommitdiff
path: root/ext/webgpu/01_webgpu.js
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-08-06 03:00:32 -0700
committerGitHub <noreply@github.com>2024-08-06 15:30:32 +0530
commitc0e9512b39a4ed3713d1fd9b28469d0edf68f578 (patch)
tree48194976942488e9ded45464e76cef943db5dedb /ext/webgpu/01_webgpu.js
parent7f6b484684279b643d8ed6374bed0b92b3038b50 (diff)
BREAKING(webgpu/unstable): Replace async .requestAdapterInfo() with sync .info (#24783)
Closes https://github.com/denoland/deno/issues/24779 Ref https://github.com/gpuweb/gpuweb/pull/4662
Diffstat (limited to 'ext/webgpu/01_webgpu.js')
-rw-r--r--ext/webgpu/01_webgpu.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/ext/webgpu/01_webgpu.js b/ext/webgpu/01_webgpu.js
index 15b82a8e3..2c30e47f0 100644
--- a/ext/webgpu/01_webgpu.js
+++ b/ext/webgpu/01_webgpu.js
@@ -423,6 +423,8 @@ class GPUAdapter {
[_adapter];
/** @type {bool} */
[_invalid];
+ /** @type {GPUAdapterInfo | undefined} */
+ #adapterInfo;
/** @returns {GPUSupportedFeatures} */
get features() {
@@ -502,9 +504,9 @@ class GPUAdapter {
}
/**
- * @returns {Promise<GPUAdapterInfo>}
+ * @returns {GPUAdapterInfo}
*/
- requestAdapterInfo() {
+ get info() {
webidl.assertBranded(this, GPUAdapterPrototype);
if (this[_invalid]) {
@@ -513,6 +515,10 @@ class GPUAdapter {
);
}
+ if (this.#adapterInfo !== undefined) {
+ return this.#adapterInfo;
+ }
+
const {
vendor,
architecture,
@@ -525,7 +531,8 @@ class GPUAdapter {
adapterInfo[_architecture] = architecture;
adapterInfo[_device] = device;
adapterInfo[_description] = description;
- return PromiseResolve(adapterInfo);
+ this.#adapterInfo = adapterInfo;
+ return adapterInfo;
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {