tum-pbs / game-physics-template

Template code for game physics lecture
2 stars 5 forks source link

Program crashes when releasing the framerate #17

Open Ceyron opened 5 hours ago

Ceyron commented 5 hours ago

I compiled the main branch, executed the program and unticked the Limit FPS under the Rendering tap in the GUI. Then the program crashes

thread '<unnamed>' panicked at 'Error in wgpuDeviceCreateSwapChain: Validation Error

Caused by:
    Requested present mode Immediate is not in the list of supported present modes: [Fifo]
', src/lib.rs:495:5
stack backtrace:
   0:     0x7c402cc2e4ba - std::backtrace_rs::backtrace::libunwind::trace::h9a6b80bbf328ba5d
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7c402cc2e4ba - std::backtrace_rs::backtrace::trace_unsynchronized::hd162ec543a11886b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7c402cc2e4ba - std::sys_common::backtrace::_print_fmt::h78a5099be12f51a6
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7c402cc2e4ba - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha1c5390454d74f71
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7c402cc4f6bf - core::fmt::write::h9ffde816c577717b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/fmt/mod.rs:1254:17
   5:     0x7c402cc2be45 - std::io::Write::write_fmt::h88186074961638e4
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/io/mod.rs:1698:15
   6:     0x7c402cc2e285 - std::sys_common::backtrace::_print::h184198273ed08d59
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7c402cc2e285 - std::sys_common::backtrace::print::h1b4d8e7add699453
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7c402cc2f61e - std::panicking::default_hook::{{closure}}::h393bcea75423915a
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:269:22
   9:     0x7c402cc2f3c5 - std::panicking::default_hook::h48c64f31d8b3fd03
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:288:9
  10:     0x7c402cc2fb7e - std::panicking::rust_panic_with_hook::hafdc493a79370062
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:691:13
  11:     0x7c402cc2fa79 - std::panicking::begin_panic_handler::{{closure}}::h0a64bc82e36bedc7
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:582:13
  12:     0x7c402cc2e926 - std::sys_common::backtrace::__rust_end_short_backtrace::hc203444fb7416a16
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:150:18
  13:     0x7c402cc2f7d2 - rust_begin_unwind
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
  14:     0x7c402c877173 - core::panicking::panic_fmt::h0f6ef0178afce4f2
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
  15:     0x7c402c9a6966 - wgpu_native::handle_error_fatal::h4dab13fcf1fc1a53
  16:     0x7c402c9b8818 - wgpuDeviceCreateSwapChain
  17:     0x618933c59b92 - _ZN4wgpu6Device15createSwapChainENS_7SurfaceERKNS_19SwapChainDescriptorE
  18:     0x618933c7edbc - _ZN8Renderer13initSwapChainEv
  19:     0x618933c7da92 - _ZN8Renderer7onFrameEv
  20:     0x618933c7ad15 - main
  21:     0x7c402c234e08 - <unknown>
  22:     0x7c402c234ecc - __libc_start_main
  23:     0x618933c57635 - _start
  24:                0x0 - <unknown>
fatal runtime error: failed to initiate panic, error 5
Aborted (core dumped)

My OS is Arch Linux. System info from CMAKE configure:

-- The CXX compiler identification is GNU 14.2.1
-- The C compiler identification is GNU 14.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Using X11 for window creation
-- Found X11: /usr/include
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Using wgpu-native backend for WebGPU
-- Using WebGPU runtime from '/home/felix/Downloads/game-physics-template-0.1.1/build/_deps/webgpu-backend-wgpu-src/bin/linux-x86_64/libwgpu_native.so'
-- Configuring done (54.0s)
-- Generating done (0.0s)
KeKsBoTer commented 3 hours ago

Can you try setting "wgpu::PresentMode::Immediate" to "wgpu::PresentMode::AutoNoVsync" here: https://github.com/tum-pbs/game-physics-template/blob/245163b94eacc53b594940a28fc90dcf4aef0261/src/Simulator.cpp#L80

see https://docs.rs/wgpu/latest/wgpu/enum.PresentMode.html#variant.AutoNoVsync

Ceyron commented 2 hours ago

wgpu::PresentMode::AutoNoVsync

gives me

[build] /home/felix/Downloads/game-physics-template/src/Simulator.cpp: In member function ‘void Simulator::onGUI()’:
[build] /home/felix/Downloads/game-physics-template/src/Simulator.cpp:85:60: error: ‘AutoNoVsync’ is not a member of ‘wgpu::PresentMode’
[build]    85 |                 renderer.setPresentMode(wgpu::PresentMode::AutoNoVsync);
[build]       |                                                            ^~~~~~~~~~~
[build] make[2]: *** [CMakeFiles/Template.dir/build.make:146: CMakeFiles/Template.dir/src/Simulator.cpp.o] Error 1
[build] make[1]: *** [CMakeFiles/Makefile2:187: CMakeFiles/Template.dir/all] Error 2
[build] make: *** [Makefile:91: all] Error 2

Could it be that this is a feature only supported by a more recent version of WebGPU?