From 74aff2cea072de6a8f9e620c8811ae6238701c08 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Wed, 12 May 2021 17:09:24 +0200 Subject: [PATCH] Add GPU Sysinfo Update vcpkg to latest master --- ScreenPlaySysInfo/CMakeLists.txt | 9 ++- ScreenPlaySysInfo/gpu.cpp | 50 +++++++++++++++++ ScreenPlaySysInfo/gpu.h | 73 +++++++++++++++++++++++++ ScreenPlaySysInfo/sysinfo.cpp | 1 + ScreenPlaySysInfo/sysinfo.h | 5 ++ Tools/install_dependencies_linux_mac.sh | 8 +-- Tools/install_dependencies_windows.bat | 6 +- 7 files changed, 142 insertions(+), 10 deletions(-) create mode 100644 ScreenPlaySysInfo/gpu.cpp create mode 100644 ScreenPlaySysInfo/gpu.h diff --git a/ScreenPlaySysInfo/CMakeLists.txt b/ScreenPlaySysInfo/CMakeLists.txt index 4cfd681f..d9fe67ca 100644 --- a/ScreenPlaySysInfo/CMakeLists.txt +++ b/ScreenPlaySysInfo/CMakeLists.txt @@ -4,6 +4,7 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOMOC ON) +find_package(infoware CONFIG REQUIRED) find_package( Qt5 COMPONENTS Quick Core @@ -15,7 +16,8 @@ set(src cpu.cpp ram.cpp storage.cpp - uptime.cpp) + uptime.cpp + gpu.cpp) set(headers screenplaysysinfo_plugin.h @@ -24,11 +26,12 @@ set(headers ram.h mathhelper.h storage.h - uptime.h) + uptime.h + gpu.h) add_library(${PROJECT_NAME} SHARED ${src} ${headers}) -target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Quick) +target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Quick infoware) # QML module deployment set(URI "ScreenPlay/Sysinfo") diff --git a/ScreenPlaySysInfo/gpu.cpp b/ScreenPlaySysInfo/gpu.cpp new file mode 100644 index 00000000..aaba929c --- /dev/null +++ b/ScreenPlaySysInfo/gpu.cpp @@ -0,0 +1,50 @@ +#include "gpu.h" + +#include "infoware/gpu.hpp" +#include "infoware/version.hpp" +#include + +static const char* vendor_name(iware::gpu::vendor_t vendor) noexcept; + +GPU::GPU(QObject* parent) + : QObject(parent) +{ + const auto device_properties = iware::gpu::device_properties(); + if (device_properties.empty()) { + qWarning() << "No detection methods enabled"; + return; + } + + for (auto i = 0u; i < device_properties.size(); ++i) { + const auto& properties_of_device = device_properties[i]; + + // Skip Windows default + if (QString::fromStdString(properties_of_device.name) == "Basic Render Driver") + continue; + + setVendor(vendor_name(properties_of_device.vendor)); + setName(QString::fromStdString(properties_of_device.name)); + setRamSize(properties_of_device.memory_size); + setCacheSize(properties_of_device.cache_size); + setMaxFrequency(properties_of_device.max_frequency); + } +} +static const char* vendor_name(iware::gpu::vendor_t vendor) noexcept +{ + switch (vendor) { + case iware::gpu::vendor_t::intel: + return "Intel"; + case iware::gpu::vendor_t::amd: + return "AMD"; + case iware::gpu::vendor_t::nvidia: + return "NVidia"; + case iware::gpu::vendor_t::microsoft: + return "Microsoft"; + case iware::gpu::vendor_t::qualcomm: + return "Qualcomm"; + case iware::gpu::vendor_t::apple: + return "Apple"; + default: + return "Unknown"; + } +} diff --git a/ScreenPlaySysInfo/gpu.h b/ScreenPlaySysInfo/gpu.h new file mode 100644 index 00000000..3c6f34d5 --- /dev/null +++ b/ScreenPlaySysInfo/gpu.h @@ -0,0 +1,73 @@ +#pragma once +#include + +class GPU : public QObject { + Q_OBJECT + Q_PROPERTY(QString vendor READ vendor WRITE setVendor NOTIFY vendorChanged) + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(int ramSize READ ramSize WRITE setRamSize NOTIFY ramSizeChanged) + Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize NOTIFY cacheSizeChanged) + Q_PROPERTY(int maxFrequency READ maxFrequency WRITE setMaxFrequency NOTIFY maxFrequencyChanged) + +public: + explicit GPU(QObject* parent = nullptr); + const QString& vendor() const { return m_vendor; } + const QString& name() const { return m_name; } + int ramSize() const { return m_ramSize; } + int cacheSize() const { return m_cacheSize; } + int maxFrequency() const { return m_maxFrequency; } + +public slots: + void setVendor(const QString& vendor) + { + if (m_vendor == vendor) + return; + m_vendor = vendor; + emit vendorChanged(m_vendor); + } + void setName(const QString& name) + { + if (m_name == name) + return; + m_name = name; + emit nameChanged(m_name); + } + + void setRamSize(int ramSize) + { + if (m_ramSize == ramSize) + return; + m_ramSize = ramSize; + emit ramSizeChanged(m_ramSize); + } + + void setCacheSize(int cacheSize) + { + if (m_cacheSize == cacheSize) + return; + m_cacheSize = cacheSize; + emit cacheSizeChanged(m_cacheSize); + } + + void setMaxFrequency(int maxFrequency) + { + if (m_maxFrequency == maxFrequency) + return; + m_maxFrequency = maxFrequency; + emit maxFrequencyChanged(m_maxFrequency); + } + +signals: + void vendorChanged(const QString& vendor); + void nameChanged(const QString& name); + void ramSizeChanged(int ramSize); + void cacheSizeChanged(int cacheSize); + void maxFrequencyChanged(int maxFrequency); + +private: + QString m_vendor; + QString m_name; + int m_ramSize = 0; + int m_cacheSize = 0; + int m_maxFrequency = 0; +}; diff --git a/ScreenPlaySysInfo/sysinfo.cpp b/ScreenPlaySysInfo/sysinfo.cpp index 5c4348e9..9072a67e 100644 --- a/ScreenPlaySysInfo/sysinfo.cpp +++ b/ScreenPlaySysInfo/sysinfo.cpp @@ -4,6 +4,7 @@ SysInfo::SysInfo(QQuickItem* parent) : QQuickItem(parent) , m_ram(std::make_unique()) , m_cpu(std::make_unique()) + , m_gpu(std::make_unique()) , m_storage(std::make_unique()) , m_uptime(std::make_unique()) { diff --git a/ScreenPlaySysInfo/sysinfo.h b/ScreenPlaySysInfo/sysinfo.h index 9ca2b337..6293b7c3 100644 --- a/ScreenPlaySysInfo/sysinfo.h +++ b/ScreenPlaySysInfo/sysinfo.h @@ -38,6 +38,7 @@ #include #include "cpu.h" +#include "gpu.h" #include "ram.h" #include "storage.h" #include "uptime.h" @@ -45,6 +46,7 @@ class SysInfo : public QQuickItem { Q_OBJECT + Q_PROPERTY(GPU* gpu READ gpu NOTIFY gpuChanged) Q_PROPERTY(RAM* ram READ ram NOTIFY ramChanged) Q_PROPERTY(CPU* cpu READ cpu NOTIFY cpuChanged) Q_PROPERTY(Storage* storage READ storage NOTIFY storageChanged) @@ -57,16 +59,19 @@ public: CPU* cpu() const { return m_cpu.get(); } Storage* storage() const { return m_storage.get(); } Uptime* uptime() const { return m_uptime.get(); } + GPU* gpu() const { return m_gpu.get(); } signals: void ramChanged(RAM* ram); void cpuChanged(CPU* cpu); void storageChanged(Storage* storage); void uptimeChanged(Uptime* uptime); + void gpuChanged(GPU*); private: std::unique_ptr m_ram; std::unique_ptr m_cpu; std::unique_ptr m_storage; std::unique_ptr m_uptime; + std::unique_ptr m_gpu; }; diff --git a/Tools/install_dependencies_linux_mac.sh b/Tools/install_dependencies_linux_mac.sh index 2de3c045..02dff8a8 100644 --- a/Tools/install_dependencies_linux_mac.sh +++ b/Tools/install_dependencies_linux_mac.sh @@ -5,16 +5,16 @@ cd .. git clone https://github.com/microsoft/vcpkg.git ScreenPlay-vcpkg cd ScreenPlay-vcpkg git pull -# master 27.03.2021 - 9f6157a -git checkout 9f6157a +# master 12.05.2021 - 7b1016e10ef0434fe7045d320a9ee05b63e0efe9 +git checkout 7b1016e10ef0434fe7045d320a9ee05b63e0efe9 chmod +x bootstrap-vcpkg.sh ./bootstrap-vcpkg.sh chmod +x vcpkg if [[ "$OSTYPE" == "darwin"* ]]; then -./vcpkg install openssl-unix sentry-native doctest benchmark --triplet x64-osx --recurse +./vcpkg install openssl-unix sentry-native doctest benchmark infoware[opencl] --triplet x64-osx --recurse else -./vcpkg install openssl-unix sentry-native doctest benchmark --triplet x64-linux --recurse +./vcpkg install openssl-unix sentry-native doctest benchmark infoware[opencl] --triplet x64-linux --recurse fi ./vcpkg upgrade --no-dry-run \ No newline at end of file diff --git a/Tools/install_dependencies_windows.bat b/Tools/install_dependencies_windows.bat index 4de27ec6..8c504efe 100644 --- a/Tools/install_dependencies_windows.bat +++ b/Tools/install_dependencies_windows.bat @@ -5,12 +5,12 @@ cd .. git clone https://github.com/microsoft/vcpkg.git ScreenPlay-vcpkg cd ScreenPlay-vcpkg git pull -rem master 27.03.2021 - 9f6157a -git checkout 9f6157a +rem master 12.05.2021 - 7b1016e10ef0434fe7045d320a9ee05b63e0efe9 +git checkout 7b1016e10ef0434fe7045d320a9ee05b63e0efe9 call bootstrap-vcpkg.bat rem Install vcpkg dependencies -vcpkg.exe install openssl sentry-native doctest benchmark --triplet x64-windows --recurse +vcpkg.exe install openssl sentry-native doctest benchmark infoware[d3d] --triplet x64-windows --recurse vcpkg.exe upgrade --no-dry-run cd ..