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

Add an initial UI to Hypermine #391

Closed
wants to merge 10 commits into from
Closed

Conversation

patowen
Copy link
Collaborator

@patowen patowen commented May 5, 2024

This is currently a draft, as there are two issues:

  • Fixed: Since Hypermine has two subpasses (the second one for fog), to ensure the UI gets drawn on top of everything and is unaffected by fog, the UI needs to be in the second subpass or possibly a third one. Currently, Yakui doesn't seem to support rendering anywhere except the first subpass. (It creates a vk::GraphicsPipelineCreateInfo struct and keeps the subpass field in that struct as its default.)
  • Fixed: I get the following validation error on the second call to draw::draw (but strangely, no frames before or after):
    Validation Error: [ VUID-vkFreeMemory-memory-00677 ] | MessageID = 0x485c8ea2 | vkFreeMemory(): can't be called on VkDeviceMemory 0xeeeba00000000288[] that is currently in use by VkBuffer 0x8f6f470000000287[]. The Vulkan spec states: All submitted commands that refer to memory (via images or buffers) must have completed execution (https://vulkan.lunarg.com/doc/view/1.3.280.0/windows/1.3-extensions/vkspec.html#VUID-vkFreeMemory-memory-00677) id=VUID-vkFreeMemory-memory-00677 number=1214025378 queue_labels= cmd_labels= objects=. The error seems to trigger when I call transfers_finished. I haven't fully looked into the root cause yet, so it could just be a simple mistake on my part, as I've mainly been blindly following the yakui-vulkan example.

Note that long-term, I'm not sure whether we can keep putting fog in a separate subpass, since that likely wouldn't work properly if there are any transparent objects in the scene.

(Fixed) If I ignore the fog and just render the UI after everything else in the first subpass, the letters are replaced with their bounding boxes filled in with the sky color. If I turn the fog off, everything works.

I would like to keep this PR as a draft until we have the following (which I may file as a separate PR, closing this one):

  • No Vulkan validation errors
  • A central cursor
  • Some indicator (likely textual) of the block you have selected
  • A UI toggle for screenshot purposes
  • Good code quality

@Ralith
Copy link
Owner

Ralith commented May 5, 2024

to ensure the UI gets drawn on top of everything and is unaffected by fog, the UI needs to be in the second subpass or possibly a third one

The second should do, blending always happens as if draws were executed in order. However, if we write a depth of 1 for fragments occupied by UI, the first subpass might also do just fine.

Currently, Yakui doesn't seem to support rendering anywhere except the first subpass.

This would be a straightforward PR to yakui. Alternatively, we could migrate hypermine to dynamic rendering, which doesn't have subpasses, but that would take more work.

that likely wouldn't work properly if there are any transparent objects in the scene.

Transparency is a huge can of worms no matter what. I suggest we plan to avoid it entirely. Even if we do want glass, we can do just fine with opaque dust/dirt + additively-blended reflections, IMO.

The error seems to trigger when I call transfers_finished

Sounds like you're probably calling it too early. It probably only happens once because that's the only time yakui needs to do a transfer so far.

@patowen
Copy link
Collaborator Author

patowen commented May 5, 2024

The second should do, blending always happens as if draws were executed in order. However, if we write a depth of 1 for fragments occupied by UI, the first subpass might also do just fine.

I'll try the second one for now, then. Text especially benefits from anti-aliasing, and that could interact weirdly with fog, since that involves transparency. One issue with the second one is that it seems to use the alpha channel in an unusual way, with 0 being opaque and 1 being invisible in most places, which may confuse yakui.

(EDIT: It didn't confuse yakui as much as I thought it would. It seems like the second subpass is totally viable, as the text looks perfectly fine to me).

This would be a straightforward PR to yakui. Alternatively, we could migrate hypermine to dynamic rendering, which doesn't have subpasses, but that would take more work.

I'll go ahead with the PR, as it seems easy enough (as dynamic rendering seems beyond the scope of what to work on at the moment).

Transparency is a huge can of worms no matter what. I suggest we plan to avoid it entirely. Even if we do want glass, we can do just fine with opaque dust/dirt + additively-blended reflections, IMO.

This seems like something we could easily change our minds on at some point (to support water or stained glass, for example), but fog would be the least of our worries, so I agree with ignoring it entirely for now. Preparing for transparency seems like a cousin of premature optimization now that I think about it.

Sounds like you're probably calling it too early. It probably only happens once because that's the only time yakui needs to do a transfer so far.

I had copied it from the yakui_vulkan demo, which calls transfers_finished and transfer together before vkCmdBeginRenderPass and after vkBeginCommandBuffer Even pushing it as late as possible before vkCmdBeginRenderPass does not fix the validation error, and pushing it any later starts telling me that I'm doing things I'm not supposed to do inside a render pass.

@patowen
Copy link
Collaborator Author

patowen commented May 5, 2024

Created SecondHalfGames/yakui#154 to hopefully address the subpass issue. I've tested it locally, and it fixes that issue in Hypermine.

@patowen
Copy link
Collaborator Author

patowen commented May 5, 2024

I was able to get rid of the validation error by calling yakui_vulkan.transfers_submitted(); twice at the beginning instead of once. The documentation says

To support N concurrent frames in flight, call this N times before creating any textures.

This suggests that Hypermine has up to 2 concurrent frames in flight, which makes sense in retrospect, although I don't remember how to confirm that.

@Ralith
Copy link
Owner

Ralith commented May 5, 2024

This suggests that Hypermine has up to 2 concurrent frames in flight, which makes sense in retrospect, although I don't remember how to confirm that.

/// Maximum number of simultaneous frames in flight
const PIPELINE_DEPTH: u32 = 2;

@patowen
Copy link
Collaborator Author

patowen commented May 5, 2024

Oh, right. Thanks!

@patowen
Copy link
Collaborator Author

patowen commented May 5, 2024

Thanks for the help! Things seem to be going a lot more smoothly now, so I'll go ahead and close this draft in favor of a fresh PR when I have something ready.

@patowen patowen closed this May 5, 2024
@patowen
Copy link
Collaborator Author

patowen commented May 5, 2024

When I change which text displays on the screen (by switching material), sometimes, I get the following stack trace, and the game crashes (I can reliably get this to happen if I'm generating terrain at the same time):

thread 'main' panicked at client\src\graphics\draw.rs:560:14: 
called `Result::unwrap()` on an `Err` value: ERROR_DEVICE_LOST
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:645
   1: core::panicking::panic_fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\panicking.rs:72
   2: core::result::unwrap_failed
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\result.rs:1654
   3: enum2$<core::result::Result<tuple$<>,ash::vk::enums::Result> >::unwrap
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\result.rs:1077
   4: client::graphics::draw::Draw::draw
             at .\draw.rs:547
   5: client::graphics::window::Window::draw
             at .\window.rs:359
   6: winit::platform_impl::platform::event_loop::impl$3::run_on_demand::closure$0<tuple$<>,client::graphics::window::impl$1::run::closure_env$0>
             at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop.rs:236
   7: alloc::boxed::impl$48::call_mut
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\alloc\src\boxed.rs:2027
   8: winit::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure$0
             at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop\runner.rs:250
   9: core::panic::unwind_safe::impl$25::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\panic\unwind_safe.rs:272
  10: std::panicking::try::do_call
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\panicking.rs:552
  11: std::panicking::try<tuple$<>,core::panic::unwind_safe::AssertUnwindSafe<winit::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<tuple$<> > > >
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\panicking.rs:516
  12: std::panic::catch_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\panic.rs:146
  13: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<tuple$<> >::catch_unwind<tuple$<>,tuple$<>,winit::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<tuple$<> > >
             at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop\runner.rs:183
  14: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<tuple$<> >::call_event_handler
             at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop\runner.rs:246
  15: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<tuple$<> >::send_event<tuple$<> >
             at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop\runner.rs:224
  16: winit::platform_impl::platform::event_loop::public_window_callback_inner::closure$4<tuple$<> >
             at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop.rs:1144
  17: core::ops::function::FnOnce::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\ops\function.rs:250
  18: core::panic::unwind_safe::impl$25::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\panic\unwind_safe.rs:272
  19: std::panicking::try::do_call
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\panicking.rs:552
  20: std::panicking::try<tuple$<>,core::panic::unwind_safe::AssertUnwindSafe<winit::platform_impl::platform::event_loop::public_window_callback_inner::closure_env$4<tuple$<> > > >
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\panicking.rs:516
  21: std::panic::catch_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\panic.rs:146
  22: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<tuple$<> >::catch_unwind<tuple$<>,tuple$<>,winit::platform_impl::platform::event_loop::public_window_callback_inner::closure_env$4<tuple$<> > >
             at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop\runner.rs:183
  23: winit::platform_impl::platform::event_loop::public_window_callback_inner<tuple$<> >
             at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop.rs:2285
  24: winit::platform_impl::platform::event_loop::public_window_callback<tuple$<> >
             at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop.rs:983
  25: CallWindowProcW
  26: CallWindowProcW
  27: glPushClientAttrib
  28: CallWindowProcW
  29: DispatchMessageW
  30: SendMessageTimeoutW
  31: KiUserCallbackDispatcher
  32: NtUserDispatchMessage
  33: DispatchMessageW
  34: winit::platform_impl::platform::event_loop::EventLoop<tuple$<> >::wait_and_dispatch_message<tuple$<> >
             at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop.rs:406
  35: winit::platform_impl::platform::event_loop::EventLoop<tuple$<> >::run_on_demand<tuple$<>,client::graphics::window::impl$1::run::closure_env$0>
             at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop.rs:241
  36: winit::platform_impl::platform::event_loop::EventLoop<tuple$<> >::run
             at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop.rs:218
  37: winit::event_loop::EventLoop<tuple$<> >::run
             at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\event_loop.rs:249
  38: client::graphics::window::Window::run
             at .\window.rs:133
  39: client::main
             at E:\Gamma\git\rust\hypermine\client\src\main.rs:84
  40: core::ops::function::FnOnce::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\ops\function.rs:250
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
2024-05-05T19:41:42.132073Z ERROR Validation Error: [ VUID-vkDestroySemaphore-semaphore-05149 ] | MessageID = 0x93e24db1 | vkDestroySemaphore(): semaphore can't be called on VkSemaphore 0xa808d50000000033[image acquired] that is currently in use by VkSemaphore 0xa808d50000000033[image acquired]. The Vulkan spec states: All submitted batches that refer to semaphore must have completed execution (https://vulkan.lunarg.com/doc/view/1.3.280.0/windows/1.3-extensions/vkspec.html#VUID-vkDestroySemaphore-semaphore-05149) id=VUID-vkDestroySemaphore-semaphore-05149 number=-1813885519 queue_labels= cmd_labels= objects=
2024-05-05T19:41:42.133178Z ERROR Validation Error: [ VUID-vkDestroyFence-fence-01120 ] Object 0: handle = 0x2b424a0000000034, name = render complete, type = VK_OBJECT_TYPE_FENCE; | MessageID = 0x5d296248 | vkDestroyFence(): fence (VkFence 0x2b424a0000000034[render complete]) is in use. 
The Vulkan spec states: All queue submission commands that refer to fence must have completed execution (https://vulkan.lunarg.com/doc/view/1.3.280.0/windows/1.3-extensions/vkspec.html#VUID-vkDestroyFence-fence-01120) id=VUID-vkDestroyFence-fence-01120 number=1562993224 queue_labels= cmd_labels= objects=FENCE 2b424a0000000034 VUID-vkDestroyFence-fence-01120
2024-05-05T19:41:42.133700Z ERROR Validation Error: [ VUID-vkDestroyBuffer-buffer-00922 ] | MessageID = 0xe4549c11 | vkDestroyBuffer():  can't be called on VkBuffer 0x4b7df1000000002f[uniforms] that is currently in use by VkCommandBuffer 0x20d8972c110[frame]. The Vulkan spec states: All 
submitted commands that refer to buffer, either directly or via a VkBufferView, must have completed execution (https://vulkan.lunarg.com/doc/view/1.3.280.0/windows/1.3-extensions/vkspec.html#VUID-vkDestroyBuffer-buffer-00922) id=VUID-vkDestroyBuffer-buffer-00922 number=-464217071 queue_labels= cmd_labels= objects=
2024-05-05T19:41:42.134542Z ERROR Validation Error: [ VUID-vkDestroyBuffer-buffer-00922 ] | MessageID = 0xe4549c11 | vkDestroyBuffer():  can't be called on VkBuffer 0x996422000000026b[voxel transforms] that is currently in use by VkCommandBuffer 0x20d8972c110[frame]. The Vulkan spec states: All submitted commands that refer to buffer, either directly or via a VkBufferView, must have completed execution (https://vulkan.lunarg.com/doc/view/1.3.280.0/windows/1.3-extensions/vkspec.html#VUID-vkDestroyBuffer-buffer-00922) id=VUID-vkDestroyBuffer-buffer-00922 number=-464217071 queue_labels= cmd_labels= objects=
thread 'main' panicked at C:\Users\Patrick\.cargo\git\checkouts\yakui-c018569f7fc10152\cbac6c0\crates\yakui-vulkan\src\lib.rs:553:35:
called `Result::unwrap()` on an `Err` value: ERROR_DEVICE_LOST
stack backtrace:
   0:     0x7ff7f51beb1a - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:99
   1:     0x7ff7f51beb1a - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff7f51beb1a - std::sys_common::backtrace::_print_fmt
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\sys_common\backtrace.rs:68
   3:     0x7ff7f51beb1a - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\sys_common\backtrace.rs:44
   4:     0x7ff7f51da11b - core::fmt::rt::Argument::fmt
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\fmt\rt.rs:142
   5:     0x7ff7f51da11b - core::fmt::write
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\fmt\mod.rs:1153
   6:     0x7ff7f51bae91 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\io\mod.rs:1843
   7:     0x7ff7f51be906 - std::sys_common::backtrace::print
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\sys_common\backtrace.rs:34
   8:     0x7ff7f51c0aaf - std::panicking::default_hook::closure$1
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:272
   9:     0x7ff7f51c0747 - std::panicking::default_hook
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:292
  10:     0x7ff7f51c0fed - std::panicking::rust_panic_with_hook
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:779
  11:     0x7ff7f51c0ea9 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:657
  12:     0x7ff7f51bf1a9 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\sys_common\backtrace.rs:171
  13:     0x7ff7f51c0b66 - std::panicking::begin_panic_handler
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:645
  14:     0x7ff7f5284e67 - core::panicking::panic_fmt
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\panicking.rs:72
  15:     0x7ff7f5285463 - core::result::unwrap_failed
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\result.rs:1654
  16:     0x7ff7f4e78bbc - enum2$<core::result::Result<tuple$<>,ash::vk::enums::Result> >::unwrap
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\result.rs:1077
  17:     0x7ff7f4e78bbc - yakui_vulkan::YakuiVulkan::cleanup
                               at C:\Users\Patrick\.cargo\git\checkouts\yakui-c018569f7fc10152\cbac6c0\crates\yakui-vulkan\src\lib.rs:553
  18:     0x7ff7f4d18617 - client::graphics::draw::impl$1::drop
                               at E:\Gamma\git\rust\hypermine\client\src\graphics\draw.rs:595
  19:     0x7ff7f4d0a3a2 - core::ptr::drop_in_place<client::graphics::draw::Draw>
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\ptr\mod.rs:515
  20:     0x7ff7f4d0bcad - core::ptr::drop_in_place
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\ptr\mod.rs:515
  21:     0x7ff7f4d0bcad - client::graphics::window::impl$2::drop
                               at E:\Gamma\git\rust\hypermine\client\src\graphics\window.rs:399
  22:     0x7ff7f4d0bcad - core::ptr::drop_in_place<client::graphics::window::Window>
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\ptr\mod.rs:515
  23:     0x7ff7f4bea8f6 - core::ptr::drop_in_place<alloc::boxed::Box<dyn$<quinn_proto::cid_generator::ConnectionIdGenerator>,alloc::alloc::Global> >
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\ptr\mod.rs:515
  24:     0x7ff7f4db9bdf - winit::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure$0
                               at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop\runner.rs:253
  25:     0x7ff7f4db9bdf - core::panic::unwind_safe::impl$25::call_once
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\panic\unwind_safe.rs:272
  26:     0x7ff7f4db9bdf - std::panicking::try::do_call
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\panicking.rs:552
  27:     0x7ff7f4db9bdf - std::panicking::try<tuple$<>,core::panic::unwind_safe::AssertUnwindSafe<winit::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<tuple$<> > > >
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\panicking.rs:516
  28:     0x7ffbcfe91030 - <unknown>
  29:     0x7ffbcfe94f5e - is_exception_typeof
  30:     0x7ffbcfe94138 - is_exception_typeof
  31:     0x7ffbcfe9fe41 - _CxxFrameHandler3
  32:     0x7ffc01c3242f - _chkstk
  33:     0x7ffc01bc0939 - RtlUnwindEx
  34:     0x7ffbcfe9f9ce - _C_specific_handler
  35:     0x7ffbcfe92e25 - is_exception_typeof
  36:     0x7ffbcfe93244 - is_exception_typeof
  37:     0x7ffbcfe94268 - is_exception_typeof
  38:     0x7ffbcfe9fe41 - _CxxFrameHandler3
  39:     0x7ffc01c323af - _chkstk
  40:     0x7ffc01be14b4 - RtlRaiseException
  41:     0x7ffc01c30ebe - KiUserExceptionDispatcher
  42:     0x7ffbff8bab89 - RaiseException
  43:     0x7ffbcfe96720 - CxxThrowException
  44:     0x7ff7f51c7eee - panic_unwind::real_imp::panic
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\panic_unwind\src\seh.rs:323
  45:     0x7ff7f51c7eee - panic_unwind::__rust_start_panic
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\panic_unwind\src\lib.rs:106
  46:     0x7ff7f51c1379 - std::panicking::rust_panic
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:831
  47:     0x7ff7f51c1076 - std::panicking::rust_panic_with_hook
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:801
  48:     0x7ff7f51c0ea9 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:657
  49:     0x7ff7f51bf1a9 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\sys_common\backtrace.rs:171
  50:     0x7ff7f51c0b66 - std::panicking::begin_panic_handler
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:645
  51:     0x7ff7f5284e67 - core::panicking::panic_fmt
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\panicking.rs:72
  52:     0x7ff7f5285463 - core::result::unwrap_failed
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\result.rs:1654
  53:     0x7ff7f4dda122 - enum2$<core::result::Result<tuple$<>,ash::vk::enums::Result> >::unwrap
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\result.rs:1077
  54:     0x7ff7f4dda122 - client::graphics::draw::Draw::draw
                               at E:\Gamma\git\rust\hypermine\client\src\graphics\draw.rs:547
  55:     0x7ff7f4d21533 - client::graphics::window::Window::draw
                               at E:\Gamma\git\rust\hypermine\client\src\graphics\window.rs:359
  56:     0x7ff7f4e0dbc4 - winit::platform_impl::platform::event_loop::impl$3::run_on_demand::closure$0<tuple$<>,client::graphics::window::impl$1::run::closure_env$0>
                               at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop.rs:236
  57:     0x7ff7f4db9af4 - alloc::boxed::impl$48::call_mut
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\alloc\src\boxed.rs:2027
  58:     0x7ff7f4db9af4 - winit::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure$0
                               at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop\runner.rs:250
  59:     0x7ff7f4db9af4 - core::panic::unwind_safe::impl$25::call_once
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\panic\unwind_safe.rs:272
  60:     0x7ff7f4db9af4 - std::panicking::try::do_call
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\panicking.rs:552
  61:     0x7ff7f4db9af4 - std::panicking::try<tuple$<>,core::panic::unwind_safe::AssertUnwindSafe<winit::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<tuple$<> > > >
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\panicking.rs:516
  62:     0x7ff7f4e0ebe1 - std::panic::catch_unwind
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\panic.rs:146
  63:     0x7ff7f4e0ebe1 - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<tuple$<> >::catch_unwind<tuple$<>,tuple$<>,winit::platform_impl::platform::event_loop::runner::impl$3::call_event_handler::closure_env$0<tuple$<> > >
                               at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop\runner.rs:183
  64:     0x7ff7f4e0e6ff - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<tuple$<> >::call_event_handler
                               at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop\runner.rs:246
  65:     0x7ff7f4e0e6ff - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<tuple$<> >::send_event<tuple$<> >
                               at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop\runner.rs:224
  66:     0x7ff7f4dbec71 - winit::platform_impl::platform::event_loop::public_window_callback_inner::closure$4<tuple$<> >
                               at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop.rs:1144
  67:     0x7ff7f4dba388 - core::ops::function::FnOnce::call_once
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\ops\function.rs:250
  68:     0x7ff7f4dba388 - core::panic::unwind_safe::impl$25::call_once
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\panic\unwind_safe.rs:272
  69:     0x7ff7f4dba388 - std::panicking::try::do_call
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\panicking.rs:552
  70:     0x7ff7f4dba388 - std::panicking::try<tuple$<>,core::panic::unwind_safe::AssertUnwindSafe<winit::platform_impl::platform::event_loop::public_window_callback_inner::closure_env$4<tuple$<> > > >
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\panicking.rs:516
  71:     0x7ff7f4e0f22a - std::panic::catch_unwind
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\panic.rs:146
  72:     0x7ff7f4e0f22a - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<tuple$<> >::catch_unwind<tuple$<>,tuple$<>,winit::platform_impl::platform::event_loop::public_window_callback_inner::closure_env$4<tuple$<> > >
                               at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop\runner.rs:183
  73:     0x7ff7f4dd1428 - winit::platform_impl::platform::event_loop::public_window_callback_inner<tuple$<> >
                               at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop.rs:2285
  74:     0x7ff7f4dcf8e8 - winit::platform_impl::platform::event_loop::public_window_callback<tuple$<> >
                               at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop.rs:983
  75:     0x7ffc0032ef75 - CallWindowProcW
  76:     0x7ffc0032e9ee - CallWindowProcW
  77:     0x7ffba898f0f0 - glPushClientAttrib
  78:     0x7ffc0032ef75 - CallWindowProcW
  79:     0x7ffc0032e8dc - DispatchMessageW
  80:     0x7ffc003416d3 - SendMessageTimeoutW
  81:     0x7ffc01c30e64 - KiUserCallbackDispatcher
  82:     0x7ffbffb91704 - NtUserDispatchMessage
  83:     0x7ffc0032e7c6 - DispatchMessageW
  84:     0x7ff7f4dcf30e - winit::platform_impl::platform::event_loop::EventLoop<tuple$<> >::wait_and_dispatch_message<tuple$<> >
                               at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop.rs:406
  85:     0x7ff7f4dcf06e - winit::platform_impl::platform::event_loop::EventLoop<tuple$<> >::run_on_demand<tuple$<>,client::graphics::window::impl$1::run::closure_env$0>
                               at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop.rs:241
  86:     0x7ff7f4d1fe96 - winit::platform_impl::platform::event_loop::EventLoop<tuple$<> >::run
                               at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\platform_impl\windows\event_loop.rs:218
  87:     0x7ff7f4d1fe96 - winit::event_loop::EventLoop<tuple$<> >::run
                               at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winit-0.29.15\src\event_loop.rs:249
  88:     0x7ff7f4d1fe96 - client::graphics::window::Window::run
                               at E:\Gamma\git\rust\hypermine\client\src\graphics\window.rs:133
  89:     0x7ff7f4be7076 - client::main
                               at E:\Gamma\git\rust\hypermine\client\src\main.rs:84
  90:     0x7ff7f4be4ce6 - core::ops::function::FnOnce::call_once
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\core\src\ops\function.rs:250
  91:     0x7ff7f4be4ce6 - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\sys_common\backtrace.rs:155
  92:     0x7ff7f4be52ec - std::rt::lang_start::closure$0<tuple$<> >
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6\library\std\src\rt.rs:166
  93:     0x7ff7f51b6f12 - std::rt::lang_start_internal
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\rt.rs:148
  94:     0x7ff7f4be912c - main
  95:     0x7ff7f525ae2c - invoke_main
                               at d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  96:     0x7ff7f525ae2c - __scrt_common_main_seh
                               at d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  97:     0x7ffc01637344 - BaseThreadInitThunk
  98:     0x7ffc01be26b1 - RtlUserThreadStart

Out of all of this, these four lines seem the most relevant:
Validation Error: [ VUID-vkDestroySemaphore-semaphore-05149 ] | MessageID = 0x93e24db1 | vkDestroySemaphore(): semaphore can't be called on VkSemaphore 0xa808d50000000033[image acquired] that is currently in use by VkSemaphore 0xa808d50000000033[image acquired]. The Vulkan spec states: All submitted batches that refer to semaphore must have completed execution (https://vulkan.lunarg.com/doc/view/1.3.280.0/windows/1.3-extensions/vkspec.html#VUID-vkDestroySemaphore-semaphore-05149) id=VUID-vkDestroySemaphore-semaphore-05149 number=-1813885519 queue_labels= cmd_labels= objects=

ERROR Validation Error: [ VUID-vkDestroyFence-fence-01120 ] Object 0: handle = 0x2b424a0000000034, name = render complete, type = VK_OBJECT_TYPE_FENCE; | MessageID = 0x5d296248 | vkDestroyFence(): fence (VkFence 0x2b424a0000000034[render complete]) is in use. The Vulkan spec states: All queue submission commands that refer to fence must have completed execution (https://vulkan.lunarg.com/doc/view/1.3.280.0/windows/1.3-extensions/vkspec.html#VUID-vkDestroyFence-fence-01120) id=VUID-vkDestroyFence-fence-01120 number=1562993224 queue_labels= cmd_labels= objects=FENCE 2b424a0000000034 VUID-vkDestroyFence-fence-0112

ERROR Validation Error: [ VUID-vkDestroyBuffer-buffer-00922 ] | MessageID = 0xe4549c11 | vkDestroyBuffer(): can't be called on VkBuffer 0x4b7df1000000002f[uniforms] that is currently in use by VkCommandBuffer 0x20d8972c110[frame]. The Vulkan spec states: All submitted commands that refer to buffer, either directly or via a VkBufferView, must have completed execution (https://vulkan.lunarg.com/doc/view/1.3.280.0/windows/1.3-extensions/vkspec.html#VUID-vkDestroyBuffer-buffer-00922) id=VUID-vkDestroyBuffer-buffer-00922 number=-464217071 queue_labels= cmd_labels= objects=

ERROR Validation Error: [ VUID-vkDestroyBuffer-buffer-00922 ] | MessageID = 0xe4549c11 | vkDestroyBuffer(): can't be called on VkBuffer 0x996422000000026b[voxel transforms] that is currently in use by VkCommandBuffer 0x20d8972c110[frame]. The Vulkan spec states: All submitted commands that refer to buffer, either directly or via a VkBufferView, must have completed execution (https://vulkan.lunarg.com/doc/view/1.3.280.0/windows/1.3-extensions/vkspec.html#VUID-vkDestroyBuffer-buffer-00922) id=VUID-vkDestroyBuffer-buffer-00922 number=-464217071 queue_labels= cmd_labels= objects=

None of these validation errors appear until the game crashes.

@patowen
Copy link
Collaborator Author

patowen commented May 5, 2024

With some more experimentation, I got this validation error without crashing:
Validation Error: [ VUID-vkDestroyImage-image-01000 ] | MessageID = 0xf2d29b5a | vkDestroyImage(): can't be called on VkImage 0xe3343f000000028f[] that is currently in use by VkCommandBuffer 0x20919128700[frame]. The Vulkan spec states: All submitted commands that refer to image, either directly or via a VkImageView, must have completed execution (https://vulkan.lunarg.com/doc/view/1.3.280.0/windows/1.3-extensions/vkspec.html#VUID-vkDestroyImage-image-01000) id=VUID-vkDestroyImage-image-01000 number=-221078694 queue_labels= cmd_labels= objects=

@patowen
Copy link
Collaborator Author

patowen commented May 5, 2024

I'll use this comment to document things I've tried to fix it:

  • I tried calling draw.yakui_vulkan.transfers_submitted(); twice after queue_present as well as in the beginning to see if it always had to be called twice. This did not seem to have any effect.
  • It seems like the validation without the stack trace is likely more relevant. I may have somehow missed it earlier when copying my stack trace, but when I reproduced it again, it showed up above the thread 'main' panicked line. The validation errors after the panic were likely related to stack unwinding caused by the panic and should be ignored.
  • After further investigation, this seems likely to be a yakui bug, so I opened Fix Vulkan crash with TextureChange::Modified SecondHalfGames/yakui#155.

@patowen patowen reopened this May 5, 2024
@patowen
Copy link
Collaborator Author

patowen commented May 5, 2024

I reopened this PR because otherwise, the latest changes on the "yakui-wip" branch won't show up, which would cause problems for anyone trying to help.

@patowen
Copy link
Collaborator Author

patowen commented May 6, 2024

Closing this PR again, as I now have a new PR (#395) that's ready to be upgraded from a draft to a regular PR as soon as an upstream fix to yakui is applied. Any further changes to the code will be made to that PR.

@patowen patowen closed this May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants