wlroots
wlroots copied to clipboard
Change separator for WLR_DRM_DEVICES
At some point recently, udev started adding /dev/dri/by-path
symlinks (similar to the disk ones) which provide a stable way to refer to DRM devices over reboots.
Unfortunately, these paths contain a colon character, referring to PCI bus ids:
/dev/dri/by-path/pci-0000:07:00.0-card
These colons mess with the way we separate the paths for multiple DRM devices.
It's much more preferable to use these symlinks instead of pointing to device nodes directly, so we need to do something to fix this. Ideas:
- Change the separator to something else like a comma. Would probably be fine, but not guaranteed to not cause issues again in the future.
- Introduce a way to escape colons. More complex processing and generally uglier strings required to be entered, as well as possibly interacting badly with a shells own escaping.
- Change the separator to actually be ":/". Seems too hacky, but the strings would look the same as they do now.
I'd probably just go with changing to a comma or semi-colon, unless someone else wants to input anything.
wlroots has migrated to gitlab.freedesktop.org. This issue has been moved to:
https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/1386
Sorry for the necro, but I think this would be worth reviewing. I know I'm at fault for buying an egpu to begin with, but this issue alone would mean a lot for the viability of eGPUs for sway. The fact that the WLR_DRM_DEVICES envvar exists alone is fantastic, but unfortunately the use of eGPUs is hampered by the fact that the card names (card1, card2) of the dedicated GPU in my laptop and my external GPU seem to switch often, while the PCI bus IDs do not.
Why do you need WLR_DRM_DEVICES
for an eGPU setup?
If the order of device names is random, the compositor might choose the wrong gpu as the primary rendering target. As a workaround add udev rules to create predictable symlinks.
By default, wlroots uses the boot_vga device, so it should always pick the iGPU as primary.
Why do you need
WLR_DRM_DEVICES
for an eGPU setup?
As you said, sway picks the iGPU as primary, but I was hoping to use the eGPU instead, especially for games and such. Which, if glxinfo is to be trusted, works very well with WLR_DRM_DEVICES
, though the order of rendering devices in /dev/dri/
is random. I technically have three cards, an iGPU, a dedicated GPU in my laptop and then an external GPU. iGPU is always card0, but wheter card1 refers to the dGPU or eGPU and so forth with card2 seems to change between reboots.
If the order of device names is random, the compositor might choose the wrong gpu as the primary rendering target. As a workaround add udev rules to create predictable symlinks.
I know next to nothing about udev, but I'll try. Thanks.
Udev already creates predictable symlinks, but the format it uses contains ':'s, which is what this issue is about.
Why do you need
WLR_DRM_DEVICES
for an eGPU setup?
Sorry to bother again, but does this mean there is a better way to set the GPU the system will use than the WLR_DRM_DEVICES variable?
No, it means wlroots will use the right GPU by default.
No, it means wlroots will use the right GPU by default.
What do you mean by "the right GPU?" If glxinfo is to be trusted, it seems that by default the integrated GPU in my processor is being used without WLR_DRM_DEVICES being specified.
Yes. This is desirable for power savings. You can set DRI_PRIME=1
to make individual applications use the dGPU.
Yes. This is desirable for power savings. You can set
DRI_PRIME=1
to make individual applications use the dGPU.
I see, now I don't know the specifics, but it'd make me a bit nervous to use PRIME switching between an iGPU and an external GPU since afaik it's not really what it was designed for, and power savings aren't much of a concern since whenever the external gpu is being used, the computer is always being charged.
On the other hand, if I use WLR_DRM_DEVICES, will the said device be used for all programs launched under Sway?
Yes. This is desirable for power savings. You can set
DRI_PRIME=1
to make individual applications use the dGPU.I see, now I don't know the specifics, but it'd make me a bit nervous to use PRIME switching between an iGPU and an external GPU since afaik it's not really what it was designed for, and power savings aren't much of a concern since whenever the external gpu is being used, the computer is always being charged.
PRIME switching is exactly what "external" laptop GPUs are designed for, some don't even have dedicated display outputs and can only be used by rendering to a framebuffer in the iGPU. Thats what DRI_PRIME was designed for.
This sure is getting off-topic from the original point. This is literally a 1 line change, but will just require users to modify their environment if they're already using this.
PRIME switching is exactly what "external" laptop GPUs are designed for, some don't even have dedicated display outputs and can only be used by rendering to a framebuffer in the iGPU. Thats what DRI_PRIME was designed for.
I think this may be a misunderstanding, what I was referring to as external gpu is one of those gpu boxes you connect via thunderbolt rather than a dedicated gpu in a laptop.
This sure is getting off-topic from the original point. This is literally a 1 line change, but will just require users to modify their environment if they're already using this.
I apologise for that. I from my POV what you proposed would be a rational solution that would negate the need for dirty workarounds and instead support the udev symlinks already there. I would like to see it.
This issue is only about changing the syntax of the WLR_DRM_DEVICES environment variable away from using a colon separator to permit using sysfs paths.
Please only comment with constructive discussion for that particular topic, and open new issues for anything else.