Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.
C++
perf: archive full compute graph correctness and measured queue results
Veyra Goal Agent6b5718e8a45d
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 15dbef49..210849f6 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -1044,6 +1044,10 @@ add_executable(veyra_sr_reconstruction_tests tests/integration/SrReconstructionTtarget_compile_features(veyra_ngx_compute_queue_experiment PRIVATE cxx_std_20)target_compile_options(veyra_ngx_compute_queue_experiment PRIVATE /utf-8)target_link_libraries(veyra_ngx_compute_queue_experiment PRIVATE veyra_engine)+ add_executable(veyra_nr_graph_queue_experiment tests/perf/NrGraphQueueExperiment.cpp)+ target_compile_features(veyra_nr_graph_queue_experiment PRIVATE cxx_std_20)+ target_compile_options(veyra_nr_graph_queue_experiment PRIVATE /utf-8)+ target_link_libraries(veyra_nr_graph_queue_experiment PRIVATE veyra_engine)target_compile_features(veyra_nr_recent_cache_experiment PRIVATE cxx_std_20)target_compile_options(veyra_nr_recent_cache_experiment PRIVATE /utf-8)target_link_libraries(veyra_nr_recent_cache_experiment PRIVATE veyra_engine bcrypt)diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.mdindex 1bef75f2..97b22d11 100644--- a/docs/CURRENT_STATUS.md+++ b/docs/CURRENT_STATUS.md@@ -4,6 +4,8 @@追加实测:2d空闲预热三组首次成功软件Present约1942→100、2053→107、1733→92ms,54张完整输出0差异、5项生命周期通过,已保留待R0(23591e2)。2c仅单NR保留,SR/SRNR旧实例复用每轮21/50帧不一致已拒绝;2b后台创建新鲜输出Present P99 32.044→74.189ms、间隔>33.333ms次数3→55,未加入产品。队列/自动尺寸/黑边/多NR/跨帧与全回归继续,不称全方案完成。+本轮队列检查已收尾:HIGH实际2X/3X竞争12组,2X P99退0.46%而3X改善1.35%,不足以默认启用;原普通队列保持。compute单特性540帧与完整Graph/NVOF/2X/3X二十四组2502输出及PTS均一致、debug0,源码只保留为测试候选,真实UI性能及B-off未跑,不记提速。用户要求这一轮结束汇报,当前无运行测试;整份Goal仍active,不标完成或暂停。+公开版本:2.0.3(main `354b1c6`,产品源码 `f82f649`);AMD/NVIDIA分包、AMD NR宿主、VFG全档、Xbox/导出码率/背景/极简缺口修复已发布。当前优化从本地修复tip `8cdc612` 开出 `codex/perf-nr-20261004`,工作树 `E:/项目/Veyra/worktrees/perf-nr-20261004`;继承已验RTSS误提示/重启循环、自定义倍速/字幕/UI热路径/专业布局和全屏恢复。它们尚未进入远端2.0.3,不能将本地候选称为公开版本。本轮按 `PERF_PLAN_NR_2026-10-03.md` / `PERF_EXECUTION_NR_2026-10-04.md`:先对齐文档/归档,再全新构建当前基线、逐节点A/B/B-off复测和存档,负优化回退。原方案中RTSS/启动优化“未合并”和2.0.1基线为历史状态,不再执行重复合并。M1五设置各三轮优化前基线已封存;2a核心复用暖创建减少约65–76%,三轮画面完全一致,保留待R0。重复帧整链复用/节奏盲预测均有画面反例,未加入产品;E1/E2/E3实验分别记录边界。5c已保留:单NR暂停残差编辑减少89.74%,自身暂停GPU三轮约2.237→0.011%;四FG暂停/恢复/seek通过,导出等最终回归仍待。2c单NR缓存实际界面create约363.9→3.6ms,画面及压力失效通过;3a三档已接入,普通默认,实测60Hz实时P99改善6.83%,High无稳定收益。其余节点继续,不能称全方案完成。下面早期阶段条目均按各自日期理解。diff --git a/docs/PERF_3C_QUEUES_2026-10-04.md b/docs/PERF_3C_QUEUES_2026-10-04.mdindex 5d4c57ec..363dccca 100644--- a/docs/PERF_3C_QUEUES_2026-10-04.md+++ b/docs/PERF_3C_QUEUES_2026-10-04.md@@ -10,6 +10,23 @@ RTX5070/616.56、原版E16及Lecram F95 NR各direct/compute三轮、DLSS SR dire官方接口接收ID3D12GraphicsCommandList,不因此推断所有命令类型通用,兼容性由本轮实际调用验证:[NVIDIA接口定义](https://github.com/NVIDIA/DLSS/blob/main/include/nvsdk_ngx.h)。跨队列仍必须使用正确资源状态与fence:[Microsoft资源依赖说明](https://learn.microsoft.com/en-us/windows/win32/direct3d12/using-resource-barriers-to-synchronize-resource-states-in-direct3d-12)。-## HIGH呈现实测(进行中)+## HIGH呈现实测(已完成,拒绝默认HIGH)-独立FG DIRECT呈现队列,先CheckFeatureSupport再Create,读回GetDesc记录实际Priority。进程调度保持普通,两个NR+DLSS SR+DLSS2X/3X,另一个自有三NR满载进程;相同M1/尺寸/运行库/驱动,每档三轮Normal/HIGH交错,50秒稳态。记录新鲜原/生成帧成功Present间隔、GPU/掉帧、竞争进程实际完成率。nr-queue-priority.py B2d B3c-present-priority-v1正在执行;结果未完成前不判断收益,也不默认开启HIGH。后续完整compute路径根据实际兼容与尾部间隔再决定,R0仍待。+独立FG DIRECT呈现队列,先CheckFeatureSupport再Create,读回GetDesc记录实际Priority。进程调度保持普通,两个NR+DLSS SR+DLSS2X/3X,另一个自有三NR满载进程;相同M1/尺寸/运行库/驱动,每档三轮Normal/HIGH交错,50秒稳态。nr-queue-priority.py B2d B3c-present-priority-v1十二组完成,所有请求实际读回0/100,无source preview skip/设备故障。++| 设置 | 队列 | 软件Present P95 | P99 | 每轮max中位 | 处理时间滚动P95中位 | 竞争图完成/s |+|---|---|---:|---:|---:|---:|---:|+| 2X | Normal | 17.1023 | 17.3202 | 63.1653 | 27.653 | 15.8293 |+| 2X | HIGH | 17.0946 | 17.4002 | 73.4092 | 27.677 | 15.7525 |+| 3X | Normal | 11.5513 | 16.7883 | 78.4057 | 30.436 | 13.2248 |+| 3X | HIGH | 11.5418 | 16.5618 | 74.1415 | 30.587 | 13.2990 |++各列为三个运行统计量的中位数,ms(最后列除外),不是物理扫描;滚动P95观察的中位也不冒充全帧aggregate percentile。2X P99+0.46%、max+16.22%;3X P99-1.35%、max-5.44%,处理成本+0.50%。改善随倍率不稳定,拒绝默认HIGH,产品仍普通队列。测试ENV暂留用于尚未完成的compute组合对照,不当成可用性能功能或发布默认。三轮范围、每帧submit/负载/GPU环境/构建身份见同任务B3c-present-priority-v1-*、B3c-present-priority-v1-summary.json与B3c-present-priority-v1-comparison.json。++## 完整处理图正确性(已完成,性能仍待)++前存档0212db3 / checkpoint/perf-nr-3c-graph-before-20261004。单PreviewGpuSession增加仅测试ENV的COMPUTE生产队列,device/Core/adapter仍一个;ring作为该fence唯一signaler。EnhanceGraph的解码、输入、NVOF、GPU-DIS/AMD和呈现归还依赖均等待ring实际queue,GPU timer也查询实际queue。DIRECT绘制/Present保留独立ring/fence;生产输出交给DIRECT时既有COMMON→PIXEL→COMMON往返保持,等待/生命周期不删。测试默认关闭,尚未获保留结论。++build-graph-compute-v1构建产品UI、负载fixture及native fixture,exit0。nr-graph-queue.py B2d B3c-graph-native-v1四组(单NR、NR+SR、双NR+SR+DLSS2X/3X)各direct/compute三次,共24/24通过;M1真实自然视频60帧/进程,1440当前真实输出+1062全部生成输出=2502完整图像。2X每进程59生成帧,3X118,完整SHA、dimensions/subframe/PTS每行均一致,fresh A-A噪声0。所有D3D12 debug错误/设备移除0,Core关闭通过。该native测试因诊断读回串行等待,只验证完整图/NVOF/生成/时间戳正确性,不用于吞吐收益。++CSV/全SHA/关键原始RGBA、身份/环境/命令均E:/项目/Veyra/logs/perf-nr-20261004/B3c-graph-native-v1-*与B3c-graph-native-v1-summary.json,build日志同目录。现阶段源码按checkpoint/perf-nr-3c-graph-candidate-20261004存档,校验收据E:/项目/Veyra/archives/perf-nr-20261004/3c-graph-candidate/checkpoint.json;下一轮需实际Qt在负载下DIRECT-normal/COMPUTE-normal/COMPUTE-HIGH三轮交错比较及独立B-off,收益不成立则revert该候选。用户要求当前轮结束汇报,尚未启动下一轮,R0仍待。diff --git a/docs/PERF_EXECUTION_NR_2026-10-04.md b/docs/PERF_EXECUTION_NR_2026-10-04.mdindex 210851ec..415dd643 100644--- a/docs/PERF_EXECUTION_NR_2026-10-04.md+++ b/docs/PERF_EXECUTION_NR_2026-10-04.md@@ -38,7 +38,7 @@| 3b | NR自动内部尺寸 | pending | 取决于E1、真实预算/画质证据 || 1b | 内容帧率预算 | rejected-prerequisite | 1a画面不成立,完整求值仍按transport次数;实测成本构造预算反例,PERF_1B_CONTENT_BUDGET;无生产改动 || 1c | 重复节奏预测 | rejected | 三种节奏单像素瞬态反例均漏第49帧且后续未检测;PERF_1C_CADENCE_REJECTION;无产品代码需回退 |-| 3c | 队列分工/呈现优先级 | in-progress | NR两运行库及SR共540帧compute/direct完整SHA0差异/debug0;HIGH独立呈现2X/3X竞争12组在跑;PERF_3C_QUEUES |+| 3c | 队列分工/呈现优先级 | in-progress-correctness-passed | 单特性540帧及完整Graph24组2502输出/PTS均一致/debug0;HIGH12组2X P99退0.46%而3X升1.35%,拒绝默认HIGH;完整compute实际性能下一轮;PERF_3C_QUEUES || 5b | 文件/导出跨帧并行 | pending | 保留源帧/PTS/flow依赖,不扩大实时延迟 || 4a | 多NR整链低分辨率调度 | pending | 保留每层残差参数;先测同尺寸与一致性 || 4b | 先粗后细组合 | pending | 核对现有逐层尺寸;不新增强制预设 |@@ -52,4 +52,4 @@基线驱动 `nr-series.py A` 已完成M1/S1、S2-720、S3、S4、S5-existing各三轮、稳态50秒;每个产品进程和驱动有270/280/299秒上限。1280×800窗口、真实GPU timestamp及CPU提交统计,不将16ms UI Timer当渲染FPS。现有UI没有精确50%档位,S2明确为1280×720(1080p输入维度66.7%、像素44.4%)。多层先粗后细已有逐层尺寸参数,S5核对现有行为,不计为新收益。-2a核心复用已实现并经修订版三轮A/B/B-off、真实UI、实际SDK容量与初始化失败检查,保留待R0最终回归。1a与1c有可复现画面反例,未加入产品。其余节点继续;不能用2a数据冒充持续播放或整个方案收益。+2a核心复用、2c单NR缓存、2d空闲预热、5c暂停复用已保留,3a提供用户可选进程优先级且普通默认,均待R0最终产品回归。1a/1c、依赖它们的1b、2b后台创建及SR缓存扩展均拒绝,证据保留。3c完整处理图正确性通过,但compute性能尚未验收,默认DIRECT;本轮候选源码存档checkpoint/perf-nr-3c-graph-candidate-20261004,收据E:/项目/Veyra/archives/perf-nr-20261004/3c-graph-candidate/checkpoint.json。当前轮测试结束先汇报,下一轮未启动;5a/3b/5b/4a/4b/UI/R0仍待,不能将局部耗时或暂停GPU改善冒充持续播放或整个方案收益。diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex a446ec93..164d3a3c 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -1,5 +1,11 @@# Veyra 工作记录+## 2026-10-04 PERF本轮收尾汇报:3c正确性通过、提速未验收++nr-queue-priority.py B2d B3c-present-priority-v1十二组全部exit0,实际HIGH100/Normal0读回;2X软件Present P99中位17.3202→17.4002ms/max63.1653→73.4092,3X P99 16.7883→16.5618/max78.4057→74.1415,拒绝默认HIGH。全环境/receipt/submit/竞争CSV与比较JSON已保存,详PERF_3C_QUEUES。++完整compute候选前存档0212db3,将原GPU依赖/计时指向实际ring queue,保留DIRECT呈现COMMON往返和消费者fence,默认关闭,仅VEYRA_TEST_GRAPH_COMPUTE。build-graph-compute-v1 UI/native/load构建exit0;nr-graph-queue.py B2d B3c-graph-native-v1二十四组(NR、SRNR、双NR+SR+DLSS2X/3X各direct/compute三次)exit0,1440当前原帧+1062全部生成帧完整SHA/PTS一致、A-A噪声0/debug0/device0/Core关闭。测试读回等待不用于吞吐收益。矩阵新增可审计TEST env和stageLabel避免重链接后复用旧EXE,后续完整compute交错性能驱动已准备但未启动。guard、diff-check、i18n1947项/零缺失通过。用户要求这轮跑完汇报进度,现无测试进程,Goal active未完成;本轮candidate归档后汇报,不merge/push/发布。收尾核对原始summary.json的24/24、2502输出、实际queueType与全部比较为0,Python AST通过;存档命令nr-control.py checkpoint 3c-graph candidate,标签checkpoint/perf-nr-3c-graph-candidate-20261004,收据E:/项目/Veyra/archives/perf-nr-20261004/3c-graph-candidate/checkpoint.json。+## 2026-10-04 PERF 3c候选与compute兼容CommandSlotRing匹配实际DIRECT/COMPUTE Type、频率用实际queue,HIGH独立呈现仅测试ENV/驱动查询/读回。build-compute-priority-v1 15步、v2 2步exit0。nr-compute.py B2d B3c-compute-v1 两NR DLL+SR各direct/compute三轮,18/18共540帧完整SHA一致/A-A噪声0,debug0/device0,正确RGBA16F SR输入;只证明API与作者图案兼容,不计速度收益。nr-queue-priority.py B2d B3c-present-priority-v1开始实际2X/3X竞争Normal/HIGH交错12组,结果仍待。完整日志/CSV/选帧像素/身份位于同任务label;详PERF_3C_QUEUES。diff --git a/include/veyra/engine/PreviewGpuSession.h b/include/veyra/engine/PreviewGpuSession.hindex 2984080c..5054da80 100644--- a/include/veyra/engine/PreviewGpuSession.h+++ b/include/veyra/engine/PreviewGpuSession.h@@ -8,6 +8,7 @@ namespace veyra::engine {// moves from idle prewarm to playback; no second device or snippet Init owner.struct PreviewGpuSession {gfx::D3D12DeviceContext context;+ Microsoft::WRL::ComPtr<ID3D12CommandQueue> executionQueue; // optional experimental compute producergfx::CommandSlotRing ring;ngx::NgxCoreCache core;RecentGraphCache recent{context};diff --git a/include/veyra/gfx/CommandSlotRing.h b/include/veyra/gfx/CommandSlotRing.hindex 96fd3c3d..2c4a67b2 100644--- a/include/veyra/gfx/CommandSlotRing.h+++ b/include/veyra/gfx/CommandSlotRing.h@@ -42,6 +42,7 @@ public:uint32_t slotCount() const { return slotCount_; }bool initialized() const { return initialized_; }+ ID3D12CommandQueue* queue() const {return queue_;}// Waits for this slot's outstanding fence value (if any), then resets the// allocator and command list. Returns the recycled list ready for record.diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.hindex 9e25cb59..4183e85a 100644--- a/include/veyra/pipeline/EnhanceGraph.h+++ b/include/veyra/pipeline/EnhanceGraph.h@@ -542,6 +542,7 @@ public:bool presentMotionValid(uint32_t slot) const { return presentMotionValid_[slot%2]; }uint64_t motionPreviousSource(uint32_t slot) const { return motionPreviousSource_[slot%2]; }uint64_t lastNvofSignal() const;+ bool usesComputeQueue() const;// Present-side access to the produced frame slots (probe sink path).ID3D12Resource* videoFrameResource(uint32_t slot) const;diff --git a/scripts/perf/nr-graph-queue.py b/scripts/perf/nr-graph-queue.pynew file mode 100644index 00000000..e4cf1742--- /dev/null+++ b/scripts/perf/nr-graph-queue.py@@ -0,0 +1,41 @@+"""Whole natural graph/NVOF/FG pixel and timestamp equality before timing."""+from pathlib import Path+import csv,importlib.util,json,os,re,shutil,subprocess,sys,time+ROOT=Path(__file__).resolve().parents[2];BASE=Path('E:/项目/Veyra');TASK='perf-nr-20261004'+spec=importlib.util.spec_from_file_location('matrix',ROOT/'scripts/perf/nr-matrix.py');matrix=importlib.util.module_from_spec(spec);spec.loader.exec_module(matrix)+variant,label=sys.argv[1:3];groups=sys.argv[3:] or ['nr','srnr','2x','3x'];matrix.assert_gpu_tests_idle()+app=BASE/'tests'/TASK/(label+'-app');assert not app.exists()+shutil.copytree(BASE/'test-packages'/TASK/'Veyra-2.0.3-perf-baseline-A-NVIDIA-win64-portable',app,copy_function=matrix.copy_dependency)+exe=app/'veyra_nr_graph_queue_experiment.exe';shutil.copy2(BASE/'build'/TASK/variant/exe.name,exe);results=[]+for group in groups:+ for repeat in range(1,4):+ for mode in ('direct','compute'):+ matrix.assert_gpu_tests_idle();name=f'{label}-{group}-{mode}-r{repeat}';out=BASE/'logs'/TASK/name;tmp=BASE/'tmp'/TASK/name+ for p in (out,tmp):p.mkdir(parents=True,exist_ok=False)+ env=os.environ.copy()+ for key in tuple(env):+ if key.upper().startswith('VEYRA_'):env.pop(key)+ env.update(TEMP=str(tmp),TMP=str(tmp))+ if mode=='compute':env['VEYRA_TEST_GRAPH_COMPUTE']='1'+ command=[str(exe),str(matrix.SOURCES['M1']),str(out),group];print('START',name,flush=True);before=matrix.gpu_query();start=time.monotonic()+ with (out/'console.log').open('xb') as f:+ try:rc=subprocess.run(command,cwd=app,env=env,stdout=f,stderr=subprocess.STDOUT,timeout=150).returncode+ except subprocess.TimeoutExpired:rc=124+ text=(out/'console.log').read_text(encoding='utf-8',errors='replace');line=next((s for s in text.splitlines() if s.startswith('GRAPH_QUEUE_RESULT ')),'')+ metrics={k:float(v) for k,v in re.findall(r'(\w+)=(-?\d+(?:\.\d+)?)',line)}+ rows=list(csv.DictReader((out/'frames.csv').open())) if (out/'frames.csv').exists() else []+ result={'group':group,'mode':mode,'repeat':repeat,'command':command,'exitCode':rc,'metrics':metrics,'frames':rows,'wallSeconds':time.monotonic()-start,+ 'exeSha256':matrix.digest(exe),'runtimeSha256':matrix.digest(app/'runtime/experimental/nvngx_dlssnr.dll'),+ 'sourceSha256':matrix.digest(matrix.SOURCES['M1']),'beforeGpu':before,'afterGpu':matrix.gpu_query(),+ 'passed':rc==0 and metrics.get('pass')==1 and metrics.get('debugErrors')==0,+ 'measurement':'Full product graph and NVOF; all current real/generated output pixels and PTS, waits/readbacks diagnostic only; no throughput claim'}+ (out/'result.json').write_text(json.dumps(result,ensure_ascii=False,indent=2),encoding='utf-8');results.append(result);print('RESULT',name,result['passed'],metrics,flush=True)+ if not result['passed']:print(text[-8500:],flush=True);raise SystemExit(1)+comparisons=[]+for group in groups:+ rows=[r for r in results if r['group']==group];ref=rows[0]['frames']+ comparisons.append({'group':group,'freshNoiseDifferentRows':sum(a!=b for r in rows if r['mode']=='direct' for a,b in zip(ref,r['frames'])),+ 'computeDifferentRows':sum(a!=b for r in rows if r['mode']=='compute' for a,b in zip(ref,r['frames'])),+ 'sameRowCounts':all(len(r['frames'])==len(ref) for r in rows)})+with (BASE/'logs'/TASK/(label+'-summary.json')).open('x',encoding='utf-8') as f:json.dump({'results':results,'comparisons':comparisons},f,ensure_ascii=False,indent=2)+print('GRAPH_QUEUE_COMPARISONS',comparisons,flush=True)diff --git a/scripts/perf/nr-matrix.py b/scripts/perf/nr-matrix.pyindex 657f9e18..fe277458 100644--- a/scripts/perf/nr-matrix.py+++ b/scripts/perf/nr-matrix.py@@ -88,8 +88,9 @@ def set_owned_gpu_priority(proc, priority):'setStatus':hex(b&0xffffffff),'afterStatus':hex(c&0xffffffff),'afterClass':after.value,'getAttempts':attempts,'applied':a==b==c==0 and after.value==priority}-def stage(variant):- path = BASE / 'tests' / TASK / ('app-' + variant)+def stage(variant,stageLabel=None):+ assert stageLabel is None or stageLabel.replace('-','').isalnum()+ path = BASE / 'tests' / TASK / ('app-' + variant+('-'+stageLabel if stageLabel else ''))if path.exists():assert digest(path/'veyra_qml_ui.exe')==digest(BUILD/variant/'veyra_qml_ui.exe'), 'Existing stage executable is stale; use a fresh variant'return path@@ -110,10 +111,10 @@ def stage(variant):main.write_text(text, encoding='utf-8')return path-def run(variant, material, setting, label, seconds, gpuPriority=None, allowedGpuPids=(),testEnv=None):+def run(variant, material, setting, label, seconds, gpuPriority=None, allowedGpuPids=(),testEnv=None,stageLabel=None):assert_gpu_tests_idle(allowedGpuPids)subprocess.run([sys.executable, '-B', str(ROOT / 'scripts/perf/nr-control.py'), 'guard'], check=True)- app = stage(variant)+ app = stage(variant,stageLabel)media = SOURCES.get(material, BASE / 'tests/perf-matrix/media' / (material + '.mkv'))assert media.is_file(), medialogs = BASE / 'logs' / TASK / labeldiff --git a/scripts/perf/nr-queue-priority.py b/scripts/perf/nr-queue-priority.pyindex 796bc552..a167a0d6 100644--- a/scripts/perf/nr-queue-priority.py+++ b/scripts/perf/nr-queue-priority.py@@ -3,16 +3,19 @@ from pathlib import Pathimport csv,importlib.util,json,os,re,shutil,subprocess,sys,time,statisticsROOT=Path(__file__).resolve().parents[2];BASE=Path('E:/项目/Veyra');TASK='perf-nr-20261004'spec=importlib.util.spec_from_file_location('matrix',ROOT/'scripts/perf/nr-matrix.py');matrix=importlib.util.module_from_spec(spec);spec.loader.exec_module(matrix)-variant,label=sys.argv[1:3];matrix.assert_gpu_tests_idle()+variant,label=sys.argv[1:3];full_graph=sys.argv[3:] == ['graph'];matrix.assert_gpu_tests_idle()app=BASE/'tests'/TASK/(label+'-load-app');assert not app.exists()shutil.copytree(BASE/'test-packages'/TASK/'Veyra-2.0.3-perf-baseline-A-NVIDIA-win64-portable',app,copy_function=matrix.copy_dependency)shutil.copy2(BASE/'build'/TASK/variant/'veyra_nr_gpu_competition_load.exe',app/'veyra_nr_gpu_competition_load.exe')-matrix.stage(variant);results=[]+matrix.stage(variant,label);results=[]for multiplier in (2,3):setting='S4-'+str(multiplier);matrix.CONFIGS[setting]={**matrix.CONFIGS['S4'],'multiplier':multiplier}- for repeat,order in enumerate([('normal','high'),('high','normal'),('normal','high')],1):- for priority in order:- matrix.assert_gpu_tests_idle();name=f'{label}-{multiplier}X-{priority}-r{repeat}';out=BASE/'logs'/TASK/(name+'-load');tmp=BASE/'tmp'/TASK/(name+'-load')+ orders=[('normal','high'),('high','normal'),('normal','high')]+ if full_graph:orders=[('direct-normal','compute-normal','compute-high'),('compute-high','direct-normal','compute-normal'),('compute-normal','compute-high','direct-normal')]+ for repeat,order in enumerate(orders,1):+ for mode in order:+ priority='high' if mode.endswith('high') else 'normal'+ matrix.assert_gpu_tests_idle();name=f'{label}-{multiplier}X-{mode}-r{repeat}';out=BASE/'logs'/TASK/(name+'-load');tmp=BASE/'tmp'/TASK/(name+'-load')for p in (out,tmp):p.mkdir(parents=True,exist_ok=False)env=os.environ.copy()for key in tuple(env):@@ -26,7 +29,9 @@ for multiplier in (2,3):if 'LOAD_READY' in (out/'console.log').read_text(encoding='utf-8',errors='replace'):breaktime.sleep(.25)assert load.poll() is None and 'LOAD_READY' in (out/'console.log').read_text(encoding='utf-8',errors='replace')- matrix.run(variant,'M1',setting,name,50,allowedGpuPids=(load.pid,),testEnv={'VEYRA_TEST_PRESENT_QUEUE_PRIORITY':priority})+ test_env={'VEYRA_TEST_PRESENT_QUEUE_PRIORITY':priority}+ if mode.startswith('compute-'):test_env['VEYRA_TEST_GRAPH_COMPUTE']='1'+ matrix.run(variant,'M1',setting,name,50,allowedGpuPids=(load.pid,),testEnv=test_env,stageLabel=label)assert load.poll() is None,'load ended before target';(out/'stop').write_text('owned target complete',encoding='utf-8');rc=load.wait(timeout=20)finally:if load.poll() is None:load.kill();load.wait(timeout=8)@@ -44,7 +49,8 @@ for multiplier in (2,3):v=sorted(intervals);return v[min(len(v)-1,int(len(v)*p))]completed=list(csv.DictReader((out/'completed.csv').open()));ready=int(re.search(r'NR_PERF_READY (\d+)',log).group(1))/1000fps=[float(r['completedFps']) for r in completed if ready+10<float(r['wallUtc'])<ready+45];assert len(fps)>15- result={'name':name,'multiplier':multiplier,'repeat':repeat,'priority':priority,'actualQueuePriorities':actual,+ if mode.startswith('compute-'):assert 'requested=COMPUTE createHr=0x0' in log,'Compute producer was not created'+ result={'name':name,'multiplier':multiplier,'repeat':repeat,'priority':priority,'producerMode':mode,'actualQueuePriorities':actual,'presentIntervalsMs':{'p50':pct(.5),'p95':pct(.95),'p99':pct(.99),'max':max(intervals),'count':len(intervals)},'loadCompletedFpsMedian':statistics.median(fps),'targetSummary':receipt['summary'],'targetExeSha256':receipt['exeSha256'],'loadExeSha256':matrix.digest(app/'veyra_nr_gpu_competition_load.exe'),'command':command,'passed':receipt['passed'],diff --git a/src/engine/PreviewGpuSession.cpp b/src/engine/PreviewGpuSession.cppindex df74715c..bc66ce04 100644--- a/src/engine/PreviewGpuSession.cpp+++ b/src/engine/PreviewGpuSession.cpp@@ -10,7 +10,14 @@ PreviewGpuSession::~PreviewGpuSession(){shutdown();}bool PreviewGpuSession::initialize(unsigned slots){if(context.initialized()&&ring.initialized())return true;Status status;gfx::DeviceContextDesc desc;desc.commandSlotCount=6;- if(!context.initialize(desc,status)||!ring.initialize(context.device(),context.directQueue(),context.fence(),context.fenceEvent(),slots,status))return false;+ if(!context.initialize(desc,status))return false;+ if(GetEnvironmentVariableW(L"VEYRA_TEST_GRAPH_COMPUTE",nullptr,0)){+ D3D12_COMMAND_QUEUE_DESC queueDesc{};queueDesc.Type=D3D12_COMMAND_LIST_TYPE_COMPUTE;+ const auto hr=context.device()->CreateCommandQueue(&queueDesc,IID_PPV_ARGS(&executionQueue));+ log::info("graph-queue",std::format("requested=COMPUTE createHr=0x{:X}",unsigned(hr)));+ if(FAILED(hr))return false;executionQueue->SetName(L"Veyra experimental compute producer");+ }+ if(!ring.initialize(context.device(),executionQueue?executionQueue.Get():context.directQueue(),context.fence(),context.fenceEvent(),slots,status))return false;gfx::applyRequestedGpuPriority();return true;}bool PreviewGpuSession::requestAllowed(const EnhancementSettings& settings){@@ -52,6 +59,6 @@ bool PreviewGpuSession::adopt(const EnhancementSettings& settings,const pipelinevoid PreviewGpuSession::shutdown(){if(ring.initialized())ring.drainQueue();if(graph){graph->shutdown();graph.reset();}recent.evict("device-close");- core.close("device-close");ring.shutdown();context.shutdown();prepared.reset();graphBytes=0;+ core.close("device-close");ring.shutdown();executionQueue.Reset();context.shutdown();prepared.reset();graphBytes=0;}}diff --git a/src/engine/VideoPresenter.cpp b/src/engine/VideoPresenter.cppindex 745ca6d5..1171d03f 100644--- a/src/engine/VideoPresenter.cpp+++ b/src/engine/VideoPresenter.cpp@@ -25,7 +25,7 @@ bool VideoPresenter::open(gfx::D3D12DeviceContext& ctx,HWND window,pipeline::EnhviewWidth_=viewHeight_=0;bufferMonitor_=nullptr;monitorWidth_=monitorHeight_=0;++generation_;Status st=Status::Ok;- if(graph.fgEnabled()&&!graph.xessEnabled()){+ if((graph.fgEnabled()||graph.usesComputeQueue())&&!graph.xessEnabled()){D3D12_COMMAND_QUEUE_DESC desc{};desc.Type=D3D12_COMMAND_LIST_TYPE_DIRECT;wchar_t requestedPriority[16]{};if(GetEnvironmentVariableW(L"VEYRA_TEST_PRESENT_QUEUE_PRIORITY",requestedPriority,16)&&std::wstring_view(requestedPriority)==L"high"){diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cppindex 129df12f..fb180056 100644--- a/src/pipeline/EnhanceGraph.cpp+++ b/src/pipeline/EnhanceGraph.cpp@@ -488,7 +488,7 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)const size_t dSize = dPitch_ * workH_;nv12Buf_.resize(lumaSize_ + chromaSize_);- if(!gpuTimer_.initialize(context_.device(),context_.directQueue()))veyra::log::warn("gpu-timestamp","GPU timing unavailable");+ if(!gpuTimer_.initialize(context_.device(),ring_.queue()))veyra::log::warn("gpu-timestamp","GPU timing unavailable");if (!createResources()) return false;if (!initZeroAndDepthTextures()) return false;if (!initNvof()) { failedBackend_=engine::FailedBackend::OpticalFlow; return false; }@@ -1265,7 +1265,7 @@ bool EnhanceGraph::initNgxFeatures()if(desc_.hdrWorking()){veyra::log::error("amd-nr","HDR input is not yet validated for this adapter; NR disabled by backend fallback");return false;}instance->amd=std::make_unique<LmxxfNrBackend>();const auto directory=std::filesystem::path(desc_.runtimeAbsPath)/L".."/L"amd-nr";- if(!instance->amd->open(directory.lexically_normal(),context_.device(),context_.directQueue(),context_.adapter().vendorId) || !instance->amd->admits(extent.width,extent.height))return false;+ if(!instance->amd->open(directory.lexically_normal(),context_.device(),ring_.queue(),context_.adapter().vendorId) || !instance->amd->admits(extent.width,extent.height))return false;}veyra::log::info("resolution",std::format("NR layer={} internal={}x{} composite={}x{} sharedMotion={}",index+1,extent.width,extent.height,fullW,fullH,motion!=nullptr));@@ -1883,7 +1883,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame// Presentation returns the shared output to COMMON before this parity// can be written again. Direct graph callers also need the GPU dependency.if(presentationFences_[parity]){- const HRESULT hr=context_.directQueue()->Wait(presentationFences_[parity].Get(),presentationValues_[parity]);+ const HRESULT hr=ring_.queue()->Wait(presentationFences_[parity].Get(),presentationValues_[parity]);if(FAILED(hr)){veyra::log::error("graph",std::format("presentation handoff wait hr=0x{:X}",unsigned(hr)));return false;}}hardwareInputFrames_[parity].reset();@@ -1926,7 +1926,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frameif(gpuRgb){auto* texture=hardwareSurface->texture;const auto td=texture->GetDesc();if(td.Width!=srcW_||td.Height!=srcH_||(td.Format!=DXGI_FORMAT_B8G8R8A8_UNORM&&td.Format!=DXGI_FORMAT_R16G16B16A16_FLOAT))return false;- if(hardwareSurface->waitFence&&FAILED(context_.directQueue()->Wait(hardwareSurface->waitFence,hardwareSurface->waitValue)))return false;+ if(hardwareSurface->waitFence&&FAILED(ring_.queue()->Wait(hardwareSurface->waitFence,hardwareSurface->waitValue)))return false;D3D12_SHADER_RESOURCE_VIEW_DESC srv{};srv.Format=td.Format;srv.ViewDimension=D3D12_SRV_DIMENSION_TEXTURE2D;srv.Shader4ComponentMapping=D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;srv.Texture2D.MipLevels=1;stager_.stageSrv(texture,&srv,rgbPass_.heap.Get(),3+parity);@@ -2004,7 +2004,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, FramewaitValue = hardwareSurface->waitValue;}if (waitFence != nullptr) {- if (FAILED(context_.directQueue()->Wait(waitFence, waitValue))) {+ if (FAILED(ring_.queue()->Wait(waitFence, waitValue))) {veyra::log::error("graph", "nv12 fence wait");return false;}@@ -2240,7 +2240,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frametracker_.transition(list,confTex_.Get(),D3D12_RESOURCE_STATE_COMMON);// The next ring submission signals this value; the parity upload// fence above retires all uses before these descriptors are reused.- if(!gpuDis_->dispatch(list,context_.directQueue(),context_.fence(),ring_.lastSignaledValue()+1,parity,+ if(!gpuDis_->dispatch(list,ring_.queue(),context_.fence(),ring_.lastSignaledValue()+1,parity,nvofInA_.Get(),nvofInB_.Get(),flowTex_.Get(),confTex_.Get(),previousSource_,sourceFrameId))return false;tracker_.transition(list,flowTex_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);++metrics_.gpuDisExecuteCount;haveFlow=true;@@ -2258,7 +2258,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame++metrics_.nvofExecuteCount;auto waitForFlow=[&](){const auto value=nvof_->nextOutValue()-1;- const HRESULT hr=context_.directQueue()->Wait(nvofOutFence_.Get(),value);+ const HRESULT hr=ring_.queue()->Wait(nvofOutFence_.Get(),value);if(FAILED(hr))veyra::log::error("graph",std::format("NVOF output queue wait value={} hr=0x{:X}",value,unsigned(hr)));return SUCCEEDED(hr);};@@ -3088,6 +3088,8 @@ uint64_t EnhanceGraph::lastNvofSignal() constreturn (nvof_ && nvof_->initialized()) ? (nvof_->nextOutValue() - 1) : 0;}+bool EnhanceGraph::usesComputeQueue() const {return ring_.queue()&&ring_.queue()->GetDesc().Type==D3D12_COMMAND_LIST_TYPE_COMPUTE;}+bool EnhanceGraph::nvofSessionInitialized() const{return nvof_ && nvof_->initialized();@@ -3119,7 +3121,7 @@ void EnhanceGraph::shutdown()lastAppliedSettings_.reset();pausedNrSettings_.reset();if (!initialized_ && !coreHost_ && !nrAdapter_ && !nvof_ && !srcRgba_) return;for(unsigned i=0;i<2;++i)if(presentationFences_[i]){- const HRESULT hr=context_.directQueue()->Wait(presentationFences_[i].Get(),presentationValues_[i]);+ const HRESULT hr=ring_.queue()->Wait(presentationFences_[i].Get(),presentationValues_[i]);if(FAILED(hr))veyra::log::error("graph",std::format("presentation teardown wait hr=0x{:X}",unsigned(hr)));}(void)ring_.drainQueue();(void)ring_.discardRecording();diff --git a/tests/perf/NrGraphQueueExperiment.cpp b/tests/perf/NrGraphQueueExperiment.cppnew file mode 100644index 00000000..2aa5f833--- /dev/null+++ b/tests/perf/NrGraphQueueExperiment.cpp@@ -0,0 +1,49 @@+#include "veyra/engine/PreviewGpuSession.h"+#include "veyra/engine/GraphDescription.h"+#include "veyra/source/MediaFileSource.h"+#include "veyra/sink/ImageExportSink.h"+#include "veyra/RuntimePaths.h"+#include "veyra/FileIdentity.h"+#include <d3d12sdklayers.h>+#include <fstream>+#include <iostream>++int wmain(int argc,wchar_t** argv){+ using namespace veyra;if(argc!=4)return 2;const std::wstring group=argv[3];+ if(group!=L"nr"&&group!=L"srnr"&&group!=L"2x"&&group!=L"3x")return 2;+ const bool sr=group!=L"nr",fg=group==L"2x"||group==L"3x";+ const std::filesystem::path out=argv[2];std::filesystem::create_directories(out);Logger::instance().openFile((out/L"engine.log").wstring());+ Microsoft::WRL::ComPtr<ID3D12Debug> debugLayer;if(FAILED(D3D12GetDebugInterface(IID_PPV_ARGS(&debugLayer))))return 2;debugLayer->EnableDebugLayer();+ engine::EffectChain chain;chain.nodeCount=fg?2:1;+ for(unsigned i=0;i<chain.nodeCount;++i){chain.nodes[i].type=engine::EffectType::NrEnhance;chain.nodes[i].enabled=true;+ chain.nodes[i].nr.temporal=false;chain.nodes[i].nr.sizePolicy=pipeline::NrSizePolicy::Realtime;}+ engine::EnhancementSettings settings;engine::fromChain(chain,settings);settings.sr=sr;settings.videoSrQuality=0;+ settings.srTarget=pipeline::SrTarget::Uhd4K;settings.multiplier=fg?(group==L"3x"?3:2):1;+ engine::StageRequest request;request.width=1920;request.height=1080;request.nr=true;request.sr=sr;request.fg=fg;request.fgMultiplier=settings.multiplier;+ pipeline::EnhanceGraphDesc desc;engine::describeStages(request,settings,desc);desc.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();+ engine::PreviewGpuSession session;if(!session.initialize()||!session.graph->initialize(desc)||!session.graph->createViews())return 2;+ source::MediaFileSource source;source::SourceOpenDesc open;open.path=argv[1];open.preferHardwareDecode=false;if(!source.open(open))return 2;+ std::ofstream frames(out/L"frames.csv");frames<<"frame,subframe,pts100ns,width,height,sha256\n";bool pass=true;unsigned completed=0,generated=0;+ for(unsigned i=0;i<60&&pass;++i){+ pipeline::FramePacket packet;const AVFrame* input=nullptr;pipeline::EnhanceGraph::FrameOutputs output;+ pass=source.read(packet,&input)==source::SourceReadStatus::Frame&&+ session.graph->process(input,packet.pts.toDouble()*1000,i==0,output,packet.sequence,&packet.colorInfo)&&session.ring.waitIdle();+ if(pass&&fg){for(unsigned spin=0;spin<1000&&!session.graph->resolveGeneration(output);++spin)Sleep(1);pass=output.gpuComplete();}+ auto record=[&](ID3D12Resource* texture,unsigned subframe,int64_t pts){sink::RgbaImage image;+ const bool ok=sink::readRgba8(session.context,session.ring,texture,image);if(ok){frames<<i<<','<<subframe<<','<<pts<<','<<image.width<<','<<image.height<<','<<sha256Hex(image.pixels.data(),image.pixels.size())<<'\n';frames.flush();+ if(i<3||i==59){std::ofstream raw(out/(L"frame-"+std::to_wstring(i)+L"-"+std::to_wstring(subframe)+L".rgba"),std::ios::binary);+ raw.write(reinterpret_cast<const char*>(image.pixels.data()),std::streamsize(image.pixels.size()));}}return ok;};+ if(pass)pass=record(session.graph->videoFrameResource(output.videoSlot),0,int64_t(packet.pts.toDouble()*10000000));+ for(unsigned f=0;f<output.batch.count&&pass;++f){const auto& item=output.batch.frames[f];if(item.kind!=pipeline::FrameKind::Generated)continue;+ pass=item.validity==pipeline::GenerationValidity::Valid&&item.lease&&record(item.lease->texture.Get(),item.subframe,item.pts100ns);if(pass)++generated;}+ if(pass)++completed;+ }+ source.close();session.ring.drainQueue();session.graph->shutdown();pass=session.core.close("graph-queue-test")&&pass;+ Microsoft::WRL::ComPtr<ID3D12InfoQueue> debug;unsigned errors=0;if(FAILED(session.context.device()->QueryInterface(IID_PPV_ARGS(&debug))))return 2;+ for(UINT64 i=0;i<debug->GetNumStoredMessages();++i){SIZE_T n=0;debug->GetMessage(i,nullptr,&n);std::vector<unsigned char> bytes(n);auto* m=reinterpret_cast<D3D12_MESSAGE*>(bytes.data());+ if(FAILED(debug->GetMessage(i,m,&n)))return 2;if(m->Severity<=D3D12_MESSAGE_SEVERITY_ERROR){++errors;std::cerr<<"DEBUG_ERROR "<<m->pDescription<<std::endl;}}+ const auto removed=session.context.device()->GetDeviceRemovedReason();const auto type=session.ring.queue()->GetDesc().Type;+ pass=pass&&completed==60&&(!fg||generated>40)&&errors==0&&SUCCEEDED(removed);debug.Reset();session.shutdown();+ std::cout<<"GRAPH_QUEUE_RESULT pass="<<pass<<" frames="<<completed<<" generated="<<generated<<" debugErrors="<<errors<<" deviceRemoved="<<unsigned(removed)<<" queueType="<<unsigned(type)<<std::endl;+ return pass?0:1;+}