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: Missing enumeration(s) in WGPUBlendFactor compared to Dawn #21552

Open
birsoyo opened this issue Mar 18, 2024 · 6 comments
Open

WebGPU: Missing enumeration(s) in WGPUBlendFactor compared to Dawn #21552

birsoyo opened this issue Mar 18, 2024 · 6 comments
Assignees
Labels

Comments

@birsoyo
Copy link

birsoyo commented Mar 18, 2024

I am using emscripten 3.1.55 for web and Dawn@ad853f80 for using webgpu natively on windows.

clang version 19.0.0git (https:/github.com/llvm/llvm-project 6c7805d5d186a6d1263f90b8033ad85e2d2633d7)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: [snip]\upstream\bin

As far as I can tell Dawn@ad853f80 should match emscripten 3.1.55 version of the webgpu headers.
 
When compiling with emscripten, the code fails with

[snip]: error: no member named 'OneMinusSrc1' in 'wgpu::BlendFactor'; did you mean 'OneMinusSrc'?
  457 |       return wgpu::BlendFactor::OneMinusSrc1;

It looks like the following blend factor enumerations are missing.

    WGPUBlendFactor_Src1 = 0x0000000E,
    WGPUBlendFactor_OneMinusSrc1 = 0x0000000F,
    WGPUBlendFactor_Src1Alpha = 0x00000010,
    WGPUBlendFactor_OneMinusSrc1Alpha = 0x00000011,
// Above are from Dawn@ad853f80

Are these missing enumerations intentional for not being supported on web?

Is there a place I can take a look how emscripten generates webgpu headers (from Dawn) so that I can match emscripten headers better with my native webgpu code?

@kainino0x
Copy link
Collaborator

kainino0x commented Mar 18, 2024

Dual source blending hasn't landed in the WebGPU spec yet: gpuweb/gpuweb#4283
More importantly you wouldn't be able to use it even behind browser flags: These enums haven't been wired up in Chromium yet and I don't think we have implemented the shader compiler part for the latest spec decision EDIT: Actually the shader part is done too, only Blink needs to be updated. (I don't suspect any other browser would have implemented it yet either.) Filed https://crbug.com/330066244 about it.

@beaufortfrancois
Copy link
Contributor

@kainino0x Dual source blending is going to ship soon: https://groups.google.com/a/chromium.org/g/blink-dev/c/C3VH1EMrs1Y

  1. Shall we update Emscripten?
  2. Is there anything we should do in emdawnwebgpu as well? My naive understanding is that it's working already as https://source.chromium.org/chromium/chromium/src/+/main:third_party/dawn/third_party/emdawnwebgpu/library_webgpu.js doesn't have any enum and feature names.

@kainino0x
Copy link
Collaborator

Basically the WebGPU bindings in Emscripten are a snapshot / in "maintenance mode" for the moment. The header currently in here was generated out of an older revision of Dawn, but even at that time there were differences between Dawn and Emscripten because Dawn has experimental features not available on the Web (including dual source blending at that time, before it was standardized).

Right now we are working on bringing the Emscripten bindings up to speed in a fork maintained inside Dawn instead of trying to do everything across two projects at once. So we strongly prefer to spend time on that fork so we can get it completed and merged back into Emscripten sooner rather than later.

@birsoyo do you need to use dual source blending for your application? (Or did you just encounter the difference in some other way?) If you wish to use Dawn's fork instead of Emscripten's snapshot you can do that, but note that it is going to be receiving many small breaking changes over the next few months. Or if you want to contribute a small patch to add just this feature to Emscripten, please open a PR and @ me for review!

@kainino0x
Copy link
Collaborator

kainino0x commented Aug 29, 2024

2. Is there anything we should do in emdawnwebgpu as well? My naive understanding is that it's working already as https://source.chromium.org/chromium/chromium/src/+/main:third_party/dawn/third_party/emdawnwebgpu/library_webgpu.js doesn't have any enum and feature names.

Correct, we (hopefully) shouldn't need to do anything, because emdawnwebgpu got rid of all the manually maintained tables in favor of autogeneration.

@beaufortfrancois
Copy link
Contributor

beaufortfrancois commented Aug 30, 2024

@kainino0x Thank you for the detailed explanation! May I suggest updating https://github.com/emscripten-core/emscripten/blob/main/system/include/webgpu/README.md so that developers interested in latest changes know what to do and expect?
Moreover, the README currently points to files in https://source.chromium.org/chromium/chromium/src/+/main:out/linux-Debug/gen/third_party/dawn/src/emdawnwebgpu/include which does not exist. Is this outdated or simply wrong?

@kainino0x
Copy link
Collaborator

Moreover, the README currently points to files in https://source.chromium.org/chromium/chromium/src/+/main:out/linux-Debug/gen/third_party/dawn/src/emdawnwebgpu/include which does not exist. Is this outdated or simply wrong?

The link was correct but those generated files aren't getting indexed by code search anymore. IIRC might be because we moved some of that codegen stuff into the CMake build instead (which doesn't run for chromium code search). @lokokung would remember.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants