Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

GPU usage orb measures one adapter, chosen in settings (default discrete)

Veyra Goal Agent563e18a3722b
diff --git a/include/veyra/ui/QmlPlayerBridge.h b/include/veyra/ui/QmlPlayerBridge.h
index 9667c9ef..ddecaf35 100644
--- a/include/veyra/ui/QmlPlayerBridge.h
+++ b/include/veyra/ui/QmlPlayerBridge.h
@@ -186,6 +186,11 @@ class QmlPlayerBridge : public QObject {
// stored choice (preferences.audioDevice, empty = system default) and what
// the renderer actually opened, including a fallback to the default.
Q_PROPERTY(QVariantList audioDevices READ audioDevices NOTIFY audioDevicesChanged)
+ // The GPU the "GPU 占用" orb measures (设置 → 通用与外观): [{id, label}], the first
+ // entry ("", 自动) picks the high-performance (discrete) GPU. Field report
+ // 2026-10-02: the orb used to add the integrated and the discrete GPU together.
+ Q_PROPERTY(QVariantList gpuMonitorChoices READ gpuMonitorChoices CONSTANT)
+ Q_PROPERTY(QString gpuMonitorName READ gpuMonitorName NOTIFY preferencesChanged)
Q_PROPERTY(QString audioOutputStatus READ audioOutputStatus NOTIFY audioDevicesChanged)
Q_PROPERTY(bool audioOutputFallback READ audioOutputFallback NOTIFY audioDevicesChanged)
Q_PROPERTY(QString logFile READ logFile CONSTANT)
@@ -606,6 +611,8 @@ public:
Q_INVOKABLE void openFeedbackPage();
Q_INVOKABLE void openReleasesPage();
QVariantList audioDevices() const;
+ QVariantList gpuMonitorChoices() const;
+ QString gpuMonitorName() const;
QString audioOutputStatus() const;
bool audioOutputFallback() const;
Q_INVOKABLE void refreshAudioDevices();
diff --git a/qml/Veyra/ProPage.qml b/qml/Veyra/ProPage.qml
index 866043fd..96d21ccd 100644
--- a/qml/Veyra/ProPage.qml
+++ b/qml/Veyra/ProPage.qml
@@ -246,7 +246,7 @@ VPage {
fraction: veyra.gpuUtilization / 100
value: known ? Math.round(veyra.gpuUtilization) + "%" : "—"
label: "GPU 占用"
- tip: "Windows GPU 引擎占用率(最忙的引擎类型,全系统),每秒采样"
+ tip: "Windows GPU 引擎占用率(" + (veyra.gpuMonitorName || "全部显卡") + ",最忙的引擎类型,全系统),每秒采样;在 设置 → 通用与外观 中更换监控的显卡"
}
// How much of one source frame's time the enhancement chain uses (the plan's
// "负载预算 = 耗时 / 预算"). It used to show output fps / target fps, which
diff --git a/qml/Veyra/SettingsPage.qml b/qml/Veyra/SettingsPage.qml
index ac36a200..4e22e828 100644
--- a/qml/Veyra/SettingsPage.qml
+++ b/qml/Veyra/SettingsPage.qml
@@ -243,6 +243,17 @@ VPage {
onPicked: id => veyra.setPreference("windowSize", id)
}
}
+ VRow {
+ label: "GPU 占用监控"
+ hint: "专业页「GPU 占用」只统计这一块显卡" + (veyra.gpuMonitorName ? ";当前:" + veyra.gpuMonitorName : "")
+ VSelect {
+ objectName: "set-monitor-gpu"
+ implicitWidth: 230
+ options: veyra.gpuMonitorChoices
+ value: (options.find(o => o.id === (veyra.preferences.monitorGpu || "")) || options[0] || { label: "—" }).label
+ onPicked: id => veyra.setPreference("monitorGpu", id)
+ }
+ }
}
VGroup {
VRow {
diff --git a/scripts/ui-check/gpu-monitor.qml b/scripts/ui-check/gpu-monitor.qml
new file mode 100644
index 00000000..076797a5
--- /dev/null
+++ b/scripts/ui-check/gpu-monitor.qml
@@ -0,0 +1,29 @@
+ // ---- GPU usage orb measures one adapter, chosen in settings (default: high-performance) ----
+ Timer { interval: 150; running: true; repeat: true; onTriggered: veyra.logUi("uitest-tick", "") }
+ Timer {
+ interval: 1000; running: true; repeat: true
+ property int ticks: 0
+ property var choices: []
+ onTriggered: {
+ ++ticks
+ if (ticks === 1) {
+ choices = veyra.gpuMonitorChoices
+ veyra.logUi("uitest", "UITEST_NOTE choices " + choices.map(c => (c.id || "auto") + "=" + c.label).join(" | ") + " monitor=" + veyra.gpuMonitorName)
+ veyra.openUrl("@VIDEO@")
+ }
+ if (ticks >= 5 && ticks <= 9) veyra.logUi("uitest", "UITEST_NOTE auto gpu=" + veyra.gpuUtilization.toFixed(1) + " known=" + veyra.gpuUtilizationKnown)
+ if (ticks === 10) {
+ const other = choices.length > 2 ? choices[2].id : (choices.length > 1 ? choices[1].id : "")
+ veyra.logUi("uitest", "UITEST_NOTE switch to " + other + " ok=" + veyra.setPreference("monitorGpu", other) + " monitor=" + veyra.gpuMonitorName)
+ }
+ if (ticks >= 13 && ticks <= 16) veyra.logUi("uitest", "UITEST_NOTE chosen gpu=" + veyra.gpuUtilization.toFixed(1))
+ if (ticks === 17) {
+ const bad = veyra.setPreference("monitorGpu", "dead:beef:00000000")
+ veyra.setPreference("monitorGpu", "")
+ root.goPage("set")
+ veyra.logUi("uitest", "UITEST_NOTE unknown id accepted=" + bad + " back to auto monitor=" + veyra.gpuMonitorName)
+ }
+ if (ticks === 19) veyra.logUi("uitest", "UITEST_SHOT settings")
+ if (ticks === 20) { veyra.logUi("uitest", "UITEST_DONE"); running = false }
+ }
+ }
diff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cpp
index 67c76bb7..34367915 100644
--- a/src/ui/QmlPlayerBridge.cpp
+++ b/src/ui/QmlPlayerBridge.cpp
@@ -84,6 +84,7 @@ namespace Gdiplus { using std::min; using std::max; }
#include <pdhmsg.h>
#pragma comment(lib, "pdh.lib")
#include <atomic>
+#include <set>
#include <mutex>
#include <thread>
#include "veyra/pipeline/ColorGradeTables.h"
@@ -91,7 +92,7 @@ namespace Gdiplus { using std::min; using std::max; }
#include "veyra/gfx/XessMfgUnlock.h"
#include "veyra/gfx/D3D12DeviceContext.h"
#include "veyra/gfx/PresentationHooks.h"
-#include <dxgi1_4.h>
+#include <dxgi1_6.h>
#include <wrl/client.h>
#include "veyra/ngx/NrArchitecturePolicy.h"
#include "veyra/source/CaptureCardSource.h"
@@ -331,6 +332,65 @@ struct QmlPlayerBridge::Impl {
int historyTicks = 0;
QString runStatus, runLevel, runDetail;
std::atomic<double> gpuUtil{-1.0};
+ // Hardware adapters in Windows' high-performance order (discrete first). The
+ // sampler only counts engines of the adapter whose LUID is in gpuMonitorLuid
+ // (0: every adapter, the old behaviour, used only when none was found).
+ struct GpuAdapter { QString id, name; uint32_t luidHigh = 0, luidLow = 0; };
+ std::vector<GpuAdapter> gpuAdapters;
+ std::atomic<uint64_t> gpuMonitorLuid{0};
+ QString gpuMonitorName;
+ // LUIDs that have "GPU Engine" counter instances. DXGI can list one physical GPU
+ // twice (a virtual display driver such as GameViewer's exposes a second adapter
+ // with the GPU's own name); only the real one has engines to measure.
+ static std::set<uint64_t> gpuEngineLuids() {
+ std::set<uint64_t> found;
+ DWORD counterBytes = 0, instanceBytes = 0;
+ if (PdhEnumObjectItemsW(nullptr, nullptr, L"GPU Engine", nullptr, &counterBytes, nullptr, &instanceBytes, PERF_DETAIL_WIZARD, 0) != PDH_MORE_DATA)
+ return found;
+ std::vector<wchar_t> counters(counterBytes + 1), instances(instanceBytes + 1);
+ if (PdhEnumObjectItemsW(nullptr, nullptr, L"GPU Engine", counters.data(), &counterBytes, instances.data(), &instanceBytes, PERF_DETAIL_WIZARD, 0) != ERROR_SUCCESS)
+ return found;
+ for (const wchar_t* name = instances.data(); *name; name += wcslen(name) + 1) {
+ unsigned high = 0, low = 0;
+ if (const wchar_t* at = wcsstr(name, L"luid_"); at && swscanf_s(at, L"luid_0x%x_0x%x", &high, &low) == 2)
+ found.insert(uint64_t(high) << 32 | low);
+ }
+ return found;
+ }
+ void enumerateGpuAdapters() {
+ const auto measured = gpuEngineLuids();
+ Microsoft::WRL::ComPtr<IDXGIFactory6> factory;
+ if (FAILED(CreateDXGIFactory2(0, IID_PPV_ARGS(&factory)))) return;
+ Microsoft::WRL::ComPtr<IDXGIAdapter1> adapter;
+ for (UINT i = 0; SUCCEEDED(factory->EnumAdapterByGpuPreference(i, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, IID_PPV_ARGS(adapter.ReleaseAndGetAddressOf()))); ++i) {
+ DXGI_ADAPTER_DESC1 d{};
+ if (FAILED(adapter->GetDesc1(&d)) || (d.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) || d.VendorId == 0x1414) continue;
+ const uint64_t luid = uint64_t(uint32_t(d.AdapterLuid.HighPart)) << 32 | d.AdapterLuid.LowPart;
+ if (!measured.empty() && !measured.count(luid)) {
+ veyra::log::info("perf", std::format("gpu adapter skipped (no engine counters) luid={:08X}:{:08X} {}", uint32_t(luid >> 32), uint32_t(luid),
+ QString::fromWCharArray(d.Description).toStdString()));
+ continue;
+ }
+ // LUIDs change at every boot, so the saved choice is vendor:device:subsystem,
+ // with an ordinal for two identical cards.
+ QString id = QStringLiteral("%1:%2:%3").arg(d.VendorId, 4, 16, QLatin1Char('0')).arg(d.DeviceId, 4, 16, QLatin1Char('0')).arg(d.SubSysId, 8, 16, QLatin1Char('0'));
+ int same = 0;
+ for (const auto& a : gpuAdapters) if (a.id.section('#', 0, 0) == id) ++same;
+ if (same) id += QStringLiteral("#%1").arg(same);
+ gpuAdapters.push_back({id, QString::fromWCharArray(d.Description).trimmed(), uint32_t(d.AdapterLuid.HighPart), d.AdapterLuid.LowPart});
+ veyra::log::info("perf", std::format("gpu adapter {} id={} luid={:08X}:{:08X} dedicatedMiB={}", gpuAdapters.size() - 1,
+ id.toStdString(), uint32_t(d.AdapterLuid.HighPart), d.AdapterLuid.LowPart, d.DedicatedVideoMemory >> 20));
+ }
+ }
+ void resolveGpuMonitor() {
+ const QString wanted = prefString("monitorGpu");
+ const GpuAdapter* chosen = gpuAdapters.empty() ? nullptr : &gpuAdapters.front();
+ for (const auto& a : gpuAdapters) if (!wanted.isEmpty() && a.id == wanted) chosen = &a;
+ gpuMonitorLuid = chosen ? (uint64_t(chosen->luidHigh) << 32 | chosen->luidLow) : 0;
+ gpuMonitorName = chosen ? chosen->name : QString();
+ veyra::log::info("perf", std::format("gpu monitor wanted={} using={}", wanted.isEmpty() ? "auto" : wanted.toStdString(),
+ chosen ? chosen->name.toStdString() : "all adapters"));
+ }
double gpuPublished = -2.0;
double rateRatio = -1.0;
std::deque<double> frameTimes; // frame interval ms, newest last
@@ -675,6 +735,8 @@ QmlPlayerBridge::QmlPlayerBridge(engine::EngineController& engine, std::filesyst
connect(this,&QmlPlayerBridge::snapshotChanged,this,&QmlPlayerBridge::fgChoicesChanged);
connect(this,&QmlPlayerBridge::settingsChanged,this,&QmlPlayerBridge::fgChoicesChanged);
impl_->loadPrefs();
+ impl_->enumerateGpuAdapters();
+ impl_->resolveGpuMonitor();
connect(&impl_->exportQueue,&QmlExportQueueModel::changed,this,&QmlPlayerBridge::exportChanged);
if (qApp) qApp->installEventFilter(this);
#ifdef VEYRA_ENABLE_MOONLIGHT
@@ -4234,6 +4296,10 @@ bool QmlPlayerBridge::setPreference(const QString& key, const QVariant& value) {
stored = v;
} else if (key == QLatin1String("rememberPosition") || key == QLatin1String("dockPinned")) {
stored = value.toBool();
+ } else if (key == QLatin1String("monitorGpu")) {
+ const QString v = value.toString();
+ if (!v.isEmpty() && std::none_of(impl_->gpuAdapters.begin(), impl_->gpuAdapters.end(), [&](const auto& a) { return a.id == v; })) return false;
+ stored = v;
} else if (key == QLatin1String("windowSize")) {
const QString v = value.toString();
static const QStringList sizes{"1280x800", "1600x1000", "1920x1200", "last"};
@@ -4259,7 +4325,15 @@ void QmlPlayerBridge::applyPreference(const QString& key) {
if (key == QLatin1String("audioDevice")) sink::setPreferredRenderEndpoint(impl_->prefString("audioDevice").toStdWString());
else if (key == QLatin1String("audioForceStereo")) sink::setForceStereoDownmix(impl_->prefBool("audioForceStereo", false));
else if (key == QLatin1String("magewellLowLatency")) source::magewell::setLowLatencyPreference(impl_->prefBool("magewellLowLatency", false));
+ else if (key == QLatin1String("monitorGpu")) { impl_->resolveGpuMonitor(); impl_->gpuUtil = -1.0; emit perfChanged(); }
+}
+QVariantList QmlPlayerBridge::gpuMonitorChoices() const {
+ QVariantList out;
+ out << QVariantMap{{"id", QString()}, {"label", tr("自动(独立显卡)")}};
+ for (const auto& a : impl_->gpuAdapters) out << QVariantMap{{"id", a.id}, {"label", a.name}};
+ return out;
}
+QString QmlPlayerBridge::gpuMonitorName() const { return impl_->gpuMonitorName; }
QVariantList QmlPlayerBridge::audioDevices() const {
QVariantList out;
out << QVariantMap{{"id", QString()}, {"label", tr("跟随系统默认")}, {"isDefault", false}};
@@ -5164,9 +5238,14 @@ void QmlPlayerBridge::startGpuSampler() {
auto* items = reinterpret_cast<PDH_FMT_COUNTERVALUE_ITEM_W*>(buffer.data());
if (PdhGetFormattedCounterArrayW(counter, PDH_FMT_DOUBLE, &bytes, &count, items) != ERROR_SUCCESS) continue;
std::map<std::wstring, double> byType;
+ // Instance names carry the adapter: pid_<n>_luid_0x<high>_0x<low>_phys_..._engtype_<type>.
+ const uint64_t luid = impl->gpuMonitorLuid.load();
+ const std::wstring luidKey = luid ? std::format(L"luid_0x{:08x}_0x{:08x}_", uint32_t(luid >> 32), uint32_t(luid)) : std::wstring{};
for (DWORD i = 0; i < count; ++i) {
if (items[i].FmtValue.CStatus != PDH_CSTATUS_VALID_DATA && items[i].FmtValue.CStatus != PDH_CSTATUS_NEW_DATA) continue;
- const std::wstring name = items[i].szName ? items[i].szName : L"";
+ std::wstring name = items[i].szName ? items[i].szName : L"";
+ std::transform(name.begin(), name.end(), name.begin(), [](wchar_t ch) { return wchar_t(towlower(ch)); });
+ if (!luidKey.empty() && name.find(luidKey) == std::wstring::npos) continue;
const auto at = name.find(L"engtype_");
byType[at == std::wstring::npos ? std::wstring{} : name.substr(at + 8)] += items[i].FmtValue.doubleValue;
}