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

wgpu Adapter and Surface might not be compatible #224

Closed
rosefromthedead opened this issue Dec 8, 2022 · 5 comments
Closed

wgpu Adapter and Surface might not be compatible #224

rosefromthedead opened this issue Dec 8, 2022 · 5 comments

Comments

@rosefromthedead
Copy link
Contributor

Since RequestAdapterOptions field compatible_surface is not specified (see here), wgpu may not give an adapter that can render to the display. But the current API means the Instance and Adapter are constructed at the same time and the Surface is constructed later, so without changing the API (which admittedly seems pretty natural how it is), it's not possible to fix this. Maybe it's worth separating Instance and Adapter creation? Or making the user provide Instance and Surface themselves?

FWIW I ran into this incompatibility on my intel+nvidia laptop, but the default PowerPreference should select intel, so I might just not have any compatible combinations. Still might be worth allowing this for other machines.

@dfrg
Copy link
Collaborator

dfrg commented Dec 9, 2022

Thanks for reporting this. The intent behind separating surface and device creation is to support multiple windows (which may come and go, particularly in UI contexts) that can share resources on a single device. If the current design is failing on dual GPU setups, it’s definitely something that we need to address even if that makes the API less pleasant.

I am curious about the error message. Is it general surface incompatibility or is the format (we unconditionally choose Bgra8Unorm) incompatible?

@rosefromthedead
Copy link
Contributor Author

The error message is Error in Surface::configure: surface does not support the adapter's queue family, so it seems not to be pixel format, but idk how to check.

@rosefromthedead
Copy link
Contributor Author

IMO it would be good to have error handling at surface creation time, to request an adapter that is compatible with the new surface if the current adapter is not, and then continue using both adapters for their respective surfaces. This means that if I have 2 cards with 1 display each then my app can draw to surfaces on both displays simultaneously without incompatibility issues, which might not be possible if vello only keeps one adapter around. Helpfully, it also solves the original problem :P

Here's hoping it's not too hard to add multi-adapter support?

rosefromthedead added a commit to rosefromthedead/piet-gpu that referenced this issue Dec 13, 2022
some `RenderContext` stuff is now `DeviceHandle` stuff, and device
handles are created alongside surfaces to ensure compatibility, but are
reused if possible.

Fixes linebender#224 wgpu Adapter and Surface might not be compatible
rosefromthedead added a commit to rosefromthedead/piet-gpu that referenced this issue Dec 14, 2022
some `RenderContext` stuff is now `DeviceHandle` stuff, and device
handles are created alongside surfaces to ensure compatibility, but are
reused if possible.

Fixes linebender#224 wgpu Adapter and Surface might not be compatible
canselcik pushed a commit to canselcik/vello that referenced this issue Jan 2, 2023
some `RenderContext` stuff is now `DeviceHandle` stuff, and device
handles are created alongside surfaces to ensure compatibility, but are
reused if possible.

Fixes linebender#224 wgpu Adapter and Surface might not be compatible
@dfrg dfrg closed this as completed in f0faadc Jan 9, 2023
@dhardy
Copy link

dhardy commented Jan 10, 2023

Just a little note, I had a similar report recently, and while at first glance use of a compatible_surface to ensure compatibility may appear a good idea, my conclusion was that this only really does anything for users with multiple GPUs (in the reporter's case, Intel iGPU + NVidia discrete graphics). The better solution, for a general purpose GUI, is to make the surface compatible with as many adapters as possible (including old Intel iGPUs).

@rosefromthedead
Copy link
Contributor Author

rosefromthedead commented Jan 11, 2023

Looks like you did that by using the fifo present mode, but vello was already using that before my change, and still didn't work.

FWIW if I "remove" my nvidia vulkan driver, vello works fine (albeit very slowly) regardless of Wayland, X11, #227 or no #227. Maybe that's the bigger problem - wgpu is selecting the nvidia driver very aggressively. Even with PowerPreference::LowPower I can't get it to ignore the nvidia device.

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

No branches or pull requests

3 participants