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

4k texture model loading is way to slow. #1947

Closed
HyeokSuLee opened this issue Apr 17, 2021 · 5 comments
Closed

4k texture model loading is way to slow. #1947

HyeokSuLee opened this issue Apr 17, 2021 · 5 comments
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Performance A change motivated by improving speed, memory usage or compile times

Comments

@HyeokSuLee
Copy link

It took over 1 minute as gltf extension.
Is there some solution for pre load?
Or command to load and check when loading is complete.

@alice-i-cecile alice-i-cecile added A-Assets Load files from disk to use for things like images, models, and sounds C-Performance A change motivated by improving speed, memory usage or compile times labels Apr 17, 2021
@alice-i-cecile
Copy link
Member

See #1307 for your last request :)

@DJMcNab
Copy link
Member

DJMcNab commented Apr 17, 2021

Have you tried running in release mode? The image crate is very slow in debug mode

You can also set up your project so that cargo builds your dependencies in release mode. I'm on mobile, so it's hard to check, but I think it's in Cargo.toml:

[profile.dev.package.*]
opt-level = 3

@HyeokSuLee
Copy link
Author

HyeokSuLee commented Apr 17, 2021

Have you tried running in release mode? The image crate is very slow in debug mode

You can also set up your project so that cargo builds your dependencies in release mode. I'm on mobile, so it's hard to check, but I think it's in Cargo.toml:

[profile.dev.package.*]
opt-level = 3

yeah, you are right. in release mode it is fast enough.

  1. Can you tell me more detail about build dependencies in release mode ?
    I've tried with below but it doesn't seem to work.
[dependencies]
bevy = "0.5.0"
[profile.dev.package.bevy]
opt-level = 3
  1. And after build, assets folder doesn't copy to target/debug(or release).
    I know it can be done by build scripts, but bevy examples look like not use build script.
    Is there a way to automatically copy assets to target folder?

@DJMcNab
Copy link
Member

DJMcNab commented Apr 17, 2021

Dependencies are built with whatever profile applies to them. In this case, you have asked exactly the bevy crate to be built in release mode, which will have no effect, because the bevy crate itself is only a wrapper crate. I personally use exactly the code snippet I advised you use (the one using using [profile.dev.package.*]) in my Cargo.toml. There is more documentation in the cargo book.

Bevy locates assets based on the cargo workspace root, environment environment variable with a fallback to the current executable location. This is implemented here:

pub fn get_root_path() -> PathBuf {
if let Ok(manifest_dir) = env::var("CARGO_MANIFEST_DIR") {
PathBuf::from(manifest_dir)
} else {
env::current_exe()
.map(|path| {
path.parent()
.map(|exe_parent_path| exe_parent_path.to_owned())
.unwrap()
})
.unwrap()
}
}

To use a bevy program in a different folder, you should set the CARGO_MANIFEST_DIR environment variable, or you can move the executable manually. There are plans for further integration with Distill, which might improve this situation. This work is tracked in #708

@alice-i-cecile
Copy link
Member

I'm going to close this for now, but feel free to ask for any more assistance that you need, either here, in the Discussions or on Discord @HyeokSuLee <3

Asset loading speed will continue to be improved, but I think the issue is resolved for now thanks to release mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Performance A change motivated by improving speed, memory usage or compile times
Projects
None yet
Development

No branches or pull requests

3 participants