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

Closed
Tracked by #23563
chirsz-ever opened this issue Apr 23, 2024 · 2 comments
Closed
Tracked by #23563
Labels
bug Something isn't working correctly webgpu WebGPU API

Comments

@chirsz-ever
Copy link
Contributor

Version: Deno 1.42.4

Example code

import { WindowBuilder } from "jsr:@divy/[email protected]";

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
@slydor
Copy link

slydor commented May 24, 2024

Is this related? #22446

@lucacasonato lucacasonato added the bug Something isn't working correctly label Jun 8, 2024
@lucacasonato
Copy link
Member

Dupe of #22446 (and it's fixed now!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly webgpu WebGPU API
Projects
None yet
Development

No branches or pull requests

4 participants