mesa merge requestshttps://gitlab.freedesktop.org/mesa/mesa/-/merge_requests2024-03-21T20:24:21Zhttps://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27397Draft: nouveau: nil: rewrite the library in Rust2024-03-21T20:24:21ZDaniel AlmeidaDraft: nouveau: nil: rewrite the library in Rust@gfxstrand Hi Faith,
This is a POC so that we can discuss the strategy for binding between C and Rust, and it's working :smile:
We use bindgen as usual to bind over C, and then export a C API through `nil_rs.h`.
Unfortunately, there ...@gfxstrand Hi Faith,
This is a POC so that we can discuss the strategy for binding between C and Rust, and it's working :smile:
We use bindgen as usual to bind over C, and then export a C API through `nil_rs.h`.
Unfortunately, there is no support for cbindgen in Meson. We discussed this in #mesonbuild yesterday and changes are needed in both cbindgen and Meson to make it work. More info at https://github.com/mozilla/cbindgen/issues/922 (cc @dbaker )
For now, I am writing `nil_rs.h` by hand. It's a bit tricky to get this right, because it is very easy for this file to get out of sync.
We also need to manually move `exports.c` from `/tmp/bindgen/exports.c` and then edit it slightly. This is needed to bind over inlined and static symbols.
For now, we just build `nil_rs::Image` and then dump its fields through `fprintf`, no crashes.
Let me know what you think. I think this can scale if we're careful. Waiting for a green light here to keep improving on this PR.https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20298Draft: Add infrastructure for Vulkan drivers written in Rust2024-01-05T22:36:28ZFaith EkstrandDraft: Add infrastructure for Vulkan drivers written in RustWe all know that C sucks. Many of us think C++ sucks worse. Rust doesn't suck. Wouldn't it be great if we could write Vulkan drivers in a competent language? If we can figure out how to avoid the mental overhead of the C <-> Rust int...We all know that C sucks. Many of us think C++ sucks worse. Rust doesn't suck. Wouldn't it be great if we could write Vulkan drivers in a competent language? If we can figure out how to avoid the mental overhead of the C <-> Rust interface leaking everywhere, Rust would probably be a great language for writing drivers.
This MR is going to stay a draft and be my personal scratch pad for this for a while. I don't expect to see any Rust Vulkan drivers in Mesa any time soon.
A few of the problems I want to solve:
- [x] Make working with Vulkan allocators reasonable
- [ ] Wrap our vk_log framework into something that looks like Rust write/print.
- [ ] Handle Vulkan errors using `Result<T, VkResult>` or similar
- [ ] Automatic unwrapping `Result<(), VkResult>`
- [ ] Automatic unwrapping `Result<VkObjBox<T>, VkResult>` for constructor functions
- [ ] A Rust equivalent of `vk_error()` and `vk_errorf()`.
- [x] Make object construction with `vk_foo` base objects reasonable.
- This probably means some sort of `VkObjBox<T>` type which constructs an object which is a `vk_foo` followed by a driver type with some sort of magic to make initializing it using C initializers not a giant pain. Rust's lack of placement-new makes this a tad annoying.
- [ ] Generate entrypoint wrappers using Vulkan explicit sync to determine `mut`
- This one is tricky because we can't just pull the weak function pointer trick for automatically NULLing out entrypoints. We probably need to somehow scan the rust project and generate only the wrappers we need or something like that.https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14862Draft: Grover: a new frontend for the Glide API!2023-09-12T20:06:50ZLink MauveDraft: Grover: a new frontend for the Glide API!This driver might come as a surprise, 21 years after the last 3DFX card
released, but it makes it possible to run programs targeting this
family of GPUs on top of any Gallium driver (so far I only tested iris
and radeonsi).
This is the ...This driver might come as a surprise, 21 years after the last 3DFX card
released, but it makes it possible to run programs targeting this
family of GPUs on top of any Gallium driver (so far I only tested iris
and radeonsi).
This is the second attempt at making a Gallium frontend in Rust, the
first one being OpenCL by karolherbst. I tried to make a clear
separation between the C API exposed to the user (in
`src/gallium/targets/glide`), and the inner driver (in
`src/gallium/frontends/glide`). The inner driver uses raw bindings
generated with `bindgen` to expose the Gallium C API to Rust (see
`meson.build` and `bindgen.h`), a higher level and safer wrapper on top of
it (`pipe.rs`), a definition of the Glide types (`gr.rs`) and the actual
driver (`glide.rs`).
There is no winsys integration so far, mainly because I could find no
Linux game (Unreal and Unreal Tournament apparently got Linux builds,
but I couldn’t find them so far), and also because I couldn’t figure out
how to create a dll for use in Wine, with winebuild, even with the help
of wine-nine-standalone. As such, the only interface with the user so far is dumping `frame-%03d.bmp` files in the current working directory…
I have restricted the implemented APIs to the programs I had at hand,
mainly some samples and a game, [Pandemonium!](https://www.gog.com/game/pandemonium). I’m sure I still have
some CDs around with other games from this era, but so far couldn’t find
them, so if you have more I’d really like you to send me a trace using
`grtrace` (see the next two commits), or even a donation on GOG.com
(username: linkmauve) or whatever. If you don’t have any game to test, you can replay this trace of Pandemonium: [pandemonium.grtrace.zst](/uploads/e6a815685d89652e43f35c721abb22a8/pandemonium.grtrace.zst)
All in all, I don’t expect this driver to be used much, I mostly wrote
it for fun and in order to experiment with Rust inside of Mesa, but I do
intend to maintain it and eventually to make it support all APIs used by
all games from that 1996-2000 era which targeted it.
I’m also interested in getting a donation of any 3DFX card, so that I could test that this driver actually respects how the games were made to look like.
Feel free to get in touch at xmpp:glide@muc.linkmauve.fr?join (or [using a web client](https://converse.linkmauve.fr/glide@muc.linkmauve.fr)).
Have a screenshot!
![pandemonium](/uploads/817978da9d09c331bfc9694ad796495d/pandemonium.png)