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
This commit is contained in:
Divy Srivastava 2024-08-06 03:00:32 -07:00 committed by GitHub
parent 7f6b484684
commit c0e9512b39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 5 deletions

View File

@ -123,10 +123,10 @@ declare type GPUPowerPreference = "low-power" | "high-performance";
declare class GPUAdapter {
readonly features: GPUSupportedFeatures;
readonly limits: GPUSupportedLimits;
readonly info: GPUAdapterInfo;
readonly isFallbackAdapter: boolean;
requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice>;
requestAdapterInfo(): Promise<GPUAdapterInfo>;
}
/**

View File

@ -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) {

View File

@ -78,11 +78,11 @@ enum GPUPowerPreference {
[Exposed=(Window, Worker), SecureContext]
interface GPUAdapter {
[SameObject] readonly attribute GPUSupportedFeatures features;
[SameObject] readonly attribute GPUAdapterInfo info;
[SameObject] readonly attribute GPUSupportedLimits limits;
readonly attribute boolean isFallbackAdapter;
Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
Promise<GPUAdapterInfo> requestAdapterInfo();
};
dictionary GPUDeviceDescriptor