bevyengine / bevy

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

Surface is not taken into account in wgpu adapter selection #16291

Open ilyas-taouaou opened 3 weeks ago

ilyas-taouaou commented 3 weeks ago

Bevy version

master branch

`SystemInfo { os: "Windows 11 Pro", kernel: "22631", cpu: "Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz", core_count: "6", memory: "15.9 GiB" }`
`AdapterInfo { name: "NVIDIA GeForce GTX 1650", vendor: 4318, device: 8066, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "566.03", backend: Vulkan }`

What you did

added

dbg!(&primary_window)

in bevy_render wgpu context initialization code

What went wrong

it seems to always be None for me. It should be some surface, for wgpu to make sure that the surface is compatible with the selected wgpu adapter (physical device)

Additional information

it could be that the primary window is not initialized yet somehow? Maybe system ordering problem as the same system would give a valid surface if ran at Startup

BenjaminBrienen commented 3 weeks ago

Can you demonstrate this hypothetical scenario where not knowing the primary monitor at that point creates a problem? Alternatively, can you describe a concrete example of when it would create a problem?

ilyas-taouaou commented 3 weeks ago

@BenjaminBrienen Unfortunately I can't but that's a requirement in the Vulkan spec to check if a specific device and queue family is compatible with window surface. When wgpu doesn't get a compatible surface, it can't guarantee that it would be compatible with the selected physical device and queue family. Btw the primary monitor doesn't matter here I think, as long as you pass a dummy surface, to my knowledge it should be fine.