1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-06 19:12:30 +01:00

Add GPU Sysinfo

Update vcpkg to latest master
This commit is contained in:
Elias Steurer 2021-05-12 17:09:24 +02:00
parent 0db6c76dd0
commit 74aff2cea0
7 changed files with 142 additions and 10 deletions

View File

@ -4,6 +4,7 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
find_package(infoware CONFIG REQUIRED)
find_package( find_package(
Qt5 Qt5
COMPONENTS Quick Core COMPONENTS Quick Core
@ -15,7 +16,8 @@ set(src
cpu.cpp cpu.cpp
ram.cpp ram.cpp
storage.cpp storage.cpp
uptime.cpp) uptime.cpp
gpu.cpp)
set(headers set(headers
screenplaysysinfo_plugin.h screenplaysysinfo_plugin.h
@ -24,11 +26,12 @@ set(headers
ram.h ram.h
mathhelper.h mathhelper.h
storage.h storage.h
uptime.h) uptime.h
gpu.h)
add_library(${PROJECT_NAME} SHARED ${src} ${headers}) 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 # QML module deployment
set(URI "ScreenPlay/Sysinfo") set(URI "ScreenPlay/Sysinfo")

50
ScreenPlaySysInfo/gpu.cpp Normal file
View File

@ -0,0 +1,50 @@
#include "gpu.h"
#include "infoware/gpu.hpp"
#include "infoware/version.hpp"
#include <QDebug>
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";
}
}

73
ScreenPlaySysInfo/gpu.h Normal file
View File

@ -0,0 +1,73 @@
#pragma once
#include <QObject>
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;
};

View File

@ -4,6 +4,7 @@ SysInfo::SysInfo(QQuickItem* parent)
: QQuickItem(parent) : QQuickItem(parent)
, m_ram(std::make_unique<RAM>()) , m_ram(std::make_unique<RAM>())
, m_cpu(std::make_unique<CPU>()) , m_cpu(std::make_unique<CPU>())
, m_gpu(std::make_unique<GPU>())
, m_storage(std::make_unique<Storage>()) , m_storage(std::make_unique<Storage>())
, m_uptime(std::make_unique<Uptime>()) , m_uptime(std::make_unique<Uptime>())
{ {

View File

@ -38,6 +38,7 @@
#include <memory> #include <memory>
#include "cpu.h" #include "cpu.h"
#include "gpu.h"
#include "ram.h" #include "ram.h"
#include "storage.h" #include "storage.h"
#include "uptime.h" #include "uptime.h"
@ -45,6 +46,7 @@
class SysInfo : public QQuickItem { class SysInfo : public QQuickItem {
Q_OBJECT Q_OBJECT
Q_PROPERTY(GPU* gpu READ gpu NOTIFY gpuChanged)
Q_PROPERTY(RAM* ram READ ram NOTIFY ramChanged) Q_PROPERTY(RAM* ram READ ram NOTIFY ramChanged)
Q_PROPERTY(CPU* cpu READ cpu NOTIFY cpuChanged) Q_PROPERTY(CPU* cpu READ cpu NOTIFY cpuChanged)
Q_PROPERTY(Storage* storage READ storage NOTIFY storageChanged) Q_PROPERTY(Storage* storage READ storage NOTIFY storageChanged)
@ -57,16 +59,19 @@ public:
CPU* cpu() const { return m_cpu.get(); } CPU* cpu() const { return m_cpu.get(); }
Storage* storage() const { return m_storage.get(); } Storage* storage() const { return m_storage.get(); }
Uptime* uptime() const { return m_uptime.get(); } Uptime* uptime() const { return m_uptime.get(); }
GPU* gpu() const { return m_gpu.get(); }
signals: signals:
void ramChanged(RAM* ram); void ramChanged(RAM* ram);
void cpuChanged(CPU* cpu); void cpuChanged(CPU* cpu);
void storageChanged(Storage* storage); void storageChanged(Storage* storage);
void uptimeChanged(Uptime* uptime); void uptimeChanged(Uptime* uptime);
void gpuChanged(GPU*);
private: private:
std::unique_ptr<RAM> m_ram; std::unique_ptr<RAM> m_ram;
std::unique_ptr<CPU> m_cpu; std::unique_ptr<CPU> m_cpu;
std::unique_ptr<Storage> m_storage; std::unique_ptr<Storage> m_storage;
std::unique_ptr<Uptime> m_uptime; std::unique_ptr<Uptime> m_uptime;
std::unique_ptr<GPU> m_gpu;
}; };

View File

@ -5,16 +5,16 @@ cd ..
git clone https://github.com/microsoft/vcpkg.git ScreenPlay-vcpkg git clone https://github.com/microsoft/vcpkg.git ScreenPlay-vcpkg
cd ScreenPlay-vcpkg cd ScreenPlay-vcpkg
git pull git pull
# master 27.03.2021 - 9f6157a # master 12.05.2021 - 7b1016e10ef0434fe7045d320a9ee05b63e0efe9
git checkout 9f6157a git checkout 7b1016e10ef0434fe7045d320a9ee05b63e0efe9
chmod +x bootstrap-vcpkg.sh chmod +x bootstrap-vcpkg.sh
./bootstrap-vcpkg.sh ./bootstrap-vcpkg.sh
chmod +x vcpkg chmod +x vcpkg
if [[ "$OSTYPE" == "darwin"* ]]; then 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 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 fi
./vcpkg upgrade --no-dry-run ./vcpkg upgrade --no-dry-run

View File

@ -5,12 +5,12 @@ cd ..
git clone https://github.com/microsoft/vcpkg.git ScreenPlay-vcpkg git clone https://github.com/microsoft/vcpkg.git ScreenPlay-vcpkg
cd ScreenPlay-vcpkg cd ScreenPlay-vcpkg
git pull git pull
rem master 27.03.2021 - 9f6157a rem master 12.05.2021 - 7b1016e10ef0434fe7045d320a9ee05b63e0efe9
git checkout 9f6157a git checkout 7b1016e10ef0434fe7045d320a9ee05b63e0efe9
call bootstrap-vcpkg.bat call bootstrap-vcpkg.bat
rem Install vcpkg dependencies 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 vcpkg.exe upgrade --no-dry-run
cd .. cd ..