[Migrated] Consider build CLI (e.g. `cargo gpu`) mapping `spirv-std` deps to toolchain & backend versions.
Nessuno ha ancora preso questa issue.
- Lingua principale
- Rust
- Stelle
- 3.4k
- Fork
- 125
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/1137
Originally creatd by eddyb on 2024-02-27T08:47:30Z
I was looking at minimal shader Cargo.tomls and they're often mainly:
[dependencies]
spirv-std = "0.9.0"
In the past (e.g. https://github.com/EmbarkStudios/rust-gpu/issues/911#issuecomment-1220547953) any speculation was focused on the backend (rustc_codegen_spirv) being built in some way tied to whatever interface (e.g. spirv-builder, or some future CLI) was being used to actually build, and therefore their versions being tied.
For example we thought maybe we could have a way to "install Rust-GPU 0.123.0" but then you will have to install a new one every Rust-GPU release, and anyone who wants to interact with your shader crates has to do the same etc.
Also, as big as it is, the (still unmerged) PR I made on a whim a few months ago also has that limitation:
But what if we instead made a future-compatible tool (usable as build dep/CLI/etc.) that:
- used
cargo_metadatato understand the shader's dependency graph (fromCargo.toml, workspace etc.)- in hot-reload mode, this would add more latency but at the same time we probably do want more visibility into stuff like that, and ideally it could be used in such a way that changing only the source code is much faster
- expects exactly one
spirv-stddependency, and uses it to get the actual toolchain+backend- wrt #1103:
- this is actually very similar to that PR, just
spirv-stdinstead ofspirv-builder - in theory, there's not much stopping us from having
spirv-std's build script build the backend, or anything that silly, I would just be worried about making it too much a house of cards
- this is actually very similar to that PR, just
- an important consequence is that any path/git rev/crates.io version dependency for
spirv-stdwould work (just like the PR which does this forspirv-build)- this is important to avoid impeding testing! (unlike "install a Rust-GPU version" workflows)
- wrt #1103:
- gets the toolchain it wants with
rustupand builds the right version ofrustc_codegen_spirv- (again this is the same as the PR that does all that in
spirv-builder's build script) - another potential advantage is that dependening on how this is done, it could let it show progress for that slower part of the build (though if you were using build scripts you'd have the same problem again, I think?)
- (again this is the same as the PR that does all that in
- expose e.g. Cargo subcommands, with the env vars set to get you a Rust-GPU build
- this could potentially mean
cargo gpu check/cargo gpu clippy! (tricky to expose right now)
- this could potentially mean
- ???
- profit
- more seriously, it would be nice if we could have a "safe hot-reload" interface eventually, where the build script "freezes" your shader interface and generates Rust types/impls so you can safely fill compatible buffers, and also generating the Rust code for a hot-reloading convenience that forces that "frozen interface" to keep matching (i.e. rebuild the app itself if you want to change the interface incompatibly)
I'm not sure if I've heard this kind of "dependency consequence inversion" being used anywhere - usually libraries might be driven by compiler versions, not the other way around. If anyone had suggested this for Rust-GPU in the past, I apologize for being unfamiliar with your game because all my other ideas until now have been mediocre compromises at bets.
EDIT1: forgot to mention an incidental source of inspiration - back around Rust-GPU 0.4 (which had to change how #[spirv(...)] works due to upstream rustc changes), we considered making spirv-std-macros turn #[spirv(foo)] into #[rust_gpu_0_9_0_git9d8095177::spirv_foo] (or some other kind of verbose encoding of a version) - and once you have that kind of "self-awareness" in spirv-std about the backend version it wants, a build tool can pull that out. (stricter checks around that would've saved me from some confusing build failures just earlier, which is probably why it was on my mind)
EDIT2: in theory, this is comparable to if Rust itself let you do:
[dependencies]
std = "1.79.0"
and have that act as a rust-toolchain.toml replacement. (likely unviable without replacing (parts of) rustup+cargo+rustc CLIs all at once with a combined rust one or something similarly extreme)
Actually, if we allow more "conceptual" dependencies, the comparison becomes
[dependencies]
rust = "1.79.0"
rust-gpu = "0.123.0"
And we do have the rust-gpu package on crates.io so that could be used instead of spirv-std to be more explicit (and then "namespaced dependencies" like rust-gpu/spirv-std, or really rust_gpu::spirv_std could exist? also the attribute could then not have to go into spirv-std etc.)
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia leggendo l’approccio alla gestione delle dipendenze in PR #1103 e lo script di build esistente di spirv-builder, quindi ricostruisci come vengono attualmente utilizzati cargo_metadata, spirv-std, rustc_codegen_spirv e rustup. L’issue è completa quando il progetto dispone di un design concordato per associare una dipendenza shader alla relativa toolchain e al backend, inclusa l’interfaccia cargo gpu proposta.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust
- Ambito
- build-system, cli, compilers, tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100