Skip to content

Unable to load texture array file in ktx2 format #4495

@FishHawk

Description

@FishHawk

Bevy version

0.7.0

Operating system & version

Manjaro

What you did

  • Generate a texture array file in ktx2 format with basisu -ktx2 -uastc -tex_array a.png b.png.
  • Load it with asset_server.load("c.ktx2").

What you expected to happen

Should be loaded successfully.

What actually happened

Runs with an error. Error message:

thread 'main' panicked at 'range end index 1048576 out of range for slice of length 524288', library/core/src/slice/index.rs:73:5
stack backtrace:
   0:     0x7f5da6c9e22d - std::backtrace_rs::backtrace::libunwind::trace::h35daaff92d098ed0
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f5da6c9e22d - std::backtrace_rs::backtrace::trace_unsynchronized::h2a49b328879f3c62
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f5da6c9e22d - std::sys_common::backtrace::_print_fmt::hbf865a25210831d9
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f5da6c9e22d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h320151e111e06ced
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f5da6cf808c - core::fmt::write::h7413aa28bee1cfbc
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/fmt/mod.rs:1194:17
   5:     0x7f5da6c8f781 - std::io::Write::write_fmt::h0e72b6ed17789afa
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/io/mod.rs:1655:15
   6:     0x7f5da6ca1315 - std::sys_common::backtrace::_print::h983440bc61c2f2c3
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f5da6ca1315 - std::sys_common::backtrace::print::ha1f03110bb78cc22
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f5da6ca1315 - std::panicking::default_hook::{{closure}}::heffa35a5a8b52a05
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/panicking.rs:295:22
   9:     0x7f5da6ca0fc9 - std::panicking::default_hook::h7c0cbeac47c399c7
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/panicking.rs:314:9
  10:     0x7f5da6ca19b2 - std::panicking::rust_panic_with_hook::hffbd90fcd9b72f27
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/panicking.rs:698:17
  11:     0x7f5da6ca1897 - std::panicking::begin_panic_handler::{{closure}}::h0f77f2c8e7085cd5
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/panicking.rs:588:13
  12:     0x7f5da6c9e6e4 - std::sys_common::backtrace::__rust_end_short_backtrace::h28c89a19b94c2378
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/sys_common/backtrace.rs:138:18
  13:     0x7f5da6ca15c9 - rust_begin_unwind
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/panicking.rs:584:5
  14:     0x7f5da6c65713 - core::panicking::panic_fmt::h3125391edcfdcf8d
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/panicking.rs:143:14
  15:     0x7f5da6cfa7e6 - core::slice::index::slice_end_index_len_fail_rt::h493a6b5e8024446f
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/slice/index.rs:73:5
  16:     0x7f5da6cedca7 - core::ops::function::FnOnce::call_once::hbaf2e71c84be90d3
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/ops/function.rs:227:5
  17:     0x7f5da6cf3bb6 - core::intrinsics::const_eval_select::h9dc0f307c31ffada
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/intrinsics.rs:2361:5
  18:     0x7f5da6c65826 - core::slice::index::slice_end_index_len_fail::hc8c70d9750178b9f
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/slice/index.rs:67:9
  19:     0x7f5da8c155cd - <core::ops::range::Range<usize> as core::slice::index::SliceIndex<[T]>>::index::h1c16295a0b7953d4
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/slice/index.rs:303:13
  20:     0x7f5da8c155cd - core::slice::index::<impl core::ops::index::Index<I> for [T]>::index::h40ed29ef6e1b0401
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/slice/index.rs:18:9
  21:     0x7f5da8c155cd - <wgpu::Device as wgpu::util::device::DeviceExt>::create_texture_with_data::hc10f537afcaf4a20
                               at /home/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.12.0/src/util/device.rs:128:22
  22:     0x7f5da87e5903 - bevy_render::renderer::render_device::RenderDevice::create_texture_with_data::haf0edabb37881ed4
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_render/src/renderer/render_device.rs:136:28
  23:     0x7f5da87e5903 - <bevy_render::texture::image::Image as bevy_render::render_asset::RenderAsset>::prepare_asset::hec184748db387b6f
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_render/src/texture/image.rs:562:13
  24:     0x7f5da87f41ad - bevy_render::render_asset::prepare_assets::h20c1da272b880407
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_render/src/render_asset.rs:204:15
  25:     0x7f5da87f41ad - core::ops::function::FnMut::call_mut::hca5c269926e38184
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/ops/function.rs:150:5
  26:     0x7f5da87f41ad - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::h37f7aadf5974c218
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/ops/function.rs:269:13
  27:     0x7f5da87ee823 - <Func as bevy_ecs::system::function_system::SystemParamFunction<(),Out,(F0,F1,F2,F3),()>>::run::call_inner::hda28a3fd465d2d5b
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_ecs/src/system/function_system.rs:525:21
  28:     0x7f5da87ee823 - <Func as bevy_ecs::system::function_system::SystemParamFunction<(),Out,(F0,F1,F2,F3),()>>::run::h6f12cf377d89591d
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_ecs/src/system/function_system.rs:528:17
  29:     0x7f5da87ee823 - <bevy_ecs::system::function_system::FunctionSystem<In,Out,Param,Marker,F> as bevy_ecs::system::system::System>::run_unsafe::h88dfd0228f2d6253
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_ecs/src/system/function_system.rs:399:19
  30:     0x7f5da93fa32c - bevy_ecs::schedule::executor_parallel::ParallelExecutor::prepare_systems::{{closure}}::hb1e0b85206b2b3af
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_ecs/src/schedule/executor_parallel.rs:196:30
  31:     0x7f5da93fa32c - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::ha573c00f34cc3604
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/future/mod.rs:91:19
  32:     0x7f5da93f9197 - async_executor::Executor::spawn::{{closure}}::h648cdeeb5c07e365
                               at /home/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.1/src/lib.rs:144:19
  33:     0x7f5da93f9197 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h1461d3b0911659ba
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/future/mod.rs:91:19
  34:     0x7f5da93d3813 - async_task::raw::RawTask<F,T,S>::run::h1ad8bb31029f65b0
                               at /home/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.2.0/src/raw.rs:489:20
  35:     0x7f5da940a502 - async_executor::Executor::try_tick::h7cee8d4246ccd0d8
                               at /home/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.1/src/lib.rs:181:17
  36:     0x7f5da93b3f2f - bevy_tasks::task_pool::TaskPool::scope::{{closure}}::h8e81370706d56001
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_tasks/src/task_pool.rs:233:21
  37:     0x7f5da93b3f2f - std::thread::local::LocalKey<T>::try_with::ha8218cc8c428d9db
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/thread/local.rs:442:16
  38:     0x7f5da93b3f2f - std::thread::local::LocalKey<T>::with::h85904f7b5dba493c
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/thread/local.rs:418:9
  39:     0x7f5da93b3f2f - bevy_tasks::task_pool::TaskPool::scope::hfe5ab490cd8aa28c
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_tasks/src/task_pool.rs:180:9
  40:     0x7f5da93caa77 - <bevy_ecs::schedule::executor_parallel::ParallelExecutor as bevy_ecs::schedule::executor::ParallelSystemExecutor>::run_systems::hbcc5d740ffd92969
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_ecs/src/schedule/executor_parallel.rs:129:9
  41:     0x7f5da93eafce - <bevy_ecs::schedule::stage::SystemStage as bevy_ecs::schedule::stage::Stage>::run::hc803f9c28caebcf9
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_ecs/src/schedule/stage.rs:852:17
  42:     0x7f5da88592d9 - <bevy_render::RenderPlugin as bevy_app::plugin::Plugin>::build::{{closure}}::h58305ed0962b3ecc
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_render/src/lib.rs:223:21
  43:     0x7f5da9394beb - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hc2ed313b19b549c2
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/alloc/src/boxed.rs:1875:9
  44:     0x7f5da9394beb - bevy_app::app::App::update::hd97233e3642e4d9a
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_app/src/app.rs:116:13
  45:     0x7f5da7e48d22 - bevy_winit::winit_runner_with::{{closure}}::ha084ea67d2dfbd92
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_winit/src/lib.rs:563:21
  46:     0x7f5da7e65a4a - winit::platform_impl::platform::sticky_exit_callback::h02eb27666407f278
                               at /home/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/linux/mod.rs:753:5
  47:     0x7f5da7e65a4a - winit::platform_impl::platform::x11::EventLoop<T>::run_return::hee3f2a971f3ebf6d
                               at /home/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/linux/x11/mod.rs:293:17
  48:     0x7f5da7e662a9 - winit::platform_impl::platform::x11::EventLoop<T>::run::h85db1368f53af0af
                               at /home/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/linux/x11/mod.rs:392:9
  49:     0x7f5da7e475ec - winit::platform_impl::platform::EventLoop<T>::run::h7508ed602940ab86
                               at /home/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/linux/mod.rs:669:56
  50:     0x7f5da7e7df2c - winit::event_loop::EventLoop<T>::run::hced646a0f709b419
                               at /home/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/event_loop.rs:154:9
  51:     0x7f5da7e819cc - bevy_winit::run::h3acda91c35d44236
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_winit/src/lib.rs:180:5
  52:     0x7f5da7e8251d - bevy_winit::winit_runner_with::hea76666e4a434fb4
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_winit/src/lib.rs:604:9
  53:     0x7f5da7e62a24 - bevy_winit::winit_runner::h7f1605361358c9d8
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_winit/src/lib.rs:220:5
  54:     0x7f5da7e62a24 - core::ops::function::Fn::call::h3910591a8bdab206
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/ops/function.rs:70:5
  55:     0x7f5da9394ded - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h6ca520cec3b7d023
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/alloc/src/boxed.rs:1875:9
  56:     0x7f5da9394ded - bevy_app::app::App::run::hf40b1a61b61ba258
                               at /home/xx/.cargo/git/checkouts/bevy-f7ffde730c324c74/83c6ffb/crates/bevy_app/src/app.rs:130:9
  57:     0x557d44808785 - deep::main::h7b88112f51499135
                               at /home/xx/Projects/deep/src/main.rs:13:5
  58:     0x557d448275c3 - core::ops::function::FnOnce::call_once::h8fdcc299ac68ce09
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/ops/function.rs:227:5
  59:     0x557d448275c3 - std::sys_common::backtrace::__rust_begin_short_backtrace::hb8a24fd5cb209aca
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/sys_common/backtrace.rs:122:18
  60:     0x557d4481e9e9 - std::rt::lang_start::{{closure}}::hfe6efb8e3e3c1e3f
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/rt.rs:145:18
  61:     0x7f5da6c7ffbe - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h5c071915d75cd829
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/core/src/ops/function.rs:259:13
  62:     0x7f5da6c7ffbe - std::panicking::try::do_call::h08843c3ac1a8e5a3
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/panicking.rs:492:40
  63:     0x7f5da6c7ffbe - std::panicking::try::h4bd4483e759d3fb2
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/panicking.rs:456:19
  64:     0x7f5da6c7ffbe - std::panic::catch_unwind::h95c3030cb73fa2c8
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/panic.rs:137:14
  65:     0x7f5da6c7ffbe - std::rt::lang_start_internal::{{closure}}::hb916b8f5e47e7d77
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/rt.rs:128:48
  66:     0x7f5da6c7ffbe - std::panicking::try::do_call::h2626835d15a1ba22
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/panicking.rs:492:40
  67:     0x7f5da6c7ffbe - std::panicking::try::h553a474c5bf334b2
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/panicking.rs:456:19
  68:     0x7f5da6c7ffbe - std::panic::catch_unwind::h349dcbfb0acf7e28
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/panic.rs:137:14
  69:     0x7f5da6c7ffbe - std::rt::lang_start_internal::hc61e09f23af3880d
                               at /rustc/6af09d2505f38e4f1df291df56d497fb2ad935ed/library/std/src/rt.rs:128:20
  70:     0x557d44808ed8 - main
  71:     0x7f5da6a23310 - __libc_start_call_main
  72:     0x7f5da6a233c1 - __libc_start_main@GLIBC_2.2.5
  73:     0x557d44806075 - _start
  74:                0x0 - <unknown>

Additional information

When using basisu -ktx2 -uastc -tex_array a.png to generate a texture array which contains only 1 image, it can be loaded successfully. Also, the same images can be loaded using basis.

The ktx2 file used:
stack.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AssetsLoad files from disk to use for things like images, models, and soundsA-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions