-
Notifications
You must be signed in to change notification settings - Fork 247
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
Refactor how rustc_codegen_spirv is compiled #911
Comments
I agree it's noticeably suboptimal right now, and we have been wondering for a while about alternatives. However, there are more variations to what we could do (cc @repi @oisyn). How should
|
I think that this is not what I meant, I'd like to decouple the process of compiling let path_to_dylib = rustc_codegen_spirv:: dylib_path(); If you think about it The next question is, from what perspective are we looking at it? For example from user's perspective who is running |
This is orthogonal from pretty much everything I described, at least AFAICT. You can imagine that (almost) every time I said
Oh that's in an This probably means we need to split up
"What needs to run every time you change the shaders" is how I see it (and this applies to both build scripts and hot reloading usecases) - there's no reason (IMO) to keep checking if we need to rebuild But that is a quite minor point compared to everything else, a microoptimization almost. Generally, I'm trying to describe how |
I'll point out some things:
I'd like to have all of this to prepare Ps: The "nested-creates" approach (solution proposed by me) would satisfy the 3rd point. |
Finally took a stab at something like this, in: It's While Also, I've kept the dual features that @watjurk disliked, but I can kinda see how bad they are for this, I ended up having to treat them like they cause different |
New (conceptual) development: This is simultaneously very similar to existing setups (mostly only what decides the Rust-GPU version changes!), but also unlocks a lot more, because we can make a single version of some CLI tool work with many backend versions, as long as it's picked up from the shader crate (whether AFAICT in the original nomenclature earlier in the thread, The easiest thing we could try would be: Also, if we get |
Summary
rustc_codegen_spirv
is compiled and discovered in a very hacky way. Cargo compilesrustc_codegen_spirv
because it is insidespirv-builder
's Cargo.toml as a dependency, and thenspirv-builder
discovers therustc_codegen_spirv
's dylib by this super hacky function:find_rustc_codegen_spirv
. I think this should be avoided.Motivation
When I've tried to build something using
spirv-builder
this hacky discovery was not working for me.Also
rustc_codegen_spirv
is compiled using the same profile asspirv-builder
and we end up withrustc_codegen_spirv
being build without optimizations (if we are in debug mode). This is a big problem because compilingrustc_codegen_spirv
is a one time cost, but while developing one would recompile thier shaders many times.Proposed solution is much more elegant than current implemention.
Solution
Let's move
rustc_codegen_spirv
into another trait witch will compilerustc_codegen_spirv
and provide path to it's dylib file.I've crated an example of how this could be implements: https://github.com/watjurk/spirv-builder-alternative, here is a short summary:
All of this happens inside crates/rustc_codegen_spirv:
Cargo.toml
:src/lib.rs
:src/rustc_codegen_spirv
Future
In the future this approach could be modified without breaking code that relies on
dylib_path
function, for example we can serve pre-builed dylib's of rustc_codegen_spirv anddylib_path
instead of buildingrustc_codegen_spirv
will download one of the pre-build dylib's depending on user's hardware.The text was updated successfully, but these errors were encountered: