-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Update WebGPU WebIDL #1896
Update WebGPU WebIDL #1896
Conversation
Thanks for the PR! This is a little tricky to land though because it's a breaking change. We've occasionally made breaking changes to web-sys methods in the past, but they've been pretty minor. Are the bindings, as listed today, totally unusable? Ideally this would never have been exposed in the first place and would have been gated. There's discussion on #1712 about how the gating would work, although it has not yet been implemented. |
I don't think the current bindings will be very useful to people because they're relatively outdated at this point. The WebGPU specification also isn't finished yet so there will still be (probably many) breaking changes before it stabilizes. Gating it sounds alright to me if we could find a good way to do that. We were basically hoping to start using web-sys with wgpu-rs releases (when targeting wasm instead of native) even before the WebGPU specification stabilizes. |
Ok if that's the case then I'm tempted to prefer a course of action that looks like:
(or at least that's how I'd personally prefer to proceed here) |
Are you still working on this? I also need to add some unstable webidls so might try to implement |
@alexlapa I started working on it but the changes are a bit more involved than I hoped. For example, we have to update the code generator in a few places to output the I plan to continue working on it sometime over the next couple weeks, but please feel free to implement it in the meantime if you'd like |
So i've tried the most straightforward
Now i am trying to add all webidls that i need, and it seems that it is hard to get right:
I have also thought about passing every file to compiler and overriding stable apis based on item names, that would definitely be more precise, but still has some drawbacks. Another solution might be to allow users to add their own webidls.
In this way, every user would be able to generate any binding that he needs for his use-case. UPD: another interesting way that such feature can be used, is to allow users to make bindings for any JS libraries that they need to use. Not sure how to make that work atm, but that would be pretty awesome. |
Hm now that you mention it I wonder if that's the best way to do this? We could publish a stable crate whose purpose is solely to generate a crate from webidl files. That way we wouldn't have to change web sys at all here and users could maintain their own webidl in their own crates? |
I think that would work well for our use case, at least until WebGPU stabilizes. |
I guess so. Another option might be releasing some web-sys-unstable crate, that would contain all the webidls from https://github.com/mozilla/gecko-dev/tree/master/dom/webidl, and update them every month or so. That would be enough for many cases, i believe. But, obviously, that would require to keep binding generator up to date with latest webidl language changes.
Would work for me! My only concern is interop with web-sys, but, i guess it could be achieved via JSCast with no problem. |
Ah that's a good point about interop, but I we could probably have crates depend on web-sys automatically and also auto-enable features for classes that the WebIDL inherits from? |
I've gone ahead and opened up #1950 to track longer-term strategies of how to support unstable WebIDL files (like this) I'm going to go ahead and close this because I don't think we want to change this in web-sys right now, but rather I think we need to figure out a general scheme for unstable WebIDL files going forward. |
FWIW using the webidl embedded in the spec itself (and accompanying tool to extract it) gives you near perfect bindings for the current implementations. See #1968 From there, you need only make minor alterations to support vendor-specific extensions such as Chrome's GPUComputePipeline::getBindGroupLayout and Safari's WHLSL. |
This was updated using the WebIDL for WebGPU available at https://github.com/mozilla/gecko-dev/blob/master/dom/webidl/WebGPU.webidl because it looks like most WebIDL in this repository was vendored from mozilla-central originally.
The only change I made to the WebIDL was to remove a trailing comma that seems to be invalid which caused weedle parsing to fail (which will be fixed upstream in Gecko).
Note that WebGPU is being worked on actively in Gecko, so parts of the API are commented out until they're available there. If we'd prefer to avoid these comments, I could add the WebIDL from the WebGPU specification itself. cc @kvark