-
Notifications
You must be signed in to change notification settings - Fork 251
Compile shaders at runtime #423
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
Compile shaders at runtime #423
Conversation
Moves shader building from a build.rs to runtime. Recompile shaders with F5 while the app is running. Fixes validation errors on minimize.
Android and wasm can't run rustc so they work the same as before.
I think this is a good direction to head in, but we should discuss before accepting this change if removing a significant test for our |
Duplicate the compilation logic from spirv-builder to circumvent cargo issues.
With rust-lang/cargo#9216 fixed, the cargo issues you're hitting may have been resolved! (still need to wait for a nightly with the fix though) |
Thanks for following up on that 😃 looks like it should be on nightly soon |
The issue has been resolved. |
Hmm, having spirv-builder be referenced twice on non-android/wasm32 targets (once as normal dep, once as build dep) causes a warning when using
It'd be really nice to not have to build spirv-builder as a build-dep on runtime-compiled platforms, if that's possible |
Setting
LNK1104 is most likely being caused by multiple compilation instances trying to access the same file. There's a related cargo issue about this issue already. The same warning also occurs without the resolver flag, but for Regarding changing it to not import it twice, I don't think it's possible in the current form of SpirvBuilder. |
Looks like a way around being unable to cfg dependencies in build.rs is the approach this PR used - platform-specific specifying of a feature in a helper crate's build.rs cart/glsl-to-spirv#7 |
This PR closes #231 though it does things a little differently.
Fixes validation errors on minimize.(see Fix wgpu-runner validation errors on minimize #424, same fix without the baggage)Currently, this won't work for Android or wasm targets. The internal logic is all in place, but it won't build.
The issue is entirely in the
cargo.toml
, the relevant parts:This should work but fails for the
aarch64-linux-android
target:Commenting out the normal
spirv-builder
dependency - the one that should be ignored for Android - fixes the issue, but then PC targets don't work.This works for both PC and Android:
However, this isn't an acceptable solution because it forces everyone to have
spirv-tools
to run the examples (or devs/CI to compile them every time, which takes a long time). Uncommenting the features causes the same issue as before, even though the optional feature isn't enabled.Renaming one of them also doesn't work, cargo does not allow the same dependency to have different names, even if one is a build dependency and one isn't. I don't know why, but c'est la vie.
The only workable solution I see here is reimplementing the
SpirvBuilder
logic in thecompile_shader
function, however this was flagged as an issue when I did that in the ash runner.