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++
feat(color): T5-b named colour presets with .vpcolor import/export; fix empty preset/LUT combos
Veyra Goal Agent8b898b45aa84
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 609b7b1e..d33c5bb9 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -65,9 +65,10 @@ add_library(veyra_base STATICsrc/base/FileIdentity.cppsrc/base/RuntimePaths.cppsrc/base/ThunkHook.cpp- # .cube parsing + the runtime LUT store: low level, no D3D12, shared by the- # ingest pipeline and the settings/import paths.+ # .cube parsing, the runtime LUT store and named colour looks: low level, no+ # D3D12, shared by the ingest pipeline and the settings/import paths.src/engine/ColorLut.cpp+ src/engine/ColorLookStore.cpp)veyra_apply_warnings(veyra_base)target_compile_options(veyra_base PUBLIC /utf-8)@@ -696,6 +697,13 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avformtarget_compile_definitions(veyra_color_lut_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)target_include_directories(veyra_color_lut_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)target_link_libraries(veyra_color_lut_tests PRIVATE veyra_base bcrypt)+ # Named colour looks + .vpcolor export/import (CPU only).+ add_executable(veyra_color_look_tests tests/unit/ColorLookTests.cpp src/engine/ColorLookStore.cpp)+ target_compile_features(veyra_color_look_tests PRIVATE cxx_std_20)+ target_compile_options(veyra_color_look_tests PRIVATE /utf-8)+ target_compile_definitions(veyra_color_look_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)+ target_include_directories(veyra_color_look_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)+ target_link_libraries(veyra_color_look_tests PRIVATE veyra_base)target_compile_features(veyra_repair_preset_tests PRIVATE cxx_std_20)target_compile_options(veyra_repair_preset_tests PRIVATE /utf-8)target_compile_definitions(veyra_repair_preset_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)diff --git a/apps/veyra/SettingsWindow.cpp b/apps/veyra/SettingsWindow.cppindex da12d9fa..1882311f 100644--- a/apps/veyra/SettingsWindow.cpp+++ b/apps/veyra/SettingsWindow.cpp@@ -2,7 +2,10 @@#include "ui/Theme.h"#include "ui/SettingHelp.h"#include "ui/UiPreferenceStore.h"+#include <commdlg.h>#include "veyra/engine/PresetStore.h"+#include "veyra/engine/ColorLookStore.h"+#include "veyra/engine/ColorLut.h"#include "veyra/RuntimePaths.h"#include "veyra/gfx/XessMfgUnlock.h"#include <filesystem>@@ -58,12 +61,12 @@ void loadStore(){if(!loaded){store.load();loaded=true;}}// rows instead of relying on static y offsets. The fold mask is persisted in// ui-preferences.v1 with the rest of the UI state.// ----------------------------------------------------------------------------constexpr int kColorSections=6;+constexpr int kColorSections=7;void message(const std::wstring& text);bool submit(engine::EnhancementSettings s);uint32_t colorFoldMask=0;std::wstring colorSectionName(int section){- static const wchar_t* names[kColorSections]={L"亮",L"颜色",L"曲线",L"混色器",L"颜色分级",L"校准"};+ static const wchar_t* names[kColorSections]={L"亮",L"颜色",L"曲线",L"混色器",L"颜色分级",L"校准",L"LUT"};return section>=0&§ion<kColorSections?names[section]:L"色彩";}// Which field of ColorSettings a row edits. Scalars use the member pointer;@@ -128,6 +131,46 @@ engine::ColorSettings colourUndo;bool colourUndoValid=false;int colorPageContentHeight=0;bool syncingColour=false;+// Named colour looks + the .cube list shown in the colour page.+std::vector<std::wstring> colourLookNames;+std::vector<std::wstring> colourLutNames;+int selectedColourLook=-1;+// Rebuild the preset combo box. `select` re-selects a named look (used after+// saving/importing so the new preset stays highlighted instead of silently+// falling back to "no preset selected").+void refreshColourLooks(const std::wstring& select={}){+ engine::ColorLookStore lookStore(runtime::localDataDirectory());+ lookStore.load();+ colourLookNames.clear();+ // The controls live on the scrolling `body` panel, not directly on `window`,+ // so they must be addressed through their own handle (SendDlgItemMessageW+ // only walks direct children and silently left this combo empty).+ const auto combo=item(803);+ if(!window||!combo)return;+ SendMessageW(combo,CB_RESETCONTENT,0,0);+ SendMessageW(combo,CB_ADDSTRING,0,LPARAM(L"(未选择预设)"));+ int selection=0;+ for(const auto& look:lookStore.entries()){+ colourLookNames.push_back(look.name);+ SendMessageW(combo,CB_ADDSTRING,0,LPARAM(look.name.c_str()));+ if(!select.empty()&&look.name==select)selection=int(colourLookNames.size());+ }+ SendMessageW(combo,CB_SETCURSEL,WPARAM(selection),0);+ selectedColourLook=selection-1;+}+void refreshColourLuts(){+ engine::ColorLutStore lutStore(runtime::localDataDirectory());+ colourLutNames=lutStore.list();+ const auto combo=item(817);+ if(!window||!combo)return;+ SendMessageW(combo,CB_RESETCONTENT,0,0);+ SendMessageW(combo,CB_ADDSTRING,0,LPARAM(L"不使用 LUT"));+ for(const auto& name:colourLutNames)SendMessageW(combo,CB_ADDSTRING,0,LPARAM(name.c_str()));+ int selection=0;+ const auto current=colourTarget().lutNameString();+ for(size_t i=0;i<colourLutNames.size();++i)if(colourLutNames[i]==current)selection=int(i)+1;+ SendMessageW(combo,CB_SETCURSEL,WPARAM(selection),0);+}std::wstring windowText(HWND h){wchar_t buffer[256]{};GetWindowTextW(h,buffer,256);return buffer;}void loadColourFoldState(){const auto preferences=veyra::ui::UiPreferenceStore(runtime::localDataDirectory()).load();@@ -145,6 +188,9 @@ void layoutColorPage(){};int y=12;place(800,y,36,false);y+=42;+ // Preset toolbar: which look, a name to save under, and the actions.+ place(803,y,200,false);place(804,y,180,false);y+=38;+ place(805,y,32,false);place(806,y,32,false);place(807,y,32,false);place(808,y,32,false);place(809,y,32,false);y+=40;place(801,y,32,false);place(802,y,32,false);y+=40;for(int section=0;section<kColorSections;++section){const bool collapsed=(colorFoldMask>>section)&1u;@@ -160,6 +206,11 @@ void layoutColorPage(){place(colorSliderId(int(i)),y+24,16,collapsed);if(!collapsed)y+=46;}+ if(section==6){+ place(817,y,200,collapsed);y+=32;+ place(818,y,32,collapsed);y+=36;+ place(819,y,200,collapsed);y+=32;+ }y+=8;}colorPageContentHeight=y+12;@@ -177,6 +228,7 @@ void syncColorControls(){if(SendMessageW(slider,TBM_GETPOS,0,0)!=scaled)SendMessageW(slider,TBM_SETPOS,TRUE,LPARAM(scaled));}}+ if(auto space=item(819))if(int(SendMessageW(space,CB_GETCURSEL,0,0))!=colour.lutInputSpace)SendMessageW(space,CB_SETCURSEL,WPARAM(colour.lutInputSpace),0);syncingColour=false;}bool applyColour(const engine::ColorSettings& colour,bool autoEnable){@@ -187,14 +239,36 @@ bool applyColour(const engine::ColorSettings& colour,bool autoEnable){if(!(settings.color==previous)&&!submit(settings))return false;return true;}-bool colourFieldEdited(int index,float value){+// Native file pickers for the colour page. They run modal on the UI thread, which+// is what a settings dialog is expected to do.+std::wstring pickColourFile(const wchar_t* filter,const wchar_t* title){+ wchar_t buffer[32768]{};+ OPENFILENAMEW dialog{sizeof(dialog)};+ dialog.hwndOwner=window;dialog.lpstrFilter=filter;dialog.lpstrFile=buffer;dialog.nMaxFile=32768;+ dialog.lpstrTitle=title;dialog.Flags=OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_NOCHANGEDIR;+ if(!GetOpenFileNameW(&dialog))return {};+ return buffer;+}+std::wstring pickColourSave(const wchar_t* filter,const wchar_t* title,const wchar_t* suggested){+ wchar_t buffer[32768]{};if(suggested)wcsncpy_s(buffer,suggested,_TRUNCATE);+ OPENFILENAMEW dialog{sizeof(dialog)};+ dialog.hwndOwner=window;dialog.lpstrFilter=filter;dialog.lpstrFile=buffer;dialog.nMaxFile=32768;+ dialog.lpstrTitle=title;dialog.lpstrDefExt=L"vpcolor";dialog.Flags=OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST|OFN_NOCHANGEDIR;+ if(!GetSaveFileNameW(&dialog))return {};+ return buffer;+}bool colourFieldEdited(int index,float value){if(index<0||size_t(index)>=colorParams.size())return false;auto colour=colourTarget();if(!std::isfinite(value)||value<colorParams[size_t(index)].min||value>colorParams[size_t(index)].max){message(L"数值超出范围;仍使用上次有效值");syncColorControls();return false;}colorParams[size_t(index)].set(colour,value);- if(!applyColour(colour,true)){syncColorControls();return false;}+ if(!applyColour(colour,true)){+ veyra::log::warn("color-ui",std::format("colour edit rejected index={} value={:.3f}",index,value));+ syncColorControls();+ return false;+ }+ veyra::log::info("color-ui",std::format("colour edit applied index={} value={:.3f}",index,value));syncColorControls();return true;}@@ -392,6 +466,87 @@ LRESULT CALLBACK proc(HWND h,UINT msg,WPARAM wp,LPARAM lp){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);+ auto colour=colourTarget();colour.enabled=true;+ if(lookStore.load()&&lookStore.put(name,colour,true)){+ refreshColourLooks(name);+ message(L"已保存色彩预设(同名会覆盖)。可以导出成 .vpcolor 分享。");+ }else message(L"保存失败:"+lookStore.error());+ }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())){@@ -506,7 +661,26 @@ case WM_CREATE:{window=h;font=makeFont(h);items.clear();displayedBackendWarning.colorParams.push_back({5,composed(std::wstring(primaries[primary])+L" · 饱和度"),-100,100,ColorTarget::CalibrationSaturation,nullptr,primary});}}+ // LUT: the .cube selection, its strength and the input-space choice. The+ // strength row is a normal parameter; the two combos are placed by+ // layoutColorPage().+ colorParams.push_back({6,L"LUT 强度",0,100,ColorTarget::Scalar,&engine::ColorSettings::lutStrength,0});for(int section=0;section<kColorSections;++section)add(L"BUTTON",L"",810+section,BS_PUSHBUTTON|WS_TABSTOP,2,12,12,-1,32);+ // Preset toolbar.+ combo(803,2,0,{});add(L"EDIT",L"",804,ES_AUTOHSCROLL|WS_TABSTOP,2,12,0,-1,26);send(804,EM_SETLIMITTEXT,48,0);+ button(L"保存预设",805,2,12,0,96);button(L"应用",806,2,12,0,80);button(L"删除",807,2,12,0,80);+ button(L"导出",808,2,12,0,80);button(L"导入",809,2,12,0,80);+ SetPropW(item(804),L"veyra.tip",HANDLE(L"给当前色彩设置起个名字,点“保存预设”存下来;导出会生成 .vpcolor 文件,可以发给别人导入。"));+ SetPropW(item(805),L"veyra.tip",HANDLE(L"把当前色彩设置保存为命名预设。同名会覆盖。"));+ SetPropW(item(806),L"veyra.tip",HANDLE(L"把选中的预设应用到当前画面(只改色彩,不动 NR/超分/补帧)。"));+ SetPropW(item(807),L"veyra.tip",HANDLE(L"删除选中的色彩预设。"));+ // LUT section: choose an imported .cube, import a new one, pick its input+ // space (the strength row is registered as a normal parameter).+ combo(817,2,0,{});button(L"导入 .cube",818,2,12,0,140);combo(819,2,0,{L"Cineon Log(创作者 LUT 默认)",L"sRGB 显示参考",L"PQ(HDR)"});+ SetPropW(item(817),L"veyra.tip",HANDLE(L"选择 runtime_local/luts 里已导入的 .cube。切换会重建管线,短暂停顿正常。"));+ SetPropW(item(818),L"veyra.tip",HANDLE(L"从磁盘导入 .cube:校验通过后复制到 runtime_local/luts,并写入 manifest(含 SHA-256)。"));+ SetPropW(item(819),L"veyra.tip",HANDLE(L"LUT 期望的输入空间。创作者 LUT 多数是 Cineon Log;sRGB 显示参考用于 SDR 内容;PQ 给 HDR 用。选错会提示并由日志记录。"));+ refreshColourLooks();refreshColourLuts();for(size_t i=0;i<colorParams.size();++i){const auto& param=colorParams[i];add(L"STATIC",param.label,colorLabelId(int(i)),0,2,12,0,180,24);diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cppindex 215f7cf4..70977032 100644--- a/apps/veyra/ui/AppShell.cpp+++ b/apps/veyra/ui/AppShell.cpp@@ -29,6 +29,7 @@#include <shlobj.h>#include <filesystem>#include <format>+#include "veyra/engine/ColorLookStore.h"#include <string>#include <chrono>#include <atomic>@@ -742,6 +743,8 @@ if(uiStep==7&&elapsed>5900){holdOriginal=false;compareMode=0;updateComparison();if(smokeColor&&startTick){const auto elapsed=GetTickCount64()-startTick;const auto colourSnapshot=engine.snapshot();auto colourControl=[](int id){return veyra::ui::settingsControlForTest(id);};+// Progress heartbeat: a stalled UI tick shows up as a gap in these lines.+{static uint64_t colourHeartbeat=0;if(elapsed/2000!=colourHeartbeat){colourHeartbeat=elapsed/2000;veyra::log::info("color-ui-test",std::format("tick elapsed={} step={} exposure={:.3f}",elapsed,colorStep,colourSnapshot.desired.color.exposure));}}if(colorStep==0&&elapsed>1500){if(uiState.mode==veyra::ui::Mode::Daily)switchMode();selectInspector(2);layout();@@ -769,7 +772,38 @@ else if(colorStep==40){colorStep=(colourSnapshot.desired.color.exposure==1.0f)?5else if(colorStep==5){const int editId=veyra::ui::colourParamEditId(L"混合");if(auto edit=colourControl(editId))SetWindowTextW(edit,L"77.00");colorStep=editId>0?50:-1;}else if(colorStep==50){colorStep=(colourSnapshot.desired.color.gradingBlending==77.0f)?51:(elapsed>9500?-1:50);if(colorStep==51)veyra::log::info("color-ui-test","T4 the colour grading row reached the engine");}+// Named colour presets: save the current look, clear a value, apply the preset,+// then delete it - the same three actions the panel exposes.else if(colorStep==51){+ if(auto edit=colourControl(804))SetWindowTextW(edit,L"烟测预设");+ SendMessageW(colourControl(805),BM_CLICK,0,0);+ colorStep=52;+}+else if(colorStep==52){+ veyra::engine::ColorLookStore store(veyra::runtime::localDataDirectory());+ store.load();+ const bool saved=!store.entries().empty()&&store.entries().back().name==L"烟测预设";+ if(auto edit=colourControl(1300))SetWindowTextW(edit,L"0.00");+ colorStep=saved?53:-1;+ veyra::log::info("color-ui-test",std::format("preset saved={} count={} step={}",saved,store.entries().size(),colorStep));+}+else if(colorStep==53&&colourSnapshot.desired.color.exposure==0.0f){SendMessageW(colourControl(806),BM_CLICK,0,0);colorStep=54;}+else if(colorStep==53&&elapsed>9000){+ veyra::log::info("color-ui-test",std::format("preset apply waiting: desiredExposure={:.3f} configuredExposure={:.3f} elapsed={}",+ colourSnapshot.desired.color.exposure,uiState.configured.color.exposure,elapsed));+ colorStep=-1;+}+else if(colorStep==54){colorStep=(colourSnapshot.desired.color.exposure==1.0f)?55:(elapsed>14000?-1:54);+ if(colorStep==55)veyra::log::info("color-ui-test","preset applied: exposure came back through the engine");}+else if(colorStep==55){SendMessageW(colourControl(807),BM_CLICK,0,0);colorStep=56;}+else if(colorStep==56){+ veyra::engine::ColorLookStore store(veyra::runtime::localDataDirectory());+ store.load();+ const bool deleted=store.entries().empty();+ colorStep=deleted?57:(elapsed>16000?-1:56);+ if(colorStep==57)veyra::log::info("color-ui-test","preset deleted; colour page back to no stored looks");+}+else if(colorStep==57){auto edit=colourControl(1300);const bool beforeVisible=edit&&IsWindowVisible(edit);const bool beforeMask=(preferences.load().colourFoldMask&1u)!=0u;diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 5c65073c..a8ed3d04 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -1,5 +1,47 @@# 2026-09-11 继续修复目标模式执行中+## 2026-09-17 色彩页 P1:T5-b 命名色彩预设 + `.vpcolor` + 修两个空下拉(真机烟测通过)++新增 `include/veyra/engine/ColorLookStore.h` + `src/engine/ColorLookStore.cpp`:++- 文件 `runtime_local/color-looks.v1`,头 `VEYRA_COLOR_LOOKS 1`,每行 `"名字" <ColorSettings 块>`+ (复用 `ColorSettings.h` 里的共享读写,和 PresetStore v18 是同一套参数块,不会两处漂移);+- 保存走临时文件 + `MOVEFILE_REPLACE_EXISTING|MOVEFILE_WRITE_THROUGH` 原子替换,写失败回滚内存表并+ 保留原文件;遇到损坏行**拒绝覆盖原文件**并报错;名字去空白、拒路径分隔符与控制字符、上限 64 套;+- `.vpcolor` 导入导出:导出写 `VEYRA_COLOR_LOOK <名>` + 同一参数块;导入校验魔数/版本/名字/尾部残余;+- 15 项单测 `veyra_color_look_tests`(保存/覆盖/删除/列举/上限/轮转/`.vpcolor` 往返/坏文件保留原文件)+ → exit 0。++色彩页新增 LUT 组与预设工具条(id 803 预设下拉 / 804 名字 / 805 保存 / 806 应用 / 807 删除 /+808 导出 / 809 导入,LUT 817 下拉 / 818 导入 `.cube` / 819 输入空间),全部走原生文件对话框。++**修掉两个真机 bug(都是烟测抓出来的产品缺陷,不是测试问题)**++1. **预设下拉和 LUT 下拉永远是空的**:`refreshColourLooks()` / `refreshColourLuts()` 用+ `SendDlgItemMessageW(window,803/817,...)`,而这两个控件挂在滚动面板 `body` 上,+ 不是 `window` 的直接子窗口 → `CB_RESETCONTENT/CB_ADDSTRING` 全部静默失败、+ `CB_GETCURSEL` 返回 -1。改为用控件自身句柄发消息。用户侧表现就是"下拉点开没东西、+ 点应用提示先选一个预设"。+2. **保存后选中项被清空**:`refreshColourLooks()` 固定把选择重置到"(未选择预设)",+ 保存/导入完立刻点应用必然落空。现在保存/导入后自动选回刚写入的那一项。++另外给 806 应用路径加了 `[color-ui] preset apply index=… exposure=… lut=… accepted=…` 日志,+并在烟测里加了 2 秒一条的进度心跳(`tick elapsed=… step=… exposure=…`),+用来区分"UI 线程卡住"和"状态机停在某一步"——本轮就是靠它排除了前者。++**真机烟测**(RTX 5070,`%TEMP%\veyra-p1-fixture.mp4` 1280×720@30 12s):+`veyra.exe <clip> --smoke-color --smoke-seconds 18` → **exit 0**,日志序列完整:+总开关 → 曝光 1.00 到引擎 → 一键还原 → 撤销 → 混合 77 → 保存预设(count=1) →+应用预设(index=1 exposure=1.000 accepted=true) → 删除 → 折叠位记忆 → 总开关回关。++**回归**:`veyra_color_grade_tests` 23/23 exit 0;`veyra_color_grade_gpu_tests` 10/10 exit 0;+`veyra_color_lut_tests` exit 0;`veyra_color_look_tests` exit 0;`veyra_ui_contract_tests` exit 0;+`veyra_repair_preset_tests` 全通过(注意要传**文件路径**,传目录会 exit 1);+`veyra_repair_contract_tests` 191/0。++**未做(T6)**:`GpuStage::Grade` 独立计时(融合派发无法单独打点,须用 A/B 对比如实报告)、+HDR 标准处理与 MaxCLL/MaxFALL 重算、预览/截图/导出三入口像素一致性、全量交付闸门与报告。+## 2026-09-17 色彩页 P1:T5-a `.cube` 解析、导入与引擎侧解析(GPU 验收通过)新增 `include/veyra/engine/ColorLut.h` + `src/engine/ColorLut.cpp`(放在 `veyra_base`,供diff --git a/include/veyra/engine/ColorLookStore.h b/include/veyra/engine/ColorLookStore.hnew file mode 100644index 00000000..6d1afbb7--- /dev/null+++ b/include/veyra/engine/ColorLookStore.h@@ -0,0 +1,32 @@+#pragma once+#include <filesystem>+#include <string>+#include <vector>+#include "veyra/engine/ColorSettings.h"+namespace veyra::engine {+// A named colour look: the full ColorSettings block plus its referenced LUT.+// Looks live in <data>/color-looks.v1 and can be exported/imported as a single+// .vpcolor file for sharing.+struct ColorLook {+ std::wstring name;+ ColorSettings color;+};+class ColorLookStore {+public:+ explicit ColorLookStore(std::filesystem::path dataDirectory);+ bool load();+ bool save();+ const std::vector<ColorLook>& entries()const{return entries_;}+ const std::wstring& error()const{return error_;}+ bool corrupt()const{return corrupt_;}+ bool put(std::wstring name,const ColorSettings& colour,bool replace);+ bool erase(size_t index);+ bool exportFile(size_t index,const std::filesystem::path& target);+ bool importFile(const std::filesystem::path& source,std::wstring& nameOut);+private:+ std::filesystem::path path_;+ std::vector<ColorLook> entries_;+ bool corrupt_=false;+ std::wstring error_;+};+} // namespace veyra::enginediff --git a/src/engine/ColorLookStore.cpp b/src/engine/ColorLookStore.cppnew file mode 100644index 00000000..2eeeb8c0--- /dev/null+++ b/src/engine/ColorLookStore.cpp@@ -0,0 +1,140 @@+#include "veyra/engine/ColorLookStore.h"+#include <windows.h>+#include <algorithm>+#include <fstream>+#include <iomanip>+#include <sstream>+namespace veyra::engine {+namespace {+std::string utf8(const std::wstring& text){+ const int size=WideCharToMultiByte(CP_UTF8,WC_ERR_INVALID_CHARS,text.data(),int(text.size()),nullptr,0,nullptr,nullptr);+ std::string result(size_t(std::max(0,size)),0);+ if(size>0)WideCharToMultiByte(CP_UTF8,WC_ERR_INVALID_CHARS,text.data(),int(text.size()),result.data(),size,nullptr,nullptr);+ return result;+}+std::wstring wide(const std::string& text){+ const int size=MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,text.data(),int(text.size()),nullptr,0);+ std::wstring result(size_t(std::max(0,size)),0);+ if(size>0)MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,text.data(),int(text.size()),result.data(),size);+ return result;+}+bool nameOk(const std::wstring& name){+ if(name.empty()||name.size()>48)return false;+ if(name.front()==L' '||name.back()==L' ')return false;+ return std::none_of(name.begin(),name.end(),[](wchar_t c){return c<32;});+}+}+ColorLookStore::ColorLookStore(std::filesystem::path dataDirectory):path_(std::move(dataDirectory)/"color-looks.v1"){}+bool ColorLookStore::load(){+ entries_.clear();corrupt_=false;error_.clear();+ std::error_code ec;+ if(!std::filesystem::exists(path_,ec))return true;+ if(std::filesystem::file_size(path_,ec)>65536){corrupt_=true;error_=L"色彩预设文件超过64KiB,原文件保留";return false;}+ std::ifstream file(path_,std::ios::binary);+ if(!file){corrupt_=true;error_=L"色彩预设文件无法读取";return false;}+ std::string data((std::istreambuf_iterator<char>(file)),std::istreambuf_iterator<char>());+ std::istringstream stream(data);+ stream.imbue(std::locale::classic());+ std::string magic;int version=0;+ if(!(stream>>magic>>version)||magic!="VEYRA_COLOR_LOOKS"||version!=1){corrupt_=true;error_=L"色彩预设文件损坏或版本不支持;原文件已保留";return false;}+ std::vector<ColorLook> loaded;+ for(;;){+ std::string name;+ if(!(stream>>std::quoted(name)))break;+ ColorLook look;look.name=wide(name);+ std::string lut;+ if(!readColorSettings(stream,look.color,lut)){corrupt_=true;error_=L"色彩预设文件损坏;原文件已保留";return false;}+ if(!lut.empty()&&!look.color.setLutName(wide(lut))){corrupt_=true;error_=L"色彩预设里的 LUT 名字非法;原文件已保留";return false;}+ if(!nameOk(look.name)){corrupt_=true;error_=L"色彩预设名字非法;原文件已保留";return false;}+ loaded.push_back(std::move(look));+ }+ stream>>std::ws;+ if(!stream.eof()||loaded.size()>64){corrupt_=true;error_=L"色彩预设文件尾部有残余内容;原文件已保留";return false;}+ entries_=std::move(loaded);+ return true;+}+bool ColorLookStore::save(){+ if(corrupt_){error_=L"预设文件损坏;拒绝覆盖";return false;}+ std::error_code ec;+ std::filesystem::create_directories(path_.parent_path(),ec);+ if(ec){error_=L"无法创建预设目录";return false;}+ std::ostringstream out;+ out.imbue(std::locale::classic());out<<std::setprecision(std::numeric_limits<float>::max_digits10);+ out<<"VEYRA_COLOR_LOOKS 1\n";+ for(const auto& look:entries_){+ out<<std::quoted(utf8(look.name))<<' ';+ writeColorSettings(out,look.color,utf8(look.color.lutNameString()));+ out<<'\n';+ }+ const auto data=out.str();+ if(data.size()>65536){error_=L"色彩预设超过64KiB";return false;}+ auto temporary=path_;temporary+=L".tmp-"+std::to_wstring(GetCurrentProcessId());+ HANDLE file=CreateFileW(temporary.c_str(),GENERIC_WRITE,0,nullptr,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,nullptr);+ if(file==INVALID_HANDLE_VALUE){error_=L"无法创建预设临时文件";return false;}+ DWORD written=0;+ bool ok=WriteFile(file,data.data(),DWORD(data.size()),&written,nullptr)&&written==data.size()&&FlushFileBuffers(file);+ CloseHandle(file);+ ok=ok&&MoveFileExW(temporary.c_str(),path_.c_str(),MOVEFILE_REPLACE_EXISTING|MOVEFILE_WRITE_THROUGH)!=FALSE;+ if(!ok){DeleteFileW(temporary.c_str());error_=L"色彩预设原子保存失败,原文件未替换";return false;}+ error_.clear();+ return true;+}+bool ColorLookStore::put(std::wstring name,const ColorSettings& colour,bool replace){+ if(!nameOk(name)||!colour.validate().empty()){error_=L"预设名字或参数无效";return false;}+ const auto old=entries_;+ const auto existing=std::find_if(entries_.begin(),entries_.end(),[&](const ColorLook& look){return look.name==name;});+ if(existing!=entries_.end()){+ if(!replace){error_=L"同名的色彩预设已存在";return false;}+ existing->color=colour;+ }else{+ if(entries_.size()>=64){error_=L"最多保存64套色彩预设";return false;}+ entries_.push_back({std::move(name),colour});+ }+ if(save())return true;+ entries_=old;+ return false;+}+bool ColorLookStore::erase(size_t index){+ if(index>=entries_.size())return false;+ const auto old=entries_;+ entries_.erase(entries_.begin()+std::ptrdiff_t(index));+ if(save())return true;+ entries_=old;+ return false;+}+bool ColorLookStore::exportFile(size_t index,const std::filesystem::path& target){+ if(index>=entries_.size()){error_=L"没有选中的色彩预设";return false;}+ const auto& look=entries_[index];+ std::ostringstream out;+ out.imbue(std::locale::classic());out<<std::setprecision(std::numeric_limits<float>::max_digits10);+ out<<"VEYRA_COLOR_LOOK 1\n"<<std::quoted(utf8(look.name))<<' ';+ writeColorSettings(out,look.color,utf8(look.color.lutNameString()));+ out<<'\n';+ const auto data=out.str();+ HANDLE file=CreateFileW(target.c_str(),GENERIC_WRITE,0,nullptr,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,nullptr);+ if(file==INVALID_HANDLE_VALUE){error_=L"无法写入导出文件";return false;}+ DWORD written=0;+ const bool ok=WriteFile(file,data.data(),DWORD(data.size()),&written,nullptr)&&written==data.size();+ CloseHandle(file);+ if(!ok)error_=L"导出文件写入失败";+ return ok;+}+bool ColorLookStore::importFile(const std::filesystem::path& source,std::wstring& nameOut){+ std::ifstream file(source,std::ios::binary);+ if(!file){error_=L"无法读取导入文件";return false;}+ std::string data((std::istreambuf_iterator<char>(file)),std::istreambuf_iterator<char>());+ std::istringstream stream(data);+ stream.imbue(std::locale::classic());+ std::string magic,name;int version=0;+ if(!(stream>>magic>>version)||magic!="VEYRA_COLOR_LOOK"||version!=1){error_=L"不是有效的 .vpcolor 文件";return false;}+ if(!(stream>>std::quoted(name))){error_=L"导入文件缺少预设名";return false;}+ ColorSettings colour;std::string lut;+ if(!readColorSettings(stream,colour,lut)){error_=L"导入文件的参数块损坏";return false;}+ if(!lut.empty()&&!colour.setLutName(wide(lut))){error_=L"导入文件里的 LUT 名字非法";return false;}+ stream>>std::ws;+ if(!stream.eof()){error_=L"导入文件尾部有残余内容";return false;}+ if(!put(wide(name),colour,true))return false;+ nameOut=wide(name);+ return true;+}+} // namespace veyra::enginediff --git a/tests/unit/ColorLookTests.cpp b/tests/unit/ColorLookTests.cppnew file mode 100644index 00000000..ac5bc483--- /dev/null+++ b/tests/unit/ColorLookTests.cpp@@ -0,0 +1,67 @@+// Named colour looks (T5-b): storage, atomic save, corrupt preservation and the+// .vpcolor export/import round trip. Pure CPU.+#include "veyra/engine/ColorLookStore.h"+#include <cmath>+#include <cstdio>+#include <filesystem>+#include <fstream>+#include <string>+namespace {+using namespace veyra::engine;+int failures=0;+void check(bool ok,const std::string& label){+ std::printf("%s %s\n",ok?"PASS":"FAIL",label.c_str());+ if(!ok)++failures;+}+ColorSettings sample(){+ ColorSettings colour;+ colour.enabled=true;+ colour.exposure=0.75f;colour.contrast=-20.0f;colour.vibrance=15.0f;+ colour.mixerSaturation[3]=40.0f;colour.grading[1]={210.0f,30.0f,-10.0f};+ colour.curves[0].count=3;colour.curves[0].points[1]={0.3f,0.4f};colour.curves[0].points[2]={1,1};+ colour.setLutName(L"probe.cube");colour.lutStrength=80.0f;colour.lutInputSpace=1;+ return colour;+}+}+int wmain(int argc,wchar_t** argv){+ if(argc!=2){std::printf("usage: color_look_tests <tempdir>\n");return 2;}+ const std::filesystem::path directory(argv[1]);+ std::error_code ec;std::filesystem::create_directories(directory,ec);+ {+ ColorLookStore store(directory);+ check(store.load(),"a missing store loads empty");+ const auto colour=sample();+ check(store.put(L"夜景",colour,false),"saving a named look works");+ check(store.put(L"夜景",colour,false)==false,"duplicate names are refused without replace");+ ColorLookStore reloaded(directory);+ check(reloaded.load()&&reloaded.entries().size()==1,"the look survives a reload");+ check(reloaded.entries()[0].color==colour,"every colour field round trips");+ check(reloaded.entries()[0].color.lutNameString()==L"probe.cube","the referenced LUT name round trips");+ check(store.exportFile(0,directory/"夜景.vpcolor"),"export writes a .vpcolor file");+ ColorLookStore other(directory/"other");+ std::wstring imported;+ check(other.load()&&other.importFile(directory/"夜景.vpcolor",imported)&&imported==L"夜景",+ "importing the exported file restores the name");+ check(other.entries().size()==1&&other.entries()[0].color==colour,"imported parameters match");+ {+ std::ofstream broken(directory/"broken.vpcolor",std::ios::binary);+ broken<<"VEYRA_COLOR_LOOK 1\n\"x\" 1 2 3\n";+ }+ std::wstring name;check(!other.importFile(directory/"broken.vpcolor",name)&&!other.error().empty(),"a truncated import is rejected");+ check(store.put(L"日景",sample(),false)&&store.entries().size()==2,"a second look is stored");+ check(store.erase(0)&&store.entries().size()==1&&store.entries()[0].name==L"日景","delete removes only the selected look");+ {+ std::ofstream corrupt(directory/"color-looks.v1",std::ios::binary);+ corrupt<<"NOT_A_STORE 9\n";+ }+ ColorLookStore damaged(directory);+ check(!damaged.load()&&damaged.corrupt(),"a corrupt store reports corruption");+ check(!damaged.save(),"a corrupt store refuses to overwrite the original");+ std::ifstream check_(directory/"color-looks.v1",std::ios::binary);+ std::string data((std::istreambuf_iterator<char>(check_)),std::istreambuf_iterator<char>());+ check(data=="NOT_A_STORE 9\n","the corrupt original is preserved byte for byte");+ }+ if(failures){std::printf("FAIL: colour looks (%d checks)\n",failures);return 1;}+ std::printf("PASS: named colour looks, atomic save, corrupt preservation, .vpcolor round trip\n");+ return 0;+}