File size: 1,339 Bytes
034d0a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2023 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#include "citra_qt/util/graphics_device_info.h"

#ifdef ENABLE_OPENGL
#include <QOffscreenSurface>
#include <QOpenGLContext>
#include <QOpenGLFunctions>
#endif

#ifdef ENABLE_VULKAN
#include "video_core/renderer_vulkan/vk_instance.h"
#endif

#ifdef ENABLE_OPENGL
QString GetOpenGLRenderer() {
    QOffscreenSurface surface;
    surface.create();

    QOpenGLContext context;
    if (context.create()) {
        context.makeCurrent(&surface);
        return QString::fromUtf8(context.functions()->glGetString(GL_RENDERER));
    } else {
        return QStringLiteral("");
    }
}
#endif

#ifdef ENABLE_VULKAN
std::vector<QString> GetVulkanPhysicalDevices() {
    std::vector<QString> result;
    try {
        Vulkan::Instance instance{};
        const auto physical_devices = instance.GetPhysicalDevices();

        for (const vk::PhysicalDevice physical_device : physical_devices) {
            const QString name = QString::fromUtf8(physical_device.getProperties().deviceName, -1);
            result.push_back(name);
        }
    } catch (const std::runtime_error& err) {
        LOG_ERROR(Frontend, "Error occured while querying for physical devices: {}", err.what());
    }

    return result;
}
#endif