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++
perf(capture): eliminate redundant P010 and P016 upload staging
Veyra Goal Agentedfd886fb176
diff --git a/CMakeLists.txt b/CMakeLists.txtindex aff520dc..a246a8cb 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -821,6 +821,10 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avformtarget_link_libraries(veyra_popup_selector_tests PRIVATE veyra_base comctl32)add_dependencies(veyra_engine veyra_shader_hdr_video_sr veyra_shader_present_motion veyra_shader_present_blit)add_executable(veyra_hdr_color_tests tests/integration/HdrColorTests.cpp)+ add_executable(veyra_cpu_yuv_upload_tests tests/integration/CpuYuvUploadTests.cpp)+ target_compile_features(veyra_cpu_yuv_upload_tests PRIVATE cxx_std_20)+ target_compile_definitions(veyra_cpu_yuv_upload_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)+ target_link_libraries(veyra_cpu_yuv_upload_tests PRIVATE veyra_engine)add_executable(veyra_multichannel_tests tests/integration/MultichannelTests.cpp)target_compile_features(veyra_multichannel_tests PRIVATE cxx_std_20)target_compile_definitions(veyra_multichannel_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.mdindex de98b0bf..b17ddabf 100644--- a/docs/CURRENT_STATUS.md+++ b/docs/CURRENT_STATUS.md@@ -1,5 +1,15 @@# 当前项目状态 / Current Status+## 最新实修:5090 P010 采集反馈(2026-09-21)++工作分支 `codex/5090-capture-fg-20260921`,开工存档 `3953bff`。+已去掉 CPU P010/P016 上传前的冗余转换/复制;本机两轮 P010 上传中位耗时+约 2.4ms 降至 0.93–0.98ms,18 项实际 GPU 像素输出与基线完全一致,HDR+颜色测试及 DLSS 呈现资源回归通过。不改变画质、倍率或增加等待。+这不是 5090 整链路帧率验收;15 秒卡顿、欠速闪烁、高倍率不均匀仍未解决。+实测工况、范围和证据见 [5090 采集修复记录](RTX5090_CAPTURE_FG_REPAIR_2026-09-21.md)。+未更新既有便携包;本轮仅本地构建,无合并、推送或发布。+## 当前执行入口(2026-09-21,链路复核后)1.4.3 之后的完整修复、回退、诊断和未完成项总账见diff --git a/docs/RTX5090_CAPTURE_FG_REPAIR_2026-09-21.md b/docs/RTX5090_CAPTURE_FG_REPAIR_2026-09-21.mdnew file mode 100644index 00000000..1a21c067--- /dev/null+++ b/docs/RTX5090_CAPTURE_FG_REPAIR_2026-09-21.md@@ -0,0 +1,124 @@+# RTX5090 P010 capture / FG investigation++## Scope and checkpoint++- Pre-change checkpoint: `3953bff`; branch `codex/5090-capture-fg-20260921`.+- User log: `C:/Users/123/Desktop/logs-4knr+dlss质量光流X2,跑不满120,GPU占用60,5090(1).log`.+- Investigate DLSS/XeSS throughput, intermittent flicker and reported 15-second hitches. No quality reduction, automatic multiplier downgrade or fixed extra delay.+- Existing rejected experiments remain rejected; see `FG_EXPERIMENT_INDEX_2026-09-21.md`.++## Evidence from the supplied log++- RTX5090; 3840x2160 P010 capture at 60 Hz, native NR, DLSS 2X, SR off, manual PQ/BT2020 HDR with HDR output.+- Before the quality-flow switch: source 60 / submission approximately 120 FPS, flow P95 3.36 ms, NR 8.56 ms, GPU readiness 13.35 ms.+- At 14:07:07.584 a settings rebuild changes NVOF SDK performance level from 10 to 5. Rebuild lasts 1618 ms (create 1448 ms), accounting for about 95 mailbox overwrites. These are not steady-state losses.+- Afterwards: processed source about 56-58 FPS, submission 106-114 FPS, flow P95 5.27-5.45 ms, GPU readiness 14.7-15.3 ms, process CPU about 3.3-3.46 ms. Percentiles must not be summed as exact frame duration.+- Admission: 999 accepted / 1 rejected. Revision 4: 735 evaluated, 45 warmup, 690 valid, 0 invalid; 689 generated presented, 1 expired. This is not primarily mass FG admission rejection or generated-frame expiry.+- Repeated mailbox overwrites coincide with repeated history resets after rebuild. Dropped source frames must still reset temporal history. Reducing processing overhead may prevent some drops; removing the resets is not a valid fix.+- Low-queue mode starts after throughput already falls. Aggregate GPU utilization is insufficient to prove available capacity on the dependent critical path.+- Capture recording lasts only about 20 seconds and includes settings changes. It cannot establish a recurring 15-second hitch. Flicker mechanism remains unproven.++## Bounded implementation / validation++1. Measure and remove the redundant same-format CPU P010/P016 staging copy. Preserve bit depth, metadata, row pitch, negative stride, odd chroma dimensions and CPU luma analysis. No reads from write-combined upload memory.+2. Compare real GPU color/precision output before and after, then run focused HDR and live FG regressions. Hardware decode/import remains separate.+3. Inspect provider/history/presentation lifetimes and run bounded sustained playback for periodic stalls. Do not label unobserved user symptoms fixed.++Generated artifacts: `E:/项目/Veyra/tests/5090-capture-fg-20260921/`, `E:/项目/Veyra/tmp/5090-capture-fg-20260921/`. Existing build directory reused: `E:/项目/Veyra/build/1.4.4-xess-current-20260921-r1/`.++## Accepted change++`src/pipeline/EnhanceGraph.cpp` now copies matching CPU NV12/P010/P016 planes+directly into the already-fenced mapped upload slot. P010/P016 no longer pass+through a same-format swscale staging buffer followed by another full-frame+copy. Signed source pitch, padded rows, odd chroma dimensions and all input code+values are preserved. Scene/cadence analysis reads ordinary source CPU memory,+not write-combined upload memory. Hardware decode/import is unchanged.++No quality, optical-flow setting, FG multiplier, queue depth or presentation+delay was changed. This is a CPU upload improvement, not a rewritten scheduler.++## Verification on local RTX5070++Built `veyra`, `veyra_cpu_yuv_upload_tests`, `veyra_hdr_color_tests`,+`veyra_fg_sustained_tests`, `veyra_live_presentation_tests` and+`veyra_fg_presentation_tests` successfully in the existing isolated build.+The latter accepts an optional absolute runtime directory instead of requiring+runtime files in the source tree. Compilation alone is not test execution.++### Same-input CPU upload A/B++The user closed the running app before these measurements. Each format uses+240 4K frames, excludes 40 warmup frames, and measures CPU upload separately+from the GPU drain. Two baseline/fixed rounds, all exit 0:++| Format | Baseline P50/P95 ms, round 1 | Fixed P50/P95, round 1 | Baseline P50/P95, round 2 | Fixed P50/P95, round 2 |+| --- | --- | --- | --- | --- |+| NV12 | 0.4656 / 0.5279 | 0.4636 / 0.5420 | 0.4614 / 0.5177 | 0.4504 / 0.5075 |+| P010 | 2.3926 / 2.6036 | 0.9804 / 1.0819 | 2.4355 / 2.6131 | 0.9289 / 1.0011 |+| P016 | 2.0466 / 2.3053 | 0.9752 / 1.1339 | 2.1069 / 2.5139 | 0.9775 / 1.1005 |++P010 saves approximately 1.4-1.5 ms per CPU upload (59-62% of this stage's+median). This is not a measured end-to-end capture or RTX5090 FPS improvement.+NV12 shows no material change. `baseline/concurrent.stdout.log` was recorded+while another Veyra instance was running and is excluded from acceptance.++`CpuYuvUploadTests` checks actual GPU linear-output FP16 hashes for 18 cases:+NV12/P010/P016, widths 64/65/66, height 35, padded pitch, positive/negative stride.+All hashes match baseline exactly in both rounds. The existing no-argument HDR+color test also passes (PQ/HLG, ranges, formats, tone mapping and grading);+it does not exercise a real HDR NR model loop.++### Sustained playback and presentation++Three 60-second UI runs with `p001.mp4`, realtime 1080-internal NR and balanced+flow all exit 0. This file/hardware-decode setup bypasses the changed CPU upload+path and is a regression check, not the user's native4K quality-flow capture.+The bounded trace retains only the final window; its FPS is not a whole-run+average or physical scanout measurement.++| Mode | Retained window | App submit FPS | Interval P95/P99/max ms | Device GPU mean |+| --- | --- | --- | --- | --- |+| DLSS 2X | 9.74 s | 120.00 | 8.74 / 8.89 / 9.03 | 60.94% |+| DLSS 6X | 5.23 s | 297.88 | 4.62 / 16.80 / 17.44 | 91.24% |+| XeSS 4X | 13.65 s | 60.00 real inputs | 17.22 / 17.39 / 17.83, real inputs only | 88.35% |++XeSS's per-second SDK records report 60 real plus 180 generated submissions+per second in steady state (`framesPresented=4`); app Present intervals do not+measure its internally generated-frame cadence. Whole-run counters are DLSS2+3411 real / 3408 generated; DLSS6 3455 / 13145; XeSS4 3452 / 10338. DLSS6 still+does not meet uniform 360 FPS. Do not market the retained 298 FPS as a fix.++Both DLSS6 and XeSS4 recorded a wall-time NR Evaluate stall near source frame+605, approximately 10 seconds after initialization: 30.565 and 30.750 ms. A+35-second NR-only control had no graph wall-time event above the 30 ms logging+threshold and maintained 60 source FPS. The wrapper directly calls the runtime+with a null progress callback; no matching 600-frame/15-second timer was found+in that path. This does not identify the runtime/driver/descheduling cause,+prove repeated 15-second stalls, or measure 31 ms of GPU computation.++`veyra_fg_presentation_tests` passed DLSS 4X -> 6X -> 4X, generated counts+114/190/114, maximum checked pixel error 0, debug-layer errors 0. It exercises+history reset, window resize, output parity reuse and consumer-fence retirement.+This focused SDR test does not reproduce a user's HDR under-target flicker.++## Remaining issues and next evidence++- RTX5090 P010 capture acceptance is pending; this machine has RTX5070. Re-run+ the affected user's exact quality-flow/HDR/NR settings and compare source FPS,+ mailbox overwrites, reset frequency and generated submissions.+- The supplied capture interval is too short to establish 15-second periodicity.+ Need a continuous affected session with settings unchanged. Preserve the+ frame-605 observation as a separate unresolved lead.+- No proven bad resource reuse or mismatched original/generated color format+ was found in this audit. Under-target flicker remains unresolved; do not+ remove required history resets or add fixed delay to conceal it.+- No failed admission, overlap, queue-depth or forced-delay experiment was+ restored. No merge, push, release or distributable package was created.++Evidence root: `E:/项目/Veyra/tests/5090-capture-fg-20260921/`.+Upload logs are `baseline-{1,2}.stdout.log` and `fixed-{1,2}.stdout.log`;+HDR logs are `hdr.*.log`; sustained cases are under `sustained/`; the control+is under `nr-only/`; presentation logs are `presentation.*.log`.+The isolated runnable app is `app/veyra.exe`, dependent on local runtime/shader+junctions. Do not distribute this staging folder as a portable package.diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 03c34883..c3657830 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -6010,3 +6010,61 @@ reported zero FG candidates on the available local media/runtime, so an attempteassertion that an admission skip must be nonzero was removed as an invalidenvironment-dependent test requirement. This does not count as FG runtimeacceptance; it only verifies the cleanup build and the normal replay path.++## 2026-09-21 RTX5090 P010 capture feedback: accepted CPU upload improvement++Checkpoint `3953bff`; isolated branch `codex/5090-capture-fg-20260921` in+`E:/项目/Veyra/worktrees/playback-nr-20260920`. Supplied log analysis and complete+results: `docs/RTX5090_CAPTURE_FG_REPAIR_2026-09-21.md`. The log loses throughput+after native4K quality-flow selection; 999/1000 FG admissions were accepted,+so the evidence does not support blaming mass admission rejection here.++Removed redundant same-format CPU P010/P016 staging in EnhanceGraph. Matching+NV12/P010/P016 now upload exact rows once; luma analysis uses CPU source data.+Added CpuYuvUploadTests/CMake target and optional runtime path argument to the+existing FgPresentationTests, avoiding runtime artifacts in the source tree.++Build command (targets built across two invocations):++```powershell+./scripts/build-isolated.ps1 -Root 'E:/项目/Veyra/worktrees/playback-nr-20260920' -BuildDirectory 'E:/项目/Veyra/build/1.4.4-xess-current-20260921-r1' -DependencyCache 'E:/项目/Veyra/build/1.4.4-xess-current-20260921-r1/CMakeCache.txt' -TempDirectory 'E:/项目/Veyra/tmp/5090-capture-fg-20260921' -Targets @('veyra','veyra_cpu_yuv_upload_tests','veyra_hdr_color_tests','veyra_fg_sustained_tests','veyra_live_presentation_tests','veyra_fg_presentation_tests')+```++Build succeeded with existing dependency/FFmpeg warnings. Runtime test processes+use the same task TEMP/TMP and the patched FFmpeg bin on PATH. After the user+closed their app, ran the saved baseline and current CPU upload executable twice+each, no arguments; all exit 0. P010 median 2.39/2.44 -> 0.98/0.93 ms; 18 GPU+pixel hashes match exactly each round. NV12 unchanged. These are isolated CPU+upload measurements, not capture/FG or screen-latency measurements. The earlier+concurrent baseline is excluded. `veyra_hdr_color_tests.exe` without arguments+passed; it does not test actual HDR model execution.++```powershell+python scripts/acceptance/fg-utilization-matrix.py --exe 'E:/项目/Veyra/tests/5090-capture-fg-20260921/app/veyra.exe' --native 'E:/项目/Likely7 个人账号/Deepseek Grok/p001.mp4' --derived 'E:/项目/Veyra/tests/nr-fg-followup-20260921/p001-derived1080.mp4' --output 'E:/项目/Veyra/tests/5090-capture-fg-20260921/sustained' --temp 'E:/项目/Veyra/tmp/5090-capture-fg-20260921' --cases native-nr-dlss2 native-nr-dlss6 native-nr-xess4 --seconds 60+```++All three runs exit 0. Original4K file input, realtime1080 NR, balanced flow;+hardware import bypasses the changed CPU upload. DLSS2 tail120 FPS; DLSS6+tail298 FPS but P99 16.8ms and incomplete360 target; XeSS4 real input60 and SDK+4-output groups, not a measured uniform240 scanout. Another matrix command with+`--output .../nr-only --cases native-nr-dlss1 --seconds 35` passed. Two FG runs+showed ~31ms wall-time stalls in NR Evaluate at frame605; NR-only did not exceed+the30ms logging threshold. No proven periodic timer or root cause, no speculative+NR/runtime mutation. Missing exploratory src/player, src/render, src/app and+runtime_local/nvidia paths were corrected by inspecting the actual tree/runtime;+these failed read-only queries did not change files.++```powershell+& 'E:/项目/Veyra/build/1.4.4-xess-current-20260921-r1/veyra_fg_presentation_tests.exe' 'E:/项目/Veyra/tests/5090-capture-fg-20260921/presentation' 'E:/项目/Veyra/tests/5090-capture-fg-20260921/app/runtime/experimental'+```++Exit0; DLSS4/6/4 generated114/190/114, checked pixel error0, D3D12 errors0;+includes resize, reset and producer/consumer retirement checks. Not an HDR+under-target flicker reproduction. Other built test binaries were not separately+executed and are not counted as passed tests.++Artifacts remain under `E:/项目/Veyra/tests/5090-capture-fg-20260921/` and+`E:/项目/Veyra/tmp/5090-capture-fg-20260921/`; existing isolated build reused.+Retained baseline executable/logs and one runnable fixed staging app; no ZIP,+portable duplication, runtime mutation, proprietary Git files, merge, push or+release. 5090 live acceptance, 15-second hitch and user flicker remain unresolved.diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cppindex a3a19d14..8f46b0c4 100644--- a/src/pipeline/EnhanceGraph.cpp+++ b/src/pipeline/EnhanceGraph.cpp@@ -1486,24 +1486,44 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Framestager_.stageSrv(nv12Texture, &chromaSrv, yuvPass_.heap.Get(), 4 + parity * 2);tracker_.transition(list, nv12Texture, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);} else {+ const auto uploadFormat=desc_.captureBitDepth==16?AV_PIX_FMT_P016:desc_.wideYuvInput()?AV_PIX_FMT_P010:AV_PIX_FMT_NV12;+ const bool sameLayout=frame->format==uploadFormat;+ const unsigned sampleBytes=desc_.wideYuvInput()?2u:1u;+ const bool directUpload=sameLayout||(!desc_.wideYuvInput()&&(frame->format==AV_PIX_FMT_YUV420P||frame->format==AV_PIX_FMT_YUVJ420P));+ uint8_t* planes[4] = { directUpload?mappedLuma_[parity]:nv12Buf_.data(), directUpload?mappedChroma_[parity]:nv12Buf_.data() + lumaSize_ };+ const int strides[4] = { static_cast<int>(lumaPitch_), static_cast<int>(chromaPitch_) };+ if(sameLayout){+ // Native semiplanar capture already matches the upload textures.+ // Copy rows once, preserving every code value and signed stride.+ const size_t rowBytes[2]={size_t(srcW_)*sampleBytes,size_t((srcW_+1)/2)*2*sampleBytes};+ const unsigned rows[2]={srcH_,(srcH_+1)/2};+ for(unsigned plane=0;plane<2;++plane){+ const auto pitch=int64_t(frame->linesize[plane]);+ if(!frame->data[plane]||uint64_t(pitch<0?-pitch:pitch)<rowBytes[plane]){+ veyra::log::error("color","Invalid native YUV plane or row stride");return false;+ }+ }+ for(unsigned plane=0;plane<2;++plane)for(unsigned y=0;y<rows[plane];++y)+ std::memcpy(planes[plane]+size_t(y)*strides[plane],frame->data[plane]+ptrdiff_t(y)*frame->linesize[plane],rowBytes[plane]);+ }else{nv12Ctx_ = sws_getCachedContext(nv12Ctx_, frame->width, frame->height,static_cast<AVPixelFormat>(frame->format),- frame->width, frame->height, desc_.captureBitDepth==16?AV_PIX_FMT_P016:desc_.wideYuvInput()?AV_PIX_FMT_P010:AV_PIX_FMT_NV12, SWS_POINT,+ frame->width, frame->height, uploadFormat, SWS_POINT,nullptr, nullptr, nullptr);if (nv12Ctx_ == nullptr) { veyra::log::error("graph", "sws"); return false; }const int colorSpace=resolved.matrix==YuvMatrix::BT2020NCL?SWS_CS_BT2020:resolved.matrix==YuvMatrix::BT601?SWS_CS_ITU601:SWS_CS_ITU709;const int* coefficients=sws_getCoefficients(colorSpace);const int full=resolved.range==ColorRange::Full?1:0;if(sws_setColorspaceDetails(nv12Ctx_,coefficients,full,coefficients,full,0,1<<16,1<<16)<0)return false;- // Planar 8-bit YUV already exposes CPU luma for cadence analysis.- // Convert directly into the fenced upload slot instead of writing and- // copying another full NV12 frame. Never sample write-combined memory.- const bool directUpload=!desc_.wideYuvInput()&&(frame->format==AV_PIX_FMT_YUV420P||frame->format==AV_PIX_FMT_YUVJ420P||frame->format==AV_PIX_FMT_NV12);- uint8_t* planes[4] = { directUpload?mappedLuma_[parity]:nv12Buf_.data(), directUpload?mappedChroma_[parity]:nv12Buf_.data() + lumaSize_ };- const int strides[4] = { static_cast<int>(lumaPitch_), static_cast<int>(chromaPitch_) };if(sws_scale(nv12Ctx_, frame->data, frame->linesize, 0, frame->height, planes, strides)!=frame->height){veyra::log::error("color","Software plane conversion failed");return false;}+ }+ // Analyze CPU luma, never write-combined upload memory. The high byte+ // of P010/P016 retains the existing 8-bit scene/cadence proxy exactly.+ const auto* sampleLuma=directUpload?frame->data[0]:planes[0];+ const auto samplePitch=directUpload?ptrdiff_t(frame->linesize[0]):ptrdiff_t(lumaPitch_);std::vector<uint8_t> sample;sample.reserve(64*36);- for(unsigned y=0;y<36;++y)for(unsigned x=0;x<64;++x){const uint8_t v=directUpload?frame->data[0][ptrdiff_t(y*srcH_/36)*frame->linesize[0]+x*srcW_/64]:planes[0][size_t(y*srcH_/36)*lumaPitch_+(x*srcW_/64)*(desc_.wideYuvInput()?2:1)+(desc_.wideYuvInput()?1:0)];sample.push_back(v);}+ for(unsigned y=0;y<36;++y)for(unsigned x=0;x<64;++x)+ sample.push_back(sampleLuma[ptrdiff_t(y*srcH_/36)*samplePitch+(x*srcW_/64)*sampleBytes+(sampleBytes-1)]);analyzeLuma(std::move(sample));if(!directUpload){for (uint32_t y = 0; y < srcH_; ++y)std::memcpy(mappedLuma_[parity] + y * lumaPitch_, planes[0] + y * lumaPitch_, srcW_*(desc_.wideYuvInput()?2:1));diff --git a/tests/integration/CpuYuvUploadTests.cpp b/tests/integration/CpuYuvUploadTests.cppnew file mode 100644index 00000000..92dcff66--- /dev/null+++ b/tests/integration/CpuYuvUploadTests.cpp@@ -0,0 +1,112 @@+#include "veyra/pipeline/EnhanceGraph.h"+#include "veyra/gfx/D3D12DeviceContext.h"+#include "veyra/gfx/CommandSlotRing.h"+#include "CaptureFormatGpuCases.h"+#include <algorithm>+#include <chrono>+#include <cstring>+#include <iostream>++using namespace veyra;+using Clock = std::chrono::steady_clock;++static AVFrame* makeFrame(AVPixelFormat format, int width, int height, bool inverted) {+ auto* frame = av_frame_alloc();+ if (!frame) return nullptr;+ frame->format = format; frame->width = width; frame->height = height;+ if (av_frame_get_buffer(frame, 256) < 0) { av_frame_free(&frame); return nullptr; }+ const bool wide = format != AV_PIX_FMT_NV12;+ for (int plane = 0; plane < 2; ++plane) {+ const int rows = plane ? (height + 1) / 2 : height;+ const int samples = plane ? ((width + 1) / 2) * 2 : width;+ if (inverted) {+ frame->data[plane] += ptrdiff_t(rows - 1) * frame->linesize[plane];+ frame->linesize[plane] = -frame->linesize[plane];+ }+ for (int y = 0; y < rows; ++y) {+ auto* row = frame->data[plane] + ptrdiff_t(y) * frame->linesize[plane];+ for (int x = 0; x < samples; ++x) {+ const unsigned value = plane ? 96 + (x * 7 + y * 3) % 64 : 16 + (x * 3 + y * 11) % 220;+ if (wide) {+ const uint16_t code = uint16_t((value << 8) | (format == AV_PIX_FMT_P010 ? ((x + y) % 4) << 6 : (x + y) % 256));+ memcpy(row + x * 2, &code, sizeof(code));+ } else row[x] = uint8_t(value);+ }+ }+ }+ return frame;+}++static pipeline::EnhanceGraphDesc graphDesc(AVPixelFormat format, int width, int height) {+ pipeline::EnhanceGraphDesc d;+ d.sourceWidth = d.workWidth = width; d.sourceHeight = d.workHeight = height;+ d.enableNr = d.enableFg = d.enableSr = false; d.noFeatures = true;+ d.captureBitDepth = format == AV_PIX_FMT_P016 ? 16 : format == AV_PIX_FMT_P010 ? 10 : 8;+ return d;+}++static pipeline::ColorDescription colorDesc() {+ pipeline::ColorDescription color;+ color.range = pipeline::ColorRange::Limited;+ color.matrix = pipeline::YuvMatrix::BT709;+ color.primaries = pipeline::ColorPrimaries::BT709;+ color.transfer = pipeline::TransferFunction::BT709;+ return color;+}++int main() {+ gfx::D3D12DeviceContext ctx; gfx::CommandSlotRing ring; Status status;+ if (!ctx.initialize({}, status) || !ring.initialize(ctx.device(), ctx.directQueue(), ctx.fence(), ctx.fenceEvent(), 4, status)) return 2;+ int failures = 0;+ const auto color = colorDesc();+ for (auto format : {AV_PIX_FMT_NV12, AV_PIX_FMT_P010, AV_PIX_FMT_P016}) {+ for (int width : {64, 65, 66}) {+ std::vector<float> reference;+ for (bool inverted : {false, true}) {+ auto* frame = makeFrame(format, width, 35, inverted);+ pipeline::EnhanceGraph graph(ctx, ring);+ pipeline::EnhanceGraph::FrameOutputs out;+ std::vector<float> pixels;+ bool ok = frame && graph.initialize(graphDesc(format, width, 35)) && graph.createViews() &&+ graph.process(frame, 0, true, out, 1, &color) && captureReadFp16(ctx, ring, graph.diagnosticLinearInput(), pixels);+ if (ok) { if (!inverted) reference = pixels; else ok = reference == pixels; }+ uint64_t hash = 14695981039346656037ull;+ for (size_t i = 0; i < pixels.size() * sizeof(float); ++i) { hash ^= reinterpret_cast<const uint8_t*>(pixels.data())[i]; hash *= 1099511628211ull; }+ std::cout << "UPLOAD_PIXELS format=" << format << " width=" << width << " inverted=" << inverted << " hash=" << hash << " pass=" << ok << std::endl;+ failures += !ok;+ out = {}; ring.drainQueue(); graph.shutdown(); av_frame_free(&frame);+ }+ }+ auto* frame = makeFrame(format, 3840, 2160, false);+ auto desc = graphDesc(format, 3840, 2160);+ Clock::time_point start;+ double uploadMs = 0;+ desc.stageMark = [&](const char* stage) {+ if (strcmp(stage, "upload") == 0) uploadMs = std::chrono::duration<double, std::milli>(Clock::now() - start).count();+ };+ pipeline::EnhanceGraph graph(ctx, ring);+ bool ok = frame && graph.initialize(desc) && graph.createViews();+ std::vector<double> upload, process;+ // Drain outside the timed region to measure CPU upload into the real+ // mapped D3D12 buffers, without conflating previous GPU work or FG.+ for (int i = 0; ok && i < 240; ++i) {+ pipeline::EnhanceGraph::FrameOutputs out;+ start = Clock::now();+ ok = graph.process(frame, i * (1000.0 / 60), i == 0, out, i + 1, &color);+ const double cpuMs = std::chrono::duration<double, std::milli>(Clock::now() - start).count();+ if (i >= 40) { upload.push_back(uploadMs); process.push_back(cpuMs); }+ out = {}; ok = ring.drainQueue() && ok;+ }+ auto percentile = [](std::vector<double> values, double fraction) {+ if (values.empty()) return -1.0;+ std::sort(values.begin(), values.end()); return values[size_t((values.size() - 1) * fraction)];+ };+ std::cout << "UPLOAD_4K format=" << format << " samples=" << upload.size()+ << " uploadP50=" << percentile(upload, .5) << " uploadP95=" << percentile(upload, .95)+ << " processP50=" << percentile(process, .5) << " processP95=" << percentile(process, .95)+ << " pass=" << ok << std::endl;+ failures += !ok;+ ring.drainQueue(); graph.shutdown(); av_frame_free(&frame);+ }+ return failures ? 1 : 0;+}diff --git a/tests/integration/FgPresentationTests.cpp b/tests/integration/FgPresentationTests.cppindex c6e1c169..9339bf1f 100644--- a/tests/integration/FgPresentationTests.cpp+++ b/tests/integration/FgPresentationTests.cpp@@ -13,7 +13,8 @@ extern "C" {int wmain(int argc,wchar_t** argv){using namespace veyra;- if(argc!=2||FAILED(CoInitializeEx(nullptr,COINIT_MULTITHREADED)))return 2;+ if((argc!=2&&argc!=3)||FAILED(CoInitializeEx(nullptr,COINIT_MULTITHREADED)))return 2;+ const auto runtimePath=argc==3?std::filesystem::absolute(argv[2]):std::filesystem::path(VEYRA_PROJECT_ROOT)/"runtime_local/nvidia";std::filesystem::create_directories(argv[1]);HWND window=CreateWindowExW(0,L"STATIC",L"FG presentation regression",WS_POPUP,0,0,640,360,nullptr,nullptr,GetModuleHandleW(nullptr),nullptr);gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status status=Status::Ok;@@ -31,7 +32,7 @@ int wmain(int argc,wchar_t** argv){++cycle;pipeline::EnhanceGraphDesc desc;desc.sourceWidth=desc.workWidth=640;desc.sourceHeight=desc.workHeight=360;desc.enableNr=desc.enableSr=false;desc.enableFg=desc.rgbInput=true;desc.fgMultiplier=multiplier;- desc.runtimeAbsPath=(std::filesystem::path(VEYRA_PROJECT_ROOT)/"runtime_local/nvidia").wstring();+ desc.runtimeAbsPath=runtimePath.wstring();ok=graph.initialize(desc)&&presenter.open(ctx,window,graph)&&graph.createViews();if(ok&&cycle==1){// A producer allocator stall must not be reported as private