Skip to content

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: restore pause idle after rollback did not repair OBS capture

Veyra Goal Agent9a30cf83d7f7
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a01ab3e0..0b36528d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1031,6 +1031,10 @@ add_executable(veyra_sr_reconstruction_tests tests/integration/SrReconstructionT
target_compile_features(veyra_nr_paused_residual_experiment PRIVATE cxx_std_20)
target_compile_options(veyra_nr_paused_residual_experiment PRIVATE /utf-8)
target_link_libraries(veyra_nr_paused_residual_experiment PRIVATE veyra_engine bcrypt)
+ add_executable(veyra_paused_present_experiment tests/perf/PausedPresentExperiment.cpp)
+ target_compile_features(veyra_paused_present_experiment PRIVATE cxx_std_20)
+ target_compile_options(veyra_paused_present_experiment PRIVATE /utf-8)
+ target_link_libraries(veyra_paused_present_experiment PRIVATE veyra_engine)
add_executable(veyra_nr_gpu_competition_load tests/perf/NrGpuCompetitionLoad.cpp)
target_compile_features(veyra_nr_gpu_competition_load PRIVATE cxx_std_20)
target_compile_options(veyra_nr_gpu_competition_load PRIVATE /utf-8)
diff --git a/apps/veyra-qml/main.cpp b/apps/veyra-qml/main.cpp
index dd1948e6..4f6462ff 100644
--- a/apps/veyra-qml/main.cpp
+++ b/apps/veyra-qml/main.cpp
@@ -665,6 +665,8 @@ static int runApplication(int argc, char** argv, QString& restartProgram, QStrin
const QStringList args = QCoreApplication::arguments();
QString openPath;
QVariantMap testOptions;
+ if(qEnvironmentVariableIsSet("VEYRA_TEST_DISABLE_PAUSED_UI_IDLE"))
+ testOptions.insert(QStringLiteral("disablePausedUiIdle"),true);
QSize testSize;
// --exit-after: see the switch table. 0 means "run until closed".
int exitAfterMs = 0;
diff --git a/include/veyra/engine/VideoPresenter.h b/include/veyra/engine/VideoPresenter.h
index eb5b35b1..b9fde910 100644
--- a/include/veyra/engine/VideoPresenter.h
+++ b/include/veyra/engine/VideoPresenter.h
@@ -8,6 +8,7 @@
#include "veyra/engine/PresentationSettings.h"
#include <chrono>
#include <array>
+#include <optional>
namespace veyra::gfx { class D3D12DeviceContext; class CommandSlotRing; }
namespace veyra::pipeline { class EnhanceGraph; }
namespace veyra::sink { struct RgbaImage; }
@@ -19,7 +20,7 @@ public:
// source (file playback). Retained for diagnostics; XeLL low latency must
// stay enabled or the provider refuses generation (result -15).
bool open(gfx::D3D12DeviceContext&, HWND, pipeline::EnhanceGraph&, bool captureCompatible=false, bool mediaClockPaced=false);
- bool present(gfx::D3D12DeviceContext&,gfx::CommandSlotRing&,pipeline::EnhanceGraph&,unsigned slot,bool generated,bool referencesValid=true,int comparison=0,bool baseReference=false,float split=.5f,pipeline::FrameIdentity identity={},PreviewView view={},int64_t sourcePts100ns=-1);
+ bool present(gfx::D3D12DeviceContext&,gfx::CommandSlotRing&,pipeline::EnhanceGraph&,unsigned slot,bool generated,bool referencesValid=true,int comparison=0,bool baseReference=false,float split=.5f,pipeline::FrameIdentity identity={},PreviewView view={},int64_t sourcePts100ns=-1,bool retainUnchanged=false);
void close();
// Present-sink providers (XeSS) block inside Present while pacing
// their generated frames. A helper-thread Present was tried on
@@ -83,6 +84,18 @@ private:
Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> rtvs_;
unsigned inc_=0;
unsigned lastBuffer_=0;bool hasPresented_=false;
+ struct RetainedFrame {
+ ID3D12Fence* producer=nullptr;
+ uint64_t fence=0;
+ unsigned slot=0,width=0,height=0;
+ bool generated=false,referencesValid=false,baseReference=false,visible=false;
+ int comparison=0;float split=.5f;
+ PreviewView view{};
+ pipeline::FrameIdentity identity{};
+ HMONITOR monitor=nullptr;
+ bool operator==(const RetainedFrame&)const=default;
+ };
+ std::optional<RetainedFrame> retainedFrame_;
HWND window_=nullptr;
std::chrono::steady_clock::time_point lastResize_{};
unsigned viewWidth_=0,viewHeight_=0;
diff --git a/qml/Veyra/ProPage.qml b/qml/Veyra/ProPage.qml
index 8f4f5700..9314a492 100644
--- a/qml/Veyra/ProPage.qml
+++ b/qml/Veyra/ProPage.qml
@@ -179,7 +179,9 @@ VPage {
property real shown: known ? Math.min(1, Math.max(0, fraction)) : 0
// Live data changes every second; animating it behind another page redrew the
// window continuously (see VDot.qml), so only while shown.
- Behavior on shown { enabled: orb.visible; NumberAnimation { duration: Theme.d(600); easing.bezierCurve: Theme.springSoft } }
+ // Paused telemetry still updates, but it does not need a 600 ms canvas
+ // animation every second. Keep live playback and user edits responsive.
+ Behavior on shown { enabled: orb.visible && (!veyra.paused || (typeof vyTest !== "undefined" && vyTest.disablePausedUiIdle === true)); NumberAnimation { duration: Theme.d(600); easing.bezierCurve: Theme.springSoft } }
onShownChanged: ring.requestPaint()
onToneChanged: ring.requestPaint()
Canvas {
diff --git a/scripts/perf/nr-present.py b/scripts/perf/nr-present.py
new file mode 100644
index 00000000..e17ef955
--- /dev/null
+++ b/scripts/perf/nr-present.py
@@ -0,0 +1,33 @@
+"""Owned native backbuffer idle/invalidation experiment, enabled/off paired."""
+from pathlib import Path
+import importlib.util
+import json
+import os
+import shutil
+import subprocess
+import sys
+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];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_paused_present_experiment.exe';shutil.copy2(BASE/'build'/TASK/variant/exe.name,exe);results=[];reference=None
+for mode in ('enabled','off'):
+ for repeat in range(1,4):
+ matrix.assert_gpu_tests_idle();name=f'{label}-{mode}-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()
+ for key in tuple(env):
+ if key.upper().startswith('VEYRA_'):env.pop(key)
+ env.update(TEMP=str(tmp),TMP=str(tmp))
+ if mode=='off':env['VEYRA_TEST_DISABLE_PAUSED_PRESENT_REUSE']='1'
+ print('START',name,flush=True)
+ with (out/'console.log').open('xb') as log:
+ proc=subprocess.run([str(exe),str(matrix.SOURCES['M1']),str(out)],cwd=app,env=env,stdout=log,stderr=subprocess.STDOUT,timeout=280)
+ text=(out/'console.log').read_text(encoding='utf-8',errors='replace');files={p.name:matrix.digest(p) for p in out.glob('*.rgba')}
+ if reference is None:reference=files
+ result={'mode':mode,'repeat':repeat,'exitCode':proc.returncode,'exeSha256':matrix.digest(exe),'imagesSha256':files,
+ 'differentImages':sum(reference[k]!=v for k,v in files.items()),'passed':proc.returncode==0 and 'RESULT pass=1' in text and files==reference and len(files)==8}
+ (out/'result.json').write_text(json.dumps(result,indent=2),encoding='utf-8');results.append(result);print('RESULT',name,json.dumps(result),flush=True)
+ if not result['passed']:print(text[-6000:],flush=True);raise SystemExit(1)
+with (BASE/'logs'/TASK/(label+'-summary.json')).open('x',encoding='utf-8') as f:json.dump(results,f,indent=2)
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index 7125ff74..df2eea55 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -1408,10 +1408,10 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
}
if(audioStarted)audioPipe.setPaused(true);wasPaused=true;
const bool referencesValid=hasOutput&&out.batch.count&&out.batch.frames[out.batch.count-1].lease&&out.batch.frames[out.batch.count-1].lease->referencesValid;
- if(hasOutput&&!presenter.present(ctx,ring,*graph,out.videoSlot,false,referencesValid,comparisonMode_,comparisonBase_,comparisonSplit_,out.batch.identity,previewView())){if(recoverXessPresentation())continue;status(L"画面呈现失败",true);break;}
+ if(hasOutput&&!presenter.present(ctx,ring,*graph,out.videoSlot,false,referencesValid,comparisonMode_,comparisonBase_,comparisonSplit_,out.batch.identity,previewView(),-1,true)){if(recoverXessPresentation())continue;status(L"画面呈现失败",true);break;}
if(hasOutput&&graph->resolveGeneration(out))completeReset(out.batch.identity);
- // Preserve the established 50 ms paused presentation path;
- // the idle-buffer candidate failed R0 OBS GPU capture.
+ // Poll live view/size changes at 50 ms; unchanged flip
+ // buffers are retained without commands or another Present.
std::this_thread::sleep_for(std::chrono::milliseconds(refreshPausedFrame_?1:50));continue;
}
if(wasPaused&&!paused_){holdFileAudio();audioRebuffering=false;if(audioStarted)audioPipe.setPaused(false);anchor=Clock::now();anchorMs=out.ptsMs;reset=true;pendingResetCause=pipeline::ResetReason::PauseResume;wasPaused=false;}
diff --git a/src/engine/VideoPresenter.cpp b/src/engine/VideoPresenter.cpp
index 55181ff4..bd38b54f 100644
--- a/src/engine/VideoPresenter.cpp
+++ b/src/engine/VideoPresenter.cpp
@@ -96,7 +96,7 @@ bool VideoPresenter::open(gfx::D3D12DeviceContext& ctx,HWND window,pipeline::Enh
return true;
}
void VideoPresenter::refresh(ID3D12Device* device){for(unsigned i=0;i<3;++i){Microsoft::WRL::ComPtr<ID3D12Resource> bb;if(SUCCEEDED(sink_.swapChain()->GetBuffer(i,IID_PPV_ARGS(&bb))))device->CreateRenderTargetView(bb.Get(),nullptr,{rtvs_->GetCPUDescriptorHandleForHeapStart().ptr+size_t(i)*inc_});}}
-bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing& sharedRing,pipeline::EnhanceGraph& graph,unsigned slot,bool generated,bool referencesValid,int comparison,bool baseReference,float split,pipeline::FrameIdentity identity,PreviewView view,int64_t sourcePts100ns) {
+bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing& sharedRing,pipeline::EnhanceGraph& graph,unsigned slot,bool generated,bool referencesValid,int comparison,bool baseReference,float split,pipeline::FrameIdentity identity,PreviewView view,int64_t sourcePts100ns,bool retainUnchanged) {
auto& ring=presentationQueue_?presentationRing_:sharedRing;
auto* fence=presentationFence_?presentationFence_.Get():ctx.fence();
const auto presentStart=std::chrono::steady_clock::now();
@@ -125,6 +125,18 @@ bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing&
// stretch current buffers there instead of repeatedly draining the GPU
// and rebuilding provider resources at monitor/DPI boundaries.
const bool windowChanging=GetPropW(window_,L"Veyra.InteractiveMove")||GetPropW(window_,L"Veyra.DpiTransition");
+ view=filmPixelAlignedView(window_,rc.right,rc.bottom,graph.workWidth(),graph.workHeight(),view);
+ const RetainedFrame retained{graph.presentationReadyFenceObject(slot,generated),graph.presentationReadyFence(slot,generated),
+ slot,unsigned(rc.right),unsigned(rc.bottom),generated,referencesValid,baseReference,IsWindowVisible(window_)!=FALSE,
+ comparison,split,view,identity,MonitorFromWindow(window_,MONITOR_DEFAULTTONEAREST)};
+ // Pausing keeps the last flip-model buffer visible. Re-submit only when
+ // its producer fence, view, comparison, visibility, monitor or size changes.
+ // Deferred resize must keep polling until the actual buffers match.
+ if(retainUnchanged&&retained.producer&&retained.fence&&retainedFrame_&&*retainedFrame_==retained&&
+ !windowChanging&&targetWidth==sink_.width()&&targetHeight==sink_.height()&&
+ SUCCEEDED(ctx.device()->GetDeviceRemovedReason())&&
+ !GetEnvironmentVariableW(L"VEYRA_TEST_DISABLE_PAUSED_PRESENT_REUSE",nullptr,0))return true;
+ retainedFrame_.reset(); // A failed present never seeds an idle cache.
if(!windowChanging&&(targetWidth!=sink_.width()||targetHeight!=sink_.height())&&GetTickCount64()>=deferUntil&&now-lastResize_>=std::chrono::milliseconds(100)&&sink_.resizeDue()) {
resized=true;
if(!ring.drainQueue())return false;sink_.resize(targetWidth,targetHeight);
@@ -159,7 +171,6 @@ bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing&
// DXGI stretches the retained buffer while the native workspace unfolds.
// Compute contain in CURRENT client coordinates, then map back to buffer
// coordinates so that the onscreen image keeps its aspect throughout.
- view=filmPixelAlignedView(window_,rc.right,rc.bottom,graph.workWidth(),graph.workHeight(),view);
const auto [renderW,renderH]=view.renderedSize(float(rc.right),float(rc.bottom),float(graph.workWidth()),float(graph.workHeight()));
D3D12_VIEWPORT viewport{0,0,float(sink_.bufferWidth()),float(sink_.bufferHeight()),0,1};
D3D12_RECT rect{0,0,LONG(sink_.bufferWidth()),LONG(sink_.bufferHeight())};list->RSSetViewports(1,&viewport);list->RSSetScissorRects(1,&rect);
@@ -283,7 +294,7 @@ bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing&
ms(presentEnd-dxgiStart),slow,identity.sourceFrameId,identity.epoch,sink_.xess()?"XeSS":"DXGI",resized,
ms(resizeEnd-presentStart),ms(beginEnd-resizeEnd),ms(dxgiStart-beginEnd),timing.beforeMs,timing.callMs,timing.bufferMs,timing.afterMs,unsigned(timing.result)));
}
- xessFailed_=sink_.xessFailed();return presented;
+ xessFailed_=sink_.xessFailed();if(presented)retainedFrame_=retained;return presented;
}
bool VideoPresenter::readPresentedFrameForTest(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing& ring,sink::RgbaImage& image){
if(presentationQueue_&&!presentationRing_.drainQueue())return false;
@@ -292,6 +303,7 @@ bool VideoPresenter::readPresentedFrameForTest(gfx::D3D12DeviceContext& ctx,gfx:
return SUCCEEDED(sink_.swapChain()->GetBuffer(lastBuffer_,IID_PPV_ARGS(&buffer)))&&sink::readRgba8(ctx,ring,buffer.Get(),image);
}
void VideoPresenter::close(){
+ retainedFrame_.reset();
xessInputId_=0;xessWork_={};xessWorkPosition_=0;
reflex_.close();reflexFrame_=0;
if(presentationRing_.initialized())presentationRing_.drainQueue();
diff --git a/tests/perf/PausedPresentExperiment.cpp b/tests/perf/PausedPresentExperiment.cpp
new file mode 100644
index 00000000..14298153
--- /dev/null
+++ b/tests/perf/PausedPresentExperiment.cpp
@@ -0,0 +1,72 @@
+#include "veyra/engine/VideoPresenter.h"
+#include "veyra/engine/GraphDescription.h"
+#include "veyra/engine/EffectChain.h"
+#include "veyra/pipeline/EnhanceGraph.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 <d3d12sdklayers.h>
+#include <filesystem>
+#include <iostream>
+#include <fstream>
+
+// Own window/backbuffer only, matching the QML video's WM_PAINT contract.
+// Uses the real graph/presenter and checks full pixels after each invalidation.
+namespace {
+LRESULT CALLBACK procedure(HWND window,UINT message,WPARAM wp,LPARAM lp){
+ if(message==WM_PAINT){ValidateRect(window,nullptr);return 0;}
+ return DefWindowProcW(window,message,wp,lp);
+}
+void pump(){MSG m{};while(PeekMessageW(&m,nullptr,0,0,PM_REMOVE)){TranslateMessage(&m);DispatchMessageW(&m);}}
+}
+int wmain(int argc,wchar_t** argv){
+ using namespace veyra;if(argc!=3)return 2;SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
+ const std::filesystem::path out=argv[2];std::filesystem::create_directories(out);Logger::instance().openFile((out/L"engine.log").wstring());
+ WNDCLASSW wc{};wc.hInstance=GetModuleHandleW(nullptr);wc.lpfnWndProc=procedure;wc.lpszClassName=L"VeyraPausedPresentOwnedFixture";
+ if(!RegisterClassW(&wc))return 2;
+ HWND window=CreateWindowExW(WS_EX_NOACTIVATE,wc.lpszClassName,L"Veyra paused-present test",WS_POPUP,50,50,640,384,nullptr,nullptr,wc.hInstance,nullptr);
+ if(!window)return 2;ShowWindow(window,SW_SHOWNOACTIVATE);pump();
+ 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))return 2;
+ pipeline::FramePacket packet;const AVFrame* input=nullptr;if(media.read(packet,&input)!=source::SourceReadStatus::Frame)return 2;
+ engine::EffectChain chain;chain.nodeCount=1;chain.nodes[0].type=engine::EffectType::NrEnhance;chain.nodes[0].enabled=true;
+ chain.nodes[0].nr.sizePolicy=pipeline::NrSizePolicy::Native;engine::EnhancementSettings settings;engine::fromChain(chain,settings);
+ engine::StageRequest request;request.width=media.info().width;request.height=media.info().height;request.nr=true;
+ pipeline::EnhanceGraphDesc desc;engine::describeStages(request,settings,desc);desc.enableNvofStandalone=true;desc.enableFg=false;desc.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();
+ pipeline::EnhanceGraph graph(ctx,ring);engine::VideoPresenter presenter;
+ if(!graph.initialize(desc)||!presenter.open(ctx,window,graph)||!graph.createViews())return 2;
+ pipeline::EnhanceGraph::FrameOutputs output;bool pass=graph.process(input,0,true,output,1,&packet.colorInfo,nullptr,true)&&ring.waitIdle();
+ engine::PreviewView view{};int comparison=0;float split=.5f;
+ auto present=[&]{return presenter.present(ctx,ring,graph,output.videoSlot,false,true,comparison,false,split,output.batch.identity,view,-1,true);};
+ auto snapshot=[&](const wchar_t* name){sink::RgbaImage image;if(!presenter.readPresentedFrameForTest(ctx,ring,image)){pass=false;return image;}
+ std::ofstream f(out/(std::wstring(name)+L".rgba"),std::ios::binary);f.write(reinterpret_cast<const char*>(image.pixels.data()),std::streamsize(image.pixels.size()));return image;};
+ pass=pass&&present();auto first=snapshot(L"initial");const auto initialCount=presenter.submittedCount();
+ for(unsigned i=0;i<300&&pass;++i)pass=present();auto idle=snapshot(L"idle");
+ const bool disabled=GetEnvironmentVariableW(L"VEYRA_TEST_DISABLE_PAUSED_PRESENT_REUSE",nullptr,0)>0;
+ pass=pass&&first.pixels==idle.pixels&&presenter.submittedCount()==initialCount+(disabled?300:0);
+ std::cout<<"IDLE pixelsEqual="<<(first.pixels==idle.pixels)<<" presents="<<presenter.submittedCount()<<" disabled="<<disabled<<std::endl;
+ view.zoom=1.2f;auto count=presenter.submittedCount();pass=pass&&present()&&presenter.submittedCount()==count+1;auto zoom=snapshot(L"zoom");pass=pass&&zoom.pixels!=idle.pixels;
+ comparison=2;count=presenter.submittedCount();pass=pass&&present()&&presenter.submittedCount()==count+1;auto compare=snapshot(L"comparison");pass=pass&&compare.pixels!=zoom.pixels;
+ split=.25f;count=presenter.submittedCount();pass=pass&&present()&&presenter.submittedCount()==count+1;auto moved=snapshot(L"split");pass=pass&&moved.pixels!=compare.pixels;
+ // Match the debounced resize deadline without touching any other window.
+ Sleep(120);SetWindowPos(window,nullptr,50,50,768,432,SWP_NOACTIVATE|SWP_NOZORDER);pump();count=presenter.submittedCount();
+ pass=pass&&present()&&presenter.submittedCount()==count+1;auto resized=snapshot(L"resized");pass=pass&&resized.width==768&&resized.height==432;
+ settings.residual.total=0;settings.nrLayers[0].residual.total=0;pass=pass&&graph.applySettings(settings);
+ pass=pass&&graph.process(input,0,true,output,1,&packet.colorInfo,nullptr,true)&&ring.waitIdle();count=presenter.submittedCount();
+ pass=pass&&present()&&presenter.submittedCount()==count+1;auto edited=snapshot(L"producer-changed");pass=pass&&edited.pixels!=resized.pixels;
+ count=presenter.submittedCount();ShowWindow(window,SW_HIDE);pump();pass=pass&&present()&&presenter.submittedCount()==count+1;
+ ShowWindow(window,SW_SHOWNOACTIVATE);pump();count=presenter.submittedCount();pass=pass&&present()&&presenter.submittedCount()==count+1;
+ auto restored=snapshot(L"restored");pass=pass&&restored.pixels==edited.pixels;
+ std::cout<<"INVALIDATIONS pass="<<pass<<" finalPresents="<<presenter.submittedCount()<<" image="<<resized.width<<'x'<<resized.height<<std::endl;
+ ring.drainQueue();output={};presenter.close();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();DestroyWindow(window);UnregisterClassW(wc.lpszClassName,wc.hInstance);
+ std::cout<<"RESULT pass="<<(pass&&errors==0&&SUCCEEDED(removed))<<" debugErrors="<<errors<<" deviceRemoved="<<unsigned(removed)<<std::endl;
+ return pass&&errors==0&&SUCCEEDED(removed)?0:1;
+}