-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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] Add Surface API #21939
[webgpu] Add Surface API #21939
Conversation
533d5f6
to
d6a8639
Compare
139b253
to
5a31c92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry haven't finished reviewing but here are some comments
src/library_webgpu.js
Outdated
'premultiplied', | ||
'unpremultiplied', | ||
'inherit', | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed (see emscripten_no_enum_table
in dawn.json)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, this is needed. I saw that it wasn't used and didn't think about the fact that it should be used.
However not all of the entries should be there, it should be something like:
CompositeAlphaMode: [
'opaque',
'opaque',
'premultiplied',
],
Thanks for starting the review @kainino0x. There are still some TODOs I'd like to solve such as presentModes, alphaModes, and the error returned by getCurrentTexture. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I addressed all my own comments, so LGTM now, but @beaufortfrancois PTAL before I land it.
@kainino0x I've just merged main branch and I've tried locally all your latest changes. LGTM. Thank you! |
Is there an IDL or a spec available to this Surface API? It doesn't seem to exist in the WebGPU spec at least. |
I believe webgpu-native/webgpu-headers#164 and webgpu-native/webgpu-headers#203 are where things got defined. |
The Web API only concerns itself with HTML Canvas, whereas Surface is a C-API-only abstraction over both HTML Canvas and native window system integration. The Surface API is very close to GPUCanvasContext though. |
What got me confused is that the JS side code but there is no such parameter defined in the IDL: https://www.w3.org/TR/webgpu/#dictdef-gpucanvasconfiguration (and no |
Ah, that's not supposed to be there. presentMode is native-only, Chrome doesn't support it in Blink, it just gets dropped on the floor because that's how WebIDL works. |
src/library_webgpu.js
Outdated
'premultiplied', | ||
'unpremultiplied', | ||
'inherit', | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, this is needed. I saw that it wasn't used and didn't think about the fact that it should be used.
However not all of the entries should be there, it should be something like:
CompositeAlphaMode: [
'opaque',
'opaque',
'premultiplied',
],
"usage": {{{ gpu.makeGetU32('config', C_STRUCTS.WGPUSurfaceConfiguration.usage) }}}, | ||
// viewFormatCount | ||
// viewFormats | ||
"alphaMode": "opaque", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be either "opaque"
or "premultiplied"
depending on the configuration, and there should be an assert that it's one of the values that's valid in JS (auto, opaque, premultiplied). (Just look it up in the table above and then assert that the result is not undefined
.)
Alternatively, assert the alphaMode is Opaque for now with a TODO, and implement this later if you'd like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've assert alphaMode is Opaque with a TODO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one last thing
@sbc100 Is there any chance we can publish next Emscripten release (3.1.61 I believe) when Chrome 126 hits stable channel (June 10th) so that developers don't have to use the ToT version of Emscripten to use the Surface API in WebGPU? |
Sure, we can basically cut releases as we please. |
(assuming the tree is green and there are no known issues) |
That's great to hear! |
As raised in [1], the default value for surfaceConfiguration alphaMode should be "auto", not "opaque". [1]: emscripten-core/emscripten#21939 (comment) Bug: dawn:2320 Change-Id: I4201f6ab623ee62a2d206121d0fe2ae1eece67cc Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/190080 Reviewed-by: Corentin Wallez <[email protected]> Commit-Queue: Fr <[email protected]>
…2006) As raised in #21939 (comment), the default value for surfaceConfiguration alphaMode should be "auto", not "opaque". Relevant Dawn CL: https://dawn-review.googlesource.com/c/dawn/+/190080
@sbc100 Can we schedule a new release next week? |
We are working on right now. But we have hit a few snags. |
Thanks! |
Thanks for releasing https://github.com/emscripten-core/emscripten/releases/tag/3.1.61 @sbc100! |
…scripten-core#22006) As raised in emscripten-core#21939 (comment), the default value for surfaceConfiguration alphaMode should be "auto", not "opaque". Relevant Dawn CL: https://dawn-review.googlesource.com/c/dawn/+/190080
FIX #21745