mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2025-02-16 14:34:46 -06:00
Start abstraction of GPU functions
This commit is contained in:
parent
83f1918175
commit
56653b0743
6
gputypes.cpp
Normal file
6
gputypes.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "gputypes.h"
|
||||
|
||||
gputypes::gputypes()
|
||||
{}
|
||||
gputypes::~gputypes()
|
||||
{}
|
95
gputypes.h
Normal file
95
gputypes.h
Normal file
@ -0,0 +1,95 @@
|
||||
#ifndef GPUTYPES_H
|
||||
#define GPUTYPES_H
|
||||
|
||||
#include <QObject>
|
||||
/*#include <QtX11Extras/QX11Info>
|
||||
#include <X11/Xlib.h>
|
||||
#include <NVCtrl/NVCtrlLib.h>
|
||||
#include "nvml.h"
|
||||
#include <QVector>*/
|
||||
|
||||
class gputypes
|
||||
{
|
||||
public:
|
||||
gputypes();
|
||||
/*struct GPU
|
||||
{
|
||||
char *name;
|
||||
char *uuid;
|
||||
bool overVoltAvailable = false;
|
||||
bool overClockAvailable = false;
|
||||
bool memOverClockAvailable = false;
|
||||
bool powerLimitAvailable = false;
|
||||
bool voltageReadable = false;
|
||||
bool coreClkReadable = false;
|
||||
bool memClkReadable = false;
|
||||
bool manualFanCtrlAvailable = false;
|
||||
int fanControlMode;
|
||||
int maxVoltageOffset;
|
||||
int minVoltageOffset;
|
||||
int minCoreClkOffset;
|
||||
int maxCoreClkOffset;
|
||||
int minMemClkOffset;
|
||||
int maxMemClkOffset;
|
||||
uint maxCoreClk;
|
||||
uint maxMemClk;
|
||||
|
||||
int voltageOffset;
|
||||
int coreClkOffset;
|
||||
int memClkOffset;
|
||||
|
||||
int coreFreq;
|
||||
int memFreq;
|
||||
int temp;
|
||||
int voltage;
|
||||
int fanSpeed;
|
||||
|
||||
double powerDraw;
|
||||
uint coreUtil;
|
||||
uint memUtil;
|
||||
uint minPowerLim;
|
||||
uint maxPowerLim;
|
||||
uint powerLim;
|
||||
int totalVRAM;
|
||||
int usedVRAM;
|
||||
};
|
||||
QVector <GPU> GPUList;
|
||||
|
||||
int gpuCount = 0;
|
||||
Display *dpy;
|
||||
nvmlDevice_t *device;*/
|
||||
|
||||
virtual bool setupXNVCtrl() = 0;
|
||||
virtual bool setupNVML(int GPUIndex) = 0;
|
||||
virtual void queryGPUCount() = 0;
|
||||
virtual void queryGPUNames() = 0;
|
||||
virtual void queryGPUUIDs() = 0;
|
||||
virtual void queryGPUFeatures() = 0;
|
||||
virtual void queryGPUVoltage(int GPUIndex) = 0;
|
||||
virtual void queryGPUTemp(int GPUIndex) = 0;
|
||||
virtual void queryGPUFrequencies(int GPUIndex) = 0;
|
||||
virtual void queryGPUFanSpeed(int GPUIndex) = 0;
|
||||
virtual void queryGPUUsedVRAM(int GPUIndex) = 0;
|
||||
virtual void queryGPUFreqOffset(int GPUIndex) = 0;
|
||||
virtual void queryGPUMemClkOffset(int GPUIndex) = 0;
|
||||
virtual void queryGPUVoltageOffset(int GPUIndex) = 0;
|
||||
virtual void queryGPUUtils(int GPUIndex) = 0;
|
||||
virtual void queryGPUPowerDraw(int GPUIndex) = 0;
|
||||
virtual void queryGPUPowerLimit(int GPUIndex) = 0;
|
||||
virtual void queryGPUPowerLimitLimits(int GPUIndex) = 0;
|
||||
virtual void queryGPUCurrentMaxClocks(int GPUIndex) = 0;
|
||||
virtual void queryGPUPowerLimitAvailability(int GPUIndex) = 0;
|
||||
|
||||
virtual bool assignGPUFanSpeed(int GPUIndex, int targetValue) = 0;
|
||||
virtual bool assignGPUFanCtlMode(int GPUIndex, int targetValue) = 0;
|
||||
virtual bool assignGPUFreqOffset(int GPUIndex, int targetValue) = 0;
|
||||
virtual bool assignGPUMemClockOffset(int GPUIndex, int targetValue) = 0;
|
||||
virtual bool assignGPUVoltageOffset(int GPUIndex, int targetValue) = 0;
|
||||
virtual bool assignGPUPowerLimit(uint targetValue) = 0;
|
||||
protected:
|
||||
~gputypes();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // GPUTYPES_H
|
@ -3,12 +3,11 @@
|
||||
#include "editprofile.h"
|
||||
#include "ui_editprofile.h"
|
||||
#include "newprofile.h"
|
||||
#include "monitor.h"
|
||||
#include "plotwidget.h"
|
||||
#include "nvidia.h"
|
||||
//#include "gputypes.h"
|
||||
#include <NVCtrl/NVCtrl.h>
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
@ -20,8 +19,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
tabHandler(ui->tabWidget->currentIndex());
|
||||
|
||||
// Create persistent nvidia pointer
|
||||
nvidia *nvd = new nvidia;
|
||||
nv = nvd;
|
||||
nv = new nvidia;
|
||||
//gputypes *types;
|
||||
//types = nv;
|
||||
|
||||
nv->setupXNVCtrl();
|
||||
nv->setupNVML(currentGPUIndex);
|
||||
nv->queryGPUFeatures();
|
||||
|
@ -3,11 +3,12 @@
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "editprofile.h"
|
||||
#include "monitor.h"
|
||||
//#include "monitor.h"
|
||||
#include <QProcess>
|
||||
#include <QList>
|
||||
#include <QByteArray>
|
||||
#include "nvidia.h"
|
||||
//#include "gputypes.h"
|
||||
//#include <NVCtrl/NVCtrl.h>
|
||||
|
||||
namespace Ui {
|
||||
@ -158,6 +159,7 @@ private:
|
||||
QStringList UUIDList;
|
||||
QString latestUUID;
|
||||
nvidia *nv;
|
||||
//gputypes *types;
|
||||
|
||||
QTimer *resettimer = new QTimer(this);
|
||||
QTimer *fanUpdateTimer = new QTimer(this);
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
nvidia::nvidia(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
bool nvidia::setupXNVCtrl()
|
||||
{
|
||||
@ -18,7 +17,6 @@ bool nvidia::setupXNVCtrl()
|
||||
event_basep,
|
||||
error_basep);
|
||||
qDebug() << ret;
|
||||
|
||||
queryGPUCount();
|
||||
queryGPUNames();
|
||||
queryGPUUIDs();
|
||||
|
8
nvidia.h
8
nvidia.h
@ -5,14 +5,15 @@
|
||||
#include <QDebug>
|
||||
#include <QtX11Extras/QX11Info>
|
||||
#include <QProcess>
|
||||
#include <nvml.h>
|
||||
#include "nvml.h"
|
||||
#include "gputypes.h"
|
||||
|
||||
class nvidia : public QObject
|
||||
class nvidia : public QObject, public gputypes
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit nvidia(QObject *parent = nullptr);
|
||||
|
||||
//gputypes *types;
|
||||
struct GPU
|
||||
{
|
||||
char *name;
|
||||
@ -61,7 +62,6 @@ private:
|
||||
Display *dpy;
|
||||
nvmlDevice_t *device;
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
bool setupXNVCtrl();
|
||||
bool setupNVML(int GPUIndex);
|
||||
|
@ -33,7 +33,8 @@ SOURCES += \
|
||||
editprofile.cpp \
|
||||
newprofile.cpp \
|
||||
plotwidget.cpp \
|
||||
nvidia.cpp
|
||||
nvidia.cpp \
|
||||
gputypes.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
@ -42,7 +43,8 @@ HEADERS += \
|
||||
newprofile.h \
|
||||
plotwidget.h \
|
||||
nvidia.h \
|
||||
nvml.h
|
||||
nvml.h \
|
||||
gputypes.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui \
|
||||
|
Loading…
Reference in New Issue
Block a user