https://bugs.kde.org/show_bug.cgi?id=529002

            Bug ID: 529002
           Summary: About this System: mark the compositor's GPU and list
                    GPUs in a stable, identifiable order
    Classification: Applications
           Product: kinfocenter
      Version First 6.8.3
       Reported In:
          Platform: Arch Linux
                OS: Linux
            Status: REPORTED
          Severity: wishlist
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
  Target Milestone: ---

## TL;DR

On a desktop with an AMD APU and a discrete AMD GPU, "About this System" lists
both GPUs. But it doesn't show which one the desktop renders on, the "1/2"
order is whatever the Vulkan or EGL enumeration returns, and the iGPU entry
reads exactly like the CPU name. I'm asking for three small, static things: (a)
a stable order, (b) a unique identity for each GPU, and (c) a marker such as
"Desktop renders on this GPU" for the GPU KWin picked as its primary render
device. This is not usage or activity and doesn't change while the session
runs; it's a fixed property chosen at KWin startup, like boot_vga.

## SYSTEM

- EndeavourOS (Arch), KDE Plasma 6.8.3, KDE Frameworks 6.32.0, Qt 6.12.0,
Wayland session
- kinfocenter 6.8.3-1, kwin 6.8.3-1, kde-cli-tools 6.8.3-1
- Mesa 27.0.0-devel (git-abb197d754), libdrm 2.4.134, kernel 7.3.4
- iGPU: AMD Ryzen 7 9800X3D integrated Radeon (Raphael), PCI 1002:13c0 at
0000:76:00.0, boot_vga=0
- dGPU: AMD Radeon RX 9070 XT (gfx1201), PCI 1002:7550 at 0000:03:00.0,
boot_vga=1, all monitors connected
- Both GPUs use amdgpu.

DRM nodes are identical across the last 6 boots. Minor numbers follow driver
probe order and aren't a stable interface. Note that the card and render
numbering run in opposite directions:

```
card0 -> 0000:76:00.0 (iGPU)    renderD128 -> 0000:03:00.0 (dGPU)
card1 -> 0000:03:00.0 (dGPU)    renderD129 -> 0000:76:00.0 (iGPU)
```

## STEPS TO REPRODUCE

1. On a machine with an AMD APU plus an AMD dGPU, with the monitors on the
dGPU, open System Settings > About this System, or run `kinfo`.
2. Compare with the GPU KWin renders on: `qdbus6 org.kde.KWin /KWin
supportInformation | grep "OpenGL renderer"`.
3. Optional: run `MESA_VK_DEVICE_SELECT=1002:13c0
/usr/lib/kinfocenter-vulkan-helper` to see the order change.

## OBSERVED RESULT

```
Processors: 16 × AMD Ryzen 7 9800X3D 8-Core Processor
Graphics Processor 1: AMD Radeon RX 9070 XT
Graphics Processor 2: AMD Ryzen 7 9800X3D 8-Core Processor
```

- **No entry identifies the GPU the desktop renders on.** KWin reports `OpenGL
renderer string: AMD Radeon RX 9070 XT (radeonsi, gfx1201, ...)`.
- **The order is just enumeration order.** On this machine the Vulkan helper
returns 9070 XT, iGPU, llvmpipe, while the EGL helper returns iGPU, 9070 XT.
With `MESA_VK_DEVICE_SELECT=1002:13c0`, the Vulkan helper puts the iGPU first,
so "Graphics Processor 1" becomes the iGPU, even though the desktop still
renders on the 9070 XT.
- **The iGPU entry duplicates the CPU name.** Mesa's raw name is `AMD Ryzen 7
9800X3D 8-Core Processor (RADV RAPHAEL_MENDOCINO)`.
`FancyString::fromRenderer()` cuts everything from the first "(", which removes
the only part that tells it apart.

## EXPECTED RESULT

1. **Stable order:** the desktop's GPU first, then the boot_vga GPU, then by
PCI address. It shouldn't depend on card or render minor numbers, the loader,
or the environment.
2. **Unique identity:** when the cleaned name is empty, equals the CPU model
string, or duplicates another entry, keep the parenthesized codename (e.g.
"Raphael") or append the PCI address (e.g. "0000:76:00.0").
3. **Static marker** on the GPU KWin chose as its primary render device,
labeled "Desktop renders on this GPU" or "Primary (compositor)".

Example:

```
Graphics Processor 1: AMD Radeon RX 9070 XT [discrete] [Primary (compositor)]
Graphics Processor 2: AMD Ryzen 7 9800X3D (Raphael) [integrated]
```

Bug 491527 comment 3 says the pre-6.3 single entry was "the GPU in use". I'm
not asking for usage, which is what bug 526406 (RESOLVED NOT A BUG) asked for
and plasma-systemmonitor covers ("Activity changes all the time and per
application"). What I'm asking for is static: KWin selects its primary render
device once at startup (`selectRenderDevice()`, using `listGPUs()` with
boot_vga first), and that choice holds for the session unless a GPU is removed.

**Caveat:** KWin can also drive outputs connected to secondary GPUs, so the
marker means "primary render device", not "the only GPU doing work".

## POSSIBLE WAYS TO GET THE MARKER (maintainers' choice)

- **(a) boot_vga.** Read `/sys/bus/pci/devices/<bdf>/boot_vga` for each DRM
device. It's trivial, works on X11 too, and is right on most desktops; it
matches KWin's first sort key in `listGPUs()`.
- **(b) dmabuf default feedback `main_device`.** In `zwp_linux_dmabuf_v1`, bind
version 4 or 5 and call `get_default_feedback`. KWin 6.8.3 sends `main_device`
only below version 6, where the event is deprecated. Compare devices with
`drmGetDeviceFromDevId()`/`drmDevicesEqual()` rather than raw dev_t: the
protocol says node type is unspecified and dev_t equality isn't reliable. It's
per feedback object and "may change over time", in practice only on GPU
removal.
- **(c) A property KWin exports**, for example its primary render device's node
or PCI address over D-Bus, if maintainers prefer an explicit API.

**Identity and order:** `drmGetDevices2()` is already called (only to count).
Keep each device's PCI bus info and nodes from it. Have the helpers emit a join
key (`VK_EXT_physical_device_drm`/`VK_EXT_pci_bus_info`;
`EGL_DRM_RENDER_NODE_FILE_EXT`/`EGL_DRM_DEVICE_FILE_EXT`, all exposed by Mesa
on this machine) instead of relying on list order.

**Out of scope here:** VRAM, see 508220. Pills in copied text, see 500119. EGL
fallback losing the integrated/discrete type: filed separately as bug bug
528999.

## SOURCE POINTERS (v6.8.3 tags)

- kinfocenter `GPUEntryFactory.cpp` `gpus()` L221-236 (Vulkan helper, then EGL
fallback) and `factorize()` L262-281 (numbers entries in helper order):
https://invent.kde.org/plasma/kinfocenter/-/blob/v6.8.3/kcms/about-distro/src/GPUEntryFactory.cpp#L221-236
- kinfocenter `GPUEntryFactory.cpp` `drmDeviceCount()` L65-81:
`drmGetDevices2()` is used only for a count check.
- kinfocenter `FancyString.cpp` `fromRenderer()` L18-29, truncation at L24:
https://invent.kde.org/plasma/kinfocenter/-/blob/v6.8.3/kcms/about-distro/src/FancyString.cpp#L18-29
- kwin `compositor.cpp` `selectRenderDevice()` L192-248:
https://invent.kde.org/plasma/kwin/-/blob/v6.8.3/src/compositor.cpp#L192-248
- kwin `utils/udev.cpp` `Udev::listGPUs()` L113-151 (boot_vga first,
hotpluggable last):
https://invent.kde.org/plasma/kwin/-/blob/v6.8.3/src/utils/udev.cpp#L113-151
- kwin `wayland/linuxdmabufv1clientbuffer.cpp` L561-569 (`main_device` sent
only when version < 6, check at L565):
https://invent.kde.org/plasma/kwin/-/blob/v6.8.3/src/wayland/linuxdmabufv1clientbuffer.cpp#L561-569

## ADDITIONAL INFORMATION

```
$ /usr/lib/kinfocenter-vulkan-helper
[{"name":"AMD Radeon RX 9070 XT (RADV GFX1201)","type":2},{"name":"AMD Ryzen 7
9800X3D 8-Core Processor (RADV RAPHAEL_MENDOCINO)","type":1},{"name":"llvmpipe
(LLVM 23.1.5, 256 bits)","type":4}]
$ /usr/lib/kinfocenter-egl-helper
[{"name":"AMD Ryzen 7 9800X3D 8-Core Processor (radeonsi, raphael_mendocino,
ACO, DRM 3.64, 7.3.4-1-cachyos)","vkDeviceType":0},{"name":"AMD Radeon RX 9070
XT (radeonsi, gfx1201, ACO, DRM 3.64, 7.3.4-1-cachyos)","vkDeviceType":0}]
$ MESA_VK_DEVICE_SELECT=1002:13c0 /usr/lib/kinfocenter-vulkan-helper
[{"name":"AMD Ryzen 7 9800X3D 8-Core Processor (RADV
RAPHAEL_MENDOCINO)","type":1},{"name":"AMD Radeon RX 9070 XT (RADV
GFX1201)","type":2},{"name":"llvmpipe (LLVM 23.1.5, 256 bits)","type":4}]
$ wayland-info -i zwp_linux_dmabuf_v1 | grep "main device"
        main device: 0xE280 (/dev/dri/card1 or /dev/dri/renderD128)
```

**Related:** 491527 (list all GPUs, RESOLVED FIXED in 6.3), 526406 (GPU
activity indicator, RESOLVED NOT A BUG), 459549 (switchable graphics, RESOLVED
INTENTIONAL, 2022), 500119 and 508220 (CONFIRMED).

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to