mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
change(HardwareInfo/Windows): sort GPUs by performance, use smart pointers, log errors better
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
ccc23c8bc3
commit
f99a0883af
1 changed files with 15 additions and 13 deletions
|
|
@ -65,8 +65,11 @@ bool readFromOutput(const char* command, F function)
|
||||||
#endif
|
#endif
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
#include "dxgi.h"
|
#include <dxgi1_6.h>
|
||||||
#include "windows.h"
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <wrl/client.h>
|
||||||
|
using Microsoft::WRL::ComPtr;
|
||||||
|
|
||||||
QString HardwareInfo::cpuInfo()
|
QString HardwareInfo::cpuInfo()
|
||||||
{
|
{
|
||||||
|
|
@ -104,29 +107,28 @@ uint64_t HardwareInfo::availableRamMiB()
|
||||||
|
|
||||||
QStringList HardwareInfo::gpuInfo()
|
QStringList HardwareInfo::gpuInfo()
|
||||||
{
|
{
|
||||||
IDXGIFactory* factory = nullptr;
|
ComPtr<IDXGIFactory6> factory;
|
||||||
if (CreateDXGIFactory(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&factory)) != S_OK) { // NOLINT(*-pro-type-reinterpret-cast)
|
HRESULT hr = CreateDXGIFactory1(IID_PPV_ARGS(&factory));
|
||||||
qWarning() << "Could not create DXGI factory";
|
if (FAILED(hr)) {
|
||||||
|
qWarning() << "Could not create DXGI factory:" << Qt::hex << hr;
|
||||||
return { "GPU discovery failed: could not create DXGI factory" };
|
return { "GPU discovery failed: could not create DXGI factory" };
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT i = 0;
|
UINT i = 0;
|
||||||
IDXGIAdapter* adapter = nullptr;
|
ComPtr<IDXGIAdapter> adapter;
|
||||||
QStringList out;
|
QStringList out;
|
||||||
|
while (factory->EnumAdapterByGpuPreference(i, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, IID_PPV_ARGS(&adapter)) != DXGI_ERROR_NOT_FOUND) {
|
||||||
while (factory->EnumAdapters(i, &adapter) != DXGI_ERROR_NOT_FOUND) {
|
|
||||||
DXGI_ADAPTER_DESC desc;
|
DXGI_ADAPTER_DESC desc;
|
||||||
if (adapter->GetDesc(&desc) != S_OK) {
|
hr = adapter->GetDesc(&desc);
|
||||||
qWarning() << "Could not get DXGI adapter description";
|
if (SUCCEEDED(hr)) {
|
||||||
} else {
|
|
||||||
out << "GPU: " + QString::fromWCharArray(desc.Description); // NOLINT(*-pro-bounds-array-to-pointer-decay, *-no-array-decay)
|
out << "GPU: " + QString::fromWCharArray(desc.Description); // NOLINT(*-pro-bounds-array-to-pointer-decay, *-no-array-decay)
|
||||||
|
} else {
|
||||||
|
qWarning() << "Could not get DXGI adapter description:" << Qt::hex << hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter->Release();
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
factory->Release();
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue