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++
Revert "test(perf): verify prefetch output and separate creation from pipeline time"
Veyra Goal Agent484b425c636f
diff --git a/include/veyra/diagnostics/GpuQueueTrace.h b/include/veyra/diagnostics/GpuQueueTrace.hdeleted file mode 100644index e50f79ef..00000000--- a/include/veyra/diagnostics/GpuQueueTrace.h+++ /dev/null@@ -1,30 +0,0 @@-#pragma once-#include "veyra/diagnostics/FrameMetrics.h"-#include "veyra/Log.h"-#include <format>-namespace veyra::diagnostics {-// Test-only timestamp trace. Cross-queue timestamps require each queue's-// calibration; numerical equality of raw counters alone proves no overlap.-class GpuQueueTrace {- ID3D12CommandQueue* queue_=nullptr;const char* role_="";-public:- bool initialize(ID3D12CommandQueue* queue,const char* role){queue_=queue;role_=role;return calibrate();}- bool calibrate(){- if(!queue_)return false;UINT64 gpu=0,cpu=0,frequency=0;LARGE_INTEGER before{},after{},qpc{};- QueryPerformanceFrequency(&qpc);QueryPerformanceCounter(&before);- const HRESULT a=queue_->GetTimestampFrequency(&frequency),b=queue_->GetClockCalibration(&gpu,&cpu);- QueryPerformanceCounter(&after);- log::info("prefetch-clock",std::format("role={} frequency={} gpu={} cpu={} qpcFrequency={} uncertaintyTicks={} frequencyHr=0x{:X} calibrationHr=0x{:X}",- role_,frequency,gpu,cpu,qpc.QuadPart,after.QuadPart-before.QuadPart,unsigned(a),unsigned(b)));- return SUCCEEDED(a)&&SUCCEEDED(b)&&frequency&&qpc.QuadPart;- }- void emit(const GpuFrameTiming& frame){- if(!queue_)return;- for(const auto stage:{GpuStage::Flow,GpuStage::Sr,GpuStage::NrLayer0,GpuStage::NrLayer1}){- const auto& s=frame.gpu[size_t(stage)];if(s.state!=SampleState::Measured||!s.frequency)continue;- log::info("prefetch-gpu",std::format("role={} source={} stage={} begin={} end={} frequency={}",- role_,frame.identity.sourceFrameId,unsigned(stage),s.begin,s.end,s.frequency));- }- }-};-}diff --git a/include/veyra/pipeline/FlowPrefetch.h b/include/veyra/pipeline/FlowPrefetch.hindex 78e51813..3d478031 100644--- a/include/veyra/pipeline/FlowPrefetch.h+++ b/include/veyra/pipeline/FlowPrefetch.h@@ -2,7 +2,6 @@#include "veyra/pipeline/EnhanceGraph.h"#include "veyra/gfx/D3D12DeviceContext.h"#include "veyra/gfx/CommandSlotRing.h"-#include "veyra/diagnostics/GpuQueueTrace.h"#include <array>namespace veyra::pipeline {@@ -21,6 +20,5 @@ private:gfx::D3D12DeviceContext context_;gfx::CommandSlotRing ring_;std::unique_ptr<EnhanceGraph> graph_;std::array<Slot,2> slots_;uint64_t sequence_=0,previous_=0,revision_=0;unsigned activeSlot_=0;- diagnostics::GpuQueueTrace trace_;bool traceEnabled_=false;};}diff --git a/scripts/perf/nr-export-pipeline.py b/scripts/perf/nr-export-pipeline.pyindex a3da9003..8fc9a018 100644--- a/scripts/perf/nr-export-pipeline.py+++ b/scripts/perf/nr-export-pipeline.py@@ -4,7 +4,7 @@ import importlib.util,json,os,re,shutil,subprocess,sys,timeROOT=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,mode=sys.argv[1:4];groups=sys.argv[4:] or ['none4k','nr','nr2','nrsr4k','sr8k']-assert mode in ('default','serial','events','async','async-events','prefetch','prefetch-trace','interleaved','default-interleaved','prefetch-interleaved','all')+assert mode in ('default','serial','events','async','async-events','prefetch','interleaved','default-interleaved','prefetch-interleaved','all')assert all(g in ('none4k','nr','nr2','sr4k','nrsr4k','sr8k','fg2') for g in groups)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)@@ -16,7 +16,7 @@ results=[]for group in groups:source=BASE/'tests/perf-matrix/media/M2.mkv' if group in ('none4k','sr8k') else matrix.SOURCES['M1']config='none' if group=='none4k' else group;frames=60 if group=='sr8k' else 120- for repeat in (range(1,2) if mode=='prefetch-trace' else range(1,4)):+ for repeat in range(1,4):modes=(('default','prefetch') if repeat%2 else ('prefetch','default')) if mode=='prefetch-interleaved' else (('serial','default') if repeat%2 else ('default','serial')) if mode=='default-interleaved' else (('serial','async') if repeat%2 else ('async','serial')) if mode=='interleaved' else (('serial','events','async','async-events') if repeat%2 else ('async-events','async','events','serial')) if mode=='all' else (mode,)for current in modes:matrix.assert_gpu_tests_idle();name=f'{label}-{group}-{current}-r{repeat}';out=BASE/'logs'/TASK/name;tmp=BASE/'tmp'/TASK/name@@ -28,8 +28,7 @@ for group in groups:if current=='serial':env['VEYRA_TEST_EXPORT_SERIAL']='1'if current=='events':env['VEYRA_TEST_EXPORT_ASYNC']='0'if current=='async':env['VEYRA_TEST_EXPORT_FENCE_EVENTS']='0'- if current in ('prefetch','prefetch-trace'):env['VEYRA_TEST_EXPORT_NVOF_PREFETCH']='1'- if current=='prefetch-trace':env['VEYRA_TEST_EXPORT_PREFETCH_TIMESTAMPS']='1'+ if current=='prefetch':env['VEYRA_TEST_EXPORT_NVOF_PREFETCH']='1'if current in ('async','async-events'):env['VEYRA_TEST_EXPORT_ASYNC']='1'if current in ('events','async-events'):env['VEYRA_TEST_EXPORT_FENCE_EVENTS']='1'command=[str(exe),str(source),str(dest),config,str(frames),str(out)]diff --git a/src/engine/VideoExportJob.cpp b/src/engine/VideoExportJob.cppindex 77145731..865d0846 100644--- a/src/engine/VideoExportJob.cpp+++ b/src/engine/VideoExportJob.cpp@@ -211,6 +211,7 @@ bool exportVideo(const std::wstring& input,const std::wstring& output,PlayerOptidouble previousPts=0;int64_t lastOutputUs=-1;uint64_t slowFrames=0;// Directed export measurements exclude feature/encoder creation, but include final drain.+ const auto pipelineStart=std::chrono::steady_clock::now();double completionWaitMs=0;// Acceptance hook: VEYRA_TEST_EXPORT_SLOW_FRAME=<source index>:<ms> holds that frame's// completion back, standing in for a GPU that is slow but alive. Unset in normal use.@@ -236,20 +237,14 @@ bool exportVideo(const std::wstring& input,const std::wstring& output,PlayerOpticonst bool allowed=asyncNvenc&&graph.nvofSessionInitialized()&&!gd.hdrInput&&!gd.hdrOutput&&!gd.color.enabled&&!gd.additionalColorCount&&!gd.videoHdr.enabled&&gd.opticalFlowBackend==OpticalFlowBackend::Nvidia;if(!allowed){failureReason=L"NVOF预取实验配置不受支持";veyra::log::error("flow-prefetch","experimental export admission refused");break;}- uint64_t priorBudget=0,priorUsage=0;ctx.videoMemoryInfo(priorBudget,priorUsage);flowPrefetch=std::make_unique<pipeline::FlowPrefetch>();if(!flowPrefetch->initialize(ctx,gd)){failureReason=L"NVOF预取实验初始化失败";break;}- uint64_t budget=0,usage=0;ctx.videoMemoryInfo(budget,usage);- veyra::log::info("flow-prefetch-memory",std::format("beforeMiB={} afterMiB={} budgetMiB={}",priorUsage>>20,usage>>20,budget>>20));}if(fenceEvents){const bool injected=GetEnvironmentVariableW(L"VEYRA_TEST_EXPORT_EVENT_CREATE_FAIL",nullptr,0)>0;if(!injected)completionEvent.value=CreateEventW(nullptr,FALSE,FALSE,nullptr);if(!completionEvent.value){veyra::log::warn("export-pipeline",std::format("completion event create failed error={} injected={}; keeping polling",injected?ERROR_INVALID_HANDLE:GetLastError(),injected));fenceEvents=false;}}- diagnostics::GpuQueueTrace prefetchTrace;- const bool tracePrefetch=flowPrefetch&&testFlag(L"VEYRA_TEST_EXPORT_PREFETCH_TIMESTAMPS",false);- if(tracePrefetch){prefetchTrace.initialize(ring.queue(),"consumer");graph.recordGpuTimings();}struct PendingFrame {pipeline::EnhanceGraph::FrameOutputs output;uint64_t consumerFence=0,source=0;std::chrono::steady_clock::time_point submitted;};std::deque<PendingFrame> pendingFrames;unsigned maxInFlight=1;// Preserve the 30s alive-device contract, cancellation and slow-frame hook.@@ -308,9 +303,7 @@ bool exportVideo(const std::wstring& input,const std::wstring& output,PlayerOptitimestamps.emplace_back(outputIndex,timeUs);lastOutputUs=timeUs;return encoder->encode(slot,generated,outputIndex++);};- const auto pipelineStart=std::chrono::steady_clock::now();while(!cancel){if(frameBoundary&&!frameBoundary()){error=true;break;}pipeline::FramePacket packet;const AVFrame* frame=nullptr;- if(tracePrefetch)for(const auto& timing:graph.takeGpuTimings())prefetchTrace.emit(timing);if(pendingFrames.size()>=2&&!finishOldest())break;source::SourceReadStatus rs;if(sourceCount==0){packet=firstPacket;frame=firstFrame;rs=source::SourceReadStatus::Frame;}@@ -387,7 +380,6 @@ bool exportVideo(const std::wstring& input,const std::wstring& output,PlayerOptiveyra::log::info("export-counts",std::format("slowFrames={} source={} generated={} hold={} output={} multiplier={} repairedTimestamps={} backend={} vfgQuality={} encoder={} bitrateMbps={} note={} (holds are not generated frames)",slowFrames,sourceCount,generatedCount,holdCount,outputIndex,multiplier,repairedTimestamps,frameGenerationBackendName(options.settings.frameGenerationBackend),options.settings.vfgQuality,std::string(sink::encoderBackendName(encoder->backend())),options.settings.exportBitrateMbps,utf8(fgNote)));progress(.99,L"正在收尾:等待编码器输出剩余帧");if(!encoder->finish()){if(failureReason.empty())failureReason=L"编码器收尾失败,请查看编码器诊断";break;}- if(tracePrefetch){for(const auto& timing:graph.takeGpuTimings())prefetchTrace.emit(timing);prefetchTrace.calibrate();}veyra::log::info("export-pipeline",std::format("source={} pipelineMs={:.3f} completionWaitMs={:.3f} mode={} fenceEvents={} maxInFlight={}",sourceCount,std::chrono::duration<double,std::milli>(std::chrono::steady_clock::now()-pipelineStart).count(),completionWaitMs,asyncNvenc?"async":"serial",fenceEvents,maxInFlight));if(flowPrefetch)veyra::log::info("flow-prefetch",std::format("source={} consumed={} normalMotionExecutes={}",sourceCount,graph.metrics().prefetchedFlowCount,graph.metrics().nvofExecuteCount));diff --git a/src/pipeline/FlowPrefetch.cpp b/src/pipeline/FlowPrefetch.cppindex 653acfca..b233b359 100644--- a/src/pipeline/FlowPrefetch.cpp+++ b/src/pipeline/FlowPrefetch.cpp@@ -13,8 +13,6 @@ bool FlowPrefetch::initialize(gfx::D3D12DeviceContext& owner,const EnhanceGraphDdesc.fixedExecutionPlan.reset();desc.fixedExecutionPlanError.clear();desc.runtimeNodeOrder=false;desc.additionalColorCount=0;graph_=std::make_unique<EnhanceGraph>(context_,ring_);if(!graph_->initialize(desc)||!graph_->createViews())return false;- traceEnabled_=GetEnvironmentVariableW(L"VEYRA_TEST_EXPORT_PREFETCH_TIMESTAMPS",nullptr,0)>0;- if(traceEnabled_){trace_.initialize(ring_.queue(),"producer");graph_->recordGpuTimings();}for(auto& slot:slots_){slot.flow=makeTexture(context_.device(),graph_->flowWidth(),graph_->flowHeight(),DXGI_FORMAT_R16G16_FLOAT,false);slot.confidence=makeTexture(context_.device(),graph_->flowWidth(),graph_->flowHeight(),DXGI_FORMAT_R8_UNORM,false);@@ -26,7 +24,6 @@ bool FlowPrefetch::initialize(gfx::D3D12DeviceContext& owner,const EnhanceGraphDbool FlowPrefetch::prepare(const AVFrame* frame,double pts,bool reset,uint64_t source,const ColorDescription* color,EnhanceGraph::PreparedFlow& output){output={};if(!graph_)return false;activeSlot_=unsigned(sequence_%2);auto& snapshot=slots_[activeSlot_];- if(traceEnabled_)for(const auto& timing:graph_->takeGpuTimings())trace_.emit(timing);if(snapshot.consumer&&snapshot.consumerValue){const HRESULT hr=ring_.queue()->Wait(snapshot.consumer.Get(),snapshot.consumerValue);if(FAILED(hr)){veyra::log::error("flow-prefetch",std::format("producer reuse Wait hr=0x{:X}",unsigned(hr)));return false;}@@ -58,8 +55,7 @@ void FlowPrefetch::shutdown(){}ring_.drainQueue();}- if(graph_){if(traceEnabled_){for(const auto& timing:graph_->takeGpuTimings())trace_.emit(timing);trace_.calibrate();}graph_->shutdown();}- graph_.reset();slots_={};traceEnabled_=false;ring_.shutdown();context_.shutdown();+ if(graph_)graph_->shutdown();graph_.reset();slots_={};ring_.shutdown();context_.shutdown();sequence_=previous_=revision_=0;activeSlot_=0;}}