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

Pipelined Rendering: bevy does not request surface compatibility from wgpu #3051

Open
branan opened this issue Oct 29, 2021 · 4 comments
Open
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior C-Dependencies A change to the crates that Bevy depends on

Comments

@branan
Copy link
Contributor

branan commented Oct 29, 2021

Bevy version

pipelined-rendering HEAD

Operating system & version

Ubuntu 20.04

What you did

  • Set prime to intel-only mode
  • cargo run --example 3d_scene_pipelined

What you expected to happen

3d_scene_pipelined demo to be rendered on the Intel GPU

What actually happened

thread 'main' panicked at 'Error in Surface::configure: surface does not support the adapter's queue family', /home/branan/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.11.0/src/backend/direct.rs:204:9

Additional information

The reason that wgpu selects the intel GPU even though it cannot present to it is because Bevy does not request surface compatibility when initializing the wgpu adapter.

This happens in my case because wgpu is overly-aggressive in disabling presentation on Intel GPUs on systems with prime/optimus. However, I believe that this lack of an explicit compatibility check could potentially cause wgpu to select an incorrect Vulkan device in other situations where there are GPUs which cannot present.

@branan branan added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Oct 29, 2021
@branan
Copy link
Contributor Author

branan commented Oct 29, 2021

To be clear I believe there's both a wgpu bug and a bevy bug here:

  • Bevy should explicitly request surface compatibility when initializing the renderer alongside winit. This isn't needed for headless rendering, obviously
  • wgpu should be more targeted in its workaround for bad prime configurations

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Dependencies A change to the crates that Bevy depends on and removed S-Needs-Triage This issue needs to be labelled labels Oct 29, 2021
@branan
Copy link
Contributor Author

branan commented Oct 29, 2021

Were I to attempt to fix this in Bevy myself, I think I'd:

  • Reorder things so that the winit plugin is initialized before the renderer plugin
  • Have the winit plugin do the primary window creation in its plugin setup, rather than waiting for the first run tick
  • Have the renderer plugin query for windows in its own setup and use that to ask for compatibility from wgpu

This could still cause a non-compatible GPU to be selected when an initially-windowless app creates its first window later, but that's much more of an edge case.

This feels like a big refactor, though.

@bjorn3
Copy link
Contributor

bjorn3 commented Oct 30, 2021

Since #3039 surface compatibility should be requested.

@superdump
Copy link
Contributor

Does this work on current main?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior C-Dependencies A change to the crates that Bevy depends on
Projects
None yet
Development

No branches or pull requests

4 participants