[plasma/kwin] src: core/renderdevice: add a device name

Xaver Hugl <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit e60b27971af9ff4999e68a9175730e5108ce6ae5 by Xaver Hugl.
Committed on 18/08/2026 at 11:30.
Pushed by zamundaaa into branch 'master'.

core/renderdevice: add a device name

M  +2    -2    src/core/gpumanager.cpp
M  +32   -0    src/core/renderdevice.cpp
M  +4    -0    src/core/renderdevice.h
M  +6    -0    src/vulkan/vulkan_device.cpp
M  +2    -0    src/vulkan/vulkan_device.h

https://invent.kde.org/plasma/kwin/-/commit/e60b27971af9ff4999e68a9175730e5108ce6ae5

diff --git a/src/core/gpumanager.cpp b/src/core/gpumanager.cpp
index be41e3590a5..9051ffae14e 100644
--- a/src/core/gpumanager.cpp
+++ b/src/core/gpumanager.cpp
@@ -344,7 +344,7 @@ void GpuManager::addDevice(std::unique_ptr<RenderDevice> &&device)
 {
     m_renderDevices.push_back(std::move(device));
     updateCompatibilityMap();
-    qCDebug(KWIN_CORE, "Added render device %s", qPrintable(m_renderDevices.back()->path()));
+    qCDebug(KWIN_CORE, "Added render device %s: %s", qPrintable(m_renderDevices.back()->path()), qPrintable(m_renderDevices.back()->name()));
     Q_EMIT renderDeviceAdded(m_renderDevices.back().get());
 }
 
@@ -359,7 +359,7 @@ void GpuManager::removeDevice(RenderDevice *device)
     auto ref = std::move(*it);
     m_renderDevices.erase(it);
     updateCompatibilityMap();
-    qCDebug(KWIN_CORE, "Removed render device %s", qPrintable(device->path()));
+    qCDebug(KWIN_CORE, "Removed render device %s: %s", qPrintable(device->path()), qPrintable(device->name()));
     Q_EMIT renderDeviceRemoved(device);
 }
 
diff --git a/src/core/renderdevice.cpp b/src/core/renderdevice.cpp
index 089bf62142a..070f79f0413 100644
--- a/src/core/renderdevice.cpp
+++ b/src/core/renderdevice.cpp
@@ -13,6 +13,7 @@
 #include "graphicsbuffer.h"
 #include "opengl/eglcontext.h"
 #include "opengl/egldisplay.h"
+#include "opengl/glplatform.h"
 #include "udmabufallocator.h"
 #include "utils/common.h"
 #include "utils/envvar.h"
@@ -88,6 +89,7 @@ RenderDevice::RenderDevice(std::unique_ptr<DrmDevice> &&device, std::unique_ptr<
     , m_deviceId(m_device->deviceId())
 {
     createVulkanDevice();
+    fetchName();
     m_allImportableFormats = getImportFormats(m_display.get(), m_vulkanDevice.get());
 }
 
@@ -99,6 +101,7 @@ RenderDevice::RenderDevice(std::unique_ptr<UDmabufAllocator> &&allocator, std::u
     , m_deviceId(deviceId)
 {
     createVulkanDevice();
+    fetchName();
     m_allImportableFormats = getImportFormats(m_display.get(), m_vulkanDevice.get());
 }
 
@@ -116,6 +119,11 @@ QString RenderDevice::path() const
     return m_path;
 }
 
+QString RenderDevice::name() const
+{
+    return m_name;
+}
+
 dev_t RenderDevice::deviceId() const
 {
     return m_deviceId;
@@ -384,4 +392,28 @@ bool RenderDevice::isInternal() const
     return m_display->type() == EglDisplay::GpuType::Internal;
 }
 
+static QString prettify(const QString &name)
+{
+    QString ret = name;
+    ret.replace(QStringLiteral("(TM)"), QChar(8482));
+    ret.replace(QStringLiteral("(R)"), QChar(174));
+    ret = ret.mid(0, ret.indexOf('('));
+    return ret.trimmed();
+}
+
+void RenderDevice::fetchName()
+{
+    if (m_vulkanDevice) {
+        m_name = prettify(m_vulkanDevice->name());
+        return;
+    }
+    auto context = eglContext();
+    if (context && context->makeCurrent()) {
+        m_name = prettify(QString::fromLatin1(context->glPlatform()->glRendererString()));
+        return;
+    }
+    // better than nothing
+    m_name = m_path;
+}
+
 }
diff --git a/src/core/renderdevice.h b/src/core/renderdevice.h
index e30153226c2..813b855e29c 100644
--- a/src/core/renderdevice.h
+++ b/src/core/renderdevice.h
@@ -44,6 +44,8 @@ public:
     DrmDevice *drmDevice() const;
     GraphicsBufferAllocator *allocator() const;
     QString path() const;
+    QString name() const;
+
     dev_t deviceId() const;
     EglDisplay *eglDisplay() const;
     /**
@@ -98,6 +100,7 @@ public:
 private:
     void handleVulkanDeviceLoss();
     void createVulkanDevice();
+    void fetchName();
 
     const std::unique_ptr<DrmDevice> m_device;
     const std::unique_ptr<UDmabufAllocator> m_udmabufAllocator;
@@ -111,6 +114,7 @@ private:
     bool m_inReset = false;
     const QString m_path;
     const dev_t m_deviceId;
+    QString m_name;
 };
 
 }
diff --git a/src/vulkan/vulkan_device.cpp b/src/vulkan/vulkan_device.cpp
index 5bc6f0518ab..57c48689978 100644
--- a/src/vulkan/vulkan_device.cpp
+++ b/src/vulkan/vulkan_device.cpp
@@ -26,6 +26,7 @@ VulkanDevice::VulkanDevice(vk::raii::PhysicalDevice physicalDevice, vk::raii::De
     , m_transferFormats(queryFormats(VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT))
     , m_queueProperties(std::move(queueProperties))
     , m_deviceLimits(m_physical.getProperties().limits)
+    , m_name(physicalDevice.getProperties().deviceName.data())
 {
     m_memoryProperties = physicalDevice.getMemoryProperties();
     getQueues();
@@ -330,6 +331,11 @@ vk::PhysicalDeviceType VulkanDevice::type() const
     return m_type;
 }
 
+QString VulkanDevice::name() const
+{
+    return m_name;
+}
+
 const FormatModifierMap &VulkanDevice::transferFormats() const
 {
     return m_transferFormats;
diff --git a/src/vulkan/vulkan_device.h b/src/vulkan/vulkan_device.h
index 6d939c69add..6b0aeaa79fa 100644
--- a/src/vulkan/vulkan_device.h
+++ b/src/vulkan/vulkan_device.h
@@ -41,6 +41,7 @@ public:
 
     bool isSoftwareRenderer() const;
     vk::PhysicalDeviceType type() const;
+    QString name() const;
 
     vk::raii::DeviceMemory allocateMemory(const vk::ImageCreateInfo &imageInfo, vk::MemoryPropertyFlags memoryProperties);
     vk::raii::DeviceMemory allocateMemory(const vk::BufferCreateInfo &bufferInfo, vk::MemoryPropertyFlags memoryProperties);
@@ -104,6 +105,7 @@ private:
     std::vector<VkQueueFamilyProperties> m_queueProperties;
     vk::PhysicalDeviceMemoryProperties m_memoryProperties;
     vk::PhysicalDeviceLimits m_deviceLimits;
+    QString m_name;
 
     std::unique_ptr<VulkanQueue> m_graphicsQueue;
     std::unique_ptr<VulkanQueue> m_transferQueue;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.