bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
35.08k stars 3.45k forks source link

OS-independent texture format setting in swapchain #3897

Closed nia-e closed 1 year ago

nia-e commented 2 years ago

What problem does this solve or what need does it fill?

The current bevy_render crate assumes the supported texture format based on OS. This may lead to issues, e.g. Nvidia on Wayland not supporting the expected Bgra8UnormSrgb format (only supporting Bgra8Unorm).

What solution would you like?

Perform platform-independent querying of supported texture formats in swapchain, with a preferred one then being picked for Surface:: configure.

What alternative(s) have you considered?

(In my case) using Xwayland by disabling the wayland feature works, but causes blurriness with fractional scaling.

Additional context

My current (incomplete) fix can be found at https://github.com/a-b-c-1-2-3/bevy on branch support-non-srgb, but this only allows for a feature to disable sRGB, not proper runtime querying of supported formats.

Zentropivity commented 2 years ago

I too have come across this issue. On bevy main (https://github.com/bevyengine/bevy/commit/de677dbfc9dacf1724367024fc1965dae27325a4).

The output of cargo run --release --features wayland --example bevymark:

INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce GTX 1050 Ti", vendor: 4318, device: 7298, device_type: DiscreteGpu, backend: Vulkan }
thread 'main' panicked at 'Error in Surface::configure: requested format Bgra8UnormSrgb is not in list of supported formats: [Bgra8Unorm]', /home/zen/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.12.0/src/backend/direct.rs:214:9
Using `RUST_BACKTRACE=1`, followed by: ``` stack backtrace: 0: rust_begin_unwind at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5 1: core::panicking::panic_fmt at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14 2: wgpu::backend::direct::Context::handle_error_fatal 3: ::surface_configure 4: bevy_render::view::window::prepare_windows 5: as bevy_ecs::system::system::System>::run_unsafe 6: as core::future::future::Future>::poll 7: as core::future::future::Future>::poll 8: async_task::raw::RawTask::run 9: async_executor::LocalExecutor::try_tick 10: std::thread::local::LocalKey::with 11: ::run_systems 12: ::run 13: ::build::{{closure}} 14: bevy_app::app::App::update 15: bevy_winit::winit_runner_with::{{closure}} 16: winit::platform_impl::platform::wayland::event_loop::EventLoop::run_return 17: winit::platform_impl::platform::wayland::event_loop::EventLoop::run 18: winit::platform_impl::platform::EventLoop::run 19: winit::event_loop::EventLoop::run 20: bevy_winit::run 21: bevy_winit::winit_runner_with 22: core::ops::function::Fn::call 23: bevy_app::app::App::run 24: bevymark::main ```
System information ``` -` .o+` `ooo/ `+oooo: `+oooooo: zen@zen-arch -+oooooo+: ------------ `/:-:++oooo+: OS: Arch Linux x86_64 `/++++/+++++++: Host: X570 AORUS ELITE -CF `/++++++++++++++: Kernel: 5.16.15-arch1-1 `/+++ooooooooooooo/` Uptime: 2 hours, 21 mins ./ooosssso++osssssso+` Packages: 1230 (pacman) .oossssso-````/ossssss+` Shell: fish 3.3.1 -osssssso. :ssssssso. Resolution: 1920x1080 :osssssss/ osssso+++. DE: Plasma 5.24.3 /ossssssss/ +ssssooo/- WM: kwin `/ossssso+/:- -:/+osssso+- WM Theme: Arc-Dark `+sso+:-` `.-/+oso: Theme: [Plasma], Arc-Dark-solid [GTK2/3] `++:. `-/+/ Icons: Papirus-Dark [Plasma], Papirus-Dark [GTK2/3] .` `/ Terminal: kate CPU: AMD Ryzen 7 5800X (16) @ 3.800GHz GPU: NVIDIA GeForce GTX 1050 Ti Memory: 3106MiB / 32087MiB ```

I believe that this issue should be labeled C-Crash too.

OtherCannon commented 2 years ago

I've also experienced this issue, I'm using Fedora 36 with an NVIDIA RTX 2070 SUPER. Enabling the wayland feature gives me the same error.