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++
test: verify SR and FG depth response with complete midpoint samples
Veyra Goal Agent3aa9c77e65a7
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 1aebd529..d0a0be00 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -434,6 +434,11 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avformadd_executable(veyra_repair_fg_tests tests/integration/RepairFgTests.cpp)add_executable(veyra_motion_validation_tests tests/integration/MotionValidationTests.cpp)add_executable(veyra_depth_response_tests tests/integration/DepthResponseTests.cpp)+ add_executable(veyra_srfg_depth_tests tests/integration/SrFgDepthResponseTests.cpp)+ target_compile_features(veyra_srfg_depth_tests PRIVATE cxx_std_20)+ 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)target_compile_features(veyra_depth_response_tests PRIVATE cxx_std_20)target_include_directories(veyra_depth_response_tests PRIVATE ${FFMPEG_INCLUDE_DIRS})target_compile_definitions(veyra_depth_response_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN VEYRA_PROJECT_ROOT="${CMAKE_CURRENT_SOURCE_DIR}")diff --git a/docs/REVIEW_SR_FG_DEPTH_RESPONSE_2026-09-08.md b/docs/REVIEW_SR_FG_DEPTH_RESPONSE_2026-09-08.mdnew file mode 100644index 00000000..32fef733--- /dev/null+++ b/docs/REVIEW_SR_FG_DEPTH_RESPONSE_2026-09-08.md@@ -0,0 +1,12 @@+# SR / FG depth independent review++Fresh-context read-only reviewer `review_srfg_depth_response`, scoped diff against `33d248e`. Final **PASS**, no unresolved introduced P0/P1/P2. Full Goal remains open.++Initial review identified P2: some FG depth cases could pass with incomplete generated samples. Actual initial matrix was complete, but the assertion was insufficient. Maker fixed per-source-frame exactly-one valid generation, total11, full GT sample count and unchanged real frames for FG depth-only groups. SR depth response is not hardcoded. Initial FAIL retained at `logs/optimization-goal-20260908/review-srfg-e2419a49f9cd4282be84fa790f5cbe29/`.++- Final independent matrix: `logs/optimization-goal-20260908/review-srfg-final-e1efc4f1b8124f8f9bea0aa7423b8345/`, exit0,32.210s,18cases; allFG generated11/disabled0/gtComplete1/debugErrors0. Create/Evaluate `0x1 Success / SEH=0`; stderr empty. Structured nonblack PNG inspected.+- Independent preflight71 and phase7 75 PASS: `logs/delivery/bf527e55e4914c8aa93451ec78121f18/result.json`,41.408s.+- Original-resource bindings, COMMON restoration, upload lifetime, half-frame source/GT math and PTS reviewed. No default model, normal-path pixel readback or export integrity change.+- Tracked fingerprint before/after `e582742218201647167ef712dcb63594201a7830`; source SHA256 `46727FCEDCEB0A58A9A4375E5F764F002001F8BB5BC60888B96C3794040C90AF`; EXE `2CA27A40DE4E3B812E3B9FB524DACB7DB9E0A58E67A97356925BC5D6B79749C9`.++SR final RGB8 negative response and FG small response reproduced. Constructed GT improvement does not prove natural/perceptual benefit or justify default depth inference; internal SR float response was not measured. Scoped PASS does not cover the full Goal, physical capture, long stability or distribution.diff --git a/docs/SR_FG_DEPTH_RESPONSE_2026-09-08.md b/docs/SR_FG_DEPTH_RESPONSE_2026-09-08.mdnew file mode 100644index 00000000..d6c9dc1c--- /dev/null+++ b/docs/SR_FG_DEPTH_RESPONSE_2026-09-08.md@@ -0,0 +1,43 @@+# SR / FG 深度输入受控实验++Cycle76,基线 `33d248e`。结论仅限当前共享图、固定运行时与构造输入:SR 最终 RGBA8 输出未随深度变化;FG 对非恒定深度有轻微响应,前景深度带来的误差改善不足以支持默认引入推理模型。没有新增模型或改变产品默认处理、导出完整性检查。++## 实现与方法++新增 `tests/integration/SrFgDepthResponseTests.cpp` / `veyra_srfg_depth_tests`;`EnhanceGraph.h` 增加诊断借用资源访问器,无正常路径调用。SR 使用原有 `nrZeroDepth_`,FG 使用 `depthTex_`。直接写原纹理内容,避免仅改 Evaluate 指针的缓存歧义。R32F 上传前后恢复 COMMON;测试同步等待和像素回读只在诊断程序。++SR-only:640×360 → 1280×720,12 个真实帧;FG-only:640×360,12 个真实帧与 11 个有效中间帧。两组 NR 均关闭,NVOF 11 次、reset 1 次。逐帧比较 RGB,排除 alpha;PNG 仅保存末帧,不作为整个序列的替代。检查生成帧 subframe=1、PTS 为真实半帧时刻(100ns 整数舍入容差 1)。++对照为默认深度、显式相同常量(SR .5 / FG .9)、0、1、水平梯度、棋盘格、重新创建的默认重复、源红通道 +20 阳性对照。FG 另加逐帧对齐移动前景的 .1 / 背景 .9 深度及其反向。后两者是构造的相对前后顺序,不是校准的引擎投影 Z,也不是深度模型输出。++棋盘背景每源帧左移 2px,矩形前景右移 6px;半帧参考由相同场景函数按整数中间位移生成,不是相邻帧混合。全图与前景轮廓附近区域计算 RGB8 平均绝对误差(MAE)。此样本没有自然纹理、压缩、多层几何或复杂相机运动。++## 实测++最终运行 `logs/optimization-goal-20260908/srfg-final-b3590fc9f2b1478ab4e205897cb2ef2f/`,exit 0,31.988 秒,18 组全部通过,D3D12 ERROR/CORRUPTION 0。各 FG 组实际生成 11 帧、disabled 0、gtComplete 1。实际 Create / Evaluate 与计数见该目录 `stdout.log`。++SR 所有深度变化最终 RGB 均无变化;源阳性对照改变 13,966,737 个 RGB 通道样本、最大差 117。这里只检查最终 8bit 输出,未检查 SR 内部浮点差异,不能推广为 SR 永远忽略深度。++| FG 深度 | 相对默认变化的 RGB 通道数 / 最大差 | 全图 MAE8 | 轮廓区域 MAE8 |+|---|---:|---:|---:|+| 默认 / 相同常量 / 0 / 1 / 重复默认 | 0 / 0 | 0.237438 | 1.71047 |+| 梯度 | 35231 / 5 | 0.237758 | 1.70995 |+| 棋盘格 | 27314 / 4 | 0.237427 | 1.70925 |+| 前景近、背景远 | 23980 / 3 | 0.237343 | 1.70943 |+| 反向前后景 | 10689 / 3 | 0.237453 | 1.71070 |++FG 源阳性对照改变 2,777,056 个生成 RGB 通道样本、最大差 34;源改变后的 GT 也随之改变,因此该组 MAE 不用于深度收益比较。全部深度组真实帧 RGB 不变。++正确前后景相对默认的全图误差只减少约 0.000095 个 RGB8 单位,轮廓区域约 0.00104。没有建立自然素材、统计显著性、感知提升或每帧推理成本收益。**保持默认无深度模型**;有响应不等于有值得付出成本的改善。++## 命令与证据边界++```powershell+powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/build.ps1 -Root "$PWD" -Preset x64-release+out/build/x64-release/veyra_srfg_depth_tests.exe <唯一的被忽略日志目录>+powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/loop-gate.ps1 -Gate phase7+```++测试外层实际使用隐藏进程、缓存 Process.Handle、275 秒 watchdog、WaitForExit 后 Refresh 读取退出码。构建日志 `logs/optimization-goal-20260908/build-cycle76-final.log` exit 0。之前的 16 组初测与 18 组 GT 测试保留,最终新增 PTS 检查后完整复跑。++本专项门禁与独立复核已通过,见 [独立复核](REVIEW_SR_FG_DEPTH_RESPONSE_2026-09-08.md)。初次复核发现部分深度组缺帧仍可能通过的 P2,现已强制所有 FG 组逐帧恰好一个有效生成帧、总计 11、GT 样本完整,以及 FG 深度组真实帧不变;最终独立 18 组复跑数值一致。Phase 7 / Goal 仍进行中;不覆盖自然素材画质、实卡体验、长期稳定或分发许可。diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex ab42ff43..75d316da 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -1231,3 +1231,9 @@ Newdiagnostictarget only. docs/NR_DEPTH_RESPONSE_2026-09-08.md; finaldepth-respo## Cycle75 independent scopedPASSreview_nr_depth_response nointroducedP0/P1/P2. Independentpreflight71/phase7e67dc13783b24976a68fd1118c43a18841.694s75PASS. Actualreview-depth-9678e01163c949b999231759f1fe6fc6exit0/40.440s:all24casesreproduce,depthzerochange/intensityandMVpositive,NR12NVOF11motion11reset1/debug0. Raw/residentcopy/pointer/per-frame comparisonreviewed; no universaldepthignoredclaim. docs/REVIEW_NR_DEPTH_RESPONSE_2026-09-08.md. Trackedfingerprintca90e967b7f2c588749b2eaf8dc516fed4b7eaadunchanged; exe0A0CA21053F6CDE55CB023A6AD3D71A24EEEE1C91BA6B91E2E57B894A4D8859A. Do notadddefaultNRdepthmodelwithoutnewbenefitevidence. SR/FGdepth/naturalreconstructionremainopen.++## Cycle76 candidate final matrix+18 cases actual RTX PASS, srfg-final-b3590fc9f2b1478ab4e205897cb2ef2f exit0 31.988s/debug0; SR12 or FG11/NVOF11/reset1; all generated PTS checked. SR depth RGB unchanged, FG ordinal near-depth MAE .237438->.237343, insufficient default model justification. docs/SR_FG_DEPTH_RESPONSE_2026-09-08.md. Build final exit0; frozen gate/review pending. Export integrity unchanged.++## Cycle76 independent final PASS+Initial P2 incomplete-FG-sample assertion repaired; independent18cases review-srfg-final-e1efc4f1b8124f8f9bea0aa7423b8345 exit0/32.210s, actual Create/Evaluate0x1 SEH0/debug0. Finalpreflight71 and phase7 bf527e55e4914c8aa93451ec78121f18 41.408s/75PASS. docs/REVIEW_SR_FG_DEPTH_RESPONSE_2026-09-08.md. Defaultdepthmodel remains absent; no verified cost/quality case for adding it. Next: known4K reconstruction against spatial baseline, then natural/changing-frame quality. RTX Video SDK absent from project and filename-targeted Downloads search. Export integrity unchanged; fullGoal open.diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.hindex 4febbd64..052b5d80 100644--- a/include/veyra/pipeline/EnhanceGraph.h+++ b/include/veyra/pipeline/EnhanceGraph.h@@ -160,6 +160,9 @@ public:// Guidance outputs (quality statistics; diagnostic readback only).ID3D12Resource* flowResource() const { return flowTex_.Get(); }ID3D12Resource* confidenceResource() const { return confTex_.Get(); }+ // Isolated diagnostics only: existing constant guidance, borrowed lifetime.+ // A caller writing before the first real frame must restore COMMON state.+ ID3D12Resource* diagnosticDepthResource(bool frameGeneration) const { return frameGeneration?depthTex_.Get():nrZeroDepth_.Get(); }uint32_t nvofRawWidth() const { return rawW_; }uint32_t nvofRawHeight() const { return rawH_; }diff --git a/loop/EVIDENCE.md b/loop/EVIDENCE.mdindex ce21ad59..c54aea47 100644--- a/loop/EVIDENCE.md+++ b/loop/EVIDENCE.md@@ -534,3 +534,9 @@ Newdiagnostictarget only. docs/NR_DEPTH_RESPONSE_2026-09-08.md; finaldepth-respo## Cycle75 independent scopedPASSreview_nr_depth_response nointroducedP0/P1/P2. Independentpreflight71/phase7e67dc13783b24976a68fd1118c43a18841.694s75PASS. Actualreview-depth-9678e01163c949b999231759f1fe6fc6exit0/40.440s:all24casesreproduce,depthzerochange/intensityandMVpositive,NR12NVOF11motion11reset1/debug0. Raw/residentcopy/pointer/per-frame comparisonreviewed; no universaldepthignoredclaim. docs/REVIEW_NR_DEPTH_RESPONSE_2026-09-08.md. Trackedfingerprintca90e967b7f2c588749b2eaf8dc516fed4b7eaadunchanged; exe0A0CA21053F6CDE55CB023A6AD3D71A24EEEE1C91BA6B91E2E57B894A4D8859A. Do notadddefaultNRdepthmodelwithoutnewbenefitevidence. SR/FGdepth/naturalreconstructionremainopen.++## Cycle76 candidate final matrix+18 cases actual RTX PASS, srfg-final-b3590fc9f2b1478ab4e205897cb2ef2f exit0 31.988s/debug0; SR12 or FG11/NVOF11/reset1; all generated PTS checked. SR depth RGB unchanged, FG ordinal near-depth MAE .237438->.237343, insufficient default model justification. docs/SR_FG_DEPTH_RESPONSE_2026-09-08.md. Build final exit0; frozen gate/review pending. Export integrity unchanged.++## Cycle76 independent final PASS+Initial P2 incomplete-FG-sample assertion repaired; independent18cases review-srfg-final-e1efc4f1b8124f8f9bea0aa7423b8345 exit0/32.210s, actual Create/Evaluate0x1 SEH0/debug0. Finalpreflight71 and phase7 bf527e55e4914c8aa93451ec78121f18 41.408s/75PASS. docs/REVIEW_SR_FG_DEPTH_RESPONSE_2026-09-08.md. Defaultdepthmodel remains absent; no verified cost/quality case for adding it. Next: known4K reconstruction against spatial baseline, then natural/changing-frame quality. RTX Video SDK absent from project and filename-targeted Downloads search. Export integrity unchanged; fullGoal open.diff --git a/loop/JOURNAL.md b/loop/JOURNAL.mdindex 21d2950a..5e8971e0 100644--- a/loop/JOURNAL.md+++ b/loop/JOURNAL.md@@ -1561,3 +1561,14 @@ Newdiagnostictarget only. docs/NR_DEPTH_RESPONSE_2026-09-08.md; finaldepth-respo## Cycle75 independent scopedPASSreview_nr_depth_response nointroducedP0/P1/P2. Independentpreflight71/phase7e67dc13783b24976a68fd1118c43a18841.694s75PASS. Actualreview-depth-9678e01163c949b999231759f1fe6fc6exit0/40.440s:all24casesreproduce,depthzerochange/intensityandMVpositive,NR12NVOF11motion11reset1/debug0. Raw/residentcopy/pointer/per-frame comparisonreviewed; no universaldepthignoredclaim. docs/REVIEW_NR_DEPTH_RESPONSE_2026-09-08.md. Trackedfingerprintca90e967b7f2c588749b2eaf8dc516fed4b7eaadunchanged; exe0A0CA21053F6CDE55CB023A6AD3D71A24EEEE1C91BA6B91E2E57B894A4D8859A. Do notadddefaultNRdepthmodelwithoutnewbenefitevidence. SR/FGdepth/naturalreconstructionremainopen.+## Cycle76 - separate SR and FG depth response+Previous Goal turn is progress:33d248e actualNR depthnegative/motionpositive independentlyverified. Clean tree/noSTOP. Add diagnostic-only accessor for existing SR/NR andFG depth textures; mutate contents BEFORE firstrealframe with COMMON restore, no perframeproducthook. SeparateSR-only640x360->1280x720 andFG-only640x360 12frame sequences; constant/gradient/checker/repeatedbaseline/sourcepositive controls. Observechangedoutput/disabledFG withoutcallingresponsequalitybenefit. No model/default/exportintegrity change. Eachchild<=275seconds.+Cycle76 initial818ab6a6b7f5476b9e89b9d5fd67b197exit0:SR depthchanges0, FGgradient/checker changes35231/27314RGBchannels,max5/4. Add exactproceduralhalf-timeGT error anddynamicforeground.1/background.9 plusinverse depthranking modes tojudge limitedqualitydirection. These are ordinalconstructeddepth, not calibratedengineZ; no modeldefaultadoption.++## Cycle76 candidate final matrix+18 cases actual RTX PASS, srfg-final-b3590fc9f2b1478ab4e205897cb2ef2f exit0 31.988s/debug0; SR12 or FG11/NVOF11/reset1; all generated PTS checked. SR depth RGB unchanged, FG ordinal near-depth MAE .237438->.237343, insufficient default model justification. docs/SR_FG_DEPTH_RESPONSE_2026-09-08.md. Build final exit0; frozen gate/review pending. Export integrity unchanged.++Cycle76 reviewer P2: partial FG depth groups could pass with incomplete generated GT samples. Actual18cases complete; tighten per-frame valid generation count, total and sample count, FG depth-only real invariance. Preserve initial FAIL evidence review-srfg-e2419a49f9cd4282be84fa790f5cbe29; no product changes.++## Cycle76 independent final PASS+Initial P2 incomplete-FG-sample assertion repaired; independent18cases review-srfg-final-e1efc4f1b8124f8f9bea0aa7423b8345 exit0/32.210s, actual Create/Evaluate0x1 SEH0/debug0. Finalpreflight71 and phase7 bf527e55e4914c8aa93451ec78121f18 41.408s/75PASS. docs/REVIEW_SR_FG_DEPTH_RESPONSE_2026-09-08.md. Defaultdepthmodel remains absent; no verified cost/quality case for adding it. Next: known4K reconstruction against spatial baseline, then natural/changing-frame quality. RTX Video SDK absent from project and filename-targeted Downloads search. Export integrity unchanged; fullGoal open.diff --git a/loop/STATE.json b/loop/STATE.jsonindex 68478732..9fffc74c 100644--- a/loop/STATE.json+++ b/loop/STATE.json@@ -76,19 +76,19 @@}],"cycle": {- "completed": 75,+ "completed": 76,"maximum": 120,"sameFailureAttempts": 0,"maximumSameFailureAttempts": 3,"noProgressCycles": 0,"maximumNoProgressCycles": 5},- "currentTask": "Cycle75 NR depth response independently verified; no default NR depth-model investment justified by current evidence",+ "currentTask": "Cycle76 SR/FG depth response independently passed after FG sample-completeness assertion repair","lastGate": {"name": "phase7","status": "passed","exitCode": 0,- "evidence": "logs/delivery/e67dc13783b24976a68fd1118c43a188/result.json;41.694s;75checks"+ "evidence": "logs/delivery/bf527e55e4914c8aa93451ec78121f18/result.json;41.408s;75checks"},"lastFailureFingerprint": "","failureLedger": [@@ -107,8 +107,8 @@"Current USB2 1080p50 physical throughput passed; user perceived latency/audio/actual FG display cadence still need confirmation.","Public proprietary runtime distribution rights unresolved; local delivery only."],- "nextAction": "SR/FG controlled depth response separately, then natural/known4K reconstruction and changing-frame motion quality; RTXVideo SDK dependency remains",- "updatedAt": "2026-09-08T12:04:59.733444+00:00",+ "nextAction": "Known4K downsample/reconstruction comparison against spatial baseline, then natural/changing-frame quality; RTX Video SDK unavailable",+ "updatedAt": "2026-09-08T12:28:19.1665042Z","deliveryPlan": "docs/ACTIVE_DELIVERY_PLAN.md","captureAcceptance": "throughput_short_test_passed_user_latency_audio_pending","testInvocationLimitSeconds": 300,@@ -132,7 +132,8 @@"Cycles69-70 independentPASS: motionshader/debug0; repairedresidual24constants; image29e690f3 andSR60A/B GBV0. Natural/FGquality still open.","Cycles71-73 independent scopedPASS: scene14/motionverticalcostboundary; NR600NVOF594; actualFG600source594generated6hold1200output independentlydecoded, docs/REVIEW_SCENE_BOUNDARIES_2026-09-08.md","Cycle74 independent scopedPASS, docs/REVIEW_BIDIRECTIONAL_FLOW_2026-09-08.md:360/1080/4K controlledbidirectional plus640x129alignmentfix; no defaultintegration",- "Cycle75 independent NRdepth24casesPASS:docs/REVIEW_NR_DEPTH_RESPONSE_2026-09-08.md; no depthresponse, strongMV/intensityresponse; no newmodels/defaults"+ "Cycle75 independent NRdepth24casesPASS:docs/REVIEW_NR_DEPTH_RESPONSE_2026-09-08.md; no depthresponse, strongMV/intensityresponse; no newmodels/defaults",+ "Cycle76 independent scopedPASS: docs/REVIEW_SR_FG_DEPTH_RESPONSE_2026-09-08.md; SR8bit negative depth response, FG tiny constructed benefit, no defaultmodel"],"reviewBaseCommit": "6f0ebaa687e3966d989bf138c86b6882380f20fb","localDelivery": "capture_fix_candidate_needs_review",@@ -270,8 +271,8 @@"testInvocationLimitSeconds": 300,"productModified": true,"consecutiveBlockedGoalTurns": 0,- "previousGoalTurnClassification": "progress: actual sharedNVOFBOTH validated, constructedocclusion benefitandcost measured, diagnosticoddheightP2fixed andindependentlyreviewed",- "currentGoalTurnClassification": "progress: controlledNRdepthnegative withresidenttextureupdate, MV/intensitypositive, actualRTXandindependentreview; avoidedunsupporteddefaultmodelcost",+ "previousGoalTurnClassification": "progress: controlledNRdepthnegative withresidenttextureupdate, MV/intensitypositive, actualRTXandindependentreview; avoidedunsupporteddefaultmodelcost",+ "currentGoalTurnClassification": "progress: SR/FG depth response and exact half-frame GT measured; incomplete-sample P2 fixed, independent18cases andgate PASS; default model not justified","controlSynchronizationAuthorization": "2026-09-08 user: 确认,给你全部权限; applies to previously proposed exact two-hash synchronization","diagnosticFindings": ["Q7 read-only dependency check: RTXVideoSDK not present in third_party_local; official1.1download redirects NVIDIA login. Localdepthfile vitl is Large, not permitted Small; no verified Small ONNX/provider. No dependency integrated or performance claimed."diff --git a/tests/integration/SrFgDepthResponseTests.cpp b/tests/integration/SrFgDepthResponseTests.cppnew file mode 100644index 00000000..e72ad994--- /dev/null+++ b/tests/integration/SrFgDepthResponseTests.cpp@@ -0,0 +1,76 @@+#include "veyra/pipeline/EnhanceGraph.h"+#include "veyra/gfx/D3D12DeviceContext.h"+#include "veyra/gfx/CommandSlotRing.h"+#include "veyra/sink/ImageExportSink.h"+#include <d3d12sdklayers.h>+#include <algorithm>+#include <array>+#include <cmath>+#include <filesystem>+#include <iostream>+extern "C" {+#include <libavutil/frame.h>+#include <libavutil/pixfmt.h>+}+using namespace veyra;+int experiment(bool fg,const std::filesystem::path& dir){+ constexpr unsigned sw=640,sh=360,n=12;const unsigned w=fg?sw:sw*2,h=fg?sh:sh*2;+ std::vector<sink::RgbaImage> baselineReal,baselineGenerated;+ for(unsigned mode=0;mode<(fg?10u:8u);++mode){+ gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status st;gfx::DeviceContextDesc dd;dd.enableDebugLayer=true;+ if(!ctx.initialize(dd,st)||!ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),6,st))return 2;+ pipeline::EnhanceGraph graph(ctx,ring);pipeline::EnhanceGraphDesc gd;gd.sourceWidth=sw;gd.sourceHeight=sh;gd.workWidth=w;gd.workHeight=h;gd.rgbInput=true;gd.enableNr=false;gd.enableSr=!fg;gd.enableFg=fg;gd.enableNvofStandalone=true;gd.runtimeAbsPath=(std::filesystem::path(VEYRA_PROJECT_ROOT)/"runtime_local/nvidia").wstring();+ if(!graph.initialize(gd)||!graph.createViews())return 2;+ auto* depth=graph.diagnosticDepthResource(fg);if(!depth)return 2;auto d=depth->GetDesc();if(d.Format!=DXGI_FORMAT_R32_FLOAT||d.Width!=w||d.Height!=h)return 2;+ auto up=pipeline::makeUploadBuffer(ctx.device(),size_t(w)*h*4);if(!up)return 2;+ auto uploadDepth=[&](unsigned frame){+ void* ptr=nullptr;if(FAILED(up->Map(0,nullptr,&ptr)))return false;+ for(unsigned y=0;y<h;++y)for(unsigned x=0;x<w;++x){+ bool object=x>=100+frame*6&&x<260+frame*6&&y>=90&&y<270;+ static_cast<float*>(ptr)[size_t(y)*w+x]=mode>=8?((object!=(mode==9))?.1f:.9f):mode==1?(fg?.9f:.5f):mode==2?0:mode==3?1:mode==4?.05f+.9f*x/(w-1):((x/32+y/32)%2)?.1f:.9f;+ }+ up->Unmap(0,nullptr);unsigned slot=0;auto* list=ring.acquireNext(slot,st);if(!list)return false;+ D3D12_RESOURCE_BARRIER b{};b.Type=D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;b.Transition={depth,D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,D3D12_RESOURCE_STATE_COMMON,D3D12_RESOURCE_STATE_COPY_DEST};list->ResourceBarrier(1,&b);+ D3D12_TEXTURE_COPY_LOCATION dst{},src{};dst.pResource=depth;dst.Type=D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;src.pResource=up.Get();src.Type=D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;src.PlacedFootprint.Footprint={DXGI_FORMAT_R32_FLOAT,w,h,1,w*4};list->CopyTextureRegion(&dst,0,0,0,&src,nullptr);std::swap(b.Transition.StateBefore,b.Transition.StateAfter);list->ResourceBarrier(1,&b);+ return ring.submitAndSignal(slot)&&ring.drainQueue();+ };+ if(mode>=1&&mode<=5&&!uploadDepth(0))return 2;+ AVFrame* f=av_frame_alloc();if(!f)return 2;f->width=sw;f->height=sh;f->format=AV_PIX_FMT_RGBA;f->color_range=AVCOL_RANGE_JPEG;f->color_trc=AVCOL_TRC_IEC61966_2_1;f->colorspace=AVCOL_SPC_RGB;if(av_frame_get_buffer(f,32)<0){av_frame_free(&f);return 2;}+ bool ok=true;uint64_t realChanged=0,generatedChanged=0;unsigned realMax=0,generatedMax=0,generated=0;+ uint64_t gtError=0,gtSamples=0,edgeError=0,edgeSamples=0;+ auto scenePixel=[&](unsigned x,unsigned y,unsigned halfSteps){const bool object=x>=100+halfSteps*3&&x<260+halfSteps*3&&y>=90&&y<270;unsigned q=x+halfSteps;unsigned c=((q/12+y/12)%2)?70:100;return std::array<uint8_t,4>{uint8_t((object?210:c)+(mode==7?20:0)),uint8_t(object?130:c+20),uint8_t(object?60:c+40),255};};+ auto compare=[&](const sink::RgbaImage& a,const sink::RgbaImage& b,uint64_t& changed,unsigned& maximum){if(a.width!=b.width||a.height!=b.height||a.pixels.size()!=b.pixels.size())return false;for(size_t i=0;i<a.pixels.size();++i){if(i%4==3)continue;unsigned delta=unsigned(std::abs(int(a.pixels[i])-int(b.pixels[i])));changed+=delta!=0;maximum=std::max(maximum,delta);}return true;};+ for(unsigned frame=0;frame<n&&ok;++frame){+ if(mode>=8&&!uploadDepth(frame)){ok=false;break;}+ for(unsigned y=0;y<sh;++y)for(unsigned x=0;x<sw;++x){auto p=scenePixel(x,y,frame*2);std::copy(p.begin(),p.end(),f->data[0]+size_t(y)*f->linesize[0]+x*4);}+ pipeline::EnhanceGraph::FrameOutputs out;sink::RgbaImage real,gen;ok=graph.process(f,frame*(1000.0/60),frame==0,out,frame+1)&&sink::readRgba8(ctx,ring,graph.videoFrameResource(out.videoSlot),real);+ if(ok)ok=ring.waitIdle()&&graph.resolveGeneration(out);+ if(ok){if(mode==0)baselineReal.push_back(real);else ok=compare(real,baselineReal[frame],realChanged,realMax);}+ if(ok&&fg&&frame>0){+ const unsigned generatedBefore=generated;+ for(unsigned i=0;i<out.batch.count;++i){auto& item=out.batch.frames[i];if(item.kind!=pipeline::FrameKind::Generated||item.validity!=pipeline::GenerationValidity::Valid)continue;+ if(item.subframe!=1||std::llabs(item.pts100ns-std::llround((frame-.5)*(10000000.0/60)))>1){ok=false;break;}+ ++generated;ok=sink::readRgba8(ctx,ring,graph.generatedFrameResource(item.lease->slot),gen);if(!ok)break;+ if(mode==0)baselineGenerated.push_back(gen);else ok=compare(gen,baselineGenerated[frame-1],generatedChanged,generatedMax);+ const unsigned halfSteps=frame*2-1;const int left=100+halfSteps*3,right=260+halfSteps*3;+ for(unsigned y=0;y<sh;++y)for(unsigned x=0;x<sw;++x){auto expected=scenePixel(x,y,halfSteps);const bool edge=(y>=82&&y<278&&(std::abs(int(x)-left)<=12||std::abs(int(x)-right)<=12))||(int(x)>=left-12&&int(x)<right+12&&(std::abs(int(y)-90)<=8||std::abs(int(y)-270)<=8));+ for(unsigned c=0;c<3;++c){unsigned error=unsigned(std::abs(int(gen.pixels[(size_t(y)*sw+x)*4+c])-int(expected[c])));gtError+=error;++gtSamples;if(edge){edgeError+=error;++edgeSamples;}}+ }+ }+ ok=ok&&generated==generatedBefore+1;+ }+ if(ok&&frame+1==n){std::string label=std::string(fg?"fg":"sr")+"-depth-"+std::to_string(mode);ok=sink::saveImage((dir/(label+"-real.png")).wstring(),real);if(ok&&!gen.pixels.empty())ok=sink::saveImage((dir/(label+"-generated.png")).wstring(),gen);}+ }+ av_frame_free(&f);auto m=graph.metrics();ok=ok&&m.nrEvaluateCount==0&&m.srEvaluateCount==(fg?0:n)&&m.nvofExecuteCount==n-1&&m.resetCount==1;+ if(fg)ok=ok&&generated==n-1&>Samples==uint64_t(n-1)*sw*sh*3&&edgeSamples>0&&(mode==7||realChanged==0);+ if(mode==0||mode==1||mode==6)ok=ok&&generated==(fg?n-1:0)&&realChanged==0&&generatedChanged==0;+ if(mode==7)ok=ok&&realChanged>100&&(!fg||generatedChanged>100);+ ok=ring.drainQueue()&&ok;graph.shutdown();up.Reset();+ pipeline::ComPtr<ID3D12InfoQueue> iq;unsigned errors=0;if(FAILED(ctx.device()->QueryInterface(IID_PPV_ARGS(&iq))))return 2;+ for(UINT64 i=0;i<iq->GetNumStoredMessages();++i){SIZE_T bytes=0;if(FAILED(iq->GetMessage(i,nullptr,&bytes)))return 2;std::vector<uint8_t>b(bytes);auto* msg=reinterpret_cast<D3D12_MESSAGE*>(b.data());if(FAILED(iq->GetMessage(i,msg,&bytes)))return 2;if(msg->Severity<=D3D12_MESSAGE_SEVERITY_ERROR){++errors;std::cerr<<msg->pDescription<<std::endl;}}+ std::cout<<"SRFG_DEPTH fg="<<fg<<" mode="<<mode<<" sr="<<m.srEvaluateCount<<" nvof="<<m.nvofExecuteCount<<" resets="<<m.resetCount<<" generated="<<generated<<" disabled="<<m.fgDisabledFrames<<" realChanged="<<realChanged<<" realMax="<<realMax<<" generatedChanged="<<generatedChanged<<" generatedMax="<<generatedMax<<" gtComplete="<<(fg&&generated==n-1)<<" gtMae8="<<(gtSamples?double(gtError)/gtSamples:-1)<<" edgeMae8="<<(edgeSamples?double(edgeError)/edgeSamples:-1)<<" errors="<<errors<<" pass="<<(ok&&!errors)<<std::endl;+ if(!ok||errors)return 1;+ }+ return 0;+}+int wmain(int argc,wchar_t** argv){if(argc!=2)return 2;CoInitializeEx(nullptr,COINIT_MULTITHREADED);std::filesystem::path dir=argv[1];std::filesystem::create_directories(dir);int r=experiment(false,dir);if(!r)r=experiment(true,dir);CoUninitialize();return r;}