-
Notifications
You must be signed in to change notification settings - Fork 105
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
Generating Rust types from C headers #78
Labels
help wanted
Extra attention is needed
Comments
8 tasks
bors bot
added a commit
that referenced
this issue
Apr 2, 2021
85: Start migration from cbindgen to bindgen r=kvark a=DevOrc Fix for #78 - has rust types generated by the header instead of vice-versa. Currently still needs a lot of work (most of the original codebase is deleted 😞 ) but I am slowly reimplementing everything with the generated types. Currently the triangle and compute examples _should_ work on Windows and Linux. Anyways, thought I would post this here to get initial thoughts before I finished adding everything. ## Big changes - all of the header types are generated at build time and inserted into the `crate::native` module - enums are mapped from their c types to wgt using a macro (map_enum!) - two c headers (`ffi/webgpu.h` for things in the [webgpu-native](https://github.com/webgpu-native/webgpu-headers) headers, and `ffi/wgpu.h` for stuff unique to wgpu-native) ## Small Notes - auto-generated bindings are modified at build time to change all of the *Impl to Ids (`BindGroupImpl` -> `wgc::id::BindGroupId`) - libclang now required to build (required by bindgen) - enum constants are i32 on windows and are u32 on macos/linux - example shaders are now written in WGSL - Had to change some of the makefiles for windows c development (if anyone has a better way to write makefiles please let me know :smile:) ## Stuff that still needs to be added - [x] MacOS Surfaces - [ ] Wayland Surfaces - [x] most commands - [x] undelete / update the capture example - [x] logging - [x] Textures - [x] Fix IOS - [ ] Include webgpu.h in release CI Co-authored-by: Noah Charlton <[email protected]>
This has happened. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now that we are getting closer to #6 with PRs by @Sineaggi like #77, it seems to me that trying to re-define all the types that we need for C headers is a lot of redundant work. We already have those definitions in the shared C header, perhaps we could generate the Rust types automatically? https://github.com/rust-lang/rust-bindgen would help.
So wgpu-native would not need to define anything, it would just contain logic to map from the auto-generated types into
wgpu-core
andwgpu-types
.The text was updated successfully, but these errors were encountered: