gfx-hal-tutorial
gfx-hal-tutorial copied to clipboard
Triangle example crashes on gfx-hal head at logging level info/warn
This is weird -- I can run the example code at logging level debug
, but if I try to run it at info
/warn
, I crash.
I've attached the stack trace below:
$ RUST_BACKTRACE=1 RUST_LOG=warn cargo run --bin client --features metal
Finished dev [unoptimized + debuginfo] target(s) in 0.30s
Running `target/debug/client`
[2019-02-17T17:19:38Z WARN metal::device] Shader warnings: Compilation succeeded with:
program_source:8:17: warning: unused variable '_19'
constant float2 _19[3] = { float2(0.0, -0.5), float2(0.5), float2(-0.5, 0.5) };
^
program_source:9:17: warning: unused variable '_28'
constant float3 _28[3] = { float3(1.0, 0.0, 0.0), float3(0.0, 1.0, 0.0), float3(0.0, 0.0, 1.0) };
^
[2019-02-17T17:19:38Z WARN gfx_backend_metal::window] Swapchain drawables are changed, unable to wait for 0
[2019-02-17T17:19:38Z WARN gfx_backend_metal::window] Failed to get the drawable of frame 0
thread 'main' panicked at 'presentation failed!: ()', src/libcore/result.rs:1009:5
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:59
at src/libstd/panicking.rs:211
3: std::panicking::default_hook
at src/libstd/panicking.rs:227
4: <std::panicking::begin_panic::PanicPayload<A> as core::panic::BoxMeUp>::get
at src/libstd/panicking.rs:491
5: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:398
6: std::panicking::try::do_call
at src/libstd/panicking.rs:325
7: core::char::methods::<impl char>::escape_debug
at src/libcore/panicking.rs:95
8: <alloc::vec::SetLenOnDrop<'a> as core::ops::drop::Drop>::drop
at /rustc/9fda7c2237db910e41d6a712e9a2139b352e558b/src/libcore/macros.rs:26
9: <alloc::vec::SetLenOnDrop<'a> as core::ops::drop::Drop>::drop
at /rustc/9fda7c2237db910e41d6a712e9a2139b352e558b/src/libcore/result.rs:835
10: rust_tower_defense::graphics::HelloTriangleApplication::draw_frame
at src/graphics.rs:691
11: rust_tower_defense::graphics::HelloTriangleApplication::main_loop::{{closure}}
at src/graphics.rs:745
12: winit::window::MonitorId::get_dimensions
at /Users/chrisczub/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.18.1/src/platform/macos/events_loop.rs:233
13: winit::platform::platform::events_loop::Modifiers::new
at /Users/chrisczub/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.18.1/src/platform/macos/events_loop.rs:149
14: winit::platform::platform::events_loop::Shared::new
at /Users/chrisczub/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.18.1/src/platform/macos/events_loop.rs:69
15: winit::window::MonitorId::get_dimensions
at /Users/chrisczub/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.18.1/src/platform/macos/events_loop.rs:243
16: alloc::str::<impl alloc::borrow::ToOwned for str>::to_owned
at /Users/chrisczub/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.18.1/src/lib.rs:288
17: rust_tower_defense::graphics::HelloTriangleApplication::main_loop
at src/graphics.rs:732
18: rust_tower_defense::graphics::HelloTriangleApplication::run
at src/graphics.rs:765
19: core::str::<impl str>::as_ptr
at src/graphics.rs:26
20: client::main
at src/bin/rtd.rs:16
21: std::rt::lang_start::{{closure}}
at /rustc/9fda7c2237db910e41d6a712e9a2139b352e558b/src/libstd/rt.rs:74
22: std::panicking::try::do_call
at src/libstd/rt.rs:59
at src/libstd/panicking.rs:310
23: panic_unwind::dwarf::eh::read_encoded_pointer
at src/libpanic_unwind/lib.rs:102
24: <std::panicking::begin_panic::PanicPayload<A> as core::panic::BoxMeUp>::get
at src/libstd/panicking.rs:289
at src/libstd/panic.rs:398
at src/libstd/rt.rs:58
25: std::rt::lang_start
at /rustc/9fda7c2237db910e41d6a712e9a2139b352e558b/src/libstd/rt.rs:74
26: client::main
[2019-02-17T17:19:38Z ERROR gfx_backend_metal::command] Command buffer not released properly!
[2019-02-17T17:19:38Z ERROR gfx_backend_metal::command] Command buffer not released properly!
I think it has something to do with the swapchain frame buffer and maybe a race condition in the sync objects.
I'm running against commit c16898e3
of gfx-rs
.
Thanks for reporting the issue! Most of the code is ported directly to Rust from vulkan-tutorial's C++ code, so it would be useful to check if the synchronization logic differs somehow.
https://github.com/Lokathor/learn-gfx-hal is another tutorial which might be useful to compare against.
(cc @bzm3r if you want to take a look)
I verified that Lokathor's code works. I think it's definitely something in the synchronization logic, but haven't given it too close a read.