Vulkano: assertion failed: chunk.num_gpu_accesses >= 1 when drawing large number of meshes

Created on 6 Jan 2018  路  6Comments  路  Source: vulkano-rs/vulkano

I'm drawing a scene with a moderatly large number of meshes (~500).
Each mesh has its own transformation matrix that i need to upload in a uniform.
To do this, I instanciate a new FixedSizedDescriptor for each mesh and attach a CpuBufferPool containing the matrix data as follows:

         let command_buffer = {
             let mut builder =
                 AutoCommandBufferBuilder::primary_one_time_submit(device.clone(), queue.family()).unwrap()
                 .begin_render_pass(framebuffers[idx].clone(), false, vec![[0., 0., 1., 1.].into()]).unwrap();

             let mut descriptor_sets_pool = FixedSizeDescriptorSetsPool::new(pipeline.clone(), 0);

             for mesh in &meshes {
                 let uniforms_data = vs::ty::Data {
                     transform: mesh.transform.into(),
                 };

                 let uniforms = uniforms_buffer.next(uniforms_data).unwrap();

                 let set = Arc::new(descriptor_sets_pool.next().add_buffer(uniforms).unwrap().build().unwrap());

                 builder = builder.draw_indexed(pipeline.clone(), dynamic_state.clone(),
                 mesh.vbuf.clone(), mesh.ibuf.clone(), set.clone(), ()).unwrap();
             }

             builder.end_render_pass().unwrap().build().unwrap()
         };

         let future = last_frame.join(acquire_future)
             .then_execute(queue.clone(), command_buffer).unwrap()
             .then_swapchain_present(queue.clone(), swapchain.clone(), idx)
             .then_signal_fence_and_flush().unwrap();

This code double panicks on my setup (Linux / Intel(R) HD Graphics 620 (Kaby Lake GT2)) if the number of meshes is greater than 400 (it works fine for lower values):

thread 'test::tests::run' panicked at 'assertion failed: chunk.num_gpu_accesses >= 1', /home/franck/.cargo/registry/src/github.com-1ecc6299db9ec823/vulkano-0.7.2/src/buffer/cpu_pool.rs:659:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.
thread 'test::tests::run' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/libcore/result.rs:906:4
stack backtrace:
   0:     0x555a2d5f5cfb - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::h568550e9c3581ddc
   1:     0x555a2d5e3bb4 - std::sys_common::backtrace::print::hd8ec6866e3bd8b96
   2:     0x555a2d5fa5c9 - std::panicking::default_hook::{{closure}}::h92bf5ffea3e5961d
   3:     0x555a2d5fa274 - std::panicking::default_hook::h77acee2dd9d286bf
   4:     0x555a2d5faa7b - std::panicking::rust_panic_with_hook::hf6217f2eaf058be5
   5:     0x555a2d5fa904 - std::panicking::begin_panic::h1d02da2b82a54ae9
   6:     0x555a2d5fa875 - std::panicking::begin_panic_fmt::ha745e93a6afd4c9d
   7:     0x555a2d5fa80a - rust_begin_unwind
   8:     0x555a2d63c790 - core::panicking::panic_fmt::h664ef1a8778c7464
   9:     0x555a2d205093 - core::result::unwrap_failed::hb831264b7884902f
                               at /build/rust/src/rustc-1.22.1-src/src/libcore/macros.rs:23
  10:     0x555a2d1fe2ab - <core::result::Result<T, E>>::unwrap::hd3a6fd6e3b6e560d
                               at /build/rust/src/rustc-1.22.1-src/src/libcore/result.rs:772
  11:     0x555a2d29ab9c - <vulkano::buffer::cpu_pool::CpuBufferPoolChunk<T, A> as vulkano::buffer::traits::BufferAccess>::unlock::h65718f8b38ad0a51
                               at /home/franck/.cargo/registry/src/github.com-1ecc6299db9ec823/vulkano-0.7.2/src/buffer/cpu_pool.rs:672
  12:     0x555a2d29aefc - <vulkano::buffer::cpu_pool::CpuBufferPoolSubbuffer<T, A> as vulkano::buffer::traits::BufferAccess>::unlock::h066c19ec908e3f4f
                               at /home/franck/.cargo/registry/src/github.com-1ecc6299db9ec823/vulkano-0.7.2/src/buffer/cpu_pool.rs:770
  13:     0x555a2d20cd81 - <vulkano::command_buffer::synced::base::SyncCommandBuffer<P>>::unlock::hbbe20fffaac49292
                               at /home/franck/.cargo/registry/src/github.com-1ecc6299db9ec823/vulkano-0.7.2/src/command_buffer/synced/base.rs:1197
  14:     0x555a2d31040c - <vulkano::command_buffer::auto::AutoCommandBuffer<P> as vulkano::command_buffer::traits::CommandBuffer>::unlock::hccf43612ea4c919f
                               at /home/franck/.cargo/registry/src/github.com-1ecc6299db9ec823/vulkano-0.7.2/src/command_buffer/auto.rs:1332
  15:     0x555a2d1f4f2c - <vulkano::command_buffer::traits::CommandBufferExecFuture<F, Cb> as vulkano::sync::future::GpuFuture>::signal_finished::ha84d4ae9845ad65c
                               at /home/franck/.cargo/registry/src/github.com-1ecc6299db9ec823/vulkano-0.7.2/src/command_buffer/traits.rs:266
  16:     0x555a2d1f09a8 - <vulkano::swapchain::swapchain::PresentFuture<P> as vulkano::sync::future::GpuFuture>::signal_finished::h34d6954818f01b3b
                               at /home/franck/.cargo/registry/src/github.com-1ecc6299db9ec823/vulkano-0.7.2/src/swapchain/swapchain.rs:1065
  17:     0x555a2d1f07a7 - <vulkano::sync::future::fence_signal::FenceSignalFuture<F> as core::ops::drop::Drop>::drop::h620d0a00950dbfda
                               at /home/franck/.cargo/registry/src/github.com-1ecc6299db9ec823/vulkano-0.7.2/src/sync/future/fence_signal.rs:439
  18:     0x555a2d23ae64 - core::ptr::drop_in_place::hbc6f042bbfd9011d
                               at /build/rust/src/rustc-1.22.1-src/src/libcore/ptr.rs:59
  19:     0x555a2d231fa6 - core::ptr::drop_in_place::h2d73722a81190ff8
                               at /build/rust/src/rustc-1.22.1-src/src/libcore/ptr.rs:59
  20:     0x555a2d2390b4 - core::ptr::drop_in_place::h9e689a09ab63e8d9
                               at /build/rust/src/rustc-1.22.1-src/src/libcore/ptr.rs:59
  21:     0x555a2d3297ba - vulkano::command_buffer::traits::CommandBuffer::execute_after::h90fa8af39973cf22
                               at /home/franck/.cargo/registry/src/github.com-1ecc6299db9ec823/vulkano-0.7.2/src/command_buffer/traits.rs:137
  22:     0x555a2d32b037 - vulkano::sync::future::GpuFuture::then_execute::h08b4e2c3bda4567c
                               at /home/franck/.cargo/registry/src/github.com-1ecc6299db9ec823/vulkano-0.7.2/src/sync/future/mod.rs:158
  23:     0x555a2d332af3 - test_render::test::main::h34fb08f0fa4232e8
                               at src/test.rs:251
  24:     0x555a2d22f318 - test_render::test::tests::run::h805083d89b41f4f0
                               at src/test.rs:272
  25:     0x555a2d4f16d1 - <F as test::FnBox<T>>::call_box::h86ada89b85c2e3dc
  26:     0x555a2d4ffc67 - std::panicking::try::do_call::heeed6ba046a7fd0e
  27:     0x555a2d600767 - __rust_maybe_catch_panic
  28:     0x555a2d4ffbba - std::panicking::try::hca400f7f8efb03fe
  29:     0x555a2d5061aa - std::sys_common::backtrace::__rust_begin_short_backtrace::h8ca7496d05f742c7
  30:     0x555a2d5056c2 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h6fecce067f94cb9d
  31:     0x555a2d4ffc42 - std::panicking::try::do_call::h497a57d742c488d0
  32:     0x555a2d600767 - __rust_maybe_catch_panic
  33:     0x555a2d4ffb3b - std::panicking::try::h18d0fb22b272b72f
  34:     0x555a2d50a652 - <F as alloc::boxed::FnBox<A>>::call_box::h4867ea053e4e5548
  35:     0x555a2d5e6ee2 - std::sys::imp::thread::Thread::new::thread_start::h346554e78296580f
  36:     0x7f0b5b598089 - start_thread
  37:     0x7f0b5b0b842e - __clone
  38:                0x0 - <unknown>
thread panicked while panicking. aborting.
error: An unknown error occurred

Am I hitting a hardware limit here or am I doing something wrong ?

Thanks,

hard workable bug

All 6 comments

I have encountered the same panick drawing simple 2D Textured Quads with unique uniform variables, although error occurs after trying to drawing ~100 quads or more.

I don't seem to be reaching anywhere near the limits of my gpu (Linux - Nvidia GTX 950m), unless there is some descriptorset or uniform variable limit i'm unaware of.

The main difference from your example is that im using a PersistentDescriptorSet instead of a FixedSizedDescriptor.

The closest current active issue that I have found that could be relevant is issue #758, as it reports the same error message

I must note though, on my program it runs correctly for ~1 second until it recreates the swap chain from some automatic vulkan resize call then produces the panick.

The furthest i have tracked the error is that it occurs when the .then_signal_fence_and_flush() function is called.

Hope something here is of help. (Would like to solve this issue as well, is quite frustrating)

I noticed that It does not occur if I compile and run my code as release simply with
Cargo run --release

Which if it is the case for others with same situation, it could suggest that there could be an issue with BufferAccess/BufferPoolChunk(or the drivers not playing well) when not compiled with full optimisations by the compiler.

@franckv Does compiling and running it as release solve the issue for you as well?

Yes, I confirm that the issue does not occurs when running the code in release mode.
I managed to issue up to 50k draw calls per frame without a crash.

The reason why it works in release is because this assertion is a debug_assert!.
The fact that it works doesn't mean that what happens is correct however.

Could anyone who has encountered this issue please test on the latest version in git master.

Yes, it looks like it is working fine now. Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

norru picture norru  路  11Comments

SiebenCorgie picture SiebenCorgie  路  3Comments

CleanCut picture CleanCut  路  6Comments

tomaka picture tomaka  路  7Comments

the10thWiz picture the10thWiz  路  4Comments