-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support for setting config in shader's Cargo.toml
#34
base: main
Are you sure you want to change the base?
Conversation
I'll have a look at those failing tests tomorrow. |
Cargo.toml
0e871d0
to
1bcaef6
Compare
Neat, I actually have usecase for this. I need to enable some shader features. |
Great work!
They don't have to both exist, but they have to boil down to the same thing (if I'm not mistaken) - we have to be able to determine the target specification file to give to That said, I don't think we'll ever use anything but the explicit path-to-specification-file method. |
Yes! This is why we're prioritizing this work :) |
21d6294
to
0b738cd
Compare
Thanks! So let's see if we can come to a conclusion about the old/new way of defining the target.
Ideally we want a little automation? For example something like, if the user doesn't provide an absolute path then we assume that the string is the name of an existing target that Either way I think we'll want something like BTW I've also just pushed a little change that attempts to end-to-end test the changes by altering the cargo install --path crates/cargo-gpu
cargo gpu install --shader-crate crates/shader-crate-template --auto-install-rust-toolchain
sed -i 's/^output-dir =.*/output-dir = \/tmp\/testshaders/' crates/shader-crate-template/Cargo.toml
cargo gpu build --shader-crate crates/shader-crate-template
ls -lah /tmp/test-shaders It seems a bit hacky. Can anybody think of another way? Like is there another config that we can change and detect in the final built shader? Edit: the end-to-test is actually surfacing a bug! I think it's to do with |
67bf4a5
to
bcd23c2
Compare
About defining a target - the new way is similar to the old way, but we control the paths at shader crate compile time, as opposed to them being hard coded at But I think it would be easy enough to create one more option, something like |
I think that's a fine idea, I'll create an issue for that and we can tackle it after this? |
4d9b238
to
6eee8b3
Compare
6eee8b3
to
743cb3d
Compare
Okay, for now I've just hidden the From my side this looks ready to merge, or at least ready to give a good testing to. I still want to add the |
743cb3d
to
7564036
Compare
This is particularly useful when `--auto-install-rust-toolchain` is used as the consent prompt isn't show and no indication at all of what's happening was given.
Values are set in the TOML section: `[package.metadata.rust-gpu.*]`. So now the priority, from least to most, is: * Workspace metadata * Shader crate's metadata * CLI args Fixes Rust-GPU#15 Notable changes: * All `clap` args for the `build` and `install` subcommands are now defined in the `spirv-builder-cli` crate. This makes passing all the config between `cargo gpu` and `spirv-builder-cli` trivial as `serde` now does all the heavy lifting of creating and reading the JSON arguments. * There is no longer a `toml` subcommand. The shader crate's `Cargo.toml`s are always read and their configs used as the base for CLI args to override.
7564036
to
cfdf4ed
Compare
I added the I also looked into a |
@tombh could we write a small wrapper over the enum just to provide our own (de)serialization? Would that be easier? |
I'd love to! I'm not sure how though, do you have any ideas? Another thing I tried was to type alias, making the external type internal, so I'm very open to trying other ideas 🤓 |
Because our `spirv-builder-cli` can modify itself to comply with various versions of `spirv-builder` from `rust-gpu`, then we also need to match the version of `spirv` that we use to get `spirv::Capabilities`. Namely that `rust-gpu <= v0.9.0` uses `spirv = "0.2.0"` and that `rust-gpu >= "v0.9.0"` uses `spirv = "0.3.0". Another solution to this could be to re-export `spirv` from `spirv-builder`. But I'm not sure that would avoid compiling the entirety of `spirv-builder` (which depends on specific Rust nightly versions), and besides, it's not trivial to retroactively add re-exports to already-published version of `rust-gpu`.
Found another bug and pushed the fix. Copypasting the new commit's message:
|
Managed to find quite an elegant solution where
serde_json
is doing all the heavy lifting. We even have automatic type checking on the config set in the shader crate'sCargo.toml
!Values are set in the TOML section:
[package.metadata.rust-gpu.*]
.So now the priority, from least to most, is:
Fixes #15
Notable changes:
clap
args for thebuild
andinstall
subcommands are nowdefined in the
spirv-builder-cli
crate. This makes passing all theconfig between
cargo gpu
andspirv-builder-cli
trivial asserde
now does all the heavy lifting of creating and reading the JSON
arguments.
toml
subcommand. The shader crate'sCargo.toml
sare always read and their configs used as the base for CLI args to
override.
TODO:
get_cargo_toml_as_json()
function to parse theshader crate's
spirv-std
dependency. This will simplify the codeand be more reliable. See Use
cargo metadata
to parsespirv-std
dep from shader crate #37cargo gpu show targets
See Addcargo gpu show targets
#36cargo gpu show capabilities
cargo gpu show extensions
target
andshader_target
arguments, are they both needed?