Announcement

Collapse
No announcement yet.

Experimenting Underway To Support Mesa Vulkan Drivers Written In Rust

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Experimenting Underway To Support Mesa Vulkan Drivers Written In Rust

    Phoronix: Experimenting Underway To Support Mesa Vulkan Drivers Written In Rust

    While there is Rusticl as the first Rust language code within Mesa as a modern OpenCL implementation in Gallium3D, for possible future driver efforts there is some initial exploratory work being done around coming up with bindings to support writing of Vulkan drivers with Rust...

    Phoronix, Linux Hardware Reviews, Linux hardware benchmarks, Linux server benchmarks, Linux benchmarking, Desktop Linux, Linux performance, Open Source graphics, Linux How To, Ubuntu benchmarks, Ubuntu hardware, Phoronix Test Suite

  • #2
    Originally posted by phoronix View Post
    Phoronix: Experimenting Underway To Support Mesa Vulkan Drivers Written In Rust
    for possible future driver efforts there is some initial exploratory work being done around coming up with bindings to support writing of Vulkan drivers with Rust...
    This is a difficult problem and is not just as simple as "use bindgen". The binding issue is why most software is still written in C or (semi) supersets like C++.

    I still feel they should stick a tiny C compiler frontend onto Rust to enable it to directly consume C headers and libs. Especially in problem domains where sucking on crates.io isn't possible (such as drivers).

    Comment


    • #3
      Well, well... It's getting harder by the day to resist the urge to open the door to Rust as a C replacement, it seems.

      Comment


      • #4
        I suspect that the first major mesa driver to be written in rust could come quite soon actually, in the form of the open source nvidia vulkan driver.

        Comment


        • #5
          Originally posted by Developer12 View Post
          I suspect that the first major mesa driver to be written in rust could come quite soon actually, in the form of the open source nvidia vulkan driver.
          I see that opencl is a joke to you lol, but to be fair, that is simply a part of a driver I suppose

          Comment


          • #6
            Originally posted by Quackdoc View Post
            I see that opencl is a joke to you lol, but to be fair, that is simply a part of a driver I suppose
            Yep, we already have rusticl, though it is not enabled yet.

            Comment


            • #7
              I recently started learning rust (so far I have only written a small toy-language compiler in it, single threaded, no async). I like the language overall.
              ​​​​
              • Compared to C, it is a world of difference.
              • Compared to old style C++ (pointers and references) it is also amazing.
              • Compared to modern C++ (unique_ptr, shared_ptr etc) it is a step up, but not nearly as big of a difference. However the standard library is much more consistent and cohesive, thanks to not having 40ish years of legacy.
              • Compared to Python, it is nice to work in a statically typed language again (compiler errors instead of runtime errors, though typing in python has improved this in recent years, still many libraries are not fully typed yet). However, the compilation time in Rust is annoying compared to the instant test loop in python.
              • Compared to Erlang: while rust has pattern matching, it is not as powerful. But then nothing compares to Erlang/Elixir for this aspect, except maybe Prolog.
              Rust also has a nice advanced macro system. I have yet to write any macro, but using them has been great. Getting rid of boiler plate easily. Reminds me of Lisp/Scheme.

              The package manager/build system (Cargo) has also been nice to use. With good support for extensions, like cargo-fuzz adding fuzz testing.

              I look forward to exploring Rust further in the coming months. I want to try out threads, async and embedded (ESP32).
              ​​​​​​

              Comment


              • #8
                Originally posted by kpedersen View Post
                This is a difficult problem and is not just as simple as "use bindgen". The binding issue is why most software is still written in C or (semi) supersets like C++.

                I still feel they should stick a tiny C compiler frontend onto Rust to enable it to directly consume C headers and libs. Especially in problem domains where sucking on crates.io isn't possible (such as drivers).
                Hmmm, not sure I completely understand what you mean by that, but I do want something like `zig-cc` in `cargo` so that cross-compiling external C/C++ dependencies can be pain-free.

                Currently, while rustc can cross compile any rust code trivially, any external C/C++ code still need to go through the extreme painful route of either install the cross C/C++ compiler yourself, or use cross-rs for container, or use zig-cc.

                I really hope that sth. like `zig-cc`, or even `zig-cc` can be directly embedded in `cargo` to make cross compiling rust with any external C/C++ dependencies pain-free.

                Comment


                • #9
                  Originally posted by NobodyXu View Post
                  Hmmm, not sure I completely understand what you mean by that
                  In its simplest form, the ability for the Rust compiler to natively #include C header files (C++ is a little less important I feel) and instantly be able to consume the API in them (consts, MACROS, funcs, structs, typedefs, etc).

                  Yes, unsafe (it can perhaps go in unsafe tags to localize the damage) but most importantly for small C APIs this can be used directly rather than needing to suck thin bindings or fat bindings from crates. I predict it will eliminate the need for many dependencies from crates (most sys ones).

                  Comment


                  • #10
                    This would likely be helpful for the Asahi Linux devs who already have functioning Apple Silicon GPU support using Rust in the kernel:


                    Comment

                    Working...
                    X