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

            Bug ID: 528999
           Summary: About this System: EGL fallback never shows
                    integrated/discrete GPU type
    Classification: Applications
           Product: kinfocenter
      Version First 6.8.3
       Reported In:
          Platform: Arch Linux
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
  Target Milestone: ---

When `GPUEntryFactory` falls back to `kinfocenter-egl-helper` (for example when
the Vulkan helper fails or its device count doesn't match), the GPU entries
never get an integrated/discrete pill, even when the EGL driver supports
`EGL_EXT_device_type`. Checked against v6.8.3 and master (cc0838c4), there are
three causes:

1. `GPUEntryFactory.cpp` `eglGPUs()` L209 hard-codes
`VK_PHYSICAL_DEVICE_TYPE_OTHER` and ignores the "vkDeviceType" value the helper
sends. `vulkanDevices()` reads its helper's "type" at L113.
2. `egl-helper/main.cpp` L56 queries attribute `EGL_DEVICE_EXT` (0x322C, the
display-to-device query) instead of `EGL_DEVICE_TYPE_EXT` (0x3590) from
EGL_EXT_device_type.
3. The block is guarded by `#if defined(EGL_DEVICE_TYPE_OTHER_EXT)` (L54).
Arch's headers (libglvnd 1.7.0) don't define it, so the query is compiled out:
the shipped `/usr/lib/kinfocenter-egl-helper` contains no
`eglQueryDeviceAttribEXT` reference, and the helper always outputs
"vkDeviceType":0. Mesa 27.0.0-devel on this machine advertises
`EGL_EXT_device_type`.

## STEPS TO REPRODUCE

1. Run `/usr/lib/kinfocenter-egl-helper` on a system with an integrated and a
discrete GPU.

## OBSERVED RESULT

```
[{"name":"AMD Ryzen 7 9800X3D 8-Core Processor (radeonsi, raphael_mendocino,
...)","vkDeviceType":0},{"name":"AMD Radeon RX 9070 XT (radeonsi, gfx1201,
...)","vkDeviceType":0}]
```

Even with a non-zero value, `eglGPUs()` would discard it.

## EXPECTED RESULT

The types reach `GPUEntry`, and the EGL path shows the same pills as the Vulkan
path.

## SUGGESTED FIX (against v6.8.3)

```diff
--- a/kcms/about-distro/src/GPUEntryFactory.cpp
+++ b/kcms/about-distro/src/GPUEntryFactory.cpp
@@ -206,7 +206,7 @@ std::optional<std::vector<GPUEntry::Device>> eglGPUs()
             qWarning() << "Empty name for device";
             return {};
         }
-        devices.push_back(GPUEntry::Device{name,
VK_PHYSICAL_DEVICE_TYPE_OTHER});
+        devices.push_back(GPUEntry::Device{name,
static_cast<VkPhysicalDeviceType>(obj.value("vkDeviceType").toInt(VK_PHYSICAL_DEVICE_TYPE_OTHER))});
     }

     if (!devicesAddUpAfterStripping(devices, true)) {
--- a/kcms/about-distro/src/egl-helper/main.cpp
+++ b/kcms/about-distro/src/egl-helper/main.cpp
@@ -53,7 +53,7 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char
**argv)
         const auto vkType = [&]() -> VkPhysicalDeviceType { // for practical
reasons we only send vulkan types from the helpers
 #if defined(EGL_DEVICE_TYPE_OTHER_EXT)
             auto eglQueryDeviceAttribEXT =
reinterpret_cast<PFNEGLQUERYDEVICEATTRIBEXTPROC>(eglGetProcAddress("eglQueryDeviceAttribEXT"));
-            if (EGLAttrib attribute{}; eglQueryDeviceAttribEXT(device,
EGL_DEVICE_EXT, &attribute) == EGL_TRUE) {
+            if (EGLAttrib attribute{}; eglQueryDeviceAttribEXT(device,
EGL_DEVICE_TYPE_EXT, &attribute) == EGL_TRUE) {
                 switch (attribute) {
                 case EGL_DEVICE_TYPE_OTHER_EXT:
                     return VK_PHYSICAL_DEVICE_TYPE_OTHER;
```

For point 3, define the five EGL_EXT_device_type constants locally when the
header lacks them (values 0x3590-0x3594 per the Khronos eglext.h), so
distributions with older headers still get the query.

Note: this is untested. I haven't built or run the patch.

**Source:**
-
https://invent.kde.org/plasma/kinfocenter/-/blob/v6.8.3/kcms/about-distro/src/GPUEntryFactory.cpp#L188-219
-
https://invent.kde.org/plasma/kinfocenter/-/blob/v6.8.3/kcms/about-distro/src/egl-helper/main.cpp#L53-71

**System:** EndeavourOS, Plasma 6.8.3, kinfocenter 6.8.3-1, Mesa 27.0.0-devel
(git-abb197d754), libglvnd 1.7.0-3, kernel 7.3.4.

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

Reply via email to