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

Extern definitions for WebGPU #4145

Open
kainino0x opened this issue Jan 23, 2024 · 4 comments
Open

Extern definitions for WebGPU #4145

kainino0x opened this issue Jan 23, 2024 · 4 comments

Comments

@kainino0x
Copy link
Member

kainino0x commented Jan 23, 2024

Closure doesn't yet have extern definitions for WebGPU.
Over in Emscripten, we are finally switching to externs instead of doing ["this"] everywhere (except everywhere we forgot and so it's broken).
emscripten-core/emscripten#21144

There you can see some barebones externs I generated from the WebGPU spec's WebIDL. I think it's enough for minification to work correctly(?) but it doesn't provide much else - no function arguments, in particular.

Would there be interest in bringing this into Closure as-is, or would it need more complete definitions?

@frigus02
Copy link
Contributor

Link for easy reference: https://github.com/emscripten-core/emscripten/blob/fb4bdc78cf3b99d634838418882f199e18309a5c/src/closure-externs/webgpu-externs.js

Thanks for the offer. On first glance I'd say they look nice. I'm going to check with the team if we want to include them as is.

@kainino0x
Copy link
Member Author

kainino0x commented Jan 24, 2024

If it helps, both Safari and Firefox have made strong signals about the API - Chrome shipped with positive signals from other browsers (the only caveat being that they hadn't/haven't finished implementing).
Firefox has had it on Nightly for a while (not yet shipping to stable): https://developer.mozilla.org/en-US/docs/Web/API/WebGPU_API#browser_compatibility
Safari recently enabled it behind a flag in Safari Technology Preview: https://www.webkit.org/blog/14885/release-notes-for-safari-technology-preview-185/

@frigus02
Copy link
Contributor

We talked internally. We'd rather not include the externs with JSCompiler by default, yet, because the API is currently only live Chrome.

Related: We're also thinking about generating externs using tsickle from TypeScript typings. That way we'd get better about adding new browser APIs to externs. But at the same time we'd only get them once at least 2 browser engines implement them, since that seems to be TS' policy.

I hope that makes sense. I'd kinda like to keep the issue open, though. We do need to add WebGPU externs eventually.

@kainino0x
Copy link
Member Author

Sounds good! We're happy to use our own externs in Emscripten for now. Hopefully if anyone is searching they'll find this issue and be able to copy them.

We're currently maintaining TypeScript types for WebGPU outside of upstream TypeScript: https://github.com/gpuweb/types
We've considered pushing to get them upstream, but since we're currently maintaining extra features over what TypeScript's generated types would look like (documentation pulled from the WebGPU spec, and some extra strictness), there hasn't been much pressure. And I'm sure TypeScript will add them themselves once it reaches whatever their threshold is.

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

No branches or pull requests

2 participants