Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGPU: not able to use the alphaMode member of GPUCanvasConfiguration #23509

Open
Tracked by #23563
chirsz-ever opened this issue Apr 23, 2024 · 0 comments
Open
Tracked by #23563
Labels
ext/webgpu related to the ext/webgpu

Comments

@chirsz-ever
Copy link
Contributor

Version: Deno 1.42.4

Example code

import { WindowBuilder } from "jsr:@divy/sdl2@0.10.5";

const adapter = await navigator.gpu.requestAdapter();
if (!adapter) {
    console.error("init WebGPU failed: adapter is", adapter);
    Deno.exit(1);
}
const device = await adapter.requestDevice();

const WIDTH = 800;
const HEIGHT = 600;

const surfaceFormat = navigator.gpu.getPreferredCanvasFormat();

const win = new WindowBuilder("demo", WIDTH, HEIGHT).build();
const surface = win.windowSurface();
const context = surface.getContext("webgpu")
context.configure({
    device,
    format: surfaceFormat,
    width: WIDTH,
    height: HEIGHT,
    alphaMode: "premultiplied"
})

Run it with deno run --unstable-ffi --unstable-webgpu -A alphamode-test.ts. This would cause:

error: Uncaught (in promise) TypeError: [object Object]: The provided value 'preMultiplied' is not a valid enum value of type GPUCanvasAlphaMode.
context.configure({
        ^
    at ext:deno_webidl/00_webidl.js:817:13
    at Array.GPUCanvasConfiguration (ext:deno_webidl/00_webidl.js:788:32)
    at GPUCanvasContext.configure (ext:deno_webgpu/02_surface.js:53:39)
    at file://xxx/alphamode-test.ts:18:9

But if we replace alphaMode: "premultiplied" with alphaMode: "preMultiplied", there would be another error:

error: Uncaught (in promise) TypeError: [object Object]: The provided value 'preMultiplied' is not a valid enum value of type GPUCanvasAlphaMode.
context.configure({
        ^
    at ext:deno_webidl/00_webidl.js:817:13
    at Array.GPUCanvasConfiguration (ext:deno_webidl/00_webidl.js:788:32)
    at GPUCanvasContext.configure (ext:deno_webgpu/02_surface.js:53:39)
    at file://xxx/alphamode-test.ts:18:9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ext/webgpu related to the ext/webgpu
Projects
None yet
Development

No branches or pull requests

2 participants