-
Notifications
You must be signed in to change notification settings - Fork 441
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
Add root_path_env
property to shaders macro
#2180
Conversation
I'm not exactly sure how to go about adding unit tests. I could of course add a build script that copies an glsl file into the build dir and then use it in a test, but adding that to the shaders crate directly would also cause everyone using that crate to execute that unnecessary build script. I could also add a new crate just for testing this but that also seems a little overkill. |
I don't think that this can be unit tested. It would need an integration test or a whole system test (like an example, which you mentioned) but that would be total overkill for a change like this I think. There's only so much that can go wrong with a small change like this so I wouldn't worry about it personally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the name for the field you ended up with! It's very descriptive. Everything works for me, just a couple changes I would like.
Co-authored-by: marc0246 <40955683+marc0246@users.noreply.github.com>
I just applied all your suggestions, don't really have anything to add to them |
Would you deem it valuable to add documentation that one can specify custom rustc env vars in the build script?
let out_dir = env::var("OUT_DIR").unwrap();
let shader_out_dir = format!("{out_dir}/../../../../spirv-builder/spirv-unknown-spv1.3/release/deps/example_shader.spvs/");
println!("cargo:rustc-env=SHADER_OUT_DIR={shader_out_dir}"); shader include:
|
Sure, if you want to add that I think that would be great. |
Awesome, thank you for the work! |
* shaders: minor fix that some Vecs were always allocated with capacity of 0 * shaders: add root_path_env property to allow loading shaders generated by a build script * shaders: Apply root_path_env suggestions from code review Co-authored-by: marc0246 <40955683+marc0246@users.noreply.github.com> * shaders: added root_path_env docs about env vars specified by a build script --------- Co-authored-by: Firestar99 <4696087-firestar99@users.noreply.gitlab.com> Co-authored-by: marc0246 <40955683+marc0246@users.noreply.github.com>
In order to load a shader generated by the build script one would need to specify the path from the
Cargo.toml
into the target directory, but one may not even now where exactly the target directory is located. It may be./target
on a single crate,../target
or../../target
in a workspace environment or even in a totally different folder if the crate is used as a library from some other cargo project. Assrc
/bytes
are required to be string symbols one cannot specify them toconcat!(env!("OUT_DIR"), "path.spv")
, so with this PR I introduce theroot_path_env
property to the shader! macro.For testing purposes I implemented this into my rust-gpu integration example project
in the branchnow in master:root_path_env_pr
/~https://github.com/Firestar99/rust-gpu-vulkano-example/
Update documentation to reflect any user-facing changes - in this repository.
Make sure that the changes are covered by unit-tests.
Run
cargo fmt
on the changes.Please put changelog entries in the description of this Pull Request
if knowledge of this change could be valuable to users. No need to put the
entries to the changelog directly, they will be transferred to the changelog
file by maintainers right after the Pull Request merge.
Please remove any items from the template below that are not applicable.
Describe in common words what is the purpose of this change, related
Github Issues, and highlight important implementation aspects.
Changelog: