mirror of
https://github.com/denoland/deno.git
synced 2025-02-02 04:38:21 -05:00
feat(unstable): implement navigator.gpu.getPreferredCanvasFormat()
(#22149)
This commit is contained in:
parent
2810b49bed
commit
c258834f47
3 changed files with 16 additions and 0 deletions
|
@ -247,6 +247,11 @@ Deno.test({
|
|||
Deno.close(Number(resources[resources.length - 1]));
|
||||
});
|
||||
|
||||
Deno.test(function getPreferredCanvasFormat() {
|
||||
const preferredFormat = navigator.gpu.getPreferredCanvasFormat();
|
||||
assert(preferredFormat === "bgra8unorm" || preferredFormat === "rgba8unorm");
|
||||
});
|
||||
|
||||
async function checkIsWsl() {
|
||||
return Deno.build.os === "linux" && await hasMicrosoftProcVersion();
|
||||
|
||||
|
|
1
cli/tsc/dts/lib.deno_webgpu.d.ts
vendored
1
cli/tsc/dts/lib.deno_webgpu.d.ts
vendored
|
@ -78,6 +78,7 @@ declare class GPU {
|
|||
requestAdapter(
|
||||
options?: GPURequestAdapterOptions,
|
||||
): Promise<GPUAdapter | null>;
|
||||
getPreferredCanvasFormat(): GPUTextureFormat;
|
||||
}
|
||||
|
||||
/** @category WebGPU */
|
||||
|
|
|
@ -344,6 +344,16 @@ class GPU {
|
|||
}
|
||||
}
|
||||
|
||||
getPreferredCanvasFormat() {
|
||||
// Same as Gecko.
|
||||
//
|
||||
// https://github.com/mozilla/gecko-dev/blob/b75080bb8b11844d18cb5f9ac6e68a866ef8e243/dom/webgpu/Instance.h#L42-L47
|
||||
if (core.build.os == "android") {
|
||||
return "rgba8unorm";
|
||||
}
|
||||
return "bgra8unorm";
|
||||
}
|
||||
|
||||
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
|
||||
return `${this.constructor.name} ${inspect({}, inspectOptions)}`;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue