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++
fix: prevent capture startup stalls and tighten NR panel
Veyra Goal Agentdcf1d9e5b27d
diff --git a/apps/veyra/SettingsWindow.cpp b/apps/veyra/SettingsWindow.cppindex a7d8d389..cf023ea6 100644--- a/apps/veyra/SettingsWindow.cpp+++ b/apps/veyra/SettingsWindow.cpp@@ -1171,7 +1171,7 @@ void arrange(){auto batch=BeginDeferWindowPos(int(items.size()));for(auto& entry:items){bool fixed=entry.page==-1,visible=!entry.hidden&&(entry.page==page||fixed)&&(GetDlgCtrlID(entry.h)!=1120||smoothMotionHelpExpanded);int w=entry.w<0?width-entry.x-12:entry.w;int y=fixed?(GetDlgCtrlID(entry.h)==400?0:(GetDlgCtrlID(entry.h)==211||GetDlgCtrlID(entry.h)==219)?86:42):entry.y+helpOffset(entry)-scroll;if(fixed){SetWindowPos(entry.h,nullptr,dip(window,entry.x),dip(window,y),dip(window,std::max(1,w)),dip(window,42),SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOREDRAW);continue;}batch=DeferWindowPos(batch,entry.h,nullptr,dip(window,entry.x),dip(window,y),dip(window,std::max(1,w)),dip(window,entry.height),SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCOPYBITS|(visible?SWP_SHOWWINDOW:SWP_HIDEWINDOW));}- EndDeferWindowPos(batch);RedrawWindow(body,nullptr,nullptr,RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_UPDATENOW);InvalidateRect(window,nullptr,FALSE);+ EndDeferWindowPos(batch);RedrawWindow(body,nullptr,nullptr,RDW_INVALIDATE|RDW_ALLCHILDREN);InvalidateRect(window,nullptr,FALSE);}HWND add(const wchar_t* cls,const wchar_t* text,int id,DWORD style,int group,int x,int y,int width,int height){auto h=CreateWindowExW(0,cls,text,WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|style,0,0,1,1,group==-1?window:body,reinterpret_cast<HMENU>(INT_PTR(id)),GetModuleHandleW(nullptr),nullptr);SendMessageW(h,WM_SETFONT,WPARAM(font),TRUE);themeControl(h);if(group!=-1)SetWindowSubclass(h,scrollOnly,950,0);items.push_back({h,group,x,y,width,height});return h;}@@ -1233,18 +1233,18 @@ switch(msg){case WM_CREATE:{window=h;font=makeFont(h);items.clear();displayedBackendWarning.clear();smoothMotionHelpExpanded=false;WNDCLASSW bodyClass{};bodyClass.lpfnWndProc=bodyProc;bodyClass.hInstance=GetModuleHandleW(nullptr);bodyClass.lpszClassName=L"VeyraInspectorBody";bodyClass.hCursor=LoadCursorW(nullptr,IDC_ARROW);RegisterClassW(&bodyClass);// Composite only the scrolling controls, never the video/swapchain window.- body=CreateWindowExW(WS_EX_CONTROLPARENT|WS_EX_COMPOSITED,bodyClass.lpszClassName,L"滚动参数",WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,0,88,300,300,h,nullptr,bodyClass.hInstance,nullptr);- add(L"BUTTON",L"实验性 NVIDIA NR 增强",200,BS_AUTOCHECKBOX|WS_TABSTOP,0,12,12,-1,36);+ body=CreateWindowExW(WS_EX_CONTROLPARENT,bodyClass.lpszClassName,L"滚动参数",WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,0,88,300,300,h,nullptr,bodyClass.hInstance,nullptr);+ add(L"BUTTON",L"实验性 NVIDIA NR 降噪 / 增强",200,BS_AUTOCHECKBOX|WS_TABSTOP,0,12,12,-1,36);add(L"BUTTON",L"超分辨率",201,BS_AUTOCHECKBOX|WS_TABSTOP,0,12,56,-1,36);combo(203,0,104,{L"1080p NR · 实时默认",L"原生NR · 高性能成本",L"480p NR",L"720p NR",L"900p NR",L"1440p NR"});- add(L"STATIC",L"模型参数",1100,0,0,12,146,-1,24);+ add(L"STATIC",L"NR 降噪模型参数",1100,0,0,12,146,-1,24);for(int i=0;i<12;++i){const int y=174+i*62+(i>=7?32:0);add(L"STATIC",labels[i],1000+i,0,0,12,y,176,28);- if(i>=4&&i<=6){const int group=i-4,count=group==0?3:2;for(int j=0;j<count;++j){const auto title=group==0?std::to_wstring(j):j==0?std::wstring(L"关闭"):std::wstring(L"开启");button(title.c_str(),700+group*10+j,0,12+j*88,y+28,80);}continue;}+ if(i>=4&&i<=6){const int group=i-4,count=group==0?3:2;for(int j=0;j<count;++j){const auto title=group==0?(j==0?std::wstring(L"003自然"):j==1?std::wstring(L"003电影"):std::wstring(L"003高细节")):j==0?std::wstring(L"关闭"):std::wstring(L"开启");button(title.c_str(),700+group*10+j,0,12+j*88,y+28,80);}continue;}add(L"EDIT",L"",100+i,ES_AUTOHSCROLL|WS_TABSTOP|ES_RIGHT,0,202,y,-1,28);const wchar_t* range=i<3?L"范围:0–1":i==3?L"-1表示默认;其余范围0–2(效果未证实)":L"范围:0–2";SetPropW(item(100+i),L"veyra.tip",HANDLE(range));auto slider=add(TRACKBAR_CLASSW,L"",600+i,TBS_HORZ|TBS_NOTICKS|WS_TABSTOP,0,12,y+32,-1,16);SendMessageW(slider,TBM_SETRANGE,TRUE,MAKELPARAM(i==3?-100:0,i<3?100:200));}add(L"STATIC",L"增强变化量",1101,0,0,12,606,-1,24);- add(L"STATIC",L"肤质 / 风格 / 遮罩 / UI键为本地实验参数。未验证的效果不会标成可用能力。",1102,0,0,12,956,-1,70);+ add(L"STATIC",L"003 风格映射:使用 Veyra 当前 NR 接口的 0/1/2 档参数组合;不是把 033 的闭源 DLL 搬进来。",1102,0,0,12,956,-1,52);button(L"还原默认",211,-1,12,86,88);add(L"BUTTON",L"直播兼容 · 实验",219,BS_AUTOCHECKBOX|WS_TABSTOP,-1,108,86,-1,36);SetPropW(item(219),L"veyra.tip",HANDLE(L"直播兼容模式:切换显示交换链,会短暂停顿;不改变增强算法或导出。不保证所有捕获方式有效。"));@@ -1411,15 +1411,15 @@ case WM_CREATE:{window=h;font=makeFont(h);items.clear();displayedBackendWarning.add(L"STATIC",L"导出码率",1121,0,3,12,104,-1,24);combo(508,3,132,{L"自动 · 恒定质量",L"6 Mbps",L"10 Mbps",L"16 Mbps",L"24 Mbps",L"40 Mbps",L"60 Mbps",L"100 Mbps",L"150 Mbps",L"200 Mbps"});add(L"STATIC",L"",400,0,-1,12,900,-1,92);add(L"STATIC",L"",401,0,-1,12,996,-1,86);- for(auto& entry:items)if(entry.page==0&&entry.y>=146)entry.y+=176;+ for(auto& entry:items)if(entry.page==0&&entry.y>=146)entry.y+=48;add(L"BUTTON",L"NR剔除区",206,BS_AUTOCHECKBOX|WS_TABSTOP,0,12,146,-1,36);button(L"框选剔除区",213,0,12,188,140);button(L"清除剔除区",214,0,162,188);- add(L"STATIC",L"最多4区,左键拖框,Esc取消。仅抑制NR变化;不保护SR或补帧。随增强参数一起保存;换源清空。",1109,0,0,12,232,-1,82);+ add(L"STATIC",L"最多4区,左键拖框,Esc取消。仅抑制 NR 变化;换源清空。",1109,0,0,12,232,-1,48);for(auto& entry:items)if(entry.page==0&&entry.y>=104)entry.y+=48;combo(207,0,100,{L"DLSS SR",L"RTX 视频超分 · 低",L"RTX 视频超分 · 中",L"RTX 视频超分 · 高",L"RTX 视频超分 · 最高",L"AMD FSR 超分 · 3.1.x(N卡可用)"});for(auto& entry:items)if(entry.page==0&&entry.y>=100)entry.y+=44;button(L"2K",730,0,12,100,80);button(L"4K",731,0,100,100,80);button(L"8K",732,0,188,100,80);- for(auto& entry:items)if(entry.page==0&&entry.y>=56)entry.y+=80;+ for(auto& entry:items)if(entry.page==0&&entry.y>=56)entry.y+=24;add(L"STATIC",L"NR 运行版本",1117,0,0,12,56,-1,24);combo(218,0,84,{L"NVIDIA 原版 · RTX 50",L"社区兼容 · RTX 40/50 实验",L"RTX 30 兼容 · 实验"});SetPropW(item(218),L"veyra.tip",HANDLE(L"社区版为修改运行时。RTX 30 档需单独组件,性能与兼容性待持卡验证;不解锁 DLSS 补帧。切换会重建管线,失败恢复原设置。"));diff --git a/apps/veyra/ui/UiPreferenceStore.h b/apps/veyra/ui/UiPreferenceStore.hindex b2682b55..956e88b7 100644--- a/apps/veyra/ui/UiPreferenceStore.h+++ b/apps/veyra/ui/UiPreferenceStore.h@@ -35,7 +35,7 @@ public:// inspector index 4 is the audio page (selectInspector(4)), so the valid// range is 0..4. A narrower bound here silently discarded every saved// window size, volume and subtitle style for users who last sat on it.- if(!(file>>magic>>version>>read.volume>>mute>>sub>>read.width>>read.height>>read.x>>read.y>>pos>>read.inspector>>read.subtitleSize)||magic!="VEYRA_UI"||(version<1||version>9)||!std::isfinite(read.volume)||read.volume<0||read.volume>1||mute<0||mute>1||sub<0||sub>1||pos<0||pos>1||read.width<720||read.width>10000||read.height<540||read.height>10000||abs(int64_t(read.x))>100000||abs(int64_t(read.y))>100000||read.inspector<0||read.inspector>4||read.subtitleSize<16||read.subtitleSize>56){corrupt_=true;return result;}+ if(!(file>>magic>>version>>read.volume>>mute>>sub>>read.width>>read.height>>read.x>>read.y>>pos>>read.inspector>>read.subtitleSize)||magic!="VEYRA_UI"||(version<1||version>10)||!std::isfinite(read.volume)||read.volume<0||read.volume>1||mute<0||mute>1||sub<0||sub>1||pos<0||pos>1||read.width<720||read.width>10000||read.height<540||read.height>10000||abs(int64_t(read.x))>100000||abs(int64_t(read.y))>100000||read.inspector<0||read.inspector>4||read.subtitleSize<16||read.subtitleSize>56){corrupt_=true;return result;}if(version==2&&(!(file>>read.inspectorWidth)||read.inspectorWidth<296||read.inspectorWidth>420)){corrupt_=true;return result;}if(version>=3){int outline=0,background=0,second=0;@@ -49,15 +49,15 @@ public:// it must be read here - reading it earlier shifted every following field.if(version>=4&&!(file>>read.colourFoldMask)){corrupt_=true;return result;}if(version>=5&&(!(file>>read.enhancementEnabled)||read.enhancementEnabled< -1||read.enhancementEnabled>1)){corrupt_=true;return result;}- if(version>=6){int enabled=0,mode=0,display=0;if(!(file>>enabled>>mode>>display)||enabled<0||enabled>1||mode<0||mode>2||display<0||display>2){corrupt_=true;return result;}read.presentation={enabled!=0,engine::PacingMode(mode),engine::DisplaySync(display)};read.presentation.outputRate=engine::OutputRateMode::FollowDisplay;}+ if(version>=6){int enabled=0,mode=0,display=0;if(!(file>>enabled>>mode>>display)||enabled<0||enabled>1||mode<0||mode>2||display<0||display>2){corrupt_=true;return result;}read.presentation={enabled!=0,engine::PacingMode(mode),engine::DisplaySync(display)};read.presentation.outputRate=engine::OutputRateMode::Off;}if(version>=7&&(!(file>>read.subtitleLines)||read.subtitleLines<0||read.subtitleLines>8)){corrupt_=true;return result;}- if(version>=8){int fit=0;if(!(file>>fit)||fit<0||fit>1){corrupt_=true;return result;}read.subtitleFitToLines=fit!=0;} if(version>=9){int rate=0;if(!(file>>rate>>read.presentation.customFps)||rate<0||rate>2||!std::isfinite(read.presentation.customFps)){corrupt_=true;return result;}read.presentation.outputRate=static_cast<engine::OutputRateMode>(rate);}+ if(version>=8){int fit=0;if(!(file>>fit)||fit<0||fit>1){corrupt_=true;return result;}read.subtitleFitToLines=fit!=0;} if(version>=9){int rate=0;if(!(file>>rate>>read.presentation.customFps)||rate<0||rate>2||!std::isfinite(read.presentation.customFps)){corrupt_=true;return result;}read.presentation.outputRate=static_cast<engine::OutputRateMode>(rate);if(version==9&&read.presentation.outputRate==engine::OutputRateMode::FollowDisplay)read.presentation.outputRate=engine::OutputRateMode::Off;}file>>std::ws;if(!file.eof()){corrupt_=true;return result;}read.muted=mute;read.subtitles=sub;read.positioned=pos;return read;}engine::EnhancementSettings startup(engine::EnhancementSettings fallback){engine::PresetStore last(folder_/"last-applied.v1");if(!last.load()||last.entries().empty())return fallback;return last.entries().front().settings;}bool save(const UiPreferences& p,const engine::EnhancementSettings* applied){bool ok=true;std::filesystem::create_directories(folder_);if(applied){engine::PresetStore last(folder_/"last-applied.v1");ok=last.load()&&last.put(L"Last applied",*applied,true);}- if(corrupt_)return false;std::ostringstream out;out<<"VEYRA_UI 9\n"<<p.volume<<' '<<p.muted<<' '<<p.subtitles<<' '<<p.width<<' '<<p.height<<' '<<p.x<<' '<<p.y<<' '<<p.positioned<<' '<<p.inspector<<' '<<p.subtitleSize<<' '<<p.inspectorWidth<<' '<<p.subtitleOutline<<' '<<p.subtitleBackground<<' '<<p.subtitleSecondLanguage<<' '<<p.subtitleMargin<<' '<<p.subtitleFont<<' '<<p.colourFoldMask<<' '<<p.enhancementEnabled<<' '<<p.presentation.enabled<<' '<<unsigned(p.presentation.mode)<<' '<<unsigned(p.presentation.display)<<' '<<p.subtitleLines<<' '<<p.subtitleFitToLines<<' '<<unsigned(p.presentation.outputRate)<<' '<<p.presentation.customFps<<'\n';+ if(corrupt_)return false;std::ostringstream out;out<<"VEYRA_UI 10\n"<<p.volume<<' '<<p.muted<<' '<<p.subtitles<<' '<<p.width<<' '<<p.height<<' '<<p.x<<' '<<p.y<<' '<<p.positioned<<' '<<p.inspector<<' '<<p.subtitleSize<<' '<<p.inspectorWidth<<' '<<p.subtitleOutline<<' '<<p.subtitleBackground<<' '<<p.subtitleSecondLanguage<<' '<<p.subtitleMargin<<' '<<p.subtitleFont<<' '<<p.colourFoldMask<<' '<<p.enhancementEnabled<<' '<<p.presentation.enabled<<' '<<unsigned(p.presentation.mode)<<' '<<unsigned(p.presentation.display)<<' '<<p.subtitleLines<<' '<<p.subtitleFitToLines<<' '<<unsigned(p.presentation.outputRate)<<' '<<p.presentation.customFps<<'\n';auto target=folder_/"ui-preferences.v1",tmp=folder_/(L"ui-preferences.tmp-"+std::to_wstring(GetCurrentProcessId()));auto data=out.str();HANDLE file=CreateFileW(tmp.c_str(),GENERIC_WRITE,0,nullptr,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,nullptr);if(file==INVALID_HANDLE_VALUE)return false;DWORD written=0;bool saved=WriteFile(file,data.data(),DWORD(data.size()),&written,nullptr)&&written==data.size()&&FlushFileBuffers(file);CloseHandle(file);if(saved)saved=MoveFileExW(tmp.c_str(),target.c_str(),MOVEFILE_REPLACE_EXISTING|MOVEFILE_WRITE_THROUGH)!=FALSE;return ok&&saved;}};diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 209e41f3..f80a93ed 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -1,5 +1,39 @@# Veyra 工作记录+## 2026-09-20 Capture-start and NR panel follow-up++- Fixed the physical-capture settings transaction that could wait forever for+ the first DirectShow sample. A two-second no-first-sample deadline now hands+ control to the existing capture recovery path and records+ `capture-start/no first sample`, instead of leaving the engine thread in an+ unbounded loop.+- Changed the presentation default and v9 preference migration so output rate+ limiting is off unless the user explicitly selects a cap. Preference files+ now write schema 10; an old v9 `FollowDisplay` default migrates to `Off`.+- Tightened the NR page layout: the exclusion-zone help no longer reserves a+ large unexplained block, the master control is labelled NR denoise/enhance,+ and the three runtime style buttons are named as the 003-inspired mappings+ (`003自然`, `003电影`, `003高细节`). These are parameter/style mappings to+ Veyra's current NR interface, not the closed 033 engine binary.+- Removed `WS_EX_COMPOSITED` from the scrolling settings body and removed+ synchronous `RDW_UPDATENOW` during layout. Controls remain individually+ buffered, while wheel/drag/window-move repaint is asynchronous to avoid the+ reported flashing and lag.++Validation for this slice:++- `veyra.exe` target built successfully with the Visual Studio environment:+ `E:/项目/Veyra/build/playback-nr-20260920/veyra.exe`.+- `veyra_ui_contract_tests.exe` passed (including preference round trips and+ presentation-cap combinations).+- `veyra_control_paint_tests.exe` and `veyra_live_timing_tests.exe` passed.+- The all-target build remains blocked by the pre-existing missing+ `third_party_local/amd/FidelityFX-SDK-2.3.0/.../ffx_api_loader.h` required by+ the standalone FSR probes; this is unrelated to the application target.+- No physical capture-card reproduction of the new no-first-sample path was+ possible in this short slice; it is guarded by the new timeout and uses the+ existing recovery code.+## 2026-09-20 Playback/NR implementation sliceFollow-up implementation on the same isolated branch:diff --git a/include/veyra/engine/PresentationSettings.h b/include/veyra/engine/PresentationSettings.hindex b947f0ff..a1ee9e62 100644--- a/include/veyra/engine/PresentationSettings.h+++ b/include/veyra/engine/PresentationSettings.h@@ -10,7 +10,7 @@ struct PresentationSettings {bool enabled=false;PacingMode mode=PacingMode::LowQueue;DisplaySync display=DisplaySync::Tearing;- OutputRateMode outputRate=OutputRateMode::FollowDisplay;+ OutputRateMode outputRate=OutputRateMode::Off;double customFps=60.0;bool operator==(const PresentationSettings&) const = default;bool valid()const{return unsigned(mode)<=2&&unsigned(display)<=2&&unsigned(outputRate)<=2&&std::isfinite(customFps)&&customFps>=1.0&&customFps<=1000.0;}diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cppindex 3947a23b..ce5e8014 100644--- a/src/engine/EngineController.cpp+++ b/src/engine/EngineController.cpp@@ -939,8 +939,14 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sauto rs=physicalCapture?captureSource.tryRead(pkt,&frame):activeSource->read(pkt,&frame);// Keep the accepted transaction and rollback state alive until// the next real capture sample arrives. Never bind old PTS to now.+ const auto transactionWaitStart=Clock::now();while(transaction&&isCapture&&rs==source::SourceReadStatus::Waiting&&!stop_){if(paused_&&cachedFrame){frame=cachedFrame;pkt=cachedPacket;rs=source::SourceReadStatus::Frame;break;}+ if(elapsedMs(transactionWaitStart)>2000.0){+ veyra::log::error("capture-start",std::format("no first sample after {:.0f} ms during settings transaction; handing off to recovery",elapsedMs(transactionWaitStart)));+ rs=source::SourceReadStatus::Error;+ break;+ }advanceLive();waitLive();rs=physicalCapture?captureSource.tryRead(pkt,&frame):activeSource->read(pkt,&frame);}if(stop_)break;