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 UI stack exhaustion during native window resizing
Veyra Goal Agent2b99e89ed8e0
diff --git a/apps/veyra/SettingsWindow.cpp b/apps/veyra/SettingsWindow.cppindex 7c3dd1b4..3c902d8e 100644--- a/apps/veyra/SettingsWindow.cpp+++ b/apps/veyra/SettingsWindow.cpp@@ -1182,212 +1182,10 @@ void createRowResets(){addReset(colorSliderId(int(i)),colorLabelId(int(i)),colorEditId(int(i)),[](auto& s)->auto&{return s.color.exposure;},&colorParams[i]);}}-LRESULT CALLBACK proc(HWND h,UINT msg,WPARAM wp,LPARAM lp){- if(msg==WM_COMMAND&&!populating&&HIWORD(wp)==BN_CLICKED){- if(const auto found=rowResets.find(LOWORD(wp));found!=rowResets.end()){- auto settings=enhancementEnabled?controller->snapshot().desired:configuredSettings;- found->second.reset(settings);- if(found->second.slider>=colorSliderId(0))applyColour(settings.color,false);- else submit(settings);- populate(enhancementEnabled?controller->snapshot().desired:configuredSettings);- return 0;- }- }- if(msg==WM_COMMAND&&!populating&&((LOWORD(wp)==240&&HIWORD(wp)==BN_CLICKED)||((LOWORD(wp)==241||LOWORD(wp)==242)&&HIWORD(wp)==CBN_SELCHANGE))){- auto setting=controller->snapshot().presentation;setting.enabled=checked(240)==BST_CHECKED;- setting.mode=engine::PacingMode(send(241,CB_GETCURSEL));setting.display=engine::DisplaySync(send(242,CB_GETCURSEL));- if(setting.valid()){controller->requestPresentation(setting);EnableWindow(item(241),setting.enabled);EnableWindow(item(242),setting.enabled);SendMessageW(GetParent(window),WM_APP+46,0,0);}return 0;- }- if(msg==WM_COMMAND&&LOWORD(wp)==221&&HIWORD(wp)==BN_CLICKED){smoothMotionHelpExpanded=!smoothMotionHelpExpanded;putText(221,smoothMotionHelpExpanded?L"Smooth Motion · 收起说明 ▴":L"Smooth Motion · 开启方法 ▾");arrange();return 0;}- if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==220&&HIWORD(wp)==BN_CLICKED){liveField(220);return 0;}- if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==230&&HIWORD(wp)==BN_CLICKED){SendMessageW(GetParent(window),WM_APP+44,230,checked(230));return 0;}- if(msg==WM_HSCROLL&&!populating&&lp){const auto id=GetDlgCtrlID(reinterpret_cast<HWND>(lp));if(id>=631&&id<=634){liveField(id);return 0;}}- if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==219&&HIWORD(wp)==BN_CLICKED){liveField(219);return 0;}- if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==218&&HIWORD(wp)==CBN_SELCHANGE){liveField(218);return 0;}- if(msg==WM_COMMAND&&!populating&&((LOWORD(wp)==216&&HIWORD(wp)==CBN_SELCHANGE)||(LOWORD(wp)==217&&HIWORD(wp)==EN_CHANGE))){liveField(LOWORD(wp));return 0;}- if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==222&&HIWORD(wp)==EN_CHANGE){liveField(222);return 0;}- if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==222&&HIWORD(wp)==EN_KILLFOCUS){populate(enhancementEnabled?controller->snapshot().desired:configuredSettings);return 0;}- // --- colour page (plan v4) ---------------------------------------------- if(msg==WM_COMMAND&&LOWORD(wp)==800&&HIWORD(wp)==BN_CLICKED){- auto settings=enhancementEnabled?controller->snapshot().desired:configuredSettings;- settings.color.enabled=SendMessageW(item(800),BM_GETCHECK,0,0)==BST_CHECKED;- if(!submit(settings)){syncColorControls();return 0;}- message(settings.color.enabled?L"调色已开启:链路在所有效果器之前,会有一点额外开销。":L"调色已关闭:这条链完全不存在,零开销。");- return 0;- }- // Reset / undo / redo / copy / paste / hold-to-compare (plan T3 + section 9).- // Explicit ids: 820 sits inside this range but is the black & white switch,- // which has its own handler below (a range test silently swallowed it and the- // following sync reset the checkbox).- if(msg==WM_COMMAND&&HIWORD(wp)==BN_CLICKED&&(LOWORD(wp)==801||LOWORD(wp)==802||LOWORD(wp)==822||LOWORD(wp)==823||LOWORD(wp)==824)){- const int id=LOWORD(wp);- if(id==801){- auto neutral=engine::ColorSettings{};neutral.enabled=true;- if(applyColour(neutral,false))message(L"已还原为中性;可以点“撤销”逐步找回。");- }else if(id==802){- if(colourHistoryIndex>0){- --colourHistoryIndex;- if(applyColour(colourHistory[size_t(colourHistoryIndex)],false,false))message(L"已撤销上一步。");- }else message(L"没有可撤销的步骤。");- }else if(id==824){- if(colourHistoryIndex>=0&&colourHistoryIndex+1<int(colourHistory.size())){- ++colourHistoryIndex;- if(applyColour(colourHistory[size_t(colourHistoryIndex)],false,false))message(L"已重做。");- }else message(L"没有可重做的步骤。");- }else if(id==822){- colourClipboard=colourTarget();colourClipboardValid=true;- message(L"已复制当前色彩设置;可以粘贴到别的预设或下一段素材。");- }else if(id==823){- if(colourClipboardValid&&applyColour(colourClipboard,true))message(L"已粘贴色彩设置。");- else if(!colourClipboardValid)message(L"剪贴板里还没有色彩设置,先点“复制”。");- else message(L"设置正在切换,请稍后再试。");- }- syncColorControls();arrange();return 0;- }- if(msg==WM_COMMAND&&LOWORD(wp)==colorMixerModeId&&HIWORD(wp)==BN_CLICKED){- colourBlackWhite=SendMessageW(item(colorMixerModeId),BM_GETCHECK,0,0)==BST_CHECKED;- auto colour=colourTarget();- if(colour.blackWhite!=colourBlackWhite){- colour.blackWhite=colourBlackWhite;- if(!applyColour(colour,true)){- veyra::log::warn("color-ui","mixer correction switch rejected");- syncColorControls();- return 0;- }- }- veyra::log::info("color-ui",std::format("mixer blackWhite={}",colourBlackWhite?1:0));- message(colourBlackWhite?L"黑白混色器已打开:画面转单色,下面出现“黑白”滑块。":L"已回到 HSL 混色(色相/饱和度/明亮度)。");- syncColorControls();- arrange();- return 0;- }- if(msg==WM_COMMAND&&LOWORD(wp)>=colorCurveChannelId&&LOWORD(wp)<=colorCurveChannelId+3&&HIWORD(wp)==BN_CLICKED){- colourCurveChannel=LOWORD(wp)-colorCurveChannelId;- veyra::log::info("color-ui",std::format("curve channel selected={}",colourCurveChannel));- if(auto canvas=item(colorCurveCanvasId))InvalidateRect(canvas,nullptr,FALSE);- return 0;- }- if(msg==WM_COMMAND&&LOWORD(wp)==colorCurveResetId&&HIWORD(wp)==BN_CLICKED){- auto colour=colourTarget();- curveForChannel(colour,colourCurveChannel).reset();- if(applyColour(colour,true)){- message(L"该通道曲线已拉平。");- veyra::log::info("color-ui",std::format("curve flattened channel={}",colourCurveChannel));- }- if(auto canvas=item(colorCurveCanvasId))InvalidateRect(canvas,nullptr,FALSE);- return 0;- }- if(msg==WM_COMMAND&&LOWORD(wp)>=810&&LOWORD(wp)<810+kColorSections&&HIWORD(wp)==BN_CLICKED){- const int section=LOWORD(wp)-810;- colorFoldMask^=1u<<section;- saveColourFoldState();- arrange();- return 0;- }- // --- colour presets + the .cube picker (T5-b) ---------------------------- if(msg==WM_COMMAND&&LOWORD(wp)>=805&&LOWORD(wp)<=809&&HIWORD(wp)==BN_CLICKED){- const int id=LOWORD(wp);- engine::ColorLookStore lookStore(runtime::localDataDirectory());- if(id==805){- wchar_t name[64]{};GetWindowTextW(item(804),name,64);- if(std::wstring(name).find_first_not_of(L" \t\r\n")==std::wstring::npos){- SetFocus(item(804));- MessageBoxW(window,L"请输入预设名称,再点击保存。",L"保存色彩预设",MB_OK|MB_ICONINFORMATION);- return 0;- }- if(!lookStore.load()){- MessageBoxW(window,lookStore.error().c_str(),L"保存失败",MB_OK|MB_ICONERROR);return 0;- }- const bool exists=std::any_of(lookStore.entries().begin(),lookStore.entries().end(),[&](const auto& entry){return entry.name==name;});- if(exists&&MessageBoxW(window,L"已存在同名预设,是否覆盖?",name,MB_YESNO|MB_ICONQUESTION)!=IDYES)return 0;- auto colour=colourTarget();colour.enabled=true;- if(lookStore.put(name,colour,true)){- refreshColourLooks(name);- message(L"已保存色彩预设:"+std::wstring(name));- veyra::log::info("color-ui","named preset saved to disk and selected");- }else MessageBoxW(window,lookStore.error().c_str(),L"保存失败",MB_OK|MB_ICONERROR);- }else if(id==806){- const int index=int(SendMessageW(item(803),CB_GETCURSEL,0,0));- if(lookStore.load()&&index>=1&&size_t(index-1)<lookStore.entries().size()){- const auto& colour=lookStore.entries()[size_t(index-1)].color;- const bool applied=applyColour(colour,true);- veyra::log::info("color-ui",std::format("preset apply index={} exposure={:.3f} lut={} accepted={}",- index,colour.exposure,colour.lutNameString().empty()?0:1,applied));- if(applied){- syncColorControls();refreshColourLuts();- message(L"已应用该色彩预设(只改色彩,不动 NR/超分/补帧)。");- }else message(L"设置正在切换,请稍后再试。");- }else{- veyra::log::info("color-ui",std::format("preset apply rejected index={} entries={}",index,lookStore.entries().size()));- message(L"先在列表里选一个预设。");- }- }else if(id==807){- const int index=int(SendMessageW(item(803),CB_GETCURSEL,0,0));- if(lookStore.load()&&index>=1&&lookStore.erase(size_t(index-1))){- refreshColourLooks();- message(L"已删除该色彩预设。");- }else message(L"删除失败:"+lookStore.error());- }else if(id==808){- const int index=int(SendMessageW(item(803),CB_GETCURSEL,0,0));- const auto path=pickColourSave(L"Veyra 色彩预设 (*.vpcolor)\0*.vpcolor\0所有文件 (*.*)\0*.*\0\0",L"导出色彩预设",L"look.vpcolor");- if(!path.empty()&&lookStore.load()&&lookStore.exportFile(size_t(std::max(0,index-1)),path))message(L"已导出 .vpcolor。");- else if(!path.empty())message(L"导出失败:"+lookStore.error());- }else{- const auto path=pickColourFile(L"Veyra 色彩预设 (*.vpcolor)\0*.vpcolor\0所有文件 (*.*)\0*.*\0\0",L"导入色彩预设");- if(!path.empty()){- std::wstring name;- if(lookStore.load()&&lookStore.importFile(path,name)){refreshColourLooks(name);message(L"已导入预设:"+name);}- else message(L"导入失败:"+lookStore.error());- }- }- return 0;- }- if(msg==WM_COMMAND&&LOWORD(wp)==817&&HIWORD(wp)==CBN_SELCHANGE){- const int index=int(SendMessageW(item(817),CB_GETCURSEL,0,0));- auto colour=colourTarget();colour.enabled=true;- if(index<=0)colour.clearLut();- else if(size_t(index-1)<colourLutNames.size()&&!colour.setLutName(colourLutNames[size_t(index-1)])){message(L"LUT 名字非法。");return 0;}- if(index>0&&colour.lutStrength<=0.0f)colour.lutStrength=100.0f;- if(!applyColour(colour,false))message(L"设置正在切换,请稍后再试。");- else message(index<=0?L"已停用 LUT。":L"已选择 LUT;管线会重建一次,短暂停顿正常。");- syncColorControls();- return 0;- }- if(msg==WM_COMMAND&&LOWORD(wp)==819&&HIWORD(wp)==CBN_SELCHANGE){- const int index=int(SendMessageW(item(819),CB_GETCURSEL,0,0));- auto colour=colourTarget();- colour.lutInputSpace=std::clamp(index,0,2);- if(applyColour(colour,true))message(L"已切换 LUT 输入空间(日志会记录)。");- return 0;- }- if(msg==WM_COMMAND&&LOWORD(wp)==818&&HIWORD(wp)==BN_CLICKED){- const auto path=pickColourFile(L"Cube LUT (*.cube)\0*.cube\0所有文件 (*.*)\0*.*\0\0",L"导入 .cube LUT");- if(!path.empty()){- engine::ColorLutStore lutStore(runtime::localDataDirectory());- std::wstring name;std::string error;- if(lutStore.importFile(path,name,error)&&!name.empty()){- auto colour=colourTarget();colour.enabled=true;- colour.setLutName(name);- if(colour.lutStrength<=0.0f)colour.lutStrength=100.0f;- refreshColourLuts();- if(!applyColour(colour,false))message(L"LUT 已导入,但设置正在切换;稍后重选即可。");- else message(L"已导入并选择 LUT:"+name+L"(已写入 manifest)。");- }else message(L"导入失败:"+std::wstring(error.begin(),error.end()));- }- return 0;- }- if(msg==WM_COMMAND&&!populating&&!syncingColour&&LOWORD(wp)>=colorEditId(0)&&LOWORD(wp)<colorEditId(0)+kColorMaxParams&&HIWORD(wp)==EN_CHANGE){- const int index=LOWORD(wp)-colorEditId(0);- if(index<int(colorParams.size())){- wchar_t buffer[64]{};GetWindowTextW(item(LOWORD(wp)),buffer,64);- wchar_t* end=nullptr;const float value=wcstof(buffer,&end);- if(end==buffer||*end||!std::isfinite(value))message(L"数值未完整;仍使用上次有效值");- else colourFieldEdited(index,value);- }- return 0;- }- if(msg==WM_COMMAND&&!populating&&((LOWORD(wp)==209&&HIWORD(wp)==CBN_SELCHANGE)||(LOWORD(wp)==215&&HIWORD(wp)==BN_CLICKED))){liveField(LOWORD(wp));return 0;}- switch(msg){+// Win32 synchronously reenters this callback during layout and control painting.+// Allocate snapshots only in the message handlers that actually need them.+__declspec(noinline) LRESULT createSettingsWindow(HWND h,UINT msg,WPARAM wp,LPARAM lp){+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.@@ -1648,36 +1446,226 @@ case WM_CREATE:{window=h;font=makeFont(h);items.clear();displayedBackendWarning.for(const auto& entry:items)veyra::log::info("settings-layout",std::format("id={} page={} x={} y={} w={} h={}",GetDlgCtrlID(entry.h),entry.page,entry.x,entry.y,entry.w,entry.height));return 0;}-case WM_SIZE:arrange();return 0;-case WM_ERASEBKGND:return 1;-case WM_PAINT:{PaintBuffer paint(h);fillSurface(paint.dc,paint.rect,h);return 0;}-case WM_VSCROLL:{switch(LOWORD(wp)){case SB_LINEUP:scroll-=40;break;case SB_LINEDOWN:scroll+=40;break;case SB_PAGEUP:scroll-=240;break;case SB_PAGEDOWN:scroll+=240;break;case SB_THUMBTRACK:{SCROLLINFO si{sizeof(si),SIF_TRACKPOS};GetScrollInfo(h,SB_VERT,&si);scroll=si.nTrackPos;break;}}arrange();return 0;}-case WM_MOUSEWHEEL:scroll-=GET_WHEEL_DELTA_WPARAM(wp)/WHEEL_DELTA*36;arrange();return 0;-case WM_CTLCOLORSTATIC:case WM_CTLCOLOREDIT:case WM_CTLCOLORLISTBOX:case WM_CTLCOLORBTN:return colors(msg,wp,lp);+}return DefWindowProcW(h,msg,wp,lp);+}++__declspec(noinline) LRESULT settingsCommand(HWND h,UINT msg,WPARAM wp,LPARAM lp){++ if(msg==WM_COMMAND&&!populating&&HIWORD(wp)==BN_CLICKED){+ if(const auto found=rowResets.find(LOWORD(wp));found!=rowResets.end()){+ auto settings=enhancementEnabled?controller->snapshot().desired:configuredSettings;+ found->second.reset(settings);+ if(found->second.slider>=colorSliderId(0))applyColour(settings.color,false);+ else submit(settings);+ populate(enhancementEnabled?controller->snapshot().desired:configuredSettings);+ return 0;+ }+ }+ if(msg==WM_COMMAND&&!populating&&((LOWORD(wp)==240&&HIWORD(wp)==BN_CLICKED)||((LOWORD(wp)==241||LOWORD(wp)==242)&&HIWORD(wp)==CBN_SELCHANGE))){+ auto setting=controller->snapshot().presentation;setting.enabled=checked(240)==BST_CHECKED;+ setting.mode=engine::PacingMode(send(241,CB_GETCURSEL));setting.display=engine::DisplaySync(send(242,CB_GETCURSEL));+ if(setting.valid()){controller->requestPresentation(setting);EnableWindow(item(241),setting.enabled);EnableWindow(item(242),setting.enabled);SendMessageW(GetParent(window),WM_APP+46,0,0);}return 0;+ }+ if(msg==WM_COMMAND&&LOWORD(wp)==221&&HIWORD(wp)==BN_CLICKED){smoothMotionHelpExpanded=!smoothMotionHelpExpanded;putText(221,smoothMotionHelpExpanded?L"Smooth Motion · 收起说明 ▴":L"Smooth Motion · 开启方法 ▾");arrange();return 0;}+ if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==220&&HIWORD(wp)==BN_CLICKED){liveField(220);return 0;}+ if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==230&&HIWORD(wp)==BN_CLICKED){SendMessageW(GetParent(window),WM_APP+44,230,checked(230));return 0;}+ if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==219&&HIWORD(wp)==BN_CLICKED){liveField(219);return 0;}+ if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==218&&HIWORD(wp)==CBN_SELCHANGE){liveField(218);return 0;}+ if(msg==WM_COMMAND&&!populating&&((LOWORD(wp)==216&&HIWORD(wp)==CBN_SELCHANGE)||(LOWORD(wp)==217&&HIWORD(wp)==EN_CHANGE))){liveField(LOWORD(wp));return 0;}+ if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==222&&HIWORD(wp)==EN_CHANGE){liveField(222);return 0;}+ if(msg==WM_COMMAND&&!populating&&LOWORD(wp)==222&&HIWORD(wp)==EN_KILLFOCUS){populate(enhancementEnabled?controller->snapshot().desired:configuredSettings);return 0;}+ // --- colour page (plan v4) ---------------------------------------------+ if(msg==WM_COMMAND&&LOWORD(wp)==800&&HIWORD(wp)==BN_CLICKED){+ auto settings=enhancementEnabled?controller->snapshot().desired:configuredSettings;+ settings.color.enabled=SendMessageW(item(800),BM_GETCHECK,0,0)==BST_CHECKED;+ if(!submit(settings)){syncColorControls();return 0;}+ message(settings.color.enabled?L"调色已开启:链路在所有效果器之前,会有一点额外开销。":L"调色已关闭:这条链完全不存在,零开销。");+ return 0;+ }+ // Reset / undo / redo / copy / paste / hold-to-compare (plan T3 + section 9).+ // Explicit ids: 820 sits inside this range but is the black & white switch,+ // which has its own handler below (a range test silently swallowed it and the+ // following sync reset the checkbox).+ if(msg==WM_COMMAND&&HIWORD(wp)==BN_CLICKED&&(LOWORD(wp)==801||LOWORD(wp)==802||LOWORD(wp)==822||LOWORD(wp)==823||LOWORD(wp)==824)){+ const int id=LOWORD(wp);+ if(id==801){+ auto neutral=engine::ColorSettings{};neutral.enabled=true;+ if(applyColour(neutral,false))message(L"已还原为中性;可以点“撤销”逐步找回。");+ }else if(id==802){+ if(colourHistoryIndex>0){+ --colourHistoryIndex;+ if(applyColour(colourHistory[size_t(colourHistoryIndex)],false,false))message(L"已撤销上一步。");+ }else message(L"没有可撤销的步骤。");+ }else if(id==824){+ if(colourHistoryIndex>=0&&colourHistoryIndex+1<int(colourHistory.size())){+ ++colourHistoryIndex;+ if(applyColour(colourHistory[size_t(colourHistoryIndex)],false,false))message(L"已重做。");+ }else message(L"没有可重做的步骤。");+ }else if(id==822){+ colourClipboard=colourTarget();colourClipboardValid=true;+ message(L"已复制当前色彩设置;可以粘贴到别的预设或下一段素材。");+ }else if(id==823){+ if(colourClipboardValid&&applyColour(colourClipboard,true))message(L"已粘贴色彩设置。");+ else if(!colourClipboardValid)message(L"剪贴板里还没有色彩设置,先点“复制”。");+ else message(L"设置正在切换,请稍后再试。");+ }+ syncColorControls();arrange();return 0;+ }+ if(msg==WM_COMMAND&&LOWORD(wp)==colorMixerModeId&&HIWORD(wp)==BN_CLICKED){+ colourBlackWhite=SendMessageW(item(colorMixerModeId),BM_GETCHECK,0,0)==BST_CHECKED;+ auto colour=colourTarget();+ if(colour.blackWhite!=colourBlackWhite){+ colour.blackWhite=colourBlackWhite;+ if(!applyColour(colour,true)){+ veyra::log::warn("color-ui","mixer correction switch rejected");+ syncColorControls();+ return 0;+ }+ }+ veyra::log::info("color-ui",std::format("mixer blackWhite={}",colourBlackWhite?1:0));+ message(colourBlackWhite?L"黑白混色器已打开:画面转单色,下面出现“黑白”滑块。":L"已回到 HSL 混色(色相/饱和度/明亮度)。");+ syncColorControls();+ arrange();+ return 0;+ }+ if(msg==WM_COMMAND&&LOWORD(wp)>=colorCurveChannelId&&LOWORD(wp)<=colorCurveChannelId+3&&HIWORD(wp)==BN_CLICKED){+ colourCurveChannel=LOWORD(wp)-colorCurveChannelId;+ veyra::log::info("color-ui",std::format("curve channel selected={}",colourCurveChannel));+ if(auto canvas=item(colorCurveCanvasId))InvalidateRect(canvas,nullptr,FALSE);+ return 0;+ }+ if(msg==WM_COMMAND&&LOWORD(wp)==colorCurveResetId&&HIWORD(wp)==BN_CLICKED){+ auto colour=colourTarget();+ curveForChannel(colour,colourCurveChannel).reset();+ if(applyColour(colour,true)){+ message(L"该通道曲线已拉平。");+ veyra::log::info("color-ui",std::format("curve flattened channel={}",colourCurveChannel));+ }+ if(auto canvas=item(colorCurveCanvasId))InvalidateRect(canvas,nullptr,FALSE);+ return 0;+ }+ if(msg==WM_COMMAND&&LOWORD(wp)>=810&&LOWORD(wp)<810+kColorSections&&HIWORD(wp)==BN_CLICKED){+ const int section=LOWORD(wp)-810;+ colorFoldMask^=1u<<section;+ saveColourFoldState();+ arrange();+ return 0;+ }+ // --- colour presets + the .cube picker (T5-b) ---------------------------+ if(msg==WM_COMMAND&&LOWORD(wp)>=805&&LOWORD(wp)<=809&&HIWORD(wp)==BN_CLICKED){+ const int id=LOWORD(wp);+ engine::ColorLookStore lookStore(runtime::localDataDirectory());+ if(id==805){+ wchar_t name[64]{};GetWindowTextW(item(804),name,64);+ if(std::wstring(name).find_first_not_of(L" \t\r\n")==std::wstring::npos){+ SetFocus(item(804));+ MessageBoxW(window,L"请输入预设名称,再点击保存。",L"保存色彩预设",MB_OK|MB_ICONINFORMATION);+ return 0;+ }+ if(!lookStore.load()){+ MessageBoxW(window,lookStore.error().c_str(),L"保存失败",MB_OK|MB_ICONERROR);return 0;+ }+ const bool exists=std::any_of(lookStore.entries().begin(),lookStore.entries().end(),[&](const auto& entry){return entry.name==name;});+ if(exists&&MessageBoxW(window,L"已存在同名预设,是否覆盖?",name,MB_YESNO|MB_ICONQUESTION)!=IDYES)return 0;+ auto colour=colourTarget();colour.enabled=true;+ if(lookStore.put(name,colour,true)){+ refreshColourLooks(name);+ message(L"已保存色彩预设:"+std::wstring(name));+ veyra::log::info("color-ui","named preset saved to disk and selected");+ }else MessageBoxW(window,lookStore.error().c_str(),L"保存失败",MB_OK|MB_ICONERROR);+ }else if(id==806){+ const int index=int(SendMessageW(item(803),CB_GETCURSEL,0,0));+ if(lookStore.load()&&index>=1&&size_t(index-1)<lookStore.entries().size()){+ const auto& colour=lookStore.entries()[size_t(index-1)].color;+ const bool applied=applyColour(colour,true);+ veyra::log::info("color-ui",std::format("preset apply index={} exposure={:.3f} lut={} accepted={}",+ index,colour.exposure,colour.lutNameString().empty()?0:1,applied));+ if(applied){+ syncColorControls();refreshColourLuts();+ message(L"已应用该色彩预设(只改色彩,不动 NR/超分/补帧)。");+ }else message(L"设置正在切换,请稍后再试。");+ }else{+ veyra::log::info("color-ui",std::format("preset apply rejected index={} entries={}",index,lookStore.entries().size()));+ message(L"先在列表里选一个预设。");+ }+ }else if(id==807){+ const int index=int(SendMessageW(item(803),CB_GETCURSEL,0,0));+ if(lookStore.load()&&index>=1&&lookStore.erase(size_t(index-1))){+ refreshColourLooks();+ message(L"已删除该色彩预设。");+ }else message(L"删除失败:"+lookStore.error());+ }else if(id==808){+ const int index=int(SendMessageW(item(803),CB_GETCURSEL,0,0));+ const auto path=pickColourSave(L"Veyra 色彩预设 (*.vpcolor)\0*.vpcolor\0所有文件 (*.*)\0*.*\0\0",L"导出色彩预设",L"look.vpcolor");+ if(!path.empty()&&lookStore.load()&&lookStore.exportFile(size_t(std::max(0,index-1)),path))message(L"已导出 .vpcolor。");+ else if(!path.empty())message(L"导出失败:"+lookStore.error());+ }else{+ const auto path=pickColourFile(L"Veyra 色彩预设 (*.vpcolor)\0*.vpcolor\0所有文件 (*.*)\0*.*\0\0",L"导入色彩预设");+ if(!path.empty()){+ std::wstring name;+ if(lookStore.load()&&lookStore.importFile(path,name)){refreshColourLooks(name);message(L"已导入预设:"+name);}+ else message(L"导入失败:"+lookStore.error());+ }+ }+ return 0;+ }+ if(msg==WM_COMMAND&&LOWORD(wp)==817&&HIWORD(wp)==CBN_SELCHANGE){+ const int index=int(SendMessageW(item(817),CB_GETCURSEL,0,0));+ auto colour=colourTarget();colour.enabled=true;+ if(index<=0)colour.clearLut();+ else if(size_t(index-1)<colourLutNames.size()&&!colour.setLutName(colourLutNames[size_t(index-1)])){message(L"LUT 名字非法。");return 0;}+ if(index>0&&colour.lutStrength<=0.0f)colour.lutStrength=100.0f;+ if(!applyColour(colour,false))message(L"设置正在切换,请稍后再试。");+ else message(index<=0?L"已停用 LUT。":L"已选择 LUT;管线会重建一次,短暂停顿正常。");+ syncColorControls();+ return 0;+ }+ if(msg==WM_COMMAND&&LOWORD(wp)==819&&HIWORD(wp)==CBN_SELCHANGE){+ const int index=int(SendMessageW(item(819),CB_GETCURSEL,0,0));+ auto colour=colourTarget();+ colour.lutInputSpace=std::clamp(index,0,2);+ if(applyColour(colour,true))message(L"已切换 LUT 输入空间(日志会记录)。");+ return 0;+ }+ if(msg==WM_COMMAND&&LOWORD(wp)==818&&HIWORD(wp)==BN_CLICKED){+ const auto path=pickColourFile(L"Cube LUT (*.cube)\0*.cube\0所有文件 (*.*)\0*.*\0\0",L"导入 .cube LUT");+ if(!path.empty()){+ engine::ColorLutStore lutStore(runtime::localDataDirectory());+ std::wstring name;std::string error;+ if(lutStore.importFile(path,name,error)&&!name.empty()){+ auto colour=colourTarget();colour.enabled=true;+ colour.setLutName(name);+ if(colour.lutStrength<=0.0f)colour.lutStrength=100.0f;+ refreshColourLuts();+ if(!applyColour(colour,false))message(L"LUT 已导入,但设置正在切换;稍后重选即可。");+ else message(L"已导入并选择 LUT:"+name+L"(已写入 manifest)。");+ }else message(L"导入失败:"+std::wstring(error.begin(),error.end()));+ }+ return 0;+ }+ if(msg==WM_COMMAND&&!populating&&!syncingColour&&LOWORD(wp)>=colorEditId(0)&&LOWORD(wp)<colorEditId(0)+kColorMaxParams&&HIWORD(wp)==EN_CHANGE){+ const int index=LOWORD(wp)-colorEditId(0);+ if(index<int(colorParams.size())){+ wchar_t buffer[64]{};GetWindowTextW(item(LOWORD(wp)),buffer,64);+ wchar_t* end=nullptr;const float value=wcstof(buffer,&end);+ if(end==buffer||*end||!std::isfinite(value))message(L"数值未完整;仍使用上次有效值");+ else colourFieldEdited(index,value);+ }+ return 0;+ }+ if(msg==WM_COMMAND&&!populating&&((LOWORD(wp)==209&&HIWORD(wp)==CBN_SELCHANGE)||(LOWORD(wp)==215&&HIWORD(wp)==BN_CLICKED))){liveField(LOWORD(wp));return 0;}+switch(msg){case WM_COMMAND:{const int id=LOWORD(wp);if(!populating&&((id>=202&&id<=205||id==207||id==208)&&HIWORD(wp)==CBN_SELCHANGE||(id>=700&&id<=732)&&HIWORD(wp)==BN_CLICKED)){liveField(id);return 0;}if((id==206||id==213||id==214)&&HIWORD(wp)==BN_CLICKED){const auto accepted=SendMessageW(GetParent(h),WM_APP+45,id,checked(206));message(accepted?(id==213?L"请在画面中左键拖动框选;Esc取消。":L"已请求更新NR剔除区。"):L"未能操作:请先打开画面,或清除已满的4个区域。");return 0;}if((id==200||id==201)&&HIWORD(wp)==BN_CLICKED){const bool accepted=SendMessageW(GetParent(h),WM_APP+44,id,checked(id))!=0;message(accepted?L"已请求开关;确认帧边界结果后生效。":L"总增强正在切换,请待当前事务完成。");return 0;}if(HIWORD(wp)==EN_SETFOCUS){for(auto& item:items)if(GetDlgCtrlID(item.h)==id&&item.page==page){RECT r{};GetClientRect(h,&r);int height=MulDiv(r.bottom,96,veyra::ui::layoutDpi(h))-128;if(item.y<scroll)scroll=item.y;if(item.y+item.height>scroll+height)scroll=item.y+item.height-height;arrange();break;}}if(!populating&&id>=100&&id<=111&&HIWORD(wp)==EN_CHANGE){liveField(id);return 0;}if(!populating&&id>=100&&id<=111&&HIWORD(wp)==EN_KILLFOCUS){populate(enhancementEnabled?controller->snapshot().desired:configuredSettings);return 0;}engine::EnhancementSettings s;if(id==211){SetFocus(body);s={};if(submit(s))populate(s);message(L"已还原内建默认。");}else if(id>=501&&id<=505)SendMessageW(GetParent(h),WM_APP+41,id,id==501?send(500,CB_GETCURSEL,0,0):id==505?checked(505):0);return 0;}-case WM_HSCROLL:{int id=GetDlgCtrlID(reinterpret_cast<HWND>(lp));if(id>=600&&id<612){int index=id-600;float v=float(SendMessageW(reinterpret_cast<HWND>(lp),TBM_GETPOS,0,0))/(index>=4&&index<=6?1:100);if(index==3&&v<0)v=-1;std::wostringstream o;o<<std::setprecision(4)<<v;putText(100+index,o.str().c_str());}- else if(id>=colorSliderId(0)&&id<colorSliderId(0)+kColorMaxParams){- const int index=id-colorSliderId(0);- if(index<int(colorParams.size())){- float value=float(SendMessageW(reinterpret_cast<HWND>(lp),TBM_GETPOS,0,0))/100.0f;- // Alt+drag = fine adjust (plan section 3.3): the thumb may jump, but- // the applied value only moves a tenth of the way towards it, and the- // sync below pulls the thumb back so repeated Alt-drags stay fine.- if((GetKeyState(VK_MENU)&0x8000)!=0){- const float current=colorParams[size_t(index)].value(colourTarget());- value=current+(value-current)*0.1f;- }- colourFieldEdited(index,value);- }- }- else if(id==622){// Feather slider: the edit box owns the value, its EN_CHANGE applies it.- const int value=std::clamp(int(SendMessageW(reinterpret_cast<HWND>(lp),TBM_GETPOS,0,0)),0,64);putText(222,std::to_wstring(value).c_str());}- return 0;}+}return DefWindowProcW(h,msg,wp,lp);+}++__declspec(noinline) LRESULT settingsTimer(HWND h,UINT msg,WPARAM wp,LPARAM lp){+switch(msg){case WM_TIMER:{auto s=controller->snapshot();putText(1150,s.presentationStatus.c_str());syncProtection(enhancementEnabled?s.desired.protection:configuredSettings.protection);if(enhancementEnabled&&!dirty&&displayedSettings!=s.desired)populate(s.desired);syncColorControls();check(200,enhancementEnabled&&s.desired.nr?BST_CHECKED:BST_UNCHECKED);check(201,enhancementEnabled&&s.desired.sr?BST_CHECKED:BST_UNCHECKED);std::wostringstream o;if(!s.running&&!s.frames&&s.transport!=engine::TransportState::Opening)o<<L"未打开媒体 · 设置待启用\n";else{o<<L"期望版本 "<<s.desired.revision<<L" / 已应用 "<<s.applied.revision<<(s.applying?L" · 应用中":L"");const wchar_t* backend=s.applied.frameGenerationBackend==engine::FrameGenerationBackend::XeSS?L"XeSS":s.applied.frameGenerationBackend==engine::FrameGenerationBackend::Fsr?L"AMD FSR":L"DLSS";@@ -1695,6 +1683,40 @@ case WM_TIMER:{auto s=controller->snapshot();putText(1150,s.presentationStatus.cs.videoHdrStatus.empty()?L"等待预览状态":s.videoHdrStatus.c_str();putText(1145,hdrStatus);return 0;}+}return DefWindowProcW(h,msg,wp,lp);+}++LRESULT CALLBACK proc(HWND h,UINT msg,WPARAM wp,LPARAM lp){+ switch(msg){+case WM_CREATE:return createSettingsWindow(h,msg,wp,lp);+case WM_SIZE:arrange();return 0;+case WM_ERASEBKGND:return 1;+case WM_PAINT:{PaintBuffer paint(h);fillSurface(paint.dc,paint.rect,h);return 0;}+case WM_VSCROLL:{switch(LOWORD(wp)){case SB_LINEUP:scroll-=40;break;case SB_LINEDOWN:scroll+=40;break;case SB_PAGEUP:scroll-=240;break;case SB_PAGEDOWN:scroll+=240;break;case SB_THUMBTRACK:{SCROLLINFO si{sizeof(si),SIF_TRACKPOS};GetScrollInfo(h,SB_VERT,&si);scroll=si.nTrackPos;break;}}arrange();return 0;}+case WM_MOUSEWHEEL:scroll-=GET_WHEEL_DELTA_WPARAM(wp)/WHEEL_DELTA*36;arrange();return 0;+case WM_CTLCOLORSTATIC:case WM_CTLCOLOREDIT:case WM_CTLCOLORLISTBOX:case WM_CTLCOLORBTN:return colors(msg,wp,lp);+case WM_COMMAND:return settingsCommand(h,msg,wp,lp);+case WM_HSCROLL:{+ if(msg==WM_HSCROLL&&!populating&&lp){const auto id=GetDlgCtrlID(reinterpret_cast<HWND>(lp));if(id>=631&&id<=634){liveField(id);return 0;}}+int id=GetDlgCtrlID(reinterpret_cast<HWND>(lp));if(id>=600&&id<612){int index=id-600;float v=float(SendMessageW(reinterpret_cast<HWND>(lp),TBM_GETPOS,0,0))/(index>=4&&index<=6?1:100);if(index==3&&v<0)v=-1;std::wostringstream o;o<<std::setprecision(4)<<v;putText(100+index,o.str().c_str());}+ else if(id>=colorSliderId(0)&&id<colorSliderId(0)+kColorMaxParams){+ const int index=id-colorSliderId(0);+ if(index<int(colorParams.size())){+ float value=float(SendMessageW(reinterpret_cast<HWND>(lp),TBM_GETPOS,0,0))/100.0f;+ // Alt+drag = fine adjust (plan section 3.3): the thumb may jump, but+ // the applied value only moves a tenth of the way towards it, and the+ // sync below pulls the thumb back so repeated Alt-drags stay fine.+ if((GetKeyState(VK_MENU)&0x8000)!=0){+ const float current=colorParams[size_t(index)].value(colourTarget());+ value=current+(value-current)*0.1f;+ }+ colourFieldEdited(index,value);+ }+ }+ else if(id==622){// Feather slider: the edit box owns the value, its EN_CHANGE applies it.+ const int value=std::clamp(int(SendMessageW(reinterpret_cast<HWND>(lp),TBM_GETPOS,0,0)),0,64);putText(222,std::to_wstring(value).c_str());}+ return 0;}+case WM_TIMER:return settingsTimer(h,msg,wp,lp);case WM_DESTROY:KillTimer(h,1);DeleteObject(font);window=nullptr;body=nullptr;items.clear();rowResets.clear();return 0;}return DefWindowProcW(h,msg,wp,lp);}}diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cppindex 664588b3..2cccdd9b 100644--- a/apps/veyra/ui/AppShell.cpp+++ b/apps/veyra/ui/AppShell.cpp@@ -527,12 +527,20 @@ void startVideoExport(bool hevc){#include "UiRepairChecks.h"#include "TransportChecks.h"#include "FgOnlyChecks.h"-LRESULT CALLBACK proc(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp){switch(msg){+// Keep large snapshots out of reentrant sizing/paint/default callbacks.+// noinline prevents Release/LTCG from restoring a large common WndProc frame.+__declspec(noinline) LRESULT systemCommand(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp){+switch(msg){case WM_SYSCOMMAND:if((wp&0xfff0)==SC_SCREENSAVE||(wp&0xfff0)==SC_MONITORPOWER){const auto s=engine.snapshot();if(s.running&&!s.failed&&!s.image&&s.transport==veyra::engine::TransportState::Playing)return 0;}break;+}return DefWindowProcW(hwnd,msg,wp,lp);+}++__declspec(noinline) LRESULT createWindow(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp){+switch(msg){case WM_CREATE:{mainWindow=hwnd;backdrop.attach(hwnd);font=veyra::ui::makeFont(hwnd);veyra::ui::titleTheme(hwnd);uiState.configured=initialOptions.snapshot();uiState.enhanced=uiPreferences.enhancementEnabled<0?(initialOptions.nr||initialOptions.sr||initialOptions.fg||initialOptions.settings.videoHdr.enabled):uiPreferences.enhancementEnabled!=0;engine.requestSettings(uiState.effective());#ifdef VEYRA_ENABLE_REMOTEPLAY@@ -592,43 +600,42 @@ for(auto [id,help]:std::initializer_list<std::pair<int,const wchar_t*>>{{Seek,L"拖动跳转;松手后等待解码和增强预热。跳转中保持目标位置,不会故意弹回。"}})SetPropW(GetDlgItem(hwnd,id),L"veyra.tip",HANDLE(help));SetPropW(video,L"veyra.tip",HANDLE(L"专业模式:滚轮缩放 · 中键拖动画面 · 右键恢复适应窗口。缩放不影响增强或保存尺寸。"));tooltips=CreateWindowExW(WS_EX_TOPMOST,TOOLTIPS_CLASSW,nullptr,WS_POPUP|TTS_ALWAYSTIP|TTS_NOPREFIX,0,0,0,0,hwnd,nullptr,GetModuleHandleW(nullptr),nullptr);SetWindowTheme(tooltips,L"",L"");SendMessageW(tooltips,TTM_SETTIPBKCOLOR,RGB(28,31,33),0);SendMessageW(tooltips,TTM_SETTIPTEXTCOLOR,RGB(225,230,228),0);SendMessageW(tooltips,TTM_SETDELAYTIME,TTDT_INITIAL,550);SendMessageW(tooltips,TTM_SETDELAYTIME,TTDT_AUTOPOP,15000);SendMessageW(tooltips,TTM_SETMAXTIPWIDTH,0,360);EnumChildWindows(hwnd,[](HWND child,LPARAM context)->BOOL{auto tip=reinterpret_cast<HWND>(context);wchar_t cls[32]{};GetClassNameW(child,cls,32);if(child==video||_wcsicmp(cls,L"BUTTON")==0||_wcsicmp(cls,L"EDIT")==0||_wcsicmp(cls,L"COMBOBOX")==0||_wcsicmp(cls,TRACKBAR_CLASSW)==0){TOOLINFOW info{TTTOOLINFOW_V2_SIZE};info.uFlags=TTF_IDISHWND|TTF_SUBCLASS;info.hwnd=GetParent(child);info.uId=UINT_PTR(child);auto help=GetPropW(child,L"veyra.tip");info.lpszText=help?reinterpret_cast<wchar_t*>(help):LPSTR_TEXTCALLBACKW;if(!SendMessageW(tip,TTM_ADDTOOLW,0,LPARAM(&info)))veyra::log::error("ui-help","Tooltip registration failed");}return TRUE;},LPARAM(tooltips));if(smokeSeconds>0)startTick=GetTickCount64();diagnosticPanel=veyra::ui::createTelemetryPanel(hwnd,engine);DragAcceptFiles(hwnd,TRUE);startShellTimer(hwnd,TelemetryTimer,100);layout();return 0;}-case WM_NCCALCSIZE:if(wp)return 0;break;-case WM_NCACTIVATE:return DefWindowProcW(hwnd,msg,wp,-1);-case WM_NCPAINT:return 0;-case WM_ERASEBKGND:return 1;-case WM_NCHITTEST:{LRESULT hit=DefWindowProcW(hwnd,msg,wp,lp);if(hit==HTCLIENT&&!full){POINT p{GET_X_LPARAM(lp),GET_Y_LPARAM(lp)};ScreenToClient(hwnd,&p);RECT r{};GetClientRect(hwnd,&r);int edge=veyra::ui::dip(hwnd,7);bool left=p.x<edge,right=p.x>=r.right-edge,top=p.y<edge,bottom=p.y>=r.bottom-edge;if(top&&left)return HTTOPLEFT;if(top&&right)return HTTOPRIGHT;if(bottom&&left)return HTBOTTOMLEFT;if(bottom&&right)return HTBOTTOMRIGHT;if(left)return HTLEFT;if(right)return HTRIGHT;if(top)return HTTOP;if(bottom)return HTBOTTOM;if((uiState.mode==veyra::ui::Mode::Professional&&p.y<veyra::ui::dip(hwnd,54))||(uiState.mode==veyra::ui::Mode::Daily&&p.y>r.bottom-veyra::ui::dip(hwnd,88)))return HTCAPTION;}return hit;}+}return DefWindowProcW(hwnd,msg,wp,lp);+}++__declspec(noinline) LRESULT paintWindow(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp){+switch(msg){case WM_PAINT:{veyra::ui::PaintBuffer paint(hwnd);auto g=chromeLayout(MulDiv(paint.rect.right,96,veyra::ui::layoutDpi(hwnd)),MulDiv(paint.rect.bottom,96,veyra::ui::layoutDpi(hwnd)));veyra::ui::paintChrome(hwnd,paint.dc,g,engine.snapshot(),full);return 0;}-case WM_LBUTTONDOWN:{if(uiState.mode==veyra::ui::Mode::Professional&&!full){RECT r{};GetClientRect(hwnd,&r);int w=MulDiv(r.right,96,veyra::ui::layoutDpi(hwnd)),x=MulDiv(GET_X_LPARAM(lp),96,veyra::ui::layoutDpi(hwnd));if(w>=1180&&abs(x-(w-uiPreferences.inspectorWidth-27))<8){inspectorResizing=true;proposedInspectorWidth=uiPreferences.inspectorWidth;SetCapture(hwnd);return 0;}}break;}-case WM_MOUSEMOVE:if(inspectorResizing){RECT r{};GetClientRect(hwnd,&r);proposedInspectorWidth=std::clamp(MulDiv(r.right-GET_X_LPARAM(lp),96,veyra::ui::layoutDpi(hwnd))-27,296,420);InvalidateRect(hwnd,nullptr,FALSE);return 0;}break;-case WM_LBUTTONUP:if(inspectorResizing){inspectorResizing=false;ReleaseCapture();uiPreferences.inspectorWidth=proposedInspectorWidth;layout();return 0;}break;-case WM_CAPTURECHANGED:if(inspectorResizing){inspectorResizing=false;InvalidateRect(hwnd,nullptr,FALSE);}break;-case WM_NOTIFY:{auto header=reinterpret_cast<NMHDR*>(lp);if(header->code==TTN_GETDISPINFOW){auto info=reinterpret_cast<NMTTDISPINFOW*>(lp);HWND child=reinterpret_cast<HWND>(header->idFrom);if(auto tip=GetPropW(child,L"veyra.tip"))info->lpszText=reinterpret_cast<wchar_t*>(tip);else{static wchar_t value[512];GetWindowTextW(child,value,512);info->lpszText=value;}return 0;}break;}-case WM_GETMINMAXINFO:{auto info=reinterpret_cast<MINMAXINFO*>(lp);info->ptMinTrackSize={veyra::ui::dip(hwnd,720),veyra::ui::dip(hwnd,540)};return 0;}-case WM_CTLCOLORSTATIC:case WM_CTLCOLOREDIT:case WM_CTLCOLORBTN:case WM_CTLCOLORLISTBOX:return veyra::ui::colors(msg,wp,lp);+}return DefWindowProcW(hwnd,msg,wp,lp);+}++__declspec(noinline) LRESULT savePresentation(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp){+switch(msg){case WM_APP+46:{uiPreferences.presentation=engine.snapshot().presentation;if(smokeSeconds<=0&&!preferences.save(uiPreferences,nullptr))veyra::log::warn("preferences","Could not persist presentation settings");return 0;}+}return DefWindowProcW(hwnd,msg,wp,lp);+}++__declspec(noinline) LRESULT protectionCommand(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp){+switch(msg){case WM_APP+45:{if(masterPendingRevision)return 0;auto settings=uiState.enhanced?engine.snapshot().desired:uiState.configured;if(wp==213){auto current=engine.snapshot();if(uiState.mode!=veyra::ui::Mode::Professional||!current.running||!current.frames)return 0;bool space=false;for(auto q:settings.protection.regions)space|=q.empty();if(!space)return 0;cancelProtection();protectionArmed=true;SetFocus(video);return 1;}if(wp==214){cancelProtection();settings.protection={};}else if(wp==206)settings.protection.enabled=lp==BST_CHECKED;else if(wp==222)settings.protection.featherPixels=float(std::clamp(int(lp),0,64));else return 0;return applySettings(settings)?1:0;}+}return DefWindowProcW(hwnd,msg,wp,lp);+}++__declspec(noinline) LRESULT enhancementCommand(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp){+switch(msg){case WM_APP+44:{if(masterPendingRevision)return 0;auto setting=uiState.enhanced?engine.snapshot().desired:uiState.configured;const bool enabled=wp==202?lp>1:lp==BST_CHECKED;if(wp==200)setting.nr=enabled;else if(wp==201)setting.sr=enabled;else if(wp==230)setting.videoHdr.enabled=enabled;else if(wp==202){bool allowed=false;for(auto m:veyra::engine::kFgMultiplierChoices)if(uint32_t(lp)==m)allowed=true;if(!allowed)return 0;setting.multiplier=uint32_t(lp);if(!setting.validate().empty())return 0;}else return 0;const bool enablesMaster=enabled&&!uiState.enhanced;if(enablesMaster){masterPreviousEnabled=false;uiState.enhanced=true;}if(!applySettings(setting)){if(enablesMaster)uiState.enhanced=false;veyra::ui::settingsEnabled(uiState.enhanced,uiState.configured);return 0;}if(auto pending=engine.snapshot();enablesMaster&&pending.running){masterPendingRevision=pending.desired.revision;masterPendingSession=pending.sessionId;}veyra::log::info("ui-feature",std::format("click={} enabled={} requestedRevision={} draft-independent=true",wp==200?"NR":wp==201?"SR":wp==230?"VideoHDR":"FG",enabled,engine.snapshot().desired.revision));return 1;}-case WM_APP+43:showDiagnostics=false;layout();return 0;-case WM_APP+41:switch(wp){case 501:startVideoExport(lp!=0);break;case 502:{auto path=fileDialog(true);if(!path.empty())engine.saveFrame(path);break;}case 503:jobPaused=!jobPaused;exportJob.pause(jobPaused);break;case 504:exportJob.cancel();break;case 505:preferWatching=lp==BST_CHECKED;break;}return 0;-case WM_ENTERSIZEMOVE:- endTransition();- SetPropW(video,L"Veyra.InteractiveMove",HANDLE(1));- veyra::log::info("ui-display","interactive move begin; retaining presentation buffers");- return 0;-case WM_EXITSIZEMOVE:- RemovePropW(video,L"Veyra.InteractiveMove");- layout();- veyra::log::info("ui-display","interactive move end; presentation resize released");- return 0;-case WM_SIZE:cancelProtection();if(wp!=SIZE_MINIMIZED){endTransition();layout();}return 0;-case WM_DROPFILES:{std::vector<wchar_t> file(32768);DragQueryFileW(reinterpret_cast<HDROP>(wp),0,file.data(),32768);DragFinish(reinterpret_cast<HDROP>(wp));openFile(file.data());layout();return 0;}+}return DefWindowProcW(hwnd,msg,wp,lp);+}++__declspec(noinline) LRESULT windowCommand(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp){+switch(msg){case WM_COMMAND:switch(LOWORD(wp)){case Open:case ProRailVideo:case ImageOpen:openFile(fileDialog(false));layout();break;case ScreenCapture:veyra::ui::showScreenCapturePanel(hwnd,[](const std::wstring& path){openFile(path);layout();},[]{engine.stop();},[]{return engine.snapshot();},[](bool fill){screenFill=fill;screenFitClient={};screenFitImage={};engine.previewView({});});break;@@ -682,31 +689,17 @@ case Capture:case ProRailCapture:veyra::ui::showCapturePanel(hwnd,[](const std::case Export:if(uiState.mode==veyra::ui::Mode::Professional)startVideoExport(false);break;case Info:showDiagnostics=!showDiagnostics;layout();break;}return 0;+}return DefWindowProcW(hwnd,msg,wp,lp);+}++__declspec(noinline) LRESULT scrollCommand(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp){+switch(msg){case WM_HSCROLL:if(reinterpret_cast<HWND>(lp)==GetDlgItem(hwnd,Volume)){engine.setVolume(float(SendDlgItemMessageW(hwnd,Volume,TBM_GETPOS,0,0))/100,false);return 0;}if(reinterpret_cast<HWND>(lp)==seekBar&&LOWORD(wp)!=TB_ENDTRACK){dragging=LOWORD(wp)==TB_THUMBTRACK;auto s=engine.snapshot();if(s.duration>0)seekPreview.update(s.duration*SendMessageW(seekBar,TBM_GETPOS,0,0)/10000.0,!dragging);}return 0;-case WM_KEYDOWN:if(wp==VK_ESCAPE&&protectionArmed){cancelProtection();return 0;}if(wp==VK_SPACE){SendMessageW(hwnd,WM_COMMAND,Play,0);return 0;}if(wp==VK_F11){toggleFullscreen();return 0;}if(wp==VK_ESCAPE&&full){toggleFullscreen();return 0;}if(wp=='V'&&uiState.mode==veyra::ui::Mode::Professional){holdOriginal=true;updateComparison();return 0;}break;-case WM_KEYUP:if(wp=='V'){holdOriginal=false;updateComparison();return 0;}break;-case WM_SYSKEYDOWN:if(wp==VK_RETURN&&(lp&(1LL<<29))){toggleFullscreen();return 0;}break;-case WM_THEMECHANGED:veyra::ui::glassTextTheme().reset();[[fallthrough]];-case WM_DWMCOMPOSITIONCHANGED:backdrop.configure();RedrawWindow(hwnd,nullptr,nullptr,RDW_INVALIDATE|RDW_ALLCHILDREN);return 0;-case WM_ACTIVATEAPP:if(!wp){holdOriginal=false;updateComparison();}break;-case WM_APP+90:- if(smokeSeconds<=0||!(wp==0||wp==96||wp==144||wp==192))return 0;- veyra::ui::smokeLayoutDpi=UINT(wp);- veyra::log::info("ui-dpi-test",std::format("syntheticLayoutDpi={} windowsDpi={}",wp,GetDpiForWindow(hwnd)));- [[fallthrough]];-case WM_DPICHANGED:{- endTransition();veyra::ui::cancelPopupSelector();- veyra::log::info("ui-display",std::format("DPI transition begin dpi={} synthetic={} moving={}",veyra::ui::layoutDpi(hwnd),msg!=WM_DPICHANGED,GetPropW(video,L"Veyra.InteractiveMove")!=nullptr));- SetPropW(video,L"Veyra.DpiTransition",HANDLE(1));- if(msg==WM_DPICHANGED&&!full){auto rect=reinterpret_cast<RECT*>(lp);SetWindowPos(hwnd,nullptr,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,SWP_NOZORDER|SWP_NOACTIVATE);}- auto oldFont=font;font=veyra::ui::makeFont(hwnd);- EnumChildWindows(hwnd,[](HWND c,LPARAM f)->BOOL{SendMessageW(c,WM_SETFONT,WPARAM(f),FALSE);return TRUE;},LPARAM(font));- DeleteObject(oldFont);DeleteObject(emptyFont);emptyFont=veyra::ui::makeFont(hwnd,26);- SendDlgItemMessageW(hwnd,EmptyTitle,WM_SETFONT,WPARAM(emptyFont),FALSE);- veyra::ui::settingsDpi();veyra::ui::telemetryDpi();layout();- RemovePropW(video,L"Veyra.DpiTransition");- veyra::log::info("ui-display","DPI transition complete");return 0;}+}return DefWindowProcW(hwnd,msg,wp,lp);+}+__declspec(noinline) LRESULT windowTimer(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp){+switch(msg){case WM_TIMER:#ifdef VEYRA_ENABLE_REMOTEPLAYif(wp==ControllerTimer){const auto state=engine.snapshot();if(state.remotePlay&&(state.running||state.transport==veyra::engine::TransportState::Opening)){const bool focused=GetForegroundWindow()==hwnd;engine.remotePlayController(remoteController.poll(focused));remoteController.feedback(engine.remotePlayFeedback(),focused);}else{engine.remotePlayController({});remoteController.stop();KillTimer(hwnd,ControllerTimer);}return 0;}@@ -1133,7 +1126,76 @@ if(smokeProtection&&startTick&&GetTickCount64()-startTick>1500){}if(smokeSeconds>0&&startTick&&GetTickCount64()-startTick>ULONGLONG(smokeSeconds)*1000){veyra::log::info("app",std::format("smoke frames={} generated={} failed={} latenessMs={:.2f} absLatenessP95Ms={:.2f} controlsStep={} capture={} processedFps={:.2f} callbackFps={:.2f} captureDropped={} callbackToPresentReturnP95Ms={:.3f} schedulingWaitP95Ms={:.3f} processCpuP95Ms={:.3f} presentCpuP95Ms={:.3f} nrEvaluated={} nvofExecuted={}",s.frames,s.generated,s.failed,s.lateMs,s.lateP95Ms,smokeStep,s.capture,s.fps,s.captureFps,s.captureDropped,s.captureAgeP95Ms,s.schedulingWaitP95Ms,s.processCpuP95Ms,s.presentCpuP95Ms,s.nrEvaluated,s.nvofExecuted));resultCode=(s.frames>0||smokeEmpty)&&!s.failed&&(!smokeZoom||zoomStep==3)&&(!smokeProtection||protectionStep==4)&&(!smokeRepair||repairStep==10)&&(!smokeTransport||transportStep==10)&&(!smokeFgOnly||fgOnlyStep==4)&&(!smokeSettings||settingsStep==5)&&(!smokeColor||colorStep==8)&&(!smokeRollback||settingsStep==3)&&(!smokeUi||uiStep==8)&&(!smokeDual||dualStep==40)&&(!smokeMaster||masterStep==3)&&(!smokeAudio||audioStep==4)&&(!(smokeJob||smokeJobCancel)||jobStep==4)&&(!smokeScreenshot||screenshotStep==2)?0:1;PostMessageW(hwnd,WM_CLOSE,0,0);}return 0;}+}return DefWindowProcW(hwnd,msg,wp,lp);+}++__declspec(noinline) LRESULT closeWindow(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp){+switch(msg){case WM_CLOSE:endTransition();if(!closing&&smokeSeconds<=0&&exportJob.poll().active()&&MessageBoxW(hwnd,L"导出尚未完成。取消导出并退出?\n选择“否”返回播放器继续导出。",L"退出 Veyra",MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION)!=IDYES)return 0;if(!closing&&smokeSeconds<=0){auto snapshot=engine.snapshot();WINDOWPLACEMENT placement{sizeof(placement)};if(full)placement=windowPlacement;else GetWindowPlacement(hwnd,&placement);auto r=placement.rcNormalPosition;uiPreferences.width=MulDiv(r.right-r.left,96,veyra::ui::layoutDpi(hwnd));uiPreferences.height=MulDiv(r.bottom-r.top,96,veyra::ui::layoutDpi(hwnd));uiPreferences.x=r.left;uiPreferences.y=r.top;uiPreferences.positioned=true;uiPreferences.volume=snapshot.volume;uiPreferences.muted=snapshot.muted;uiPreferences.subtitles=uiState.subtitles;uiPreferences.subtitleSize=subtitlePixels;uiPreferences.subtitleOutline=uiState.subtitleOutline;uiPreferences.subtitleBackground=uiState.subtitleBackground;uiPreferences.subtitleSecondLanguage=uiState.subtitleSecondLanguage;uiPreferences.subtitleMargin=uiState.subtitleMargin;uiPreferences.subtitleFont=uiState.subtitleFont;uiPreferences.inspector=uiState.inspector;uiPreferences.colourFoldMask=preferences.load().colourFoldMask;uiPreferences.enhancementEnabled=uiState.enhanced?1:0;auto saved=uiState.enhanced&&snapshot.running&&snapshot.frames>0&&!snapshot.applying&&!snapshot.failed?snapshot.applied:uiState.configured;if(!preferences.save(uiPreferences,&saved))veyra::log::warn("ui-preferences","preferences save failed; existing corrupt original preserved");else veyra::log::info("ui-preferences","UI and enhancement preferences saved");}playbackPower.update(false);exportJob.cancel();closing=true;engine.stop();SetWindowTextW(statusBar,L"正在释放当前任务资源…");return 0;+}return DefWindowProcW(hwnd,msg,wp,lp);+}++LRESULT CALLBACK proc(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp){switch(msg){+case WM_SYSCOMMAND:return systemCommand(hwnd,msg,wp,lp);+case WM_CREATE:return createWindow(hwnd,msg,wp,lp);+case WM_NCCALCSIZE:if(wp)return 0;break;+case WM_NCACTIVATE:return DefWindowProcW(hwnd,msg,wp,-1);+case WM_NCPAINT:return 0;+case WM_ERASEBKGND:return 1;+case WM_NCHITTEST:{LRESULT hit=DefWindowProcW(hwnd,msg,wp,lp);if(hit==HTCLIENT&&!full){POINT p{GET_X_LPARAM(lp),GET_Y_LPARAM(lp)};ScreenToClient(hwnd,&p);RECT r{};GetClientRect(hwnd,&r);int edge=veyra::ui::dip(hwnd,7);bool left=p.x<edge,right=p.x>=r.right-edge,top=p.y<edge,bottom=p.y>=r.bottom-edge;if(top&&left)return HTTOPLEFT;if(top&&right)return HTTOPRIGHT;if(bottom&&left)return HTBOTTOMLEFT;if(bottom&&right)return HTBOTTOMRIGHT;if(left)return HTLEFT;if(right)return HTRIGHT;if(top)return HTTOP;if(bottom)return HTBOTTOM;if((uiState.mode==veyra::ui::Mode::Professional&&p.y<veyra::ui::dip(hwnd,54))||(uiState.mode==veyra::ui::Mode::Daily&&p.y>r.bottom-veyra::ui::dip(hwnd,88)))return HTCAPTION;}return hit;}+case WM_PAINT:return paintWindow(hwnd,msg,wp,lp);+case WM_LBUTTONDOWN:{if(uiState.mode==veyra::ui::Mode::Professional&&!full){RECT r{};GetClientRect(hwnd,&r);int w=MulDiv(r.right,96,veyra::ui::layoutDpi(hwnd)),x=MulDiv(GET_X_LPARAM(lp),96,veyra::ui::layoutDpi(hwnd));if(w>=1180&&abs(x-(w-uiPreferences.inspectorWidth-27))<8){inspectorResizing=true;proposedInspectorWidth=uiPreferences.inspectorWidth;SetCapture(hwnd);return 0;}}break;}+case WM_MOUSEMOVE:if(inspectorResizing){RECT r{};GetClientRect(hwnd,&r);proposedInspectorWidth=std::clamp(MulDiv(r.right-GET_X_LPARAM(lp),96,veyra::ui::layoutDpi(hwnd))-27,296,420);InvalidateRect(hwnd,nullptr,FALSE);return 0;}break;+case WM_LBUTTONUP:if(inspectorResizing){inspectorResizing=false;ReleaseCapture();uiPreferences.inspectorWidth=proposedInspectorWidth;layout();return 0;}break;+case WM_CAPTURECHANGED:if(inspectorResizing){inspectorResizing=false;InvalidateRect(hwnd,nullptr,FALSE);}break;+case WM_NOTIFY:{auto header=reinterpret_cast<NMHDR*>(lp);if(header->code==TTN_GETDISPINFOW){auto info=reinterpret_cast<NMTTDISPINFOW*>(lp);HWND child=reinterpret_cast<HWND>(header->idFrom);if(auto tip=GetPropW(child,L"veyra.tip"))info->lpszText=reinterpret_cast<wchar_t*>(tip);else{static wchar_t value[512];GetWindowTextW(child,value,512);info->lpszText=value;}return 0;}break;}+case WM_GETMINMAXINFO:{auto info=reinterpret_cast<MINMAXINFO*>(lp);info->ptMinTrackSize={veyra::ui::dip(hwnd,720),veyra::ui::dip(hwnd,540)};return 0;}+case WM_CTLCOLORSTATIC:case WM_CTLCOLOREDIT:case WM_CTLCOLORBTN:case WM_CTLCOLORLISTBOX:return veyra::ui::colors(msg,wp,lp);+case WM_APP+46:return savePresentation(hwnd,msg,wp,lp);+case WM_APP+45:return protectionCommand(hwnd,msg,wp,lp);+case WM_APP+44:return enhancementCommand(hwnd,msg,wp,lp);+case WM_APP+43:showDiagnostics=false;layout();return 0;+case WM_APP+41:switch(wp){case 501:startVideoExport(lp!=0);break;case 502:{auto path=fileDialog(true);if(!path.empty())engine.saveFrame(path);break;}case 503:jobPaused=!jobPaused;exportJob.pause(jobPaused);break;case 504:exportJob.cancel();break;case 505:preferWatching=lp==BST_CHECKED;break;}return 0;+case WM_ENTERSIZEMOVE:+ endTransition();+ SetPropW(video,L"Veyra.InteractiveMove",HANDLE(1));+ veyra::log::info("ui-display","interactive move begin; retaining presentation buffers");+ return 0;+case WM_EXITSIZEMOVE:+ RemovePropW(video,L"Veyra.InteractiveMove");+ layout();+ veyra::log::info("ui-display","interactive move end; presentation resize released");+ return 0;+case WM_SIZE:cancelProtection();if(wp!=SIZE_MINIMIZED){endTransition();layout();}return 0;+case WM_DROPFILES:{std::vector<wchar_t> file(32768);DragQueryFileW(reinterpret_cast<HDROP>(wp),0,file.data(),32768);DragFinish(reinterpret_cast<HDROP>(wp));openFile(file.data());layout();return 0;}+case WM_COMMAND:return windowCommand(hwnd,msg,wp,lp);+case WM_HSCROLL:return scrollCommand(hwnd,msg,wp,lp);+case WM_KEYDOWN:if(wp==VK_ESCAPE&&protectionArmed){cancelProtection();return 0;}if(wp==VK_SPACE){SendMessageW(hwnd,WM_COMMAND,Play,0);return 0;}if(wp==VK_F11){toggleFullscreen();return 0;}if(wp==VK_ESCAPE&&full){toggleFullscreen();return 0;}if(wp=='V'&&uiState.mode==veyra::ui::Mode::Professional){holdOriginal=true;updateComparison();return 0;}break;+case WM_KEYUP:if(wp=='V'){holdOriginal=false;updateComparison();return 0;}break;+case WM_SYSKEYDOWN:if(wp==VK_RETURN&&(lp&(1LL<<29))){toggleFullscreen();return 0;}break;+case WM_THEMECHANGED:veyra::ui::glassTextTheme().reset();[[fallthrough]];+case WM_DWMCOMPOSITIONCHANGED:backdrop.configure();RedrawWindow(hwnd,nullptr,nullptr,RDW_INVALIDATE|RDW_ALLCHILDREN);return 0;+case WM_ACTIVATEAPP:if(!wp){holdOriginal=false;updateComparison();}break;+case WM_APP+90:+ if(smokeSeconds<=0||!(wp==0||wp==96||wp==144||wp==192))return 0;+ veyra::ui::smokeLayoutDpi=UINT(wp);+ veyra::log::info("ui-dpi-test",std::format("syntheticLayoutDpi={} windowsDpi={}",wp,GetDpiForWindow(hwnd)));+ [[fallthrough]];+case WM_DPICHANGED:{+ endTransition();veyra::ui::cancelPopupSelector();+ veyra::log::info("ui-display",std::format("DPI transition begin dpi={} synthetic={} moving={}",veyra::ui::layoutDpi(hwnd),msg!=WM_DPICHANGED,GetPropW(video,L"Veyra.InteractiveMove")!=nullptr));+ SetPropW(video,L"Veyra.DpiTransition",HANDLE(1));+ if(msg==WM_DPICHANGED&&!full){auto rect=reinterpret_cast<RECT*>(lp);SetWindowPos(hwnd,nullptr,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,SWP_NOZORDER|SWP_NOACTIVATE);}+ auto oldFont=font;font=veyra::ui::makeFont(hwnd);+ EnumChildWindows(hwnd,[](HWND c,LPARAM f)->BOOL{SendMessageW(c,WM_SETFONT,WPARAM(f),FALSE);return TRUE;},LPARAM(font));+ DeleteObject(oldFont);DeleteObject(emptyFont);emptyFont=veyra::ui::makeFont(hwnd,26);+ SendDlgItemMessageW(hwnd,EmptyTitle,WM_SETFONT,WPARAM(emptyFont),FALSE);+ veyra::ui::settingsDpi();veyra::ui::telemetryDpi();layout();+ RemovePropW(video,L"Veyra.DpiTransition");+ veyra::log::info("ui-display","DPI transition complete");return 0;}++case WM_TIMER:return windowTimer(hwnd,msg,wp,lp);+case WM_CLOSE:return closeWindow(hwnd,msg,wp,lp);case WM_DESTROY:playbackPower.update(false);subtitleLoader.reset();diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.mdindex 2458473e..b5ecdc55 100644--- a/docs/CURRENT_STATUS.md+++ b/docs/CURRENT_STATUS.md@@ -1,5 +1,7 @@# 当前项目状态 / Current Status+2026-09-20 窗口边角拖动崩溃已定位为 UI 回调栈耗尽,拆分 AppShell / SettingsWindow 的重型消息处理后,本机真实鼠标拖动、采集、DLSS 6X / XeSS 4X 缩放和合成 DPI 回归通过。新版测试包输出到 `E:/项目/Veyra/test-packages/1.4.3-20260920-resize-fix/`;下方 final 目录为旧包。本轮不修改补帧调度,固定 6X 均匀呈现仍未解决。见 [窗口缩放修复](WINDOW_RESIZE_REPAIR_2026-09-20.md)。+2026-09-20 用户决定暂止优化,交付重新构建的 1.4.3 本地测试包。基于 `d60ec88`,产品代码保持 `7a3dfae`,失败实验均回退;固定 6X 均匀呈现问题仍未解决。最新包位于 `E:/项目/Veyra/test-packages/1.4.3-20260920-final/`,构建、CPU/UI 回归及便携包七项运行检查通过。未推送或发布 GitHub;此前“目标继续”和“未打包”是历史状态。2026-09-20 最新约束与实验:跳过 NR 优化,不增加等待,不自动降档。`7a3dfae` 保留用户所选倍率,`55e0bdd` 撤回不安全的共享状态回读。新增整组耗时预测、取消重复清屏、光流历史直接复制三项对照均未证明显著改善,已全部回退;固定 6X 本轮留存窗口约 298–303 提交/s,仍有约 17ms 空档,**尚未修好**。详见 [非 NR 实验记录](FG_NON_NR_EXPERIMENTS_2026-09-20.md)。下文自动 4X 结果仅是历史,已不代表当前行为。diff --git a/docs/RELEASE_NOTES_1.4.3.md b/docs/RELEASE_NOTES_1.4.3.mdindex 48be997c..335870f4 100644--- a/docs/RELEASE_NOTES_1.4.3.md+++ b/docs/RELEASE_NOTES_1.4.3.md@@ -4,7 +4,8 @@包含 1.4.2 发布后当前分支的修复:-- 本次重新构建基于 `d60ec88`,产品代码与 `7a3dfae` 一致。保留用户选择的补帧倍率,不再自动改成较低倍率。+- 保留此前 `7a3dfae` 的补帧基线,并修复拖动窗口边角时的 UI 线程栈耗尽崩溃。保留用户选择的补帧倍率,不再自动改成较低倍率。+- 拆分主窗口与设置面板的高栈占用消息处理;真实鼠标拖动、采集预览及 NR + DLSS 6X / XeSS 4X 反复缩放已通过本机短测。- 保留文件播放有限追赶、逐子帧状态读取及对应 GPU fence 保护;无收益或存在资源安全问题的后续实验已回退。没有加入额外 35/50ms 等待。- 修正 XeSS / DLSS 切换弹回、XeSS 2X 后无法切到 4X 的能力缓存问题;运行中切换失败恢复原设置。diff --git a/docs/WINDOW_RESIZE_REPAIR_2026-09-20.md b/docs/WINDOW_RESIZE_REPAIR_2026-09-20.mdnew file mode 100644index 00000000..9785b4cb--- /dev/null+++ b/docs/WINDOW_RESIZE_REPAIR_2026-09-20.md@@ -0,0 +1,93 @@+# Window resize crash repair (2026-09-20)++Scope: user reported a freeze/crash while holding and dragging a window corner+in the 1.4.3 test build. Preserve retained frame-generation repairs and timing.++## Evidence and repair++The old executable crashed during actual bottom-right mouse resizing with+capture active and all effects off. PID 22100 dump reports 0xc000041d at+__chkstk+0x37 with exhausted UI-thread stack. User PID 408 dump has the same+stack exhaustion pattern. Raw stack scans are supporting evidence, not a+complete formal unwind trace.++PE x64 unwind metadata establishes callback stack allocations:++| Callback | Old bytes | Fixed bytes |+| --- | ---: | ---: |+| AppShell proc | 162360 | 280 |+| SettingsWindow proc | 98216 | 2536 |++Win32 modal sizing, layout and painting reenter window callbacks. Previously+each invocation reserved large storage even for small messages. Extract heavy+creation, command, timer and related handlers into noinline helpers, retaining+message bodies, return/break semantics and dispatch order. Do not increase the+thread stack to conceal excessive callback allocations. Rendering, GPU fences,+NR, FG multipliers and latency policy are unchanged.++Changed product files: apps/veyra/ui/AppShell.cpp and+apps/veyra/SettingsWindow.cpp. Regression tools: ui-native-resize.py and+ui-stack-budget.py under scripts/acceptance.++## Verification++- Release 1.4.3 build: passed; UI contract and presentation worker tests passed.+- Stack budget check: fixed build passes; old executable fails as expected.+- Actual mouse bottom-right shrink and top-left drag/snap with NV12 capture:+ video continues, UI responds, clean Alt+F4 shutdown.+- Native Windows modal sizing: four grow/shrink cycles each for capture,+ NR + DLSS 6X and NR + XeSS 4X: passed with continuing presentation.+- Synthetic DPI 96/144/192/reset cycles: passed. Only one physical monitor was+ connected; this does not certify real cross-monitor transitions.+- Baseline synthetic resizing alone did not reproduce the actual mouse crash;+ actual mouse evidence and compiled stack budget are required regressions.+- Initial DLSS test result reader failed on non-UTF8 diagnostic bytes after+ successful app exit. Reader corrected to tolerate those bytes; rerun passed.++Build command: scripts/build-isolated.ps1 -Root . -BuildDirectory+E:/项目/Veyra/build/slider-reset-20260919 -DependencyCache+E:/项目/Veyra/build/slider-reset-20260919/CMakeCache.txt -TempDirectory+E:/项目/Veyra/tmp/fg-cadence-repair-20260920 -Targets+veyra,veyra_presentation_worker_tests,veyra_ui_contract_tests -DisplayVersion 1.4.3.+Linker /MAP enabled in the local cache for stack-budget inspection.++Evidence: E:/项目/Veyra/tests/resize-hang-20260920/ (fix-build.log,+fixed-mouse-capture.log, fixed-native-capture, fixed-native-dlss6-rerun,+fixed-native-xess4, fixed-dpi). OS crash dumps remain in the Windows-managed+C:/Users/123/AppData/Local/CrashDumps directory; no global WER settings changed.++Local package command: scripts/package-portable.ps1 -Root . -Version 1.4.3+-Label '-test' -BuildDirectory E:/项目/Veyra/build/slider-reset-20260919+-OutputDirectory E:/项目/Veyra/test-packages/1.4.3-20260920-resize-fix.+Process TEMP/TMP: E:/项目/Veyra/tmp/fg-cadence-repair-20260920.++Coverage is RTX5070 on this machine, not all users/devices. Fixed 6X pacing+gaps remain unresolved. No push or public release.++## Package verification++Portable smoke: all seven cases passed using visible-scene.mp4, CaseSeconds 7,+including real NR/SR/FG and app-local module checks. Logs/result:+E:/项目/Veyra/tests/resize-hang-20260920/package-smoke/.+ZIP contents: all 120 payload entries verified against package manifest sizes+and SHA256, plus the manifest itself; publisher audit forbiddenFiles=0.+Unchanged runtime identities and patched FFmpeg retained.++Packaged executable native modal resize with NR + SR + DLSS 6X passed all four+grow/shrink cycles (1280x800 to 1544x1064 and back), exit 0; evidence in+package-native-resize/result.json. Packaged --smoke-ui --smoke-seconds 12+passed F11/Esc, Alt+Enter/double-click and remaining UI checks, exit 0+(package-ui.log).++Additional --smoke-repair-ui check failed at+NR_off_click_works_with_invalid_draft on both the fixed build and old delivered+package with identical NR-on/SR-off/FG-off input. Logs fixed-repair-ui.log and+baseline-repair-ui.log preserve this existing failure. It is not counted as a+pass and is outside the resize-only repair; the invalid draft condition needs+separate investigation. Actual NR-disable request and graph application are+present in the fixed log.++ZIP: E:/项目/Veyra/test-packages/1.4.3-20260920-resize-fix/Veyra-1.4.3-test-win64-portable.zip++Size: 472349977 bytes.+SHA256: ABA2DA87D1A308629BE1CD347401DF266212D98BC9A5E904E078512AE6FADD19.diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex e25065c0..6f838c1a 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -1,5 +1,30 @@# Veyra 工作记录+## 2026-09-20 Window corner resize crash++Reproduced real mouse resize crash with capture and effects disabled. Dump and+PE unwind metadata identify UI stack exhaustion, not a GPU deadlock. Extracted+heavy AppShell/SettingsWindow message handlers into noinline helpers. Callback+stack allocations fall from 162360/98216 bytes to 280/2536 bytes. No FG timing+or rendering changes. Added native modal resizing and PE stack-budget checks.+Release build, UI contract and presentation worker tests pass; real mouse+capture resizing, native capture/DLSS6/XeSS4 resizing and synthetic DPI pass.+The initial DLSS test reader hit invalid UTF8 after successful process exit;+reader fixed and rerun passed. Full evidence, commands and limits are in+docs/WINDOW_RESIZE_REPAIR_2026-09-20.md. Artifacts stay under+E:/项目/Veyra/tests/resize-hang-20260920, existing build/slider-reset-20260919,+tmp/fg-cadence-repair-20260920 and test-packages/1.4.3-20260920-resize-fix.+No proprietary files enter Git, no push/release/shutdown.++Package completed: resize-fix/Veyra-1.4.3-test-win64-portable.zip,+472349977 bytes, SHA256 ABA2DA87D1A308629BE1CD347401DF266212D98BC9A5E904E078512AE6FADD19.+All 120 ZIP payload hashes/sizes match manifest; forbiddenFiles=0; portable+smoke seven cases passed. Additional smoke-repair-ui invalid-draft assertion+fails on both this build and old final package under identical inputs; recorded+as existing unresolved behavior, not a passing regression. See repair report.+Packaged EXE NR+SR+DLSS6 native resize passed four grow/shrink cycles, exit0;+packaged 12-second --smoke-ui passed fullscreen/restore/UI checks, exit0.+## 2026-09-20 Retained repairs: 1.4.3 local test packageUser stopped further optimization and requested a new local 1.4.3 package.diff --git a/scripts/acceptance/ui-native-resize.py b/scripts/acceptance/ui-native-resize.pynew file mode 100644index 00000000..21f15ec1--- /dev/null+++ b/scripts/acceptance/ui-native-resize.py@@ -0,0 +1,101 @@+"""Exercise the actual Windows modal sizing loop with bounded UI probes."""+import ctypes as c+import ctypes.wintypes as w+import json+import os+from pathlib import Path+import subprocess+import sys+import time++if '--worker' not in sys.argv:+ child = subprocess.Popen([sys.executable, __file__, '--worker', *sys.argv[1:]])+ try:+ sys.exit(child.wait(timeout=75))+ except subprocess.TimeoutExpired:+ subprocess.run(['taskkill.exe', '/PID', str(child.pid), '/T', '/F'], capture_output=True, timeout=5)+ sys.exit('FAIL: native resize exceeded 75 seconds')+sys.argv.remove('--worker')+exe, output = Path(sys.argv[1]).resolve(), Path(sys.argv[2]).resolve()+output.mkdir(parents=True, exist_ok=True)+u = c.WinDLL('user32', use_last_error=True)+u.SetProcessDpiAwarenessContext.argtypes = [w.HANDLE]+u.SetProcessDpiAwarenessContext(c.c_void_p(-4))+u.GetWindowThreadProcessId.argtypes = [w.HWND, c.POINTER(w.DWORD)]+u.GetClassNameW.argtypes = [w.HWND, w.LPWSTR, c.c_int]+u.PostMessageW.argtypes = [w.HWND, w.UINT, w.WPARAM, w.LPARAM]+u.GetWindowRect.argtypes = [w.HWND, c.POINTER(w.RECT)]+u.SendMessageTimeoutW.argtypes = [w.HWND, w.UINT, w.WPARAM, w.LPARAM, w.UINT, w.UINT, c.POINTER(c.c_size_t)]+visit_type = c.WINFUNCTYPE(w.BOOL, w.HWND, w.LPARAM)+env = os.environ.copy()+env['VEYRA_LOG_FILE'] = str(output / 'app.log')+result = {'passed': False, 'cycles': []}+with (output / 'stdout.log').open('w') as stdout, (output / 'stderr.log').open('w') as stderr:+ process = subprocess.Popen([str(exe), '--smoke-view', 'pro', '--smoke-seconds', '60', *sys.argv[3:]], env=env, stdout=stdout, stderr=stderr)+ try:+ found = []++ @visit_type+ def visit(hwnd, unused):+ pid = w.DWORD()+ u.GetWindowThreadProcessId(hwnd, c.byref(pid))+ name = c.create_unicode_buffer(128)+ u.GetClassNameW(hwnd, name, 128)+ if pid.value == process.pid and name.value == 'VeyraApp':+ found.append(hwnd)+ return True++ end = time.monotonic() + 10+ while not found and time.monotonic() < end:+ u.EnumWindows(visit, 0)+ time.sleep(.1)+ assert found, 'main window missing'+ main = found[0]++ def probe(message=0):+ reply = c.c_size_t()+ assert process.poll() is None, f'application exited {process.returncode}'+ assert u.SendMessageTimeoutW(main, message, 0, 0, 2, 3000, c.byref(reply)), 'UI message timeout'++ time.sleep(5)+ for cycle in range(4):+ before = w.RECT()+ u.GetWindowRect(main, c.byref(before))+ # SC_SIZE + WMSZ_BOTTOMRIGHT enters DefWindowProc's modal loop.+ u.PostMessageW(main, 0x112, 0xF008, 0)+ time.sleep(.2)+ for step in range(24):+ u.PostMessageW(main, 0x100, (0x27 if cycle % 2 == 0 else 0x25), 0)+ u.PostMessageW(main, 0x100, (0x28 if cycle % 2 == 0 else 0x26), 0)+ time.sleep(.06)+ probe()+ u.PostMessageW(main, 0x100, 0x0D, 0)+ time.sleep(.4)+ probe()+ after = w.RECT()+ u.GetWindowRect(main, c.byref(after))+ sizes = [(before.right-before.left, before.bottom-before.top), (after.right-after.left, after.bottom-after.top)]+ assert sizes[0] != sizes[1], 'native sizing did not change window dimensions'+ result['cycles'].append(sizes)+ probe(0x10)+ assert process.wait(timeout=10) == 0+ # Vendor/media diagnostics may contain bytes in the active ANSI codepage.+ log = (output / 'app.log').read_text(encoding='utf-8', errors='replace')+ segments = log.split('interactive move begin;')[1:]+ assert len(segments) >= 4, 'native loop not observed'+ for segment in segments:+ moving, released = segment.split('interactive move end;', 1)+ # The end log follows removal of the move property. A renderer+ # thread can resize in that gap, so log ordering is not a fence.+ assert '[present-cost]' in moving, 'no presentation during native loop'+ result['passed'] = True+ except Exception as error:+ result['error'] = str(error)+ raise+ finally:+ if process.poll() is None:+ process.kill()+ process.wait(timeout=5)+ result['exitCode'] = process.returncode+ (output / 'result.json').write_text(json.dumps(result, indent=2), encoding='utf-8')+print(json.dumps(result))diff --git a/scripts/acceptance/ui-stack-budget.py b/scripts/acceptance/ui-stack-budget.pynew file mode 100644index 00000000..64424638--- /dev/null+++ b/scripts/acceptance/ui-stack-budget.py@@ -0,0 +1,69 @@+"""Check Release x64 callback stack allocations using PE unwind data and a /MAP file."""+import json+from pathlib import Path+import re+import struct+import sys++data = Path(sys.argv[1]).read_bytes()+def unpack(fmt, offset):+ return struct.unpack_from('<' + fmt, data, offset)++pe, = unpack('I', 0x3c)+assert data[pe:pe+4] == b'PE\0\0'+machine, count = unpack('HH', pe+4)+assert machine == 0x8664, 'only AMD64 unwind records are supported'+optional_size, = unpack('H', pe+20)+optional = pe+24+assert unpack('H', optional)[0] == 0x20b+base, = unpack('Q', optional+24)+sections = [unpack('IIII', optional+optional_size+i*40+8) for i in range(count)]++def offset(rva):+ for virtual_size, start, raw_size, raw_start in sections:+ if start <= rva < start+max(virtual_size, raw_size):+ assert rva-start < raw_size, 'unbacked RVA'+ return raw_start+rva-start+ raise ValueError(f'unmapped RVA {rva:x}')++exception_rva, exception_size = unpack('II', optional+112+3*8)+functions = dict((start, unwind) for start, end, unwind in+ (unpack('III', offset(exception_rva)+i) for i in range(0, exception_size, 12)))++def stack_bytes(rva):+ position = offset(functions[rva])+ version, _, slots, _ = unpack('BBBB', position)+ assert version & 7 == 1 and not version & 0x20, 'unsupported/chained unwind info'+ i, total = 0, 0+ while i < slots:+ _, operation = unpack('BB', position+4+i*2)+ op, info = operation & 15, operation >> 4+ i += 1+ if op == 0:+ total += 8+ elif op == 1:+ assert info in (0, 1)+ total += unpack('H' if info == 0 else 'I', position+4+i*2)[0] * (8 if info == 0 else 1)+ i += 1 if info == 0 else 2+ elif op == 2:+ total += info*8+8+ elif op == 3:+ pass+ elif op in (4, 8):+ i += 1+ elif op in (5, 9):+ i += 2+ elif op == 10:+ total += 40+info*8+ else:+ raise ValueError(f'unsupported unwind operation {op}')+ return total++results = {}+for line in Path(sys.argv[2]).read_text().splitlines():+ match = re.match(r'\s+\w+:\w+\s+(\?proc@\S+)\s+([0-9a-fA-F]{16})\s+f\s+(AppShell|SettingsWindow)\.cpp\.obj', line)+ if match:+ results[match[3]] = stack_bytes(int(match[2], 16)-base)+assert len(results) == 2, 'both callback symbols must be present'+print(json.dumps(results, indent=2))+assert all(size <= 32768 for size in results.values()), 'reentrant UI callback exceeds 32 KiB stack budget'