Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.
C++
test: add matched 20-cycle NR SR rebuild and pixel baselines
Veyra Goal Agentad208e6d1517
diff --git a/CMakeLists.txt b/CMakeLists.txtindex d740bafe..c3291a58 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -1009,6 +1009,10 @@ add_executable(veyra_sr_reconstruction_tests tests/integration/SrReconstructionTtarget_compile_features(veyra_nr_concurrent_create_experiment PRIVATE cxx_std_20)target_compile_options(veyra_nr_concurrent_create_experiment PRIVATE /utf-8)target_link_libraries(veyra_nr_concurrent_create_experiment PRIVATE veyra_ngx)+ add_executable(veyra_nr_rebuild_benchmark tests/perf/NrRebuildBenchmark.cpp)+ target_compile_features(veyra_nr_rebuild_benchmark PRIVATE cxx_std_20)+ target_compile_options(veyra_nr_rebuild_benchmark PRIVATE /utf-8)+ target_link_libraries(veyra_nr_rebuild_benchmark PRIVATE veyra_engine)target_compile_features(veyra_nr_temporal_gpu_tests PRIVATE cxx_std_20)target_link_libraries(veyra_nr_temporal_gpu_tests PRIVATE veyra_pipeline)add_executable(veyra_gpu_timing_tests tests/integration/GpuTimingTests.cpp)diff --git a/scripts/perf/nr-rebuild.py b/scripts/perf/nr-rebuild.pynew file mode 100644index 00000000..c62a6e57--- /dev/null+++ b/scripts/perf/nr-rebuild.py@@ -0,0 +1,55 @@+"""Matched 20-cycle product-graph rebuild runs, preserving raw image outputs."""+from pathlib import Path+import csv+import importlib.util+import json+import os+import shutil+import statistics+import subprocess+import sys+import 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];assert all(x.replace('-','').isalnum() for x in (variant,label))+app=BASE/'tests'/TASK/(label+'-app');assert not app.exists()+package=BASE/'test-packages'/TASK/'Veyra-2.0.3-perf-baseline-A-NVIDIA-win64-portable'+shutil.copytree(package,app,copy_function=matrix.copy_dependency)+exe=app/'veyra_nr_rebuild_benchmark.exe';shutil.copy2(BASE/'build'/TASK/variant/exe.name,exe)+results=[]+def percentile(values,p):+ values=sorted(values);at=(len(values)-1)*p/100;low=int(at);high=min(low+1,len(values)-1)+ return values[low]+(values[high]-values[low])*(at-low)+groups=sys.argv[3:] or ['nr','sr','layers','sizes']+for group in groups:+ assert group in ('nr','sr','layers','sizes')+ for repeat in range(1,4):+ name=f'{label}-{group}-r{repeat}';out=BASE/'logs'/TASK/name;tmp=BASE/'tmp'/TASK/name+ out.mkdir(parents=True,exist_ok=False);tmp.mkdir(parents=True,exist_ok=False)+ env=os.environ.copy();env.update(TEMP=str(tmp),TMP=str(tmp),VEYRA_VERBOSE_FRAME_LOGS='1')+ if variant.endswith('off'):env['VEYRA_TEST_DISABLE_NGX_CORE_REUSE']='1'+ cmd=[str(exe),str(matrix.SOURCES['M1']),str(out),group]+ print('START',name,flush=True);start=time.monotonic()+ with (out/'console.log').open('xb') as log:+ try:rc=subprocess.run(cmd,cwd=app,env=env,stdout=log,stderr=subprocess.STDOUT,timeout=280).returncode+ except subprocess.TimeoutExpired:rc=124+ text=(out/'console.log').read_text(encoding='utf-8',errors='replace')+ rows=list(csv.DictReader((out/'rebuild.csv').open())) if (out/'rebuild.csv').exists() else []+ metrics={k:{'p50':statistics.median(float(r[k]) for r in rows),'p95':percentile([float(r[k]) for r in rows],95),+ 'min':min(float(r[k]) for r in rows),'max':max(float(r[k]) for r in rows)}+ for k in ('createMs','destroyMs','totalMs','vramLive','vramAfter')} if rows else {}+ r={'variant':variant,'group':group,'repeat':repeat,'command':cmd,'exitCode':rc,'wallSeconds':time.monotonic()-start,+ 'exeSha256':matrix.digest(exe),'sourceSha256':matrix.digest(matrix.SOURCES['M1']),+ 'nrSha256':matrix.digest(app/'runtime/experimental/nvngx_dlssnr.dll'),'rowCount':len(rows),'metrics':metrics,+ 'frameHashes':{p.name:matrix.digest(p) for p in sorted(out.glob('frame-*.rgba'))},+ 'passed':rc==0 and len(rows)==20 and 'RESULT pass=1 debugErrors=0 deviceRemoved=0' in text,+ 'measurement':'Native product graph, no actual Present; CPU create/destroy includes required GPU waits'}+ results.append(r);(out/'result.json').write_text(json.dumps(r,ensure_ascii=False,indent=2),encoding='utf-8')+ print('RESULT',name,rc,metrics,flush=True)+ if not r['passed']:+ print('\n'.join(text.splitlines()[-30:]),flush=True);raise SystemExit(1)+with (BASE/'logs'/TASK/(label+'-summary.json')).open('x',encoding='utf-8') as f:+ json.dump(results,f,ensure_ascii=False,indent=2)+print('REBUILD_COMPLETE',label,flush=True)diff --git a/tests/perf/NrRebuildBenchmark.cpp b/tests/perf/NrRebuildBenchmark.cppnew file mode 100644index 00000000..2302077a--- /dev/null+++ b/tests/perf/NrRebuildBenchmark.cpp@@ -0,0 +1,90 @@+#include "veyra/pipeline/EnhanceGraph.h"+#include "veyra/engine/GraphDescription.h"+#include "veyra/engine/EffectChain.h"+#include "veyra/source/MediaFileSource.h"+#include "veyra/sink/ImageExportSink.h"+#include "veyra/gfx/D3D12DeviceContext.h"+#include "veyra/gfx/CommandSlotRing.h"+#include "veyra/RuntimePaths.h"+#include "veyra/Log.h"+#include <dxgi1_4.h>+#include <d3d12sdklayers.h>+#include <chrono>+#include <filesystem>+#include <fstream>+#include <iostream>+#include <array>++// Fixed source frames through the real product graph, 20 rebuilds per group.+// No actual Present here: create/destroy CPU-with-GPU-wait latency is measured+// separately from pixel readbacks. Real UI/Present validation is a later test.+namespace {+double nowMs(){return std::chrono::duration<double,std::milli>(std::chrono::steady_clock::now().time_since_epoch()).count();}+}+int wmain(int argc,wchar_t** argv){+ using namespace veyra;+ if(argc!=4)return 2; // media, output, nr|sr|layers|sizes+ const std::wstring group=argv[3];+ if(group!=L"nr"&&group!=L"sr"&&group!=L"layers"&&group!=L"sizes")return 2;+ const std::filesystem::path out=argv[2];std::filesystem::create_directories(out);+ Logger::instance().openFile((out/L"engine.log").wstring());+ gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status status;+ gfx::DeviceContextDesc device;device.enableDebugLayer=true;+ if(!ctx.initialize(device,status)||!ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),6,status))return 2;+ source::MediaFileSource media;source::SourceOpenDesc open;open.path=argv[1];open.preferHardwareDecode=false;+ if(!media.open(open)||media.info().width!=1920||media.info().height!=1080)return 2;+ Microsoft::WRL::ComPtr<IDXGIFactory4> factory;Microsoft::WRL::ComPtr<IDXGIAdapter3> adapter;+ if(FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory)))||FAILED(factory->EnumAdapterByLuid(ctx.device()->GetAdapterLuid(),IID_PPV_ARGS(&adapter))))return 2;+ auto usage=[&](){DXGI_QUERY_VIDEO_MEMORY_INFO info{};return SUCCEEDED(adapter->QueryVideoMemoryInfo(0,DXGI_MEMORY_SEGMENT_GROUP_LOCAL,&info))?info.CurrentUsage:UINT64_MAX;};+ pipeline::EnhanceGraph graph(ctx,ring);+ std::ofstream csv(out/L"rebuild.csv");csv<<"cycle,nr,sr,layers,policy,destroyMs,createMs,totalMs,vramBefore,vramLive,vramAfter,nrEvaluations,srEvaluations,frameCount\n";+ bool pass=true;+ for(unsigned i=0;i<20&&pass;++i){+ const bool nr=group!=L"nr"||i%2==0,sr=group==L"sr"&&i%2==0;+ const unsigned layers=group==L"layers"?1+i%3:1;+ const pipeline::NrSizePolicy sizes[]={pipeline::NrSizePolicy::Native,pipeline::NrSizePolicy::P720,pipeline::NrSizePolicy::P480};+ const auto policy=group==L"sizes"?sizes[i%3]:pipeline::NrSizePolicy::Realtime;+ engine::EffectChain chain;chain.nodeCount=layers;+ for(unsigned layer=0;layer<layers;++layer){auto& node=chain.nodes[layer];node.type=engine::EffectType::NrEnhance;+ node.enabled=nr;node.nr.temporal=false;node.nr.sizePolicy=policy;}+ engine::EnhancementSettings settings;engine::fromChain(chain,settings);settings.sr=sr;settings.srTarget=pipeline::SrTarget::Uhd4K;+ settings.videoSrQuality=0;settings.nrTemporal=false;settings.multiplier=1;+ engine::StageRequest request;request.width=1920;request.height=1080;request.nr=nr;request.sr=sr;+ pipeline::EnhanceGraphDesc desc;engine::describeStages(request,settings,desc);+ desc.enableNvofStandalone=nr;desc.enableFg=false;desc.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();+ const auto before=usage();const auto start=nowMs();graph.shutdown();const auto destroyed=nowMs();+ pass=graph.initialize(desc)&&graph.createViews()&&ring.waitIdle();const auto created=nowMs();+ const auto live=usage();unsigned frames=0;+ const auto priorMetrics=graph.metrics();+ if(pass&&!media.seek({0,1000}))pass=false;+ sink::RgbaImage image;+ for(unsigned frame=0;frame<3&&pass;++frame){pipeline::FramePacket packet;const AVFrame* input=nullptr;+ pipeline::EnhanceGraph::FrameOutputs output;+ pass=media.read(packet,&input)==source::SourceReadStatus::Frame&&+ graph.process(input,packet.pts.toDouble()*1000,frame==0,output,packet.sequence,&packet.colorInfo)&&ring.waitIdle();+ if(pass&&frame==2)pass=sink::readRgba8(ctx,ring,graph.videoFrameResource(output.videoSlot),image);+ ++frames;+ }+ const auto metrics=graph.metrics();+ const auto nrDelta=metrics.nrEvaluateCount-priorMetrics.nrEvaluateCount,srDelta=metrics.srEvaluateCount-priorMetrics.srEvaluateCount;+ pass=pass&&frames==3&&nrDelta==uint64_t(nr?layers*3:0)&&srDelta==uint64_t(sr?3:0);+ if(pass){std::ofstream f(out/(L"frame-"+std::to_wstring(i)+L".rgba"),std::ios::binary);+ f.write(reinterpret_cast<const char*>(image.pixels.data()),std::streamsize(image.pixels.size()));+ std::cout<<"FRAME cycle="<<i<<" size="<<image.width<<'x'<<image.height<<" bytes="<<image.pixels.size()<<std::endl;}+ // A per-cycle release census complements peak/live usage and a later+ // all-features-off context close. Creation stays measured separately.+ const auto releaseStart=nowMs();graph.shutdown();const auto releaseEnd=nowMs();const auto released=usage();+ csv<<i<<','<<nr<<','<<sr<<','<<layers<<','<<unsigned(policy)<<','<<releaseEnd-releaseStart<<','<<created-destroyed<<','<<(created-destroyed)+(releaseEnd-releaseStart)<<','<<before<<','<<live<<','<<released<<','<<nrDelta<<','<<srDelta<<','<<frames<<'\n';csv.flush();+ std::cout<<"CYCLE i="<<i<<" createMs="<<created-destroyed<<" destroyMs="<<releaseEnd-releaseStart<<" pass="<<pass<<std::endl;+ }+ ring.drainQueue();graph.shutdown();media.close();+ Microsoft::WRL::ComPtr<ID3D12InfoQueue> debug;unsigned errors=0;+ if(FAILED(ctx.device()->QueryInterface(IID_PPV_ARGS(&debug))))return 2;+ for(UINT64 i=0;i<debug->GetNumStoredMessages();++i){SIZE_T size=0;debug->GetMessage(i,nullptr,&size);+ std::vector<unsigned char> data(size);auto* m=reinterpret_cast<D3D12_MESSAGE*>(data.data());+ if(FAILED(debug->GetMessage(i,m,&size)))return 2;+ if(m->Severity<=D3D12_MESSAGE_SEVERITY_ERROR){++errors;std::cerr<<m->pDescription<<std::endl;}}+ const auto removed=ctx.device()->GetDeviceRemovedReason();+ std::cout<<"RESULT pass="<<(pass&&errors==0&&SUCCEEDED(removed))<<" debugErrors="<<errors<<" deviceRemoved="<<unsigned(removed)<<std::endl;+ return pass&&errors==0&&SUCCEEDED(removed)?0:1;+}