Skip to content

Overlap with my rust-gpu-cli project? #12

@tombh

Description

@tombh

For the last couple of Rust GPU projects I've been building my shaders using a standalone compiler, https://github.com/tombh/rust-gpu-cli, which is based on Bevy's https://github.com/Bevy-Rust-GPU/rust-gpu-builder.

My own reason for this is that I found it hard maintaining both my own application code and the shader code in the same repo. I think mostly because of rust-gpu's requirement for a specific rust-toolchain.toml.

I suspect cargo gpu will also solve this problem? In which case I'd like to contribute and focus my efforts here instead 🤓

So some reflections as both a rust-gpu and rust-gpu CLI frontend user:

  • Should rust-gpu always support both ways of compiling shaders? Therefore auto-magically in a monorepo and with a standalone CLI frontend? Personally I'm currently leaning towards only supporting the latter. There are so many unconventional moving parts in compiling Rust shaders that I think hiding too much of the magic can lead to more harm than good.
  • I see that cargo gpu will be published to crates.io. I wonder if it can be taken one step further and pre-compiled to static, cross-platform binaries? Possibly that's what you were discussing in Investigate rustup component for cargo-gpu #2? I've actually already had success with this on Github Actions: see https://github.com/tombh/rust-gpu-cli/pull/1/files It compiles librustc_codegen_spirv.{so,dylib,dll}. And then the actual final rust-gpu-cli app dynamically sets the LD_LIBRARY_PATH (or DYLD_FALLBACK_LIBRARY_PATH etc depending on the OS). The only problem I faced was that rustup can't cross-compile rustc-dev so I haven't been able to get aarch64 binaries for Linux compiling yet.
  • Related to the previous point: is rust-toolchain.toml needed for compiling librustc_codegen_spirv.so or for compiling shaders or for both? Because if it's just for compiling librustc_codegen_spirv.so then does that mean that pre-compiled versions of librustc_codegen_spirv.so would avoid the need for cargo gpu to install its own rustup toolchains?
  • Also related to the above, am I understanding correctly that this project installs (or plans to install) Rust toolchains under the hood? I think it'd be good to mention that in the README. Especially if it installs to ~/.rustup/toolchains. Also I think it'd be good to have the CLI be verbose by default about what it's doing. Even the simple fact that cargo gpu build is itself calling cargo build/rustc shouldn't be assumed knowledge. It took me a long time to arrive at even the basic understanding I currently have about how rust-gpu works. So as much as a turnkey solution is a great idea, in my experience hiding all the inner workings wasn't so useful.
  • It's great to have bagged the cargo gpu namespace, but my first thought was that the gpu namespace could refer to a lot more than just compiling shaders. I wonder if something like cargo rust-gpu (whilst redundantly mentioning "rust") might be more appropriate?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions