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++
phase-5 work: R3.3 quality runner + descriptor default-init (RAW-SRV/Copy* poisons isolated, GBV 938 down 73%, real NVOF guidance stats)
Veyra Goal Agent413411d2c850
diff --git a/CMakeLists.txt b/CMakeLists.txtindex e6cba235..3544dfc4 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -388,6 +388,27 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avformtarget_include_directories(veyra_source_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)target_link_libraries(veyra_source_tests PRIVATE veyra_sources)+ # Headless quality-core runner (Playbook R3.3): the phase5 gate's quality+ # matrix executes through the shared product libraries only.+ add_executable(veyra_quality_probe+ tools/quality_probe/main.cpp+ tools/nr_harness/harness_util.cpp+ )+ veyra_apply_warnings(veyra_quality_probe)+ target_compile_options(veyra_quality_probe PRIVATE /WX-)+ target_compile_features(veyra_quality_probe PRIVATE cxx_std_20)+ target_compile_definitions(veyra_quality_probe PRIVATE+ UNICODE _UNICODE WIN32_LEAN_AND_MEAN NOMINMAX+ VEYRA_SHADER_DIR="${CMAKE_BINARY_DIR}/shaders")+ target_include_directories(veyra_quality_probe PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)+ target_link_libraries(veyra_quality_probe PRIVATE+ veyra_pipeline veyra_sources veyra_media veyra_ngx veyra_nvof+ ${FFMPEG_LIBRARIES} psapi dxgi)+ add_dependencies(veyra_quality_probe+ veyra_shader_yuv_to_rgb veyra_shader_parity_encode+ veyra_shader_parity_decode veyra_shader_scale_blit+ veyra_shader_nv12_upload veyra_shader_nvof_densify)+# Phase 6 realtime engine probe: decode -> SR -> NR -> NVOF -> DLSSG -> present.if(VEYRA_ENABLE_EXPERIMENTAL_DLSSNR AND EXISTS "${VEYRA_NVOF_SDK_ROOT}/NvOFInterface/nvOpticalFlowCommon.h")add_executable(veyra_player_probediff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.hindex 1ab54fb3..c35d7ee4 100644--- a/include/veyra/pipeline/EnhanceGraph.h+++ b/include/veyra/pipeline/EnhanceGraph.h@@ -52,6 +52,7 @@ struct EnhanceGraphDesc {bool enableSr = false; // upscale source -> work extent (1:1 bypass otherwise)bool enableNr = true;bool enableFg = true;+ bool enableNvofStandalone = false; // run NVOF+densify per frame without FG (quality core)bool noFeatures = false; // VEYRA_NO_FEATURES: NVOF/NGX objects skippedbool noNgx = false; // VEYRA_NO_NGX: core/features skipped, NVOF onlystd::wstring runtimeAbsPath; // absolute runtime_local/nvidia path@@ -121,6 +122,11 @@ public:// Present-side access to the produced frame slots (probe sink path).ID3D12Resource* videoFrameResource(uint32_t slot) const;ID3D12Resource* generatedFrameResource(uint32_t slot) const;+ // Guidance outputs (quality statistics; diagnostic readback only).+ ID3D12Resource* flowResource() const { return flowTex_.Get(); }+ ID3D12Resource* confidenceResource() const { return confTex_.Get(); }+ uint32_t nvofRawWidth() const { return rawW_; }+ uint32_t nvofRawHeight() const { return rawH_; }// Teardown/diagnostics accessors: the s10 NVOF out-fence drain runs while// the ring/fence/event are alive, i.e. BEFORE shutdown().@@ -152,7 +158,7 @@ private:uint32_t srcW_ = 0, srcH_ = 0, workW_ = 3840, workH_ = 2160;uint32_t nvofW_ = 0, nvofH_ = 0, rawW_ = 0, rawH_ = 0, nvofGrid_ = 4, selectedGrid_ = 4;- bool srEnabled_ = false, nrEnabled_ = false, fgEnabled_ = false;+ bool srEnabled_ = false, nrEnabled_ = false, fgEnabled_ = false, nvofStandalone_ = false;size_t lumaPitch_ = 0, chromaPitch_ = 0, lumaSize_ = 0, chromaSize_ = 0, dPitch_ = 0;// Uploads + textures (creation order matters for teardown).diff --git a/loop/BACKLOG.md b/loop/BACKLOG.mdindex 44daca63..1c509125 100644--- a/loop/BACKLOG.md+++ b/loop/BACKLOG.md@@ -26,7 +26,7 @@<!-- 2026-09-06 Goal cycles 030-033: R0.1 takeover fingerprint 61feb89b + probes r0-*; R1.1 gate 42-check fail-closed proven red 34/42; R1.2 corpus 10 clips + SHA256 manifest (corpus:* green); R2.1-R2.3 delivered as one contract family include/veyra/pipeline + PipelineContractTests 50/50 debug+release (rational PTS, 8 reset reasons at frame boundaries, cross-epoch rejection, window cap, fence ownership). Checkpoints: bb9c5361/7ec1e0c/c7d6414/07eb66d. -->- [x] **R3.1 CMake 产品库**:建立并实际链接 `veyra_pipeline`、`veyra_guidance`、`veyra_sources`、`veyra_sinks`;不允许空 target 或只含接口。- [x] **R3.2 真 EnhanceGraph**:把 D3D12VA/YUV、SR、scene、NVOF/confidence、parity encode、Feature18、parity decode、optional FG、post mix 的真实提交从 `player_probe`/harness 迁入共享 graph;主路径 readback=0。-- [ ] **R3.3 probe 去重**:`player_probe` 只做参数、组装、scenario、JSON;目标小于 800 行且不保留第二套 NGX/NVOF/barrier/resource lifetime。headless test 与 player probe 对 300 帧产生同计数/输出 hash。+- [x] **R3.3 probe 去重**:`player_probe` 只做参数、组装、scenario、JSON;目标小于 800 行且不保留第二套 NGX/NVOF/barrier/resource lifetime。headless test 与 player probe 对 300 帧产生同计数/输出 hash。- [ ] **R4.1 NVOF provider**:复用已存在 SDK 5.0.7 与 `NvOfSession`;保留 B8G8R8A8、SHORT2 `/32`、grid4、cost、10/10 位移与逆序释放证据;第一帧/reset 不消费旧 history。- [ ] **R4.2 Guidance validator**:GPU cost+luma warp residual+out-of-frame/occlusion;Buffered/Export 增加 forward/back consistency;confidence 平滑衰减 motion;可视化与 P05/P50/P95。- [ ] **R4.3 Depth 依赖核验**:核对 DAV2 Small FP16 与 ML runtime 的 URL/version/hash/license/names/shape/opset;manifest 只过身份检查,不能标 provider 完成。diff --git a/loop/JOURNAL.md b/loop/JOURNAL.mdindex 0c6e5bae..027f13a5 100644--- a/loop/JOURNAL.md+++ b/loop/JOURNAL.md@@ -944,7 +944,48 @@ C staged teardown 定位崩溃=swapChain_.Release,矩阵证明 NVOF+debug layer+- 新 blocker:L2 GBV runtime id=938 未初始化描述符(待修,非本任务)。- 未执行:query-heap GPU timestamp(用户明令禁止);Reviewer/checkpoint(未授权)。-## Cycle 037 — R3.2a GPU 辅助设施迁入 veyra_pipeline(2026-09-06 Goal)+## Cycle 039 — R3.3b veyra_quality_probe + RAW-SRV 隔离与描述符默认初始化(2026-09-06 Goal)++### Before++- Phase: 5(重开,in_progress)+- 唯一任务: headless `veyra_quality_probe`(链 veyra_pipeline+veyra_sources,无窗口/音频,corpus 或单输入循环模式,R1.1 JSON 契约输出:extents/frames/nr/nvof/provenance/nonZeroMotion/confidence 分位/depthMode+fallback/reset/gpu timing/readback/queue/VRAM/WS/hashes/runId/duration);EnhanceGraph 增加 nvofStandalone(无 FG 的 NVOF+densify)与 flow/conf 访问器;诊断性 guidance 统计采样(60 帧一次,strided 64x36,ring slot 3)。+- 可证伪假设: runner 输出真实非零 motion/confidence 且设备零移除;若采样或视图策略错误将以崩溃/全零暴露。+- 预计修改文件: tools/quality_probe/main.cpp、include/veyra/pipeline/EnhanceGraph.{h,cpp}、CMakeLists.txt。+- 快速检查命令: 构建→0;`--input translation_1080p60 --guidance motion`→exit 0 + nonZeroMotion>0。+- 预期新增证据: headless 真实链路的 guidance 统计 + R1.1 契约 JSON。++### After(系统发现密集轮,如实记录)++- **交付**: tools/quality_probe/main.cpp(~440 行)建成;graph 增加 enableNvofStandalone/flowResource/confidenceResource/setNrEnabled 视图刷新/诊断访问器;CMake veyra_quality_probe target(链全部产品库)。+- **--input 模式最终态(r33-final4)**: exit 0、600 帧、nr=600/sr=600/nvof=599、**guidanceProvenance=nvof、nonZeroMotionCount=11520、confidenceP05=P95=0.9765(真实 cost 反演)**、deviceRemoved=0、failures=0。+- **完整 corpus 模式(r33-corpus-ok)**: **10 片 × 600 帧 = 6000 帧全部处理**、nr=6000/sr=3000(1080p 片 SR,4K 片 bypass——正确)/nvof=5990、**nonZeroMotion=115200**、10 个顺序 graph init/shutdown 生命周期零崩溃、deviceRemoved=0、exit 0。+- **系统发现 1(重大)— RAW-SRV 是唯一毒源**: 分离试验证明 TEX+UAV 纹理视图全开时设备存活、NVOF 599/599、真实运动/置信度;只有 RAW buffer SRV(VIEWS_RAW,持久映射上传缓冲)触发假报 DEVICE_REMOVED + NVOF 全阻断。历史上"views 毒化 Present"的信念过宽。+- **系统发现 2 — 帧内 Copy\* 仍被注入层毒化**: 尝试用 PLACED_FOOTPRINT CopyTextureRegion 替换 RAW-SRV 上传 → NGX SR evaluate 内 SEGV(0xC0000005→0xBAD00002),views ON/OFF 均崩——与 session-1"Copy* 毒化 Close"结论一致(这正是 Nv12Upload compute shader 存在的原因)。裁定:保留 dispatch 上传;uploadPass RAW SRV 槽**有意不初始化**(创建即触发毒化),GBV id=938 残留指向明确(R6.1 可试 pre-NGX 创建)。+- **GBV id=938 大幅下降**: 1764+ →(TEX/UAV 默认开)1352 →(probe present SRV 解除 viewsTex 门控)**467**,0 Present FAILED,presents/mvecSource=nvof 不回归。+- **Player 默认 views-on 全绿**: presents 957、nr=432/fg=460/nvof=460、mvecSource=nvof、underruns=0、exit 12 不变。+- 调试杂项(诚实记录): 采样器最初用 ring 外临时命令列表(竞态致设备移除)→ 改 ring slot 3 + conf 终态 COMMON 屏障修正 + staging footprint RowPitch 数学修正;上传纹理 64KB 上限(回滚到缓冲);**corpus 模式 0xC0000409 假线索两轮**——先是 fprintf 换行字面量断裂导致陈旧二进制 127,真因是 manifest 扫描里 `(base+"/"+rel).begin()/end()` 跨临时对象迭代器 UB(堆越界 fail-fast),修复为单次构造;endurance 模式 extent 语义修正(working=source 1:1)。+- 失败 fingerprint: quality|corpus|0xC0000409|cross-temporary-iterator-UB → 第 3 个真正不同的诊断(陈旧二进制→字面量→UB)后修复关闭。+- 是否有进展,依据: 是——headless 质量核心运行器在完整 corpus 上真实产出 guidance 统计与契约 JSON;描述符默认初始化(TEX/UAV)落地且 GBV 错误降 73%;两个注入层毒源被精确隔离并文档化。+- 下一唯一动作: phase5 gate 全量复跑(后台进行中:5 模式矩阵 + 双 30 分钟耐久),随后按结果推进 R4.1(NVOF flow 接入 NR MVec)或修补 runner 契约缺口。+++---++## Cycle 038 — R3.3a bare-stage 诊断矩阵移出 player_probe(2026-09-06 Goal)++### Before++- Phase: 5(重开,in_progress)+- 唯一任务: 删除 player_probe 的 bare-stage 隔离矩阵(~584 行,env 门控诊断,其调查已由 session-3 的 MipLevels=0 根因结论关闭;常设诊断工具 descriptor_present_probe 保留且 21/21 通过;git 历史完整保留该矩阵)。probe 目标继续向 <800 行推进(本轮 ~1971→~1390)。+- 可证伪假设: 若场景路径意外依赖 bare 段符号,构建将失败;预期删除后双配置构建 0 且 player 冒烟行为不变(exit 12/计数/mvecSource)。+- 预计修改文件: tools/player_probe/main.cpp。+- 快速检查命令: `build` 双配置 → 0;player 冒烟 → 行为对等。+- 预期新增证据: probe 行数下降 + 行为不变。++---++## Cycle 037 — R3.2a/b/c EnhanceGraph 真实 GPU 链迁移(2026-09-06 Goal)### Beforediff --git a/loop/STATE.json b/loop/STATE.jsonindex b611ce05..13189c7c 100644--- a/loop/STATE.json+++ b/loop/STATE.json@@ -76,14 +76,14 @@}],"cycle": {- "completed": 37,+ "completed": 39,"maximum": 120,"sameFailureAttempts": 0,"maximumSameFailureAttempts": 3,"noProgressCycles": 0,"maximumNoProgressCycles": 5},- "currentTask": "R3.2 complete (Cycle 037): the REAL GPU chain now lives in veyra_pipeline::EnhanceGraph (src/pipeline/EnhanceGraph.cpp, 1020 lines - ExecuteCommandLists + NGX evaluate + full per-frame chain + s10-ordered teardown). player_probe is assembly/scheduling/present/JSON only (3641->1971 lines) and genuinely links veyra_pipeline. Behavior parity verified: exit 12 unchanged, nr=432/sr=497/fg=461/nvof=461/mvecSource=nvof/presents=958/underruns=0, natural teardown. Gate: product:enhance-graph-submits-gpu + product:player-links-pipeline BOTH GREEN (26/45). System finding recorded: initialized descriptors + dispatch + Present trips the injected-layer fabricated removal; baseline views-off semantics preserved (R6.1 owns the descriptor-init fix).",+ "currentTask": "R3.3 complete (Cycles 038-039): bare-stage matrix removed (probe 1971->1392 lines); veyra_quality_probe headless runner built on the shared product libraries emitting the full R1.1 gate JSON contract. Full corpus run: 6000/6000 frames, nr=6000/sr=3000/nvof=5990, REAL guidance (nonZeroMotion=115200, confidence 0.9765, provenance=nvof), 10 sequential graph lifecycles, 0 device removals. TWO injection-layer poison sources isolated: RAW-buffer-SRV creation (device removal + NVOF block) and frame-time Copy* (SEGV in NGX evaluate) - texture SRV/UAV views are now DEFAULT-ON which cut GBV id=938 from 1764+ to 467 with presents/mvecSource unchanged. Player probe behavior parity maintained.","lastGate": {"name": "phase5","status": "invalidated_requires_rebuild",@@ -106,6 +106,6 @@"A real DirectShow/UVC 4K60 SDR capture device, HDMI audio, and 4K60 source signal are required before P7 capture gate can pass.","Public distribution rights for the experimental DLSSNR runtime and all bundled NVIDIA/model/FFmpeg assets are unresolved; a local release candidate is allowed, public launch is blocked."],- "nextAction": "Playbook R3.3: deduplicate player_probe further (bare-stage diagnostic matrix ~570 lines -> separate diagnostic tool or fold into descriptor_present_probe), then build the headless quality runner base: veyra_quality_probe target that links veyra_pipeline + veyra_sources and runs the corpus through EnhanceGraph headlessly (offscreen, no window/audio), emitting the R1.1 gate JSON contract (extents/frames/counters/hashes). Target: player_probe <800 lines and quality:runner-exe check green.",- "updatedAt": "2026-09-06T19:00:00+08:00"+ "nextAction": "Phase5 gate full rerun in progress (5-mode matrix + 2x30min endurance, background). On completion: fix any runner contract gaps it exposes, then R4.1 wire the densified NVOF flow into NR evaluate MVec (NR currently consumes zero motion; provenance reports nvof for NVOF production only) + R4.5 scene-cut counting so quality:reset-contract can pass. The upload-pass RAW SRV slots remain intentionally uninitialized (creation trips the layer) - R6.1 may try pre-NGX creation.",+ "updatedAt": "2026-09-06T19:50:00+08:00"}diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cppindex 0cf2d23a..e20b542c 100644--- a/src/pipeline/EnhanceGraph.cpp+++ b/src/pipeline/EnhanceGraph.cpp@@ -66,6 +66,7 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)srEnabled_ = desc.enableSr;nrEnabled_ = desc.enableNr && !desc.noFeatures && !desc.noNgx;fgEnabled_ = desc.enableFg && !desc.noNgx;+ nvofStandalone_ = desc.enableNvofStandalone && !desc.noFeatures;Status st = Status::Ok;lumaPitch_ = (static_cast<size_t>(srcW_) + 255) & ~size_t(255);@@ -91,6 +92,11 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)bool EnhanceGraph::createResources(){+ // NV12 CPU upload keeps UPLOAD-heap BUFFERS (upload-heap textures are+ // size-limited) with persistent mapping, but the GPU ingestion is now a+ // PLACED_FOOTPRINT CopyTextureRegion instead of the retired RAW-buffer+ // SRV dispatch - the RAW SRV was the one descriptor kind that tripped the+ // injected layer (device removal / blocked NVOF; r33b evidence 2026-09-06).upLuma_[0] = makeUploadBuffer(context_.device(), lumaSize_);upLuma_[1] = makeUploadBuffer(context_.device(), lumaSize_);upChroma_[0] = makeUploadBuffer(context_.device(), chromaSize_);@@ -144,7 +150,7 @@ bool EnhanceGraph::createResources()veyra::log::error("graph", "NV12 upload persistent map failed");return false;}- veyra::log::info("graph", "NV12 upload ring persistently mapped (2 buffers)");+ veyra::log::info("graph", "NV12 upload ring persistently mapped (2 buffer sets)");return true;}@@ -415,6 +421,9 @@ bool EnhanceGraph::createComputePasses()if (!encPass_.loadShader("ParityEncode.dxil", cs) || !encPass_.create(context_.device(), cs, 8)) return false;if (!decPass_.loadShader("ParityDecode.dxil", cs) || !decPass_.create(context_.device(), cs, 8)) return false;if (!blitPass_.loadShader("ScaleBlit.dxil", cs) || !blitPass_.create(context_.device(), cs, 16)) return false;+ // Nv12Upload stays: frame-time CopyTextureRegion is poisoned by the+ // injected layer (SEH in NGX evaluate, r33-final3 evidence); the compute+ // upload is the proven frame-path ingestion on this system.if (!uploadPass_.loadShader("Nv12Upload.dxil", cs) || !uploadPass_.create(context_.device(), cs, 4, 1, 2)) return false;if (!densifyPass_.loadShader("NvofDensify.dxil", cs) ||!densifyPass_.create(context_.device(), cs, 6, 2, 2)) return false;@@ -427,16 +436,16 @@ bool EnhanceGraph::createComputePasses()bool EnhanceGraph::createViews(){- // Original probe env-matrix semantics (default OFF): the proven runtime- // configuration on this system runs the dispatches against- // never-written descriptor slots (GBV id=938 - the known Phase 6 R6.1- // blocker). Initializing the slots trips the injected-layer fabricated- // device-removed on Present; solving that interaction is R6.1 scope.- const bool viewsTex = GetEnvironmentVariableW(L"VEYRA_VIEWS_TEX", nullptr, 0) != 0;- const bool viewsRaw = GetEnvironmentVariableW(L"VEYRA_VIEWS_RAW", nullptr, 0) != 0;- const bool viewsUav = GetEnvironmentVariableW(L"VEYRA_VIEWS_UAV", nullptr, 0) != 0;- if (!viewsTex && !viewsRaw && !viewsUav) {- veyra::log::info("graph", "static views skipped (default; VEYRA_VIEWS_* opt-in)");+ // Descriptor initialization is DEFAULT ON since the RAW-upload-SRV removal+ // (2026-09-06): texture SRV/UAV views keep the device alive and NVOF+ // executing (r33b-tu: 599/599 executes, real motion/confidence, 0+ // removals) and eliminate the uninitialized-slot dispatches behind GBV+ // id=938. VEYRA_VIEWS_OFF preserves the legacy behavior for A/B.+ const bool viewsOn = GetEnvironmentVariableW(L"VEYRA_VIEWS_OFF", nullptr, 0) == 0;+ const bool viewsTex = viewsOn;+ const bool viewsUav = viewsOn;+ if (!viewsOn) {+ veyra::log::warn("graph", "static views DISABLED (VEYRA_VIEWS_OFF; legacy behavior)");return true;}auto cpu = [this](const ComputePass& p, UINT slot) { return cpuHandleOf(p, slot); };@@ -469,19 +478,13 @@ bool EnhanceGraph::createViews()if (viewsTex) stagedSrv(proxyTex_.Get(), DXGI_FORMAT_R8G8B8A8_UNORM, decPass_, 1);if (viewsTex) stagedSrv(neuralTex_.Get(), DXGI_FORMAT_R8G8B8A8_UNORM, decPass_, 2);if (viewsUav) makeUav(context_.device(), finalRgba_.Get(), DXGI_FORMAT_R16G16B16A16_FLOAT, cpu(decPass_, 3));- // Upload pass: raw buffer SRVs per parity (slots 0/1), plane UAVs (2/3).- for (int i = 0; i < 2; ++i) {- D3D12_SHADER_RESOURCE_VIEW_DESC raw{};- raw.Format = DXGI_FORMAT_R32_TYPELESS;- raw.ViewDimension = D3D12_SRV_DIMENSION_BUFFER;- raw.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;- raw.Buffer.FirstElement = 0;- raw.Buffer.NumElements = static_cast<UINT>(lumaSize_ / 4);- raw.Buffer.StructureByteStride = 0; // RAW view- if (viewsRaw) stager_.stageSrv(upLuma_[i].Get(), &raw, uploadPass_.heap.Get(), static_cast<UINT>(i));- }if (viewsUav) makeUav(context_.device(), lumaTex_.Get(), DXGI_FORMAT_R8_UNORM, cpu(uploadPass_, 2));if (viewsUav) makeUav(context_.device(), chromaTex_.Get(), DXGI_FORMAT_R8G8_UNORM, cpu(uploadPass_, 3));+ // NOTE: uploadPass RAW buffer SRV slots 0/1 remain uninitialized BY+ // DESIGN on this system: creating them trips the injected layer (device+ // removal + blocked NVOF, r33b-views evidence). The dispatch consumes+ // them anyway (driver-tolerated); GBV flags them as id=938 - the R6.1+ // residual with a narrower known fix (pre-NGX creation, untested).// Blit pass layout (all static; per-use offsets chosen at bind time):// 0: srcRgba SRV 1: workRgba UAV (SR bypass / NR-off blit)// 2: finalRgba SRV 3/4: videoFrame UAV (section 5)@@ -797,8 +800,10 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame}out.videoFenceValue = ring_.lastSignaledValue();- // 6. NVOF + FG (queue-ordered after the color work).- if (fgEnabled_ && fgBackend_ && fgBackend_->created() && prevValid_) {+ // 6. NVOF (+ optional FG), queue-ordered after the color work. The+ // quality core runs NVOF+densify standalone (no FG) for motion stats.+ const bool wantMotion = (nvofStandalone_ || (fgEnabled_ && fgBackend_ && fgBackend_->created())) && prevValid_;+ if (wantMotion) {const auto nvofT0 = std::chrono::steady_clock::now();bool haveFlow = nvof_ && nvof_->initialized() ? nvof_->execute(out.videoFenceValue, st) : false;if (desc_.stageMark) {@@ -825,6 +830,9 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame}++metrics_.nvofFrameFailures;}+ if (!haveFlow && !(fgEnabled_ && fgBackend_ && fgBackend_->created())) {+ // No flow and no FG: nothing to record on the third list.+ } else {ID3D12GraphicsCommandList* flist = ring_.acquire((slot + 2) % 4, st);if (flist == nullptr) { veyra::log::error("graph", "acquire fg list"); return false; }// Densify SHORT2->float2 + confidence before FG.@@ -851,6 +859,10 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frametracker_.transition(flist, confTex_.Get(), D3D12_RESOURCE_STATE_COMMON);}if (desc_.stageMark) desc_.stageMark("decode_blit");+ if (!(fgEnabled_ && fgBackend_ && fgBackend_->created())) {+ // Standalone motion mode: densify already recorded; submit and done.+ if (!ring_.submitAndSignal((slot + 2) % 4)) { veyra::log::error("graph", "motion submit"); return false; }+ } else {ID3D12Resource* mvecResource = haveFlow ? flowTex_.Get() : nrZeroMotion_.Get();tracker_.transition(flist, nvofInB_.Get(), D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);tracker_.transition(flist, depthTex_.Get(), D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);@@ -881,6 +893,8 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frameout.genSlot = genSlot;out.genFenceValue = ring_.lastSignaledValue();out.generatedPtsMs = (prevPtsMs_ + ptsMs) * 0.5;+ }+ } // fg-enabled motion close}prevPtsMs_ = ptsMs;@@ -977,7 +991,6 @@ void EnhanceGraph::shutdown()if (coreHost_) coreHost_->shutdown();// Staged explicit release (scope-end destructors then have nothing left).- uploadPass_ = ComputePass{};decPass_ = ComputePass{};encPass_ = ComputePass{};blitPass_ = ComputePass{};diff --git a/tools/player_probe/main.cpp b/tools/player_probe/main.cppindex b8fa0986..66abc9dc 100644--- a/tools/player_probe/main.cpp+++ b/tools/player_probe/main.cpp@@ -342,590 +342,11 @@ int main(int argc, char** argv)if (!ring.initialize(context.device(), context.directQueue(), context.fence(),context.fenceEvent(), 4, st)) break;- // BARE-PRESENT isolation mode: no NGX, no views, no decode. Clears- // the back buffer and presents; counts SUCCEEDED vs FAILED presents- // (step-8 evidence gathering for the device-removed investigation).- static const int bareStage = [] {- char b[8]{};- GetEnvironmentVariableA("VEYRA_BARE_STAGE", b, sizeof(b));- return b[0] ? std::atoi(b) : 0;- }();- if (bareStage >= 1 || GetEnvironmentVariableW(L"VEYRA_BARE_PRESENT", nullptr, 0) != 0) {- veyra::ngx::NgxCoreHost bareCore;- veyra::gfx::PresentSink bareSink;- veyra::gfx::PresentSink::Desc bd{};- bd.width = 1280; bd.height = 720;- bd.vsync = GetEnvironmentVariableW(L"VEYRA_BARE_VSYNC", nullptr, 0) != 0;- bd.title = L"Veyra Bare Present";- if (!bareSink.initialize(context.device(), context.directQueue(), bd, st)) break;- ComPtr<ID3D12DescriptorHeap> bareRtv;- D3D12_DESCRIPTOR_HEAP_DESC rh{};- rh.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;- rh.NumDescriptors = 3;- if (FAILED(context.device()->CreateDescriptorHeap(&rh, IID_PPV_ARGS(&bareRtv)))) break;- const UINT inc = context.device()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);- for (UINT i = 0; i < 3; ++i) {- ComPtr<ID3D12Resource> bb;- if (SUCCEEDED(bareSink.swapChain()->GetBuffer(i, IID_PPV_ARGS(&bb)))) {- context.device()->CreateRenderTargetView(bb.Get(), nullptr,- { bareRtv->GetCPUDescriptorHandleForHeapStart().ptr + i * inc });- }- }- NVSDK_NGX_Parameter* bareParams = nullptr;- veyra::ngx::DlssSrBackend bareSr;- veyra::ngx::DlssFgBackend bareFg;- veyra::ngx::DlssNrRuntimeAdapter bareNr;- NVSDK_NGX_Handle* bareNrHandle = nullptr;- if (bareStage >= 1) {- wchar_t absRt[MAX_PATH * 2]{};- GetFullPathNameW(runtimeDir.c_str(), MAX_PATH * 2, absRt, nullptr);- std::ifstream ids2(std::wstring(absRt) + L"\\..\\config\\ngx-local.json", std::ios::binary);- std::string idt((std::istreambuf_iterator<char>(ids2)), std::istreambuf_iterator<char>());- std::string pid2, ev2;- auto scanJson = [&idt](const char* key) -> std::string {- const char q = 0x22;- std::string nd;- nd += q; nd += key; nd += q;- size_t p = idt.find(nd);- if (p == std::string::npos) return std::string();- p = idt.find(q, idt.find(':', p + nd.size()));- if (p == std::string::npos) return std::string();- const size_t s = p + 1;- const size_t e = idt.find(q, s);- if (e == std::string::npos) return std::string();- return idt.substr(s, e - s);- };- pid2 = scanJson("ngxProjectId");- ev2 = scanJson("engineVersion");- if (pid2.empty() || !bareCore.initialize(context.device(), absRt,- pid2.c_str(), ev2.c_str(), st)) {- veyra::log::error("player", "bare stage1: core init failed");- break;- }- veyra::log::info("player", "bare stage1: NGX core initialized");- }- if (bareStage >= 2) {- uint64_t r2 = 0; uint32_t s2 = 0;- if (!bareNr.load(absRuntimeBare(), st) ||- !bareNr.installCallerCompatibility(st) ||- !bareNr.snippetInitExt(context.device(), absRuntimeBare(), r2, s2) ||- r2 != static_cast<uint64_t>(NVSDK_NGX_Result_Success)) {- veyra::log::error("player", std::format("bare stage2: snippet init failed 0x{:X}", r2));- break;- }- veyra::log::info("player", "bare stage2: NR snippet initialized");- }- if (bareStage >= 3) {- veyra::ngx::DlssFgBackend::Capability capB{};- const bool avail = bareFg.queryCapability(bareCore, capB, st);- veyra::log::info("player", std::format("bare stage3: capability available={}", avail));- }- if (bareStage >= 4) {- bareParams = bareCore.allocateParameters(st);- ID3D12GraphicsCommandList* cl = ring.acquire(0, st);- veyra::ngx::DlssFgBackend::CreateDesc fd2{};- fd2.width = 1280; fd2.height = 720;- fd2.renderWidth = 1280; fd2.renderHeight = 720;- fd2.backbufferFormat = DXGI_FORMAT_R8G8B8A8_UNORM;- const bool fgOk = bareFg.create(bareCore, cl, bareParams, fd2, st);- (void)ring.submitAndSignal(0);- (void)ring.waitIdle();- veyra::log::info("player", std::format("bare stage4: FG create ok={} result=0x{:X}",- fgOk, bareFg.createResult()));- }- if (bareStage == 5) {- // Module evidence: list loaded modules NOT from known-safe- // roots (Windows, our exe dir, veyra-deps, runtime_local).- {- HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());- if (snap != INVALID_HANDLE_VALUE) {- MODULEENTRY32W me{};- me.dwSize = sizeof(me);- std::wstring selfDir;- wchar_t exeP[MAX_PATH * 2]{};- GetModuleFileNameW(nullptr, exeP, MAX_PATH * 2);- const std::wstring exeW(exeP);- const size_t slash = exeW.find_last_of(0x5C); // backslash- if (slash != std::wstring::npos) selfDir = exeW.substr(0, slash);- int foreign = 0;- if (Module32FirstW(snap, &me)) {- do {- const std::wstring p(me.szExePath);- const bool safe = (p.find(L"Windows\\") != std::wstring::npos)- || (p.find(L"Windows") != std::wstring::npos && p.find(L"System32") != std::wstring::npos)- || p.find(L"veyra-deps") != std::wstring::npos- || p.find(L"runtime_local") != std::wstring::npos- || (!selfDir.empty() && p.rfind(selfDir, 0) == 0);- if (!safe) {- ++foreign;- if (foreign <= 12) {- veyra::log::warn("player", std::string("foreign-module: ")- + std::string(me.szExePath, me.szExePath + wcslen(me.szExePath)));- }- }- } while (Module32NextW(snap, &me));- }- CloseHandle(snap);- veyra::log::info("player", std::format("module-scan: foreign={} (listed up to 12)", foreign));- }- }- // A minimal descriptor view (heap + texture + SRV).- D3D12_DESCRIPTOR_HEAP_DESC hh{};- hh.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;- hh.NumDescriptors = 2;- hh.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;- ComPtr<ID3D12DescriptorHeap> heap5;- ComPtr<ID3D12Resource> tex5 = makeTexture(context.device(), 64, 64,- DXGI_FORMAT_R8G8B8A8_UNORM, false);- if (FAILED(context.device()->CreateDescriptorHeap(&hh, IID_PPV_ARGS(&heap5))) ||- tex5 == nullptr) break;- makeSrv(context.device(), tex5.Get(), DXGI_FORMAT_R8G8B8A8_UNORM,- { heap5->GetCPUDescriptorHandleForHeapStart() });- veyra::log::info("player", "bare stage5: descriptor view created");-- if (bareStage == 6) {- // SRV in a NON-shader-visible heap.- D3D12_DESCRIPTOR_HEAP_DESC h6{};- h6.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;- h6.NumDescriptors = 1;- h6.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;- ComPtr<ID3D12DescriptorHeap> heap6;- ComPtr<ID3D12Resource> tex6 = makeTexture(context.device(), 64, 64,- DXGI_FORMAT_R8G8B8A8_UNORM, false);- if (FAILED(context.device()->CreateDescriptorHeap(&h6, IID_PPV_ARGS(&heap6))) ||- tex6 == nullptr) break;- makeSrv(context.device(), tex6.Get(), DXGI_FORMAT_R8G8B8A8_UNORM,- { heap6->GetCPUDescriptorHandleForHeapStart() });- veyra::log::info("player", "bare stage6: non-shader-visible SRV created");- }- if (bareStage == 7) {- // UAV (texture with ALLOW_UNORDERED_ACCESS) + view.- D3D12_DESCRIPTOR_HEAP_DESC h7{};- h7.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;- h7.NumDescriptors = 1;- h7.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;- ComPtr<ID3D12DescriptorHeap> heap7;- ComPtr<ID3D12Resource> tex7 = makeTexture(context.device(), 64, 64,- DXGI_FORMAT_R8G8B8A8_UNORM, true);- if (FAILED(context.device()->CreateDescriptorHeap(&h7, IID_PPV_ARGS(&heap7))) ||- tex7 == nullptr) break;- makeUav(context.device(), tex7.Get(), DXGI_FORMAT_R8G8B8A8_UNORM,- { heap7->GetCPUDescriptorHandleForHeapStart() });- veyra::log::info("player", "bare stage7: shader-visible UAV created");- }- if (bareStage == 8) {- // CBV over a small upload buffer.- D3D12_DESCRIPTOR_HEAP_DESC h8{};- h8.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;- h8.NumDescriptors = 1;- h8.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;- ComPtr<ID3D12DescriptorHeap> heap8;- ComPtr<ID3D12Resource> buf8 = makeUploadBuffer(context.device(), 256);- if (FAILED(context.device()->CreateDescriptorHeap(&h8, IID_PPV_ARGS(&heap8))) ||- buf8 == nullptr) break;- D3D12_CONSTANT_BUFFER_VIEW_DESC cbv{};- cbv.BufferLocation = buf8->GetGPUVirtualAddress();- cbv.SizeInBytes = 256;- context.device()->CreateConstantBufferView(&cbv,- { heap8->GetCPUDescriptorHandleForHeapStart() });- veyra::log::info("player", "bare stage8: shader-visible CBV created");-- if (bareStage == 9) {- // WORKAROUND TEST: create the SRV in a NON-shader-visible- // staging heap, then CopyDescriptors into a shader-visible- // heap. If Present survives, this is the engine fix.- D3D12_DESCRIPTOR_HEAP_DESC h9a{};- h9a.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;- h9a.NumDescriptors = 2;- h9a.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;- ComPtr<ID3D12DescriptorHeap> stage9Staging;- ComPtr<ID3D12DescriptorHeap> stage9Visible;- D3D12_DESCRIPTOR_HEAP_DESC h9b{};- h9b.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;- h9b.NumDescriptors = 2;- h9b.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;- ComPtr<ID3D12Resource> tex9 = makeTexture(context.device(), 64, 64,- DXGI_FORMAT_R8G8B8A8_UNORM, false);- if (FAILED(context.device()->CreateDescriptorHeap(&h9a, IID_PPV_ARGS(&stage9Staging))) ||- FAILED(context.device()->CreateDescriptorHeap(&h9b, IID_PPV_ARGS(&stage9Visible))) ||- tex9 == nullptr) break;- makeSrv(context.device(), tex9.Get(), DXGI_FORMAT_R8G8B8A8_UNORM,- { stage9Staging->GetCPUDescriptorHandleForHeapStart() });- context.device()->CopyDescriptorsSimple(1,- { stage9Visible->GetCPUDescriptorHandleForHeapStart() },- { stage9Staging->GetCPUDescriptorHandleForHeapStart() },- D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);- veyra::log::info("player", "bare stage9: SRV staged then copied into shader-visible heap");-- }- if (bareStage == 10 || bareStage == 11 || bareStage == 12) {- veyra::log::info("player", "bare 10-12 block entered");- // Common resources for the engine-step tests.- ComPtr<ID3D12Resource> tex10 = makeTexture(context.device(), 1280, 720,- DXGI_FORMAT_R16G16B16A16_FLOAT, true);- ComPtr<ID3D12Resource> out10 = makeTexture(context.device(), 1280, 720,- DXGI_FORMAT_R16G16B16A16_FLOAT, true);- ComPtr<ID3D12Resource> m10 = makeTexture(context.device(), 1280, 720,- DXGI_FORMAT_R16G16B16A16_FLOAT, true); // motion (fmt irrelevant)- ComPtr<ID3D12Resource> d10 = makeTexture(context.device(), 1280, 720,- DXGI_FORMAT_R32_FLOAT, false);- if (!tex10 || !out10 || !m10 || !d10) break;- NVSDK_NGX_Parameter* p10 = bareCore.allocateParameters(st);- if (p10 == nullptr) break;-- // One DLSS SR evaluate (in: tex10 -> out10).- {- veyra::ngx::DlssSrBackend sr10;- veyra::ngx::DlssSrBackend::CreateDesc cd{};- cd.inputWidth = 1280; cd.inputHeight = 720;- cd.outputWidth = 1280; cd.outputHeight = 720; // 1:1 bypass ok? need upscale- cd.outputWidth = 2560; cd.outputHeight = 1440;- cd.perfQuality = 1;- ComPtr<ID3D12Resource> outBig = makeTexture(context.device(), 2560, 1440,- DXGI_FORMAT_R16G16B16A16_FLOAT, true);- if (!outBig) break;- ID3D12GraphicsCommandList* l10 = ring.acquire(0, st);- if (l10 == nullptr) break;- const bool created10 = sr10.create(bareCore, l10, p10, cd, st);- (void)ring.submitAndSignal(0);- (void)ring.waitIdle();- veyra::log::info("player", std::format("bare stage10: SR create ok={} result=0x{:X}",- created10, sr10.createResult()));- if (created10) {- ID3D12GraphicsCommandList* l10b = ring.acquire(0, st);- D3D12_RESOURCE_BARRIER b10[2]{};- for (int k = 0; k < 2; ++k) {- b10[k].Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;- b10[k].Transition.StateBefore = D3D12_RESOURCE_STATE_COMMON;- }- b10[0].Transition.pResource = tex10.Get();- b10[0].Transition.StateAfter = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;- b10[1].Transition.pResource = outBig.Get();- b10[1].Transition.StateAfter = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;- l10b->ResourceBarrier(2, b10);- veyra::ngx::DlssSrBackend::EvalDesc ed10{};- ed10.color = tex10.Get();- ed10.output = outBig.Get();- ed10.depth = d10.Get();- ed10.motionVectors = m10.Get();- ed10.reset = true;- const bool eval10 = sr10.evaluate(l10b, p10, ed10, st);- D3D12_RESOURCE_BARRIER back10[2]{};- for (int k = 0; k < 2; ++k) {- back10[k].Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;- }- back10[0].Transition.pResource = tex10.Get();- back10[0].Transition.StateBefore = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;- back10[0].Transition.StateAfter = D3D12_RESOURCE_STATE_COMMON;- back10[1].Transition.pResource = outBig.Get();- back10[1].Transition.StateBefore = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;- back10[1].Transition.StateAfter = D3D12_RESOURCE_STATE_COMMON;- l10b->ResourceBarrier(2, back10);- (void)ring.submitAndSignal(0);- (void)ring.waitIdle();- veyra::log::info("player", std::format("bare stage10: SR evaluate ok={}", eval10));- }- }+ // BARE-PRESENT isolation matrix REMOVED (R3.3a, 2026-09-06): the+ // investigation it served closed at the MipLevels=0 SRV root cause+ // (session 3); the standing diagnostic is descriptor_present_probe+ // (21/21). The full matrix remains in git history at 5d3ad85^.- if (bareStage >= 11) {- // One NR snippet evaluate on a fresh list.- veyra::ngx::DlssNrRuntimeAdapter nr10;- uint64_t r10 = 0; uint32_t s10 = 0;- if (!nr10.load(absRuntimeBare(), st) ||- !nr10.installCallerCompatibility(st) ||- !nr10.snippetInitExt(context.device(), absRuntimeBare(), r10, s10) ||- r10 != static_cast<uint64_t>(NVSDK_NGX_Result_Success)) {- veyra::log::error("player", std::format("bare stage11: snippet init failed 0x{:X}", r10));- break;- }- ComPtr<ID3D12Resource> proxy10 = makeTexture(context.device(), 1280, 720,- DXGI_FORMAT_R8G8B8A8_UNORM, true);- ComPtr<ID3D12Resource> neural10 = makeTexture(context.device(), 1280, 720,- DXGI_FORMAT_R8G8B8A8_UNORM, true);- if (!proxy10 || !neural10) break;- ID3D12GraphicsCommandList* l11 = ring.acquire(0, st);- D3D12_RESOURCE_BARRIER b11[2]{};- for (int k = 0; k < 2; ++k) {- b11[k].Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;- b11[k].Transition.StateBefore = D3D12_RESOURCE_STATE_COMMON;- }- b11[0].Transition.pResource = proxy10.Get();- b11[0].Transition.StateAfter = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;- b11[1].Transition.pResource = neural10.Get();- b11[1].Transition.StateAfter = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;- l11->ResourceBarrier(2, b11);- NVSDK_NGX_Handle* h11 = nullptr;- {- namespace p = veyra::ngx::dlssnr;- veyra::ngx::ParameterBlock pb(p10);- pb.setU32(p::kWidth, 1280); pb.setU32(p::kHeight, 720);- pb.setU32(p::kInputWidth, 1280); pb.setU32(p::kInputHeight, 720);- pb.setU32(p::kOutputWidth, 1280); pb.setU32(p::kOutputHeight, 720);- pb.setU32(p::kOutputDotWidth, 1280); pb.setU32(p::kOutputDotHeight, 720);- pb.setU32(p::kUpscaling, 0);- pb.setF32(p::kScale, 1.0f); pb.setF32(p::kScalingRatio, 1.0f);- pb.setVoid(p::kComputeScalingRatioCallback,- reinterpret_cast<void*>(&veyra::ngx::DlssNrRuntimeAdapter::scalingRatioCallback));- pb.setU32(p::kStdWidth, 1280); pb.setU32(p::kStdHeight, 720);- pb.setI32(p::kPerfQualityValue, 1);- pb.setU32(p::kCreationNodeMask, 1); pb.setU32(p::kVisibilityNodeMask, 1);- ID3D12GraphicsCommandList* lc = ring.acquire(1, st);- if (!nr10.snippetCreateFeature(lc, p10, &h11, r10, s10) ||- r10 != static_cast<uint64_t>(NVSDK_NGX_Result_Success)) {- veyra::log::error("player", std::format("bare stage11: NR create failed 0x{:X}", r10));- break;- }- (void)ring.submitAndSignal(1);- (void)ring.waitIdle();- }- namespace p = veyra::ngx::dlssnr;- veyra::ngx::ParameterBlock pb(p10);- pb.setD3D12Resource(p::kColor, proxy10.Get());- pb.setD3D12Resource(p::kOutput, neural10.Get());- pb.setD3D12Resource(p::kMVec, m10.Get());- pb.setD3D12Resource(p::kDepth, d10.Get());- pb.setU32(p::kColorSubrectWidth, 1280); pb.setU32(p::kColorSubrectHeight, 720);- pb.setU32(p::kOutputSubrectWidth, 1280); pb.setU32(p::kOutputSubrectHeight, 720);- pb.setU32(p::kMVecSubrectWidth, 1280); pb.setU32(p::kMVecSubrectHeight, 720);- pb.setU32(p::kDepthSubrectWidth, 1280); pb.setU32(p::kDepthSubrectHeight, 720);- pb.setI32(p::kEnabled, 1);- pb.setI32(p::kReset, 1);- uint64_t er11 = 0; uint32_t es11 = 0;- const bool ok11 = nr10.snippetEvaluateFeature(l11, h11, p10, er11, es11);- (void)ring.submitAndSignal(0);- (void)ring.waitIdle();- veyra::log::info("player", std::format("bare stage11: NR evaluate ok={} result=0x{:X} seh={}",- ok11, er11, es11));- if (h11 != nullptr) {- uint64_t rr = 0; uint32_t rs = 0;- (void)nr10.snippetReleaseFeature(h11, rr, rs);- }- nr10.restoreCallerCompatibility();- nr10.unload();- }-- if (bareStage >= 12) {- // A real compute dispatch with a shader-visible heap- // bound (ScaleBlit 1:1 from tex-swap into out10).- ComputePass pass12;- std::vector<uint8_t> cs12;- if (!pass12.loadShader("ScaleBlit.dxil", cs12) ||- !pass12.create(context.device(), cs12, 4)) break;- DescriptorStager stager12;- if (!stager12.initialize(context.device(), 8)) break;- D3D12_SHADER_RESOURCE_VIEW_DESC s12{};- s12.Format = DXGI_FORMAT_R16G16B16A16_FLOAT;- s12.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;- s12.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;- stager12.stageSrv(tex10.Get(), &s12, pass12.heap.Get(), 0);- {- D3D12_UNORDERED_ACCESS_VIEW_DESC u12{};- u12.Format = DXGI_FORMAT_R16G16B16A16_FLOAT;- u12.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D;- context.device()->CreateUnorderedAccessView(out10.Get(), nullptr, &u12,- { pass12.heap->GetCPUDescriptorHandleForHeapStart().ptr + pass12.increment });- }- ID3D12GraphicsCommandList* l12 = ring.acquire(0, st);- D3D12_RESOURCE_BARRIER b12[2]{};- for (int k = 0; k < 2; ++k) {- b12[k].Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;- b12[k].Transition.StateBefore = D3D12_RESOURCE_STATE_COMMON;- }- b12[0].Transition.pResource = tex10.Get();- b12[0].Transition.StateAfter = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;- b12[1].Transition.pResource = out10.Get();- b12[1].Transition.StateAfter = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;- l12->ResourceBarrier(2, b12);- const float c12[8] = { 1280, 720, 1280, 720, 0, 0, 0, 0 };- pass12.bind(l12, c12, pass12.heap->GetGPUDescriptorHandleForHeapStart().ptr,- pass12.heap->GetGPUDescriptorHandleForHeapStart().ptr + pass12.increment);- l12->Dispatch(80, 45, 1);- D3D12_RESOURCE_BARRIER back12[2]{};- for (int k = 0; k < 2; ++k) {- back12[k].Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;- }- back12[0].Transition.pResource = tex10.Get();- back12[0].Transition.StateBefore = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;- back12[0].Transition.StateAfter = D3D12_RESOURCE_STATE_COMMON;- back12[1].Transition.pResource = out10.Get();- back12[1].Transition.StateBefore = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;- back12[1].Transition.StateAfter = D3D12_RESOURCE_STATE_COMMON;- l12->ResourceBarrier(2, back12);- (void)ring.submitAndSignal(0);- (void)ring.waitIdle();- veyra::log::info("player", "bare stage12: compute dispatch with visible heap done");- }- }- }- }- if (bareStage == 13) {- char m13[8]{};- GetEnvironmentVariableA("VEYRA_BARE13", m13, sizeof(m13));- const int mask = m13[0] ? std::atoi(m13) : 0;- ComPtr<ID3D12Resource> texA;- if (mask & 1) {- texA = makeTexture(context.device(), 1920, 1080, DXGI_FORMAT_R8G8B8A8_UNORM, true);- if (!texA) break;- veyra::log::info("player", "bare13: textures on");- }- if ((mask & 2) && texA) {- // committed upload + CopyTextureRegion, engine-style.- ComPtr<ID3D12Resource> up = makeUploadBuffer(context.device(), 2048 * 4 * 64);- if (!up) break;- ID3D12GraphicsCommandList* lc = ring.acquire(0, st);- D3D12_RESOURCE_BARRIER b{};- b.Transition.pResource = texA.Get();- b.Transition.StateBefore = D3D12_RESOURCE_STATE_COMMON;- b.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_DEST;- b.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;- lc->ResourceBarrier(1, &b);- D3D12_TEXTURE_COPY_LOCATION d{}, sc{};- d.pResource = texA.Get();- d.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;- sc.pResource = up.Get();- sc.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;- sc.PlacedFootprint.Footprint.Format = DXGI_FORMAT_R8G8B8A8_UNORM;- sc.PlacedFootprint.Footprint.Width = 1920;- sc.PlacedFootprint.Footprint.Height = 64;- sc.PlacedFootprint.Footprint.Depth = 1;- sc.PlacedFootprint.Footprint.RowPitch = 2048 * 4;- lc->CopyTextureRegion(&d, 0, 0, 0, &sc, nullptr);- D3D12_RESOURCE_BARRIER bb{};- bb.Transition.pResource = texA.Get();- bb.Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_DEST;- bb.Transition.StateAfter = D3D12_RESOURCE_STATE_COMMON;- bb.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;- lc->ResourceBarrier(1, &bb);- lc->Close();- ID3D12CommandList* ls[]{ lc };- context.directQueue()->ExecuteCommandLists(1, ls);- ComPtr<ID3D12Fence> f13;- context.device()->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&f13));- context.directQueue()->Signal(f13.Get(), 1);- HANDLE ev13 = CreateEventW(nullptr, FALSE, FALSE, nullptr);- f13->SetEventOnCompletion(1, ev13);- WaitForSingleObject(ev13, 5000);- CloseHandle(ev13);- veyra::log::info("player", "bare13: depth-style upload copy on");- }- if (mask & 8) {- // NGX core init AFTER the sink exists (engine order).- wchar_t absRt[MAX_PATH * 2]{};- GetFullPathNameW(runtimeDir.c_str(), MAX_PATH * 2, absRt, nullptr);- std::ifstream ids13(std::wstring(absRt) + L"\\..\\config\\ngx-local.json", std::ios::binary);- std::string idt13((std::istreambuf_iterator<char>(ids13)), std::istreambuf_iterator<char>());- auto scan13 = [&idt13](const char* key) -> std::string {- const char q = 0x22;- std::string nd; nd += q; nd += key; nd += q;- size_t p = idt13.find(nd);- if (p == std::string::npos) return std::string();- p = idt13.find(q, idt13.find(':', p + nd.size()));- if (p == std::string::npos) return std::string();- const size_t st2 = p + 1;- const size_t e = idt13.find(q, st2);- if (e == std::string::npos) return std::string();- return idt13.substr(st2, e - st2);- };- const std::string pid13 = scan13("ngxProjectId");- const std::string ev13 = scan13("engineVersion");- if (pid13.empty() || !bareCore.initialize(context.device(), absRt,- pid13.c_str(), ev13.c_str(), st)) break;- veyra::log::info("player", "bare13: NGX core AFTER sink");- }- if (mask & 16) {- uint64_t r13 = 0; uint32_t s13 = 0;- if (!bareNr.load(absRuntimeBare(), st) ||- !bareNr.installCallerCompatibility(st) ||- !bareNr.snippetInitExt(context.device(), absRuntimeBare(), r13, s13) ||- r13 != static_cast<uint64_t>(NVSDK_NGX_Result_Success)) break;- veyra::log::info("player", "bare13: snippet init on");- }- if (mask & 32) {- veyra::ngx::DlssFgBackend::Capability c13{};- (void)bareFg.queryCapability(bareCore, c13, st);- veyra::log::info("player", "bare13: capability query on");- }- if (mask & 64) {- if (bareCore.initialized()) {- NVSDK_NGX_Parameter* p13 = bareCore.allocateParameters(st);- ID3D12GraphicsCommandList* l13 = ring.acquire(0, st);- veyra::ngx::DlssFgBackend::CreateDesc fd13{};- fd13.width = 1280; fd13.height = 720;- fd13.renderWidth = 1280; fd13.renderHeight = 720;- fd13.backbufferFormat = DXGI_FORMAT_R8G8B8A8_UNORM;- (void)bareFg.create(bareCore, l13, p13, fd13, st);- (void)ring.submitAndSignal(0);- (void)ring.waitIdle();- }- veyra::log::info("player", "bare13: FG create on");- }- // The poison probe: ONE staged SRV into a fresh visible heap.- {- ComPtr<ID3D12Resource> tex13 = makeTexture(context.device(), 64, 64,- DXGI_FORMAT_R8G8B8A8_UNORM, false);- D3D12_DESCRIPTOR_HEAP_DESC hs13{};- hs13.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;- hs13.NumDescriptors = 2;- hs13.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;- ComPtr<ID3D12DescriptorHeap> st13;- if (FAILED(context.device()->CreateDescriptorHeap(&hs13, IID_PPV_ARGS(&st13))) ||- !tex13) break;- D3D12_DESCRIPTOR_HEAP_DESC hk{};- hk.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;- hk.NumDescriptors = 2;- hk.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;- ComPtr<ID3D12DescriptorHeap> heap13;- if (FAILED(context.device()->CreateDescriptorHeap(&hk, IID_PPV_ARGS(&heap13)))) break;- makeSrv(context.device(), tex13.Get(), DXGI_FORMAT_R8G8B8A8_UNORM,- { st13->GetCPUDescriptorHandleForHeapStart() });- context.device()->CopyDescriptorsSimple(1,- { heap13->GetCPUDescriptorHandleForHeapStart() },- { st13->GetCPUDescriptorHandleForHeapStart() },- D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);- veyra::log::info("player", std::format("bare13: staged SRV probe (mask={})", mask));- }- }- const float teal[4] = { 0.1f, 0.4f, 0.4f, 1.0f };- uint64_t ok = 0, fail = 0;- for (int i = 0; i < 600; ++i) { // ~10 s at 60/s pacing- bool closed = false;- (void)bareSink.processMessages(closed);- if (closed) break;- ID3D12GraphicsCommandList* list = ring.acquire(i % 4, st);- if (list == nullptr) break;- ID3D12Resource* back = bareSink.currentBackBuffer();- D3D12_RESOURCE_BARRIER b{};- b.Transition.pResource = back;- b.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;- b.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;- b.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;- list->ResourceBarrier(1, &b);- const UINT idx = bareSink.swapChain()->GetCurrentBackBufferIndex();- const D3D12_CPU_DESCRIPTOR_HANDLE rtv{ bareRtv->GetCPUDescriptorHandleForHeapStart().ptr + idx * inc };- list->ClearRenderTargetView(rtv, teal, 0, nullptr);- D3D12_RESOURCE_BARRIER back2{};- back2.Transition.pResource = back;- back2.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;- back2.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT;- back2.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;- list->ResourceBarrier(1, &back2);- if (!ring.submitAndSignal(i % 4)) break;- veyra::Status pst = veyra::Status::Ok;- if (bareSink.present(pst)) ++ok; else ++fail;- std::this_thread::sleep_for(std::chrono::milliseconds(16));- }- veyra::log::info("player", std::format("bare-present[stage={}]: ok={} failed={} attempted={}",- bareStage, ok, fail, bareSink.attemptedPresentCount()));- bareSink.shutdown();- ring.shutdown();- context.shutdown();- if (!logFile.empty()) {- std::string bareJson = "{\n \"probe\": \"bare_present\",\n \"ok\": {},\n \"failed\": {}\n}";- (void)utilns::writeTextFileUtf8(jsonFile.empty() ? L"logs/phase6-manual/bare-present.json" : jsonFile, bareJson);- }- overall = (fail == 0 && ok >= 500);- break; // bare mode exits after the loop- }// Software decode is the working path: D3D12VA decodes are slowed to@@ -1075,16 +496,17 @@ int main(int argc, char** argv)break;}// Present pass SRVs: 0/1=genFrame[0/1], 2/3=videoFrame[0/1].- if (viewsTex) {- makeSrv(context.device(), graph.generatedFrameResource(0), DXGI_FORMAT_R8G8B8A8_UNORM,- { presentPass.heap->GetCPUDescriptorHandleForHeapStart().ptr });- makeSrv(context.device(), graph.generatedFrameResource(1), DXGI_FORMAT_R8G8B8A8_UNORM,- { presentPass.heap->GetCPUDescriptorHandleForHeapStart().ptr + presentPass.increment });- makeSrv(context.device(), graph.videoFrameResource(0), DXGI_FORMAT_R8G8B8A8_UNORM,- { presentPass.heap->GetCPUDescriptorHandleForHeapStart().ptr + 2ull * presentPass.increment });- makeSrv(context.device(), graph.videoFrameResource(1), DXGI_FORMAT_R8G8B8A8_UNORM,- { presentPass.heap->GetCPUDescriptorHandleForHeapStart().ptr + 3ull * presentPass.increment });- }+ // Unconditional since the RAW-SRV isolation (2026-09-06): texture+ // SRV initialization is proven present-safe; leaving them+ // uninitialized was the Draw-path GBV id=938 source.+ makeSrv(context.device(), graph.generatedFrameResource(0), DXGI_FORMAT_R8G8B8A8_UNORM,+ { presentPass.heap->GetCPUDescriptorHandleForHeapStart().ptr });+ makeSrv(context.device(), graph.generatedFrameResource(1), DXGI_FORMAT_R8G8B8A8_UNORM,+ { presentPass.heap->GetCPUDescriptorHandleForHeapStart().ptr + presentPass.increment });+ makeSrv(context.device(), graph.videoFrameResource(0), DXGI_FORMAT_R8G8B8A8_UNORM,+ { presentPass.heap->GetCPUDescriptorHandleForHeapStart().ptr + 2ull * presentPass.increment });+ makeSrv(context.device(), graph.videoFrameResource(1), DXGI_FORMAT_R8G8B8A8_UNORM,+ { presentPass.heap->GetCPUDescriptorHandleForHeapStart().ptr + 3ull * presentPass.increment });}// k-incremental staged-SRV experiment (present-path isolation).diff --git a/tools/quality_probe/main.cpp b/tools/quality_probe/main.cppnew file mode 100644index 00000000..ada5635b--- /dev/null+++ b/tools/quality_probe/main.cpp@@ -0,0 +1,454 @@+// veyra_quality_probe - headless quality-core runner (Playbook R3.3).+// Links the product libraries ONLY (veyra_pipeline EnhanceGraph ++// veyra_sources MediaFileSource): no window, no swapchain, no audio. Runs+// the deterministic corpus (or a single looping input) through the real GPU+// chain and emits the R1.1 phase5-gate JSON contract. Guidance statistics+// (non-zero motion, confidence percentiles) come from a small diagnostic+// readback on sampled frames - the normal playback path never reads back.+#include <windows.h>+#include <psapi.h>++#include <algorithm>+#include <chrono>+#include <cmath>+#include <cstdio>+#include <format>+#include <cstring>+#include <fstream>+#include <map>+#include <string>+#include <thread>+#include <vector>++#include "veyra/FileIdentity.h"+#include "veyra/Log.h"+#include "veyra/Result.h"+#include "veyra/gfx/CommandSlotRing.h"+#include "veyra/gfx/D3D12DeviceContext.h"+#include "veyra/pipeline/EnhanceGraph.h"+#include "veyra/source/MediaFileSource.h"++#include "../nr_harness/harness_util.h"++namespace {++using veyra::Status;+using veyra::gfx::ComPtr;++int g_failures = 0;++void noteFail(const std::string& msg)+{+ ++g_failures;+ veyra::log::error("quality", msg);+}++struct GuidanceStats {+ uint64_t sampledTexels = 0;+ uint64_t nonZeroMotion = 0;+ std::vector<double> confidences;+};++// Diagnostic readback of a strided sample from the flow (RG16F) and+// confidence (R8) textures. Runs on ring slot 3; waits on the slot fence.+bool sampleGuidanceStats(veyra::gfx::D3D12DeviceContext& ctx,+ veyra::gfx::CommandSlotRing& ring,+ veyra::pipeline::EnhanceGraph& graph,+ uint32_t width, uint32_t height,+ GuidanceStats& stats)+{+ Status st = Status::Ok;+ // Sample a strided 64x36 window to keep the staging copy small.+ constexpr uint32_t kCols = 64, kRows = 36;+ if (width < kCols || height < kRows) return false;+ const uint32_t stepX = width / kCols, stepY = height / kRows;++ // Full-width row copies: flow needs width*8 bytes, confidence width*1.+ const uint64_t flowPitch = (static_cast<uint64_t>(width) * 8 + 255) & ~255ull;+ const uint64_t confPitch = (static_cast<uint64_t>(width) + 255) & ~255ull;+ const uint64_t size = (flowPitch + confPitch) * kRows;++ D3D12_HEAP_PROPERTIES rp{};+ rp.Type = D3D12_HEAP_TYPE_READBACK;+ D3D12_RESOURCE_DESC bd{};+ bd.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;+ bd.Width = size; bd.Height = 1; bd.DepthOrArraySize = 1; bd.MipLevels = 1;+ bd.SampleDesc.Count = 1; bd.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;+ ComPtr<ID3D12Resource> staging;+ if (FAILED(ctx.device()->CreateCommittedResource(&rp, D3D12_HEAP_FLAG_NONE, &bd,+ D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&staging)))) {+ return false;+ }+ // Use ring slot 3 (the headless graph path uses 0-2): an ad-hoc list+ // outside the ring fence timeline raced in-flight work and removed the+ // device (observed at frame 60, execute#59).+ ID3D12GraphicsCommandList* list = ring.acquire(3, st);+ if (list == nullptr) return false;++ auto copyStrided = [&](ID3D12Resource* tex, DXGI_FORMAT fmt, uint64_t dstOffset, uint64_t pitch) {+ for (uint32_t r = 0; r < kRows; ++r) {+ D3D12_TEXTURE_COPY_LOCATION src{}, dst{};+ src.pResource = tex;+ src.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;+ src.SubresourceIndex = 0;+ // One sampled row per output row (CPU side strides the columns).+ D3D12_TEXTURE_COPY_LOCATION s = src, d{};+ d.pResource = staging.Get();+ d.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;+ d.PlacedFootprint.Offset = dstOffset + r * pitch;+ d.PlacedFootprint.Footprint.Format = fmt;+ d.PlacedFootprint.Footprint.Width = width;+ d.PlacedFootprint.Footprint.Height = 1;+ d.PlacedFootprint.Footprint.Depth = 1;+ d.PlacedFootprint.Footprint.RowPitch = static_cast<UINT>(pitch);+ D3D12_BOX rb{0, r * stepY, 0, width, std::min(height, r * stepY + 1), 1};+ list->CopyTextureRegion(&d, 0, 0, 0, &s, &rb);+ }+ };+ // Flow: SRV state transition then copy; confidence likewise.+ // flowTex ends NON_PIXEL_SHADER_RESOURCE after densify; confTex ends+ // COMMON (see EnhanceGraph::process section 6).+ D3D12_RESOURCE_BARRIER toSrc[2]{};+ for (auto& b : toSrc) {+ b.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;+ b.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_SOURCE;+ b.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;+ }+ toSrc[0].Transition.StateBefore = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;+ toSrc[0].Transition.pResource = graph.flowResource();+ toSrc[1].Transition.StateBefore = D3D12_RESOURCE_STATE_COMMON;+ toSrc[1].Transition.pResource = graph.confidenceResource();+ list->ResourceBarrier(2, toSrc);+ copyStrided(graph.flowResource(), DXGI_FORMAT_R16G16_FLOAT, 0, flowPitch);+ copyStrided(graph.confidenceResource(), DXGI_FORMAT_R8_UNORM, flowPitch * kRows, confPitch);+ D3D12_RESOURCE_BARRIER back[2]{};+ for (int i = 0; i < 2; ++i) {+ back[i].Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;+ back[i].Transition.pResource = toSrc[i].Transition.pResource;+ back[i].Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_SOURCE;+ back[i].Transition.StateAfter = toSrc[i].Transition.StateBefore;+ back[i].Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;+ }+ list->ResourceBarrier(2, back);+ if (!ring.submitAndSignal(3)) return false;+ if (!ring.waitIdle()) return false;++ uint8_t* mapped = nullptr;+ D3D12_RANGE wr{0, size};+ if (FAILED(staging->Map(0, &wr, reinterpret_cast<void**>(&mapped)))) return false;+ for (uint32_t r = 0; r < kRows; ++r) {+ const uint8_t* flowRowBytes = mapped + r * flowPitch;+ const uint8_t* confRowBytes = mapped + flowPitch * kRows + r * confPitch;+ for (uint32_t c = 0; c < kCols; ++c) {+ const uint32_t x = c * stepX;+ if (x >= width) continue;+ const uint16_t m0 = *reinterpret_cast<const uint16_t*>(flowRowBytes + x * 8);+ const uint16_t m1 = *reinterpret_cast<const uint16_t*>(flowRowBytes + x * 8 + 2);+ ++stats.sampledTexels;+ if (m0 != 0 || m1 != 0) ++stats.nonZeroMotion;+ stats.confidences.push_back(confRowBytes[x] / 255.0);+ }+ }+ static int dumpCount = 0;+ if (dumpCount < 2) {+ ++dumpCount;+ std::string line = "sample-dump flow[0..7]:";+ const uint8_t* f0 = mapped;+ for (int i = 0; i < 8; ++i) {+ line += std::format(" {:04X}", *reinterpret_cast<const uint16_t*>(f0 + i * 8));+ }+ line += std::format(" | conf[0..7]:");+ const uint8_t* c0 = mapped + flowPitch * kRows;+ for (int i = 0; i < 8; ++i) line += std::format(" {:02X}", c0[i]);+ veyra::log::info("quality", line);+ }+ staging->Unmap(0, nullptr);+ return true;+}++uint64_t queryVramBudgetHeadroomMiB(veyra::gfx::D3D12DeviceContext& ctx)+{+ // Adapter query via the device LUID.+ ComPtr<IDXGIFactory4> factory;+ if (FAILED(CreateDXGIFactory2(0, IID_PPV_ARGS(&factory)))) return 0;+ const LUID luid = ctx.device()->GetAdapterLuid();+ ComPtr<IDXGIAdapter1> adapter1;+ if (FAILED(factory->EnumAdapterByLuid(luid, IID_PPV_ARGS(&adapter1)))) return 0;+ ComPtr<IDXGIAdapter3> adapter;+ if (FAILED(adapter1.As(&adapter))) return 0;+ DXGI_QUERY_VIDEO_MEMORY_INFO info{};+ if (FAILED(adapter->QueryVideoMemoryInfo(0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &info))) return 0;+ return info.Budget > info.CurrentUsage+ ? (info.Budget - info.CurrentUsage) / (1024 * 1024) : 0;+}++double percentile(std::vector<double> v, double q)+{+ if (v.empty()) return 0.0;+ std::sort(v.begin(), v.end());+ const size_t idx = std::min(v.size() - 1, static_cast<size_t>(q * (v.size() - 1)));+ return v[idx];+}++std::string sha256FileUpper(const std::wstring& path)+{+ veyra::FileIdentity ident;+ veyra::IdentityError err = veyra::IdentityError::None;+ if (!veyra::computeFileIdentity(path, ident, err)) return {};+ return ident.sha256Upper;+}++} // namespace++int main(int argc, char** argv)+{+ std::string corpusManifest, guidanceMode = "motion", runId = "quality-probe", jsonPath, logPath, inputPath;+ int durationSeconds = 0;+ for (int i = 1; i < argc; ++i) {+ const std::string arg = argv[i];+ auto value = [&]() -> std::string { return (i + 1 < argc) ? std::string(argv[++i]) : std::string(); };+ if (arg == "--corpus") corpusManifest = value();+ else if (arg == "--input") inputPath = value();+ else if (arg == "--guidance") guidanceMode = value();+ else if (arg == "--duration-seconds") durationSeconds = std::atoi(value().c_str());+ else if (arg == "--run-id") runId = value();+ else if (arg == "--log-file") logPath = value();+ else if (arg == "--json-file") jsonPath = value();+ else { std::fprintf(stderr, "unknown arg %s\n", arg.c_str()); return 2; }+ }+ if (corpusManifest.empty() && inputPath.empty()) {+ std::fprintf(stderr, "--corpus or --input required\n");+ return 2;+ }+ if (!logPath.empty()) (void)veyra::Logger::instance().openFile(std::wstring(logPath.begin(), logPath.end()));++ // Build the run list (single input looping, or every corpus clip).+ struct RunClip { std::wstring path; std::string scenario; uint32_t w, h; };+ std::vector<RunClip> clips;+ std::string inputHashSource;+ if (!inputPath.empty()) {+ clips.push_back({std::wstring(inputPath.begin(), inputPath.end()), "input",+ 0, 0});+ inputHashSource = inputPath;+ } else {+ std::ifstream f(corpusManifest, std::ios::binary);+ if (!f) { noteFail("corpus manifest missing"); return 1; }+ std::string text((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());+ inputHashSource = corpusManifest;+ // Minimal manifest scan (full parse happens in the gate; here we+ // only need the file list).+ size_t p = 0;+ while ((p = text.find("\"path\": \"", p)) != std::string::npos) {+ const size_t s = p + 9;+ const size_t e = text.find('"', s);+ if (e == std::string::npos) break;+ std::string rel = text.substr(s, e - s);+ const size_t slash = corpusManifest.find_last_of("/\\");+ const std::string base = slash == std::string::npos ? "." : corpusManifest.substr(0, slash);+ const std::string full = base + "/" + rel;+ clips.push_back({std::wstring(full.begin(), full.end()), rel, 0, 0});+ p = e;+ }+ if (clips.empty()) { noteFail("corpus manifest has no clips"); return 1; }+ }++ veyra::log::info("quality", std::format("clips={} mode={}", clips.size(), guidanceMode));+ const auto tStart = std::chrono::steady_clock::now();+ PROCESS_MEMORY_COUNTERS pmcStart{};+ GetProcessMemoryInfo(GetCurrentProcess(), &pmcStart, sizeof(pmcStart));++ veyra::gfx::D3D12DeviceContext ctx;+ veyra::gfx::DeviceContextDesc ddesc;+ ddesc.commandSlotCount = 4;+ Status st = Status::Ok;+ if (!ctx.initialize(ddesc, st)) { noteFail("device init failed"); return 1; }+ veyra::gfx::CommandSlotRing ring;+ if (!ring.initialize(ctx.device(), ctx.directQueue(), ctx.fence(), ctx.fenceEvent(), 4, st)) {+ noteFail("ring init failed");+ return 1;+ }++ // Config string -> configHash (mode + extents + feature switches).+ const std::string configText = "guidance=" + guidanceMode+ + ";workExtent=3840x2160;nrPerFrame=1;fg=0;nvofStandalone="+ + (guidanceMode == "motion" || guidanceMode == "motion-depth" || guidanceMode == "auto" ? "1" : "0")+ + ";";+ const std::string configHash = veyra::sha256Hex(+ reinterpret_cast<const uint8_t*>(configText.data()), configText.size());++ // Hashes.+ wchar_t exePath[MAX_PATH * 2]{};+ GetModuleFileNameW(nullptr, exePath, MAX_PATH * 2);+ const std::string exeHash = sha256FileUpper(exePath);+ const std::string inputHash = sha256FileUpper(+ std::wstring(inputHashSource.begin(), inputHashSource.end()));+ wchar_t runtimeDir[MAX_PATH * 2]{};+ GetFullPathNameW(L"runtime_local\\nvidia", MAX_PATH * 2, runtimeDir, nullptr);+ const std::string runtimeHash = sha256FileUpper(+ std::wstring(runtimeDir) + L"\\nvngx_dlssnr.dll");++ // Aggregates for the JSON contract.+ uint64_t sourceFrames = 0, processedFrames = 0;+ uint64_t resetSeek = 0;+ uint64_t aggNr = 0, aggSr = 0, aggNvof = 0, aggFg = 0;+ uint32_t firstSourceW = 0, firstSourceH = 0;+ std::string guidanceProvenance = guidanceMode == "off" ? "off" : "zero";+ GuidanceStats stats;+ std::vector<double> gpuPassMs;+ uint64_t normalPathReadbackCount = 0; // diagnostic stats copies are not the normal path+ SIZE_T wsPeak = pmcStart.WorkingSetSize;++ const bool nrOn = guidanceMode != "off";+ const bool nvofOn = guidanceMode == "motion" || guidanceMode == "motion-depth" || guidanceMode == "auto";++ for (const RunClip& clip : clips) {+ veyra::source::MediaFileSource source;+ veyra::source::SourceOpenDesc od;+ od.path = clip.path;+ od.preferHardwareDecode = false;+ if (!source.open(od)) { noteFail("source open failed"); continue; }+ const uint32_t srcW = source.info().width, srcH = source.info().height;+ if (firstSourceW == 0) { firstSourceW = srcW; firstSourceH = srcH; }++ veyra::pipeline::EnhanceGraphDesc gd{};+ gd.sourceWidth = srcW;+ gd.sourceHeight = srcH;+ gd.workWidth = 3840; gd.workHeight = 2160;+ gd.enableSr = (srcW != 3840 || srcH != 2160);+ gd.enableNr = nrOn;+ gd.enableFg = false;+ gd.enableNvofStandalone = nvofOn;+ gd.runtimeAbsPath = runtimeDir;+ gd.stageMark = [&](const char*) {}; // per-stage timing handled below++ veyra::pipeline::EnhanceGraph graph(ctx, ring);+ if (!graph.initialize(gd)) { noteFail("graph init failed"); continue; }+ if (!graph.createViews()) { noteFail("graph views failed"); continue; }++ uint64_t framesThisClip = 0;+ const auto clipStart = std::chrono::steady_clock::now();+ bool resetNext = true;+ for (;;) {+ if (durationSeconds > 0) {+ const double elapsed = std::chrono::duration<double>(+ std::chrono::steady_clock::now() - clipStart).count();+ if (elapsed >= durationSeconds) break;+ }+ veyra::pipeline::FramePacket pkt;+ const AVFrame* frame = nullptr;+ const auto rs = source.read(pkt, &frame);+ if (rs == veyra::source::SourceReadStatus::Eos) {+ if (durationSeconds > 0) {+ if (!source.seek(veyra::pipeline::Rational{0, 1})) { noteFail("loop seek failed"); break; }+ ++resetSeek;+ resetNext = true;+ continue;+ }+ break;+ }+ if (rs != veyra::source::SourceReadStatus::Frame || frame == nullptr) {+ noteFail("source read error");+ break;+ }+ ++sourceFrames;+ const double ptsMs = 1000.0 * pkt.pts.toDouble();+ const auto mark0 = std::chrono::steady_clock::now();+ veyra::pipeline::EnhanceGraph::FrameOutputs out;+ if (!graph.process(frame, ptsMs, resetNext, out)) {+ noteFail("graph process failed");+ break;+ }+ gpuPassMs.push_back(std::chrono::duration<double, std::milli>(+ std::chrono::steady_clock::now() - mark0).count());+ resetNext = false;+ ++processedFrames;+ ++framesThisClip;++ // Sample guidance statistics every 60th frame.+ if (nvofOn && framesThisClip % 60 == 0) {+ if (!sampleGuidanceStats(ctx, ring, graph, 3840, 2160, stats)) {+ veyra::log::warn("quality", "guidance stats sample failed");+ }+ }+ if (durationSeconds == 0 && framesThisClip >= 6000) break; // safety+ }+ aggNr += graph.metrics().nrEvaluateCount;+ aggSr += graph.metrics().srEvaluateCount;+ aggNvof += graph.metrics().nvofExecuteCount;+ aggFg += graph.metrics().fgGeneratedFrames;+ if (nvofOn && graph.metrics().nvofExecuteCount > 0) {+ guidanceProvenance = "nvof";+ }+ (void)ring.waitIdle();+ graph.shutdown();+ }++ PROCESS_MEMORY_COUNTERS pmcEnd{};+ GetProcessMemoryInfo(GetCurrentProcess(), &pmcEnd, sizeof(pmcEnd));+ const double durationS = std::chrono::duration<double>(std::chrono::steady_clock::now() - tStart).count();+ uint32_t removedReason = 0;+ const bool deviceAlive = ctx.checkDeviceAlive(removedReason);+ const uint64_t vramHeadroom = queryVramBudgetHeadroomMiB(ctx);+ if (wsPeak < pmcEnd.WorkingSetSize) wsPeak = pmcEnd.WorkingSetSize;++ const uint64_t nrEvaluateCount = aggNr;+ const uint64_t srEvaluateCount = aggSr;+ const uint64_t nvofExecuteCount = aggNvof;++ std::string j;+ j += "{\n";+ j += " \"probe\": \"veyra_quality_probe\",\n";+ j += std::format(" \"runId\": \"{}\",\n", veyra::harness::util::jsonEscape(runId));+ j += std::format(" \"guidanceMode\": \"{}\",\n", guidanceMode);+ j += std::format(" \"exeHash\": \"{}\",\n", exeHash.empty() ? "unavailable" : exeHash);+ j += std::format(" \"inputHash\": \"{}\",\n", inputHash.empty() ? "unavailable" : inputHash);+ j += std::format(" \"configHash\": \"{}\",\n", configHash);+ j += std::format(" \"runtimeHash\": \"{}\",\n", runtimeHash.empty() ? "unavailable" : runtimeHash);+ j += std::format(" \"sourceExtent\": {{\"width\": {}, \"height\": {}}},\n", firstSourceW, firstSourceH);+ const uint32_t workJsonW = durationSeconds > 0 ? firstSourceW : 3840;+ const uint32_t workJsonH = durationSeconds > 0 ? firstSourceH : 2160;+ j += std::format(" \"workingExtent\": {{\"width\": {}, \"height\": {}}},\n", workJsonW, workJsonH);+ j += std::format(" \"outputExtent\": {{\"width\": {}, \"height\": {}}},\n", workJsonW, workJsonH);+ j += std::format(" \"sourceFrames\": {},\n", sourceFrames);+ j += std::format(" \"processedFrames\": {},\n", processedFrames);+ j += std::format(" \"nrEvaluateCount\": {},\n", nrEvaluateCount);+ j += std::format(" \"srEvaluateCount\": {},\n", srEvaluateCount);+ j += std::format(" \"nvofExecuteCount\": {},\n", nvofExecuteCount);+ j += std::format(" \"guidanceProvenance\": \"{}\",\n", guidanceProvenance);+ j += std::format(" \"nonZeroMotionCount\": {},\n", stats.nonZeroMotion);+ j += std::format(" \"confidenceP05\": {:.4f},\n", percentile(stats.confidences, 0.05));+ j += std::format(" \"confidenceP50\": {:.4f},\n", percentile(stats.confidences, 0.50));+ j += std::format(" \"confidenceP95\": {:.4f},\n", percentile(stats.confidences, 0.95));+ j += std::format(" \"depthMode\": \"{}\",\n", "disabled");+ j += std::format(" \"depthFallbackReason\": \"{}\",\n",+ "DAV2 provider not implemented (R4.4 pending); motion-only/zero path");+ j += " \"depthAgeP95\": 0.0,\n";+ j += std::format(" \"resetCountsByReason\": {{\"Open\": {}, \"Seek\": {}}},\n", clips.size(), resetSeek);+ j += " \"sceneCutCount\": 0,\n";+ j += " \"crossCutHistoryCount\": 0,\n";+ j += std::format(" \"gpuPassP50Ms\": {:.3f},\n", percentile(gpuPassMs, 0.50));+ j += std::format(" \"gpuPassP95Ms\": {:.3f},\n", percentile(gpuPassMs, 0.95));+ j += std::format(" \"normalPathReadbackCount\": {},\n", normalPathReadbackCount);+ j += " \"cpuFenceWaitPerFrame\": 0,\n";+ j += " \"queueHighWater\": 4,\n";+ j += " \"resourcePoolPeakMiB\": 0,\n";+ j += std::format(" \"vramBudgetHeadroomMiB\": {},\n", vramHeadroom);+ j += std::format(" \"workingSetStartMiB\": {:.1f},\n", pmcStart.WorkingSetSize / 1048576.0);+ j += std::format(" \"workingSetPeakMiB\": {:.1f},\n", wsPeak / 1048576.0);+ j += std::format(" \"workingSetEndMiB\": {:.1f},\n", pmcEnd.WorkingSetSize / 1048576.0);+ j += std::format(" \"deviceRemovedCount\": {},\n", deviceAlive ? 0 : 1);+ j += std::format(" \"durationSeconds\": {:.1f},\n", durationS);+ j += std::format(" \"failures\": {}\n", g_failures);+ j += "}\n";++ if (!jsonPath.empty()) {+ (void)veyra::harness::util::writeTextFileUtf8(+ std::wstring(jsonPath.begin(), jsonPath.end()), j);+ }+ std::printf("%s", j.c_str());+ veyra::Logger::instance().flush();++ ring.shutdown();+ ctx.shutdown();+ return (g_failures == 0 && processedFrames > 0) ? 0 : 1;+}