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++

feat(tools): Qt hosts the native D3D12 video window, measured

Veyra Goal Agent07d26e9c5e6d
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bc4d639d..5973f8be 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -733,7 +733,22 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avform
target_include_directories(veyra_srfg_depth_tests PRIVATE ${FFMPEG_INCLUDE_DIRS})
target_compile_definitions(veyra_srfg_depth_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN VEYRA_PROJECT_ROOT="${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(veyra_srfg_depth_tests PRIVATE veyra_engine)
- add_executable(veyra_sr_reconstruction_tests tests/integration/SrReconstructionTests.cpp)
+ # Qt 6.8.3 is staged under deps/ (the user allowed the latest Qt). The probe is
+# opt-in so a normal product build never depends on Qt being present.
+option(VEYRA_BUILD_QT_PROBE "Build the Qt + D3D12 host probe" OFF)
+if(VEYRA_BUILD_QT_PROBE)
+ find_package(Qt6 6.8 QUIET COMPONENTS Core Gui Qml Quick QuickControls2)
+endif()
+
+# Qt + D3D12 host probe (S3.0): answers whether Qt can host the native video
+# swapchain window without costing present latency. Diagnostic only.
+if(VEYRA_BUILD_QT_PROBE AND Qt6_FOUND)
+ add_executable(veyra_qt_probe tools/qt_probe/main.cpp)
+ target_compile_features(veyra_qt_probe PRIVATE cxx_std_20)
+ target_link_libraries(veyra_qt_probe PRIVATE veyra_engine Qt6::Core Qt6::Gui Qt6::Qml Qt6::Quick Qt6::QuickControls2)
+endif()
+
+add_executable(veyra_sr_reconstruction_tests tests/integration/SrReconstructionTests.cpp)
target_compile_features(veyra_sr_reconstruction_tests PRIVATE cxx_std_20)
target_include_directories(veyra_sr_reconstruction_tests PRIVATE ${FFMPEG_INCLUDE_DIRS})
target_compile_definitions(veyra_sr_reconstruction_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN VEYRA_PROJECT_ROOT="${CMAKE_CURRENT_SOURCE_DIR}")
diff --git a/docs/UI_MIGRATION_EXECUTION_2026-09-25.md b/docs/UI_MIGRATION_EXECUTION_2026-09-25.md
index 5d8551dd..940468d9 100644
--- a/docs/UI_MIGRATION_EXECUTION_2026-09-25.md
+++ b/docs/UI_MIGRATION_EXECUTION_2026-09-25.md
@@ -26,7 +26,8 @@
| S2.0 | NR 叠层可行性探针 | 完成 | `checkpoint/ui-mig-s2.0` | **4/6/8 个句柄全部成功** |
| S2.1 | NR 叠层实现 | 完成(已修 G1) | `checkpoint/ui-mig-s2.1b` | 13 项原有哈希逐像素一致;1/2/3/4 层均为真实图像 |
| S2.1b | NR 时域防闪烁修复 | 完成 | `checkpoint/ui-mig-s2.1b` | 单层路径不变;叠层下开关由“完全无效”变为生效 |
-| S3.0 | Qt 6.8.3 安装 | 完成 | | `E:\项目\Veyra\deps\qt.8.3\msvc2022_64`,含 Core/Gui/Qml/Quick/QuickControls2 + windeployqt |
+| S3.0 | Qt 6.8.3 安装 + 承载 D3D12 窗口实测 | 完成 | `checkpoint/ui-mig-s3.0` | 499/499 Present 成功,平均 0.205 ms,QML 动画未被拖慢 |
+| S3.0b | (旧行)Qt 6.8.3 安装 | 完成 | | `E:\项目\Veyra\deps\qt.8.3\msvc2022_64`,含 Core/Gui/Qml/Quick/QuickControls2 + windeployqt |
## 发现并修复的 bug
@@ -39,6 +40,28 @@
## 日志
+### S3.0(2026-09-25)Qt 承载 D3D12 视频窗口 —— 可行性已实测通过
+这是整个迁移**唯一真正的技术风险**:视频由一个原生子 HWND 承载,Veyra 为它创建 D3D12 flip-model swapchain。如果 Qt 接管了呈现,低延迟优势就没了。已用最小探针实测,不再靠推断。
+
+探针:`tools/qt_probe/main.cpp`(工具 `veyra_qt_probe`),QML 窗口里放一个持续旋转的矩形(模拟真实界面动画),同时按 ~120 Hz 上限向原生子窗口 Present,计时每个 Present 并统计 QML 动画帧数。
+
+**本机实测(RTX 5070,100 Hz 面板,Qt 6.8.3)**
+| 指标 | 结果 |
+|---|---|
+| Present 次数 | 499 次,**失败 0** |
+| 平均 Present 耗时 | **0.205 ms** |
+| Present 期间 QML 动画帧 | 402 帧 / 4 秒 ≈ 100/s,**正好是面板刷新率,未被拖慢** |
+
+**结论**:Qt 可以承载原生 D3D12 呈现窗口,**不需要** `QQuickWidget`、`QQuickRenderControl` 或任何把视频合成进 QML 场景图的方案。视频仍是原生子窗口、自己的 swapchain、自己的 Present 调用;QML 只负责它周围和上面的界面层。低延迟路径得以保留。计划中原定的 `WindowContainer` 方案(Qt 6.7+ 支持,原生窗口始终绘制在 QML 场景之上)成立。
+
+**过程中修掉的两个真问题**
+1. `EngineController.cpp:1455`:同一个 lambda 无条件捕获 `&remote`,而 `remote` 只在 `VEYRA_ENABLE_REMOTEPLAY` 打开时声明 ⇒ **关闭 remoteplay 的配置根本编译不过**。已把该捕获放进同一个宏。这不是 Qt 引入的,是既有配置组合没人编译过。
+2. Qt 部署:`windeployqt` 不扫描 QML import,QML 模块要单独拷贝;`qtquickcontrols2plugin.dll` 还需要 `bin\*.dll` 里的 Qt 库才能加载。已固化为文档步骤。
+
+**未完成 / 不夸大**:以上只证明“承载可行 + Present 不被拖慢”。**没有**验证:QML 界面本身的渲染开销、窗口缩放/移动、多显示器与 HDR 输出、真实播放负载下的端到端延迟。这些要在 S4 用真正的播放器界面复测。探针只调用 Present,不画内容,所以它的 0.205 ms 是**呈现开销**,不是端到端延迟。
+
+代码:`tools/qt_probe/main.cpp`、`scripts/build-qt-probe.{ps1,cmd}`(独立构建目录,产品构建树未被 Qt 重配置)。
+
### 单元测试基线口径(2026-09-25 核对,重要)
本仓库**当前就有大量单元测试在本机失败**,且与本次迁移无关。对照 S0(迁移开工时,16:14)与当前(21:30)两次完整跑:
- S0:pass=40 fail=35 skip=3;当前:pass=44 fail=33 skip=3。
diff --git a/scripts/build-qt-probe.cmd b/scripts/build-qt-probe.cmd
new file mode 100644
index 00000000..41c00527
--- /dev/null
+++ b/scripts/build-qt-probe.cmd
@@ -0,0 +1,24 @@
+@echo off
+rem Qt 6.8.3 + D3D12 host probe (S3.0). Its own build directory so the verified
+rem product build tree is never reconfigured by Qt. Non-ASCII paths come from the
+rem environment: a .cmd is parsed in the ANSI code page.
+rem Use scripts/build-qt-probe.ps1.
+call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat" >nul 2>&1
+if errorlevel 1 exit /b 4
+set "ROOT=%~dp0.."
+if "%VEYRA_QT_OUT%"=="" exit /b 3
+set "OUT=%VEYRA_QT_OUT%"
+if not "%VEYRA_QT_TMP%"=="" set "TEMP=%VEYRA_QT_TMP%"
+if not "%VEYRA_QT_TMP%"=="" set "TMP=%VEYRA_QT_TMP%"
+set "CMAKE=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
+if not exist "%OUT%\CMakeCache.txt" (
+ "%CMAKE%" --preset x64-release -S "%ROOT%" -B "%OUT%" -DVEYRA_BUILD_QT_PROBE=ON -DCMAKE_PREFIX_PATH="%VEYRA_QT_DIR%" -DVEYRA_ENABLE_EXPERIMENTAL_DLSSNR=ON -DVEYRA_DLSS_SDK_ROOT="%ROOT%\third_party_local\nvidia\DLSS_SDK_310.7.0" -DVEYRA_NVOF_SDK_ROOT="%ROOT%\third_party_local\nvidia\Optical_Flow_SDK_5.0.7" -DVEYRA_NVENC_HEADERS_ROOT="%ROOT%\third_party_local\nvidia\nv-codec-headers-13.0" -DVEYRA_XESS_ROOT="%ROOT%\third_party_local\intel\xess-3.0.2" -DVEYRA_FIDELITYFX_ROOT="%ROOT%\third_party_local\amd\FidelityFX-SDK\sdk" -DVEYRA_FIDELITYFX2_ROOT="%ROOT%\third_party_local\amd\FidelityFX-SDK-2.3.0\Kits\FidelityFX" -DVEYRA_FFMPEG_ROOT="C:\veyra-deps\ffmpeg-ps5-dav1d-installed" -DVEYRA_CLIP_TOOLS_ROOT="C:\veyra-deps\tools-installed\x64-windows"
+ if errorlevel 1 exit /b 5
+)
+if "%~1"=="" (
+ "%CMAKE%" --build "%OUT%"
+) else (
+ "%CMAKE%" --build "%OUT%" --target %*
+)
+if errorlevel 1 exit /b 6
+exit /b 0
diff --git a/scripts/build-qt-probe.ps1 b/scripts/build-qt-probe.ps1
new file mode 100644
index 00000000..b88cb6dd
--- /dev/null
+++ b/scripts/build-qt-probe.ps1
@@ -0,0 +1,12 @@
+# Wrapper for scripts/build-qt-probe.cmd: sets the non-ASCII paths (a .cmd is
+# parsed in the ANSI code page) and runs the build through cmd's redirection.
+param([string[]]$Targets = @(), [string]$Log = 'E:\项目\Veyra\logs\ui-qml-migration-20260925\qt-build.log')
+$env:VEYRA_QT_OUT = 'E:\项目\Veyra\build\qt-probe-20260925'
+$env:VEYRA_QT_TMP = 'E:\项目\Veyra\tmp\ui-qml-migration-20260925'
+$env:VEYRA_QT_DIR = 'E:\项目\Veyra\deps\qt\6.8.3\msvc2022_64'
+$cmd = Join-Path $PSScriptRoot 'build-qt-probe.cmd'
+& cmd.exe /c "`"$cmd`" $($Targets -join ' ') > `"$Log`" 2>&1"
+$code = $LASTEXITCODE
+Get-Content -LiteralPath $Log -Tail 30 -Encoding utf8
+"exit=$code"
+exit $code
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index 18d4a189..c24a93a3 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -1452,7 +1452,11 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
// loop, so all of these are declared above it. Adding a reference to a
// local declared after that guard is now a compile error instead of a
// silent dangling reference.
- if(!liveScheduler->push([this,&anchor,&anchorMs,&captureSource,&fedFsrGenerated,&fedFsrPresented,&fedXessGenerated,&fedXessPresented,&lastFilePresentLateness,&lastFilePresentedMs,&liveSubmissions,&presentationCompletedReal,&remote,&seekDecoded,&seekStarted,&audio,&audioPipe,&audioStarted,&cadence,&ctx,&fileAudioAlignPending,&fileAwaitingVideo,&fileInputEnded,&frameFlow,&graph,&host100ns,&isCapture,&isImage,&livePresent,&liveScheduler,&nextFgDeadlineLog,&nowMs,&options,&pendingCompletions,&physicalCapture,&presentEntryDeviation,&presentReturnDeviation,&presentationEffective,&presentationGeneration,&presentationSkippedGenerated,&presenter,&ring,&runSessionId,&seekPreviewPending,&traceFrame,&traceSubframes,watch,step,timeline,captureArrival,baselineReady,delayEnhanced,activeSeekId,lineage,jobGeneration,rereadCached,sourceIntervalMs,flow=frameFlow](int64_t now)->LiveGpuScheduler::Step{
+ if(!liveScheduler->push([this,&anchor,&anchorMs,&captureSource,&fedFsrGenerated,&fedFsrPresented,&fedXessGenerated,&fedXessPresented,&lastFilePresentLateness,&lastFilePresentedMs,&liveSubmissions,&presentationCompletedReal,
+#ifdef VEYRA_ENABLE_REMOTEPLAY
+ &remote,
+#endif
+ &seekDecoded,&seekStarted,&audio,&audioPipe,&audioStarted,&cadence,&ctx,&fileAudioAlignPending,&fileAwaitingVideo,&fileInputEnded,&frameFlow,&graph,&host100ns,&isCapture,&isImage,&livePresent,&liveScheduler,&nextFgDeadlineLog,&nowMs,&options,&pendingCompletions,&physicalCapture,&presentEntryDeviation,&presentReturnDeviation,&presentationEffective,&presentationGeneration,&presentationSkippedGenerated,&presenter,&ring,&runSessionId,&seekPreviewPending,&traceFrame,&traceSubframes,watch,step,timeline,captureArrival,baselineReady,delayEnhanced,activeSeekId,lineage,jobGeneration,rereadCached,sourceIntervalMs,flow=frameFlow](int64_t now)->LiveGpuScheduler::Step{
using State=LiveGpuScheduler::State;auto& batch=watch->output;auto& s=*step;
auto updatePending=[&](LiveStepState*){
unsigned left=0;for(unsigned i=s.next;i<batch.batch.count;++i)if(batch.batch.frames[i].kind!=pipeline::FrameKind::Generated||batch.batch.frames[i].validity==pipeline::GenerationValidity::Valid)++left;
diff --git a/tools/qt_probe/main.cpp b/tools/qt_probe/main.cpp
new file mode 100644
index 00000000..c9f086ca
--- /dev/null
+++ b/tools/qt_probe/main.cpp
@@ -0,0 +1,211 @@
+// Qt + D3D12 host probe (S3.0).
+//
+// The migration's one real technical risk: the video is presented by a native
+// child HWND that Veyra creates a D3D12 swapchain for. Qt must host that window
+// without taking over presentation, or the low-latency path is lost. This probe
+// answers three questions the plan depends on, and nothing else:
+//
+// 1. Does the video HWND render and present on top of the QML scene?
+// 2. Does the overlay QML (controls) stay visible and interactive?
+// 3. Does present still work while the QML scene animates (the latency risk)?
+//
+// It reports frame counts and present timing so the answers are numbers, not
+// impressions.
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include <QQuickWindow>
+#include <QTimer>
+#include <QElapsedTimer>
+#include <QDebug>
+#include <QWindow>
+#include <QFile>
+#include <QDir>
+#include <QLoggingCategory>
+
+#include <windows.h>
+#include <chrono>
+#include <cstdio>
+#include <atomic>
+#include <thread>
+
+namespace {
+// Progress marker: if the probe hangs, the watchdog prints where, which is the
+// answer we actually need. A silent hang would tell us nothing.
+std::atomic<const char*> g_stage{"start"};
+void mark(const char* what) {
+ g_stage.store(what, std::memory_order_relaxed);
+ std::printf("qt-probe: stage=%s\n", what);
+ std::fflush(stdout);
+}
+// Hard stop. Qt plus a native swapchain can block in a present or a message
+// pump; a diagnostic must still return a verdict.
+void armWatchdog(int seconds) {
+ std::thread([seconds] {
+ std::this_thread::sleep_for(std::chrono::seconds(seconds));
+ std::printf("qt-probe WATCHDOG after %ds at stage=%s\n", seconds,
+ g_stage.load(std::memory_order_relaxed));
+ std::fflush(stdout);
+ std::_Exit(9);
+ }).detach();
+}
+} // namespace
+
+#include "veyra/Log.h"
+#include "veyra/gfx/CommandSlotRing.h"
+#include "veyra/gfx/D3D12DeviceContext.h"
+#include "veyra/gfx/PresentSink.h"
+
+using namespace veyra;
+
+namespace {
+// A native child window: exactly what the product presents into today.
+HWND g_video = nullptr;
+LRESULT CALLBACK videoProc(HWND h, UINT m, WPARAM w, LPARAM l) {
+ if (m == WM_ERASEBKGND) return 1;
+ return DefWindowProcW(h, m, w, l);
+}
+HWND createVideoWindow(HWND parent) {
+ static bool registered = false;
+ const wchar_t* cls = L"VeyraQtProbeVideo";
+ if (!registered) {
+ WNDCLASSEXW wc{sizeof(wc)};
+ wc.lpfnWndProc = videoProc; wc.hInstance = GetModuleHandleW(nullptr);
+ wc.hCursor = LoadCursorW(nullptr, IDC_ARROW);
+ wc.lpszClassName = cls; wc.style = CS_HREDRAW | CS_VREDRAW;
+ RegisterClassExW(&wc); registered = true;
+ }
+ return CreateWindowExW(0, cls, L"", WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
+ 0, 0, 100, 100, parent, nullptr, GetModuleHandleW(nullptr), nullptr);
+}
+struct ProbeStats {
+ int prepared = 0, presented = 0, failed = 0;
+ double prepareMs = 0, presentMs = 0;
+ int qmlTicks = 0;
+};
+} // namespace
+
+int main(int argc, char** argv) {
+ setvbuf(stdout, nullptr, _IONBF, 0);
+ armWatchdog(20);
+ mark("qapp");
+ // The probe is a real Qt app; it must also be a console app so the numbers
+ // land in a log for the execution record.
+ QGuiApplication app(argc, argv);
+ // Qt's own diagnostics are the only way to know why a QML load failed; send
+ // them somewhere we can read instead of losing them to a hidden console.
+ qInstallMessageHandler([](QtMsgType, const QMessageLogContext&, const QString& m) {
+ std::printf("qt-msg: %s\n", m.toUtf8().constData());
+ std::fflush(stdout);
+ });
+ std::printf("qt-probe: qtVersion=%s qmlImportPath=%s\n",
+ qVersion(), qgetenv("QML2_IMPORT_PATH").constData());
+ std::fflush(stdout);
+ QQmlApplicationEngine engine;
+ engine.addImportPath(QCoreApplication::applicationDirPath() + "/qml");
+
+ const char* qml = R"QML(
+import QtQuick
+import QtQuick.Controls
+Window {
+ id: root
+ width: 960; height: 640
+ visible: true
+ color: "#0b0b0d"
+ // A QML item that animates continuously: this is the interference source we
+ // need present to survive. If presenting stalls while this runs, the
+ // migration would cost latency.
+ Rectangle {
+ id: spinner
+ width: 120; height: 120; radius: 12
+ color: "#7aa2f7"
+ anchors.right: parent.right; anchors.top: parent.top
+ anchors.margins: 24
+ NumberAnimation on rotation { from: 0; to: 360; duration: 1200; loops: Animation.Infinite }
+ }
+ Text {
+ anchors.left: parent.left; anchors.bottom: parent.bottom
+ anchors.margins: 16
+ color: "white"; font.pixelSize: 20
+ text: "QML overlay alive: " + spinner.rotation.toFixed(0)
+ }
+ // The slot the native video window is placed into.
+ Item { id: videoHost; objectName: "videoHost"; anchors.fill: parent; anchors.margins: 0 }
+}
+)QML";
+ engine.loadData(QByteArray(qml));
+ if (engine.rootObjects().isEmpty()) { std::fprintf(stderr, "QML failed to load\n"); return 1; }
+ auto* window = qobject_cast<QQuickWindow*>(engine.rootObjects().first());
+ if (!window) { std::fprintf(stderr, "root is not a QQuickWindow\n"); return 1; }
+
+ // Native parent handle of the QML window: the video HWND becomes its child,
+ // which is how the bridge works without Qt touching presentation.
+ mark("winId");
+ HWND parent = reinterpret_cast<HWND>(window->winId());
+ g_video = createVideoWindow(parent);
+ if (!g_video) { std::fprintf(stderr, "video child window failed\n"); return 1; }
+ std::printf("qt-probe: qml window hwnd=%p video child hwnd=%p\n", (void*)parent, (void*)g_video);
+
+ gfx::D3D12DeviceContext ctx;
+ gfx::DeviceContextDesc ddesc;
+ Status st = Status::Ok;
+ if (!ctx.initialize(ddesc, st)) { std::fprintf(stderr, "device init failed\n"); return 1; }
+ gfx::CommandSlotRing ring;
+ if (!ring.initialize(ctx.device(), ctx.directQueue(), ctx.fence(), ctx.fenceEvent(), 4, st)) return 1;
+
+ RECT rc{}; GetClientRect(g_video, &rc);
+ gfx::PresentSink present;
+ gfx::PresentSink::Desc pd;
+ pd.targetWindow = g_video;
+ pd.width = uint32_t(std::max<LONG>(rc.right, 640));
+ pd.height = uint32_t(std::max<LONG>(rc.bottom, 360));
+ pd.vsync = false; // the product's low-latency setting
+ pd.title = L"VeyraQtProbe";
+ Status pst = Status::Ok;
+ mark("present-init");
+ if (!present.initialize(ctx.device(), ctx.directQueue(), pd, pst)) {
+ std::fprintf(stderr, "present sink init failed\n");
+ return 1;
+ }
+
+ auto stats = std::make_shared<ProbeStats>();
+ QElapsedTimer wall; wall.start();
+ auto* timer = new QTimer(&app);
+ // Present at a fixed rate while QML animates, and measure how long each
+ // present takes. The point is the trend, not the absolute figure.
+ QObject::connect(timer, &QTimer::timeout, [&, stats] {
+ if (wall.elapsed() > 4000) {
+ std::printf("qt-probe RESULT prepared=%d presented=%d failed=%d "
+ "avgPrepare=%.3fms avgPresent=%.3fms qmlFrames=%d\n",
+ stats->prepared, stats->presented, stats->failed,
+ stats->prepared ? stats->prepareMs / stats->prepared : 0.0,
+ stats->presented ? stats->presentMs / stats->presented : 0.0,
+ stats->qmlTicks);
+ QCoreApplication::quit();
+ return;
+ }
+ // The sink only presents; drawing is the graph's job and is out of
+ // scope here. Present timing is the number that matters: it must not
+ // grow while the QML scene animates.
+ bool closed = false;
+ present.processMessages(closed);
+ if (closed) { QCoreApplication::quit(); return; }
+ const auto t1 = std::chrono::steady_clock::now();
+ Status st2 = Status::Ok;
+ if (present.present(st2)) {
+ const auto t2 = std::chrono::steady_clock::now();
+ stats->presentMs += std::chrono::duration<double, std::milli>(t2 - t1).count();
+ ++stats->presented;
+ } else ++stats->failed;
+ ++stats->prepared;
+ });
+ // Count QML animation frames to prove the scene kept running while the
+ // native window presented.
+ QObject::connect(window, &QQuickWindow::frameSwapped, [stats] { ++stats->qmlTicks; });
+ mark("exec");
+ timer->start(8); // ~120 Hz ceiling: faster than any panel we target
+
+ const int rc2 = app.exec();
+ present.shutdown();
+ DestroyWindow(g_video);
+ return rc2;
+}