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

DRI_PRIME is not Respected in NVidia Hybrid Setup #3464

Open
autumnontape opened this issue Feb 10, 2023 · 6 comments
Open

DRI_PRIME is not Respected in NVidia Hybrid Setup #3464

autumnontape opened this issue Feb 10, 2023 · 6 comments
Labels
api: vulkan Issues with Vulkan platform: wayland Issues with integration with linux/wayland platform: x11 Issues with integration with linux/x11 type: enhancement New feature or request

Comments

@autumnontape
Copy link

Description
My Linux PC has an integrated GPU and a discrete GPU. The discrete GPU drives the monitor, and the compositor runs on it. If I have Vulkan drivers installed for both and don't set any environment variables, initialize_adapter_from_env_or_default selects the integrated GPU.

Repro steps
On a device with integrated and discrete GPUs, plug the monitor into the discrete GPU and configure it in your BIOS as the boot GPU, leaving the integrated GPU enabled. Install Vulkan drivers for both GPUs. Run one of the wgpu examples and check which adapter it uses.

Expected vs observed behavior
It selects the integrated GPU, regardless of DRI_PRIME. I would expect it to choose the first physical device from vkEnumeratePhysicalDevices, which is normally "the one used by Wayland/Xorg or the one connected to a display."

I would make the case that this should be the behavior when a low power preference is requested, too. A discrete GPU will probably be powered on anyway if the compositor is using it, and choosing the integrated GPU in this case will cause the framebuffer to be copied to the discrete GPU every frame. I'd be interested to hear other opinions on that, though. (This would mean the integrated GPU would never be selected by default, which is what I would prefer. The only reason I have a Vulkan driver installed for it is so I can test applications on both devices.)

Platform
OS: Arch Linux
wgpu commit: 5b8c55c
Integrated and discrete GPUs both use Mesa drivers.

@teoxoy teoxoy added type: enhancement New feature or request api: vulkan Issues with Vulkan labels Feb 21, 2023
@teoxoy teoxoy added this to the WebGPU Specification V1 milestone Feb 24, 2023
@cwfitzgerald cwfitzgerald changed the title Too eager to choose an integrated GPU over a discrete GPU DRI_PRIME is not Respected in NVidia Hybrid Setup Apr 29, 2024
@cwfitzgerald cwfitzgerald added platform: x11 Issues with integration with linux/x11 platform: wayland Issues with integration with linux/wayland labels Apr 29, 2024
@autumnontape
Copy link
Author

autumnontape commented Jun 12, 2024

@cwfitzgerald The new title isn't exactly an accurate description of my issue. I have an Intel iGPU and an AMD dGPU, and the dGPU drives the monitor; it's first in the enumeration order and is my preferred default even when DRI_PRIME is unset.

@teoxoy
Copy link
Member

teoxoy commented Jun 13, 2024

This sounds like it would have been fixed by #3903. Could you confirm that it was?

@autumnontape
Copy link
Author

I'm afraid not, since wgpu will no longer select the Vulkan backend for my iGPU even when I use DRI_PRIME=1! to make it the only exposed GPU. (It instead fails to find an adapter.) vkcube makes use of it fine. I don't know why this is, but it's not surprising to me, and I wouldn't consider it a bug, since it is a Haswell GPU and doesn't expose a lot of modern Vulkan features.

@teoxoy
Copy link
Member

teoxoy commented Jun 14, 2024

#4718 is probably the cause of that, try setting ALLOW_UNDERLYING_NONCOMPLIANT_ADAPTER=1.

@autumnontape
Copy link
Author

Wonderful! Yes, it works as I expect now when no power preference is specified. The iGPU is still selected with WGPU_POWER_PREF=low. I'm curious if there's ever been a discussion on whether it's better to select an iGPU or a dGPU for low power when the dGPU is driving the monitor.

@teoxoy
Copy link
Member

teoxoy commented Jun 17, 2024

I'm curious if there's ever been a discussion on whether it's better to select an iGPU or a dGPU for low power when the dGPU is driving the monitor.

I'm not sure we have the info to detect this. Do the native APIs have a device/adapter_is_driving_a_monitor flag? I think there is still value in the low power hint picking a low power adapter despite it not being the one driving a monitor since it could still draw less power than the one driving the monitor while in use by the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vulkan Issues with Vulkan platform: wayland Issues with integration with linux/wayland platform: x11 Issues with integration with linux/x11 type: enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

3 participants