shader! with the path argument should work.When using vulkano_shaders::shader! macro with the path variant, the file indicated by path is not watched by cargo. Changes to the shader file must then be coordinated with a change in the rust file the shader macro runs in (or with a clean build) for the changes to be reflected by the executable.
It appears to be possible to add an arbitrary file dependency to cargo in some cases as indicated by this code which appears to be intended for use in a cargo build script. I'm unsure if a similar technique could work for a macro, or if there's a different API the macro could use that would result in more consistent behavior.
If it isn't currently possible to make this work reliably the docs should at least include a warning of some sort, I think.
This obviously doesn't affect the src variant of shader!, which by nature changes the file when the shader code changes.
You can use this trick as a workaround:
#[allow(dead_code)] // Used to force recompilation of shader change
const X: &str = include_str!("../shaders/fragment.glsl");
#[allow(dead_code)] // Used to force recompilation of shader change
const X1: &str = include_str!("../shaders/vertex.glsl");
src won't work with include_str! because it doesn't count as a literal, so I'm not sure how the above works.
The include_str! invocations just force cargo to watch the file for changes (which I hadn鈥檛 thought of) the actual value isn鈥檛 used.
Presumably the compiler is smart enough to drop them from the final product but I haven鈥檛 played with it yet.
Dupe of/related to https://github.com/vulkano-rs/vulkano/issues/890
I realize this is an old issue, but I have noticed this happening and the shaders seem to recompile as long as I also save the main file, even if there were no changes.
Most helpful comment
The include_str! invocations just force cargo to watch the file for changes (which I hadn鈥檛 thought of) the actual value isn鈥檛 used.
Presumably the compiler is smart enough to drop them from the final product but I haven鈥檛 played with it yet.