Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

fix(color): .cube load crash (two-temporary range) + D3D12-aligned LUT staging; refuse mismatched LUT input spaces; measure fused grade cost

Veyra Goal Agent62c82005df49
diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cpp
index 70977032..6811e599 100644
--- a/apps/veyra/ui/AppShell.cpp
+++ b/apps/veyra/ui/AppShell.cpp
@@ -871,6 +871,10 @@ CoInitializeEx(nullptr,COINIT_APARTMENTTHREADED);
initialOptions=veyra::engine::PlayerOptions::from(veyra::ui::defaultSettings());
int argc=0;auto argv=CommandLineToArgvW(GetCommandLineW(),&argc);for(int i=1;i<argc;++i){const std::wstring arg=argv[i];if(arg==L"--export-worker"&&i+1<argc)workerMapping=reinterpret_cast<HANDLE>(_wcstoui64(argv[++i],nullptr,10));else if(arg==L"--smoke-view"&&i+1<argc)smokeView=argv[++i];else if(arg==L"--smoke-fg-only")smokeFgOnly=true;else if(arg==L"--smoke-transport")smokeTransport=true;else if(arg==L"--smoke-repair-ui")smokeRepair=true;else if(arg==L"--smoke-repair-ui-reject")smokeRepair=smokeRepairReject=true;else if(arg==L"--smoke-hover")smokeZoom=smokeHover=true;else if(arg==L"--smoke-protection")smokeProtection=true;else if(arg==L"--smoke-zoom")smokeZoom=true;else if(arg==L"--smoke-empty")smokeEmpty=true;else if(arg==L"--smoke-dual")smokeDual=true;else if(arg==L"--smoke-dual-pause"){smokeDual=smokeDualPause=true;}else if(arg==L"--smoke-master-reject")smokeMaster=smokeMasterReject=true;else if(arg==L"--smoke-master")smokeMaster=true;else if(arg==L"--smoke-audio")smokeAudio=true;else if(arg==L"--smoke-job-cancel")smokeJobCancel=true;else if(arg==L"--smoke-job-exit")smokeJobExit=true;else if(arg==L"--smoke-job")smokeJob=true;else if(arg==L"--smoke-dual-export"&&i+1<argc)smokeDualOutput=argv[++i];else if(arg==L"--smoke-seconds"&&i+1<argc)smokeSeconds=std::clamp(_wtoi(argv[++i]),1,240);else if(arg==L"--export-out"&&i+1<argc)exportOutput=argv[++i];else if(arg==L"--max-frames"&&i+1<argc)exportFrames=std::max(1,_wtoi(argv[++i]));else if(arg==L"--cancel-after-ms"&&i+1<argc)cancelAfterMs=std::clamp(_wtoi(argv[++i]),1,240000);else if(arg==L"--hevc")exportHevc=true;else if(arg==L"--bitrate-mbps"&&i+1<argc)initialOptions.settings.exportBitrateMbps=uint32_t(std::clamp(_wtoi(argv[++i]),0,300));else if(arg==L"--subtitle-primary"&&i+1<argc)subtitleRequestPrimary=std::clamp(_wtoi(argv[++i]),-1,64);else if(arg==L"--subtitle-secondary"&&i+1<argc)subtitleRequestSecondary=std::clamp(_wtoi(argv[++i]),-1,64);else if(arg==L"--subtitle-offset-ms"&&i+1<argc)subtitleRequestOffsetMs=std::clamp(_wtoi(argv[++i]),-30000,30000);else if(arg==L"--subtitle-font-size"&&i+1<argc)subtitlePixels=std::clamp(_wtoi(argv[++i]),16,56);else if(arg==L"--subtitle-no-outline")uiState.subtitleOutline=false;else if(arg==L"--subtitle-background")uiState.subtitleBackground=true;else if(arg==L"--subtitle-auto-align")subtitleRequestAutoAlign=true;else if(arg==L"--smoke-rollback-flow"){smokeRollback=true;smokeRollbackFlow=true;}else if(arg==L"--smoke-rollback")smokeRollback=true;else if(arg==L"--smoke-ui")smokeUi=true;else if(arg==L"--no-fg")initialOptions.fg=false;else if(arg==L"--smoke-settings")smokeSettings=true;else if(arg==L"--smoke-color")smokeColor=true;else if(arg==L"--smoke-screenshot")smokeScreenshot=true;else if(arg==L"--smoke-controls")smokeControls=true;else if(arg==L"--smoke-save"&&i+1<argc)smokeSave=argv[++i];else if(arg==L"--native")initialOptions.realtime=false;else if(arg==L"--realtime")initialOptions.realtime=true;else if(arg==L"--fg")initialOptions.fg=true;else if(arg==L"--fg-multiplier"&&i+1<argc){initialOptions.fgMultiplier=std::clamp(_wtoi(argv[++i]),2,4);initialOptions.fg=true;}else if(arg==L"--capture-audio"&&i+1<argc)initialOptions.settings.captureAudio=static_cast<veyra::engine::CaptureAudioIngress>(std::clamp(_wtoi(argv[++i]),0,2));else if(arg==L"--flow-amd")initialOptions.settings.opticalFlowBackend=veyra::engine::OpticalFlowBackend::AmdFidelityFx;else if(arg==L"--flow-gpudis")initialOptions.settings.opticalFlowBackend=veyra::engine::OpticalFlowBackend::GpuDis;else if(arg==L"--video-sr"&&i+1<argc){initialOptions.settings.videoSrQuality=std::clamp(_wtoi(argv[++i]),1,5);initialOptions.sr=true;}else if(arg==L"--nr-ampere")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Ampere;else if(arg==L"--nr-community")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Community;else if(arg==L"--nr-original")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Original;else if(arg==L"--sr")initialOptions.sr=true;else if(arg==L"--no-nr")initialOptions.nr=false;else if(arg==L"--nr")initialOptions.nr=true;else if(arg==L"--no-sr")initialOptions.sr=false;else autoInput=arg;}LocalFree(argv);
+// Diagnostic: force the colour grade on with a fixed exposure (EV). The grade is
+// fused into the ingest dispatch, so this flag is how the graded cost is measured
+// against the grade-off baseline on the same clip.
+{int gradeArgc=0;auto gradeArgv=CommandLineToArgvW(GetCommandLineW(),&gradeArgc);for(int i=1;i<gradeArgc;++i){if(!wcsncmp(gradeArgv[i],L"--color-grade=",14)){initialOptions.settings.color.enabled=true;initialOptions.settings.color.exposure=float(_wtof(gradeArgv[i]+14));}}if(gradeArgv)LocalFree(gradeArgv);}
// The legacy argument clamp caps --fg-multiplier at 4X. Re-read the flag here so
// 6X (and 2X/3X/4X) can be exercised from the command line for diagnostics and
// smoke tests; the interactive UI uses the capability-driven list instead.
@@ -885,7 +889,7 @@ int argc=0;auto argv=CommandLineToArgvW(GetCommandLineW(),&argc);for(int i=1;i<a
// capture panel checkbox and persists captureFlipVertical with presets.
{int flipArgc=0;auto flipArgv=CommandLineToArgvW(GetCommandLineW(),&flipArgc);for(int i=1;i<flipArgc;++i){if(!_wcsicmp(flipArgv[i],L"--capture-flip"))initialOptions.settings.captureFlipVertical=true;else if(!wcsncmp(flipArgv[i],L"--capture-buffer=",17)){const wchar_t* value=flipArgv[i]+17;if(!_wcsicmp(value,L"auto"))initialOptions.settings.captureBuffer=veyra::source::CaptureBufferMode::Auto;else if(!_wcsicmp(value,L"minimum"))initialOptions.settings.captureBuffer=veyra::source::CaptureBufferMode::Minimum;else if(!_wcsicmp(value,L"driver"))initialOptions.settings.captureBuffer=veyra::source::CaptureBufferMode::DriverDefault;}else if(!_wcsicmp(flipArgv[i],L"--capture-cpu-unpack"))initialOptions.captureCpuUnpack=true;}LocalFree(flipArgv);}
int positionalArgc=0;auto positionalArgv=CommandLineToArgvW(GetCommandLineW(),&positionalArgc);std::wstring positional;
- const wchar_t* valueFlags[]={L"--export-worker",L"--smoke-view",L"--smoke-dual-export",L"--smoke-seconds",L"--export-out",L"--max-frames",L"--cancel-after-ms",L"--smoke-save",L"--fg-multiplier",L"--capture-audio",L"--video-sr",L"--bitrate-mbps",L"--subtitle-primary",L"--subtitle-secondary",L"--subtitle-offset-ms",L"--subtitle-font-size"};
+ const wchar_t* valueFlags[]={L"--export-worker",L"--smoke-view",L"--smoke-dual-export",L"--smoke-seconds",L"--export-out",L"--max-frames",L"--cancel-after-ms",L"--smoke-save",L"--fg-multiplier",L"--capture-audio",L"--video-sr",L"--bitrate-mbps",L"--subtitle-primary",L"--subtitle-secondary",L"--subtitle-offset-ms",L"--subtitle-font-size"};
for(int i=1;i<positionalArgc;++i){const std::wstring a=positionalArgv[i];
bool takesValue=false;for(const wchar_t* flag:valueFlags)if(a==flag){takesValue=true;break;}
if(takesValue){++i;continue;}
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index a8ed3d04..6ac923ee 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -1,5 +1,70 @@
# 2026-09-11 继续修复目标模式执行中
+## 2026-09-17 色彩页 P1:修 .cube 载入崩溃 + 量到调色真实 GPU 成本(T2b 计时项收口)
+
+**修掉一个会让用户直接崩程序的 bug(GPU 合同测试抓出来的,不是测试问题)**
+
+现象:`veyra_color_grade_gpu_tests` 在“导入 .cube 并建立图”这一段**随机崩**(8 次里 2–3 次,
+`0xC0000409` fail-fast)。逐步插桩定位到 `EnhanceGraph::initialize` 里 LUT 载入成功后的那一条日志:
+
+```cpp
+std::format("lut loaded name={} size={}",
+ std::string(desc_.color.lutNameString().begin(), desc_.color.lutNameString().end()), lut.size)
+```
+
+`lutNameString()` 每次返回**一个新的临时 `std::wstring`**,`.begin()` 与 `.end()` 来自两个不同的
+临时对象,区间构造算出的长度是垃圾值 → 越界读(有时只是读到别处,有时直接 fail-fast)。
+也就是说:**任何用户只要在色彩页选一个 .cube,就可能闪退**,而且概率性、难复现。
+
+修法:加文件内 `utf8Of()`(`WideCharToMultiByte(CP_UTF8)`)只转换一次再进日志;并顺手修正
+`.cube` 上传的 staging 布局——原来用 `rowPitch = size*16`,除 16 整除的尺寸外都不满足 D3D12
+要求的 256 字节对齐(2/3/17/33 这些常见尺寸全中),驱动可以据此越界读写 staging buffer;
+现在按 256 对齐并逐行写入。
+
+**调色 GPU 成本(原计划要求 `gpuGradeP95Ms` + 基线对比)**
+
+色彩 pass 按 v4 方案**融合在 ingest 的同一次 dispatch 里**,shader 执行时间无法在 GPU 上单独打点,
+所以不做假数据:改用**同一素材、同一会话参数、只切换总开关**的 A/B,量 `GpuStage::Color`
+(= 转换 + 调色,融合派发)的 p95。新增诊断开关 `--color-grade=<EV>`(与 `--flow-amd` 同族的
+命令行实验口),`player-timing` 每秒一条自带窗口 p95。
+
+命令:`veyra.exe <clip> --smoke-seconds 20 [--color-grade=1.0]`,取播放稳定后的 8/7 个采样点均值:
+
+| 素材 | 关闭总开关 | 开启 +1 EV | 差值(= 调色成本) | 方案预算 |
+| --- | --- | --- | --- | --- |
+| 1920×1080 60fps | 0.034 ms | 0.175 ms | **+0.141 ms** | ≤0.15 ms ✔ |
+| 3840×2160 30fps | 0.308 ms | 0.639 ms | **+0.331 ms** | ≤0.35 ms ✔ |
+
+原始日志:`logs/color/grade-ab/{1080p,2160p}-{off,on}.log`(素材由 `%TEMP%\veyra-p1-fixture.mp4`
+经 ffmpeg 放大生成)。结论按融合链路如实写:这是**同一次 dispatch 的增量**,
+不是独立 pass 的耗时;`player-timing` 因此没有新增 `gpuGradeP95Ms` 字段(加独立时间戳就必须拆成
+第二个 dispatch,违反 v4“单一融合 pass、不新增链路”)。
+
+## 2026-09-17 色彩页 P1:T6 前半——HDR 线性域调色与 LUT 输入空间拒绝(GPU 验证)
+
+**HDR 必须在线性光里调,且必须在 tone mapping 之前**(方案 §5.1/§5.2)。在既有 `HdrColorTests`
+里加了两项真机 GPU 验证(PQ 与 HLG、有限/全范围各一轮,`hdrToneTests::luminance` 是独立的
+BT.2390 参考实现):
+
+1. **+1 EV = 场景线性 ×2**:调色开启 +1 EV 后,HDR→SDR 输出必须等于“把参考亮度翻倍再 tone map”。
+ 结果 `HDR_TONE_GRADE hlg=0 linearError=0.00120`、`hlg=1 linearError=1.04e-05`(阈值 0.014),
+ 说明曝光确实作用在线性域、且在 tone mapping 之前;
+2. **输入空间不匹配必须拒绝**:HDR 内容选 sRGB 显示参考 → `colorLutNotice()` 非空、LUT 不参与
+ (像素与“无 LUT”逐字节一致)。SDR 侧的对称用例(SDR 内容选 PQ)加在
+ `veyra_color_grade_gpu_tests`:`PASS a PQ LUT on SDR content is refused with a notice instead
+ of applied silently`。
+
+拒绝结果会通过 `PlayerSnapshot::colorStatus` 追加显示(状态面板“实际颜色链路”一行可见),
+不只写在日志里。日志:`[color-grade] lut input space rejected space=… hdrContent=…`。
+
+**回归**:`veyra_color_grade_tests` 23/23、`veyra_color_grade_gpu_tests`(连续 8 次)全过、
+`veyra_color_lut_tests`、`veyra_color_look_tests`、`veyra_hdr_color_tests`、
+`veyra_ui_contract_tests`、`veyra_repair_preset_tests`、`veyra_repair_contract_tests` 191/0 全 exit 0。
+
+**T6 剩余(未做,不冒充完成)**:导出的 MaxCLL / MaxFALL 重算(导出是流式写头,静态元数据要在
+写 header 前就知道,需要额外一遍全片直方图 + NVENC SEI 接线)、预览/截图/导出三入口像素一致性
+验收、交付闸门与交付报告。
+
## 2026-09-17 色彩页 P1:T5-b 命名色彩预设 + `.vpcolor` + 修两个空下拉(真机烟测通过)
新增 `include/veyra/engine/ColorLookStore.h` + `src/engine/ColorLookStore.cpp`:
diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.h
index cdadf81e..b0821209 100644
--- a/include/veyra/pipeline/EnhanceGraph.h
+++ b/include/veyra/pipeline/EnhanceGraph.h
@@ -239,6 +239,10 @@ public:
ID3D12Resource* confidenceResource() const { return confTex_.Get(); }
// Test-only borrowed ingress output. Read after process, restore NON_PIXEL_SHADER_RESOURCE.
ID3D12Resource* diagnosticLinearInput() const { return srcRgba_.Get(); }
+ // Non-empty when the colour stage refused the referenced LUT (input space
+ // does not match the content domain). The engine surfaces this in the
+ // status panel so the refusal is visible, not only logged.
+ const std::wstring& colorLutNotice() const { return colorLutNotice_; }
// Isolated diagnostics only: existing constant guidance, borrowed lifetime.
// A caller writing before the first real frame must restore COMMON state.
ID3D12Resource* diagnosticDepthResource(bool frameGeneration) const { return frameGeneration?depthTex_.Get():nrZeroDepth_.Get(); }
@@ -333,6 +337,7 @@ private:
ComputePass downsamplePass_,residualPass_,flowAdaptPass_;
// --- colour grade (v4): CPU-baked tables read by the ingest shaders -----
bool colorActive_=false;
+ std::wstring colorLutNotice_;
bool colorDirty_=true;
ColorGradeTables colorTables_;
ComPtr<ID3D12Resource> colorCurveTex_,colorHueTex_,colorLumTex_,colorLutTex_;
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index 00c67934..28fbeeaa 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -1246,6 +1246,9 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
++frames;{std::lock_guard lock(mutex_);snapshot_.metrics=measured;snapshot_.colorStatus=gd.hdrOutput?(graph.hdr10Output()?L"HDR → HDR10 / PQ":L"HDR → scRGB / 浮点"):gd.hdrInput?L"HDR → SDR色调映射":L"SDR → SDR";snapshot_.position=(isCapture||isImage?pts:lastFilePresentedMs)/1000;snapshot_.frames=sourceFrames;snapshot_.generated=graphStats.fgGeneratedFrames;snapshot_.lateMs=lateness;snapshot_.lateP95Ms=sorted.empty()?0:sorted[size_t((sorted.size()-1)*0.95)];
// Measured playback speed: media-PTS advance per wall time
// over ~1s windows (1.0 = normal speed), resampled on seek.
+ // A rejected LUT input space must be visible, not only logged
+ // (plan v5.2: never apply a mismatched LUT silently).
+ if(!graph.colorLutNotice().empty())snapshot_.colorStatus+=L";"+graph.colorLutNotice();
const auto speedNow=Clock::now();
if(playbackSpeedLastWall==Clock::time_point()||pts+0.5<playbackSpeedLastPts){playbackSpeedLastPts=pts;playbackSpeedLastWall=speedNow;}
else if(std::chrono::duration<double>(speedNow-playbackSpeedLastWall).count()>=0.9){
diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cpp
index 73a88ef4..3eed3cce 100644
--- a/src/pipeline/EnhanceGraph.cpp
+++ b/src/pipeline/EnhanceGraph.cpp
@@ -108,6 +108,16 @@ EnhanceGraph::~EnhanceGraph()
// or dispatches when desc.color.enabled is false, so the "off" path costs zero.
// ---------------------------------------------------------------------------
namespace {
+// Settings carry the LUT name as UTF-16; log it as UTF-8 (never narrow
+// character by character, and never build a range from two temporaries).
+std::string utf8Of(const std::wstring& text){
+ if(text.empty())return {};
+ const int size=WideCharToMultiByte(CP_UTF8,WC_ERR_INVALID_CHARS,text.data(),int(text.size()),nullptr,0,nullptr,nullptr);
+ if(size<=0)return "<invalid>";
+ std::string out(std::size_t(size),'\0');
+ WideCharToMultiByte(CP_UTF8,WC_ERR_INVALID_CHARS,text.data(),int(text.size()),out.data(),size,nullptr,nullptr);
+ return out;
+}
ComPtr<ID3D12Resource> makeColorTable(ID3D12Device* device,uint32_t width){
return makeTexture(device,width,1,DXGI_FORMAT_R32G32B32A32_FLOAT,false);
}
@@ -167,25 +177,36 @@ void EnhanceGraph::uploadColorTables(ID3D12GraphicsCommandList* list){
copyTable(colorLumTex_.Get(),upColorLum_.Get(),ColorGradeTables::kLumEntries);
if(colorLutPending_&&!colorLutUpload_.empty()){
const unsigned size=colorLutPending_;
- const uint64_t bytes=uint64_t(size)*size*size*16;
+ // D3D12 requires the copy source row pitch to be 256-byte aligned. A
+ // tight size*16 pitch is invalid for every LUT size that is not a
+ // multiple of 16 (2, 3, ... 17, 33, ... - most creative LUTs included),
+ // and an invalid footprint lets the driver read/write past the staging
+ // buffer. Measured symptom: a 2-cube upload crashed the next D3D12 call
+ // with a fail-fast in the host process. Pad rows instead.
+ constexpr unsigned kRowPitchAlignment=256;
+ const unsigned rowPitch=(size*16u+kRowPitchAlignment-1)/kRowPitchAlignment*kRowPitchAlignment;
+ const uint64_t bytes=uint64_t(rowPitch)*size*size;
auto& staging=colorLutStaging_[colorLutStagingSlot_];
colorLutStagingSlot_=(colorLutStagingSlot_+1)%colorLutStaging_.size();
staging=makeUploadBuffer(context_.device(),bytes);
void* mapped=nullptr;
if(staging&&SUCCEEDED(staging->Map(0,nullptr,&mapped))&&mapped){
- auto* dst=static_cast<float*>(mapped);
- for(size_t i=0;i<size_t(size)*size*size;++i){
- dst[i*4+0]=colorLutUpload_[i*3+0];
- dst[i*4+1]=colorLutUpload_[i*3+1];
- dst[i*4+2]=colorLutUpload_[i*3+2];
- dst[i*4+3]=1.0f;
+ for(unsigned z=0;z<size;++z)for(unsigned y=0;y<size;++y){
+ auto* dst=reinterpret_cast<float*>(static_cast<uint8_t*>(mapped)+std::size_t(z)*rowPitch*size+std::size_t(y)*rowPitch);
+ for(unsigned x=0;x<size;++x){
+ const std::size_t i=(std::size_t(z)*size+y)*size+x;
+ dst[x*4+0]=colorLutUpload_[i*3+0];
+ dst[x*4+1]=colorLutUpload_[i*3+1];
+ dst[x*4+2]=colorLutUpload_[i*3+2];
+ dst[x*4+3]=1.0f;
+ }
}
staging->Unmap(0,nullptr);
tracker_.transition(list,colorLutTex_.Get(),D3D12_RESOURCE_STATE_COPY_DEST);
D3D12_TEXTURE_COPY_LOCATION d{},s{};
d.pResource=colorLutTex_.Get();d.Type=D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;d.SubresourceIndex=0;
s.pResource=staging.Get();s.Type=D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
- s.PlacedFootprint.Footprint={DXGI_FORMAT_R32G32B32A32_FLOAT,size,size,size,size*16};
+ s.PlacedFootprint.Footprint={DXGI_FORMAT_R32G32B32A32_FLOAT,size,size,size,rowPitch};
list->CopyTextureRegion(&d,0,0,0,&s,nullptr);
tracker_.transition(list,colorLutTex_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
}else{
@@ -358,14 +379,35 @@ bool EnhanceGraph::createResources()
// Load the optional .cube the settings reference; a LUT that cannot be
// resolved disables the lookup instead of sampling a placeholder.
if(desc_.color.hasLut()){
- engine::ColorLutData lut;
- const engine::ColorLutStore store(runtime::localDataDirectory());
- if(store.resolve(desc_.color.lutNameString(),lut)&&lut.valid()&&setColorLut(lut.rgb.data(),unsigned(lut.size))){
- veyra::log::info("color-grade",std::format("lut loaded name={} size={}",std::string(desc_.color.lutNameString().begin(),desc_.color.lutNameString().end()),lut.size));
- }else{
+ // Plan v5.2: the declared input space must match the content domain.
+ // A display-referred (sRGB) LUT on HDR content, or a PQ LUT on SDR
+ // content, is refused here instead of being applied silently with
+ // values that mean something else than the LUT author assumed.
+ const bool hdrContent=desc_.hdrInput;
+ const int space=desc_.color.lutInputSpace;
+ const bool mismatch=hdrContent?(space==engine::ColorSettings::kLutInputSrgb):(space==engine::ColorSettings::kLutInputPq);
+ if(mismatch){
+ colorLutNotice_=hdrContent?L"LUT 已禁用:HDR 内容不能使用 sRGB 显示参考输入空间(改选 Cineon Log 或 PQ)"
+ :L"LUT 已禁用:SDR 内容不能使用 PQ 输入空间(改选 Cineon Log 或 sRGB 显示参考)";
desc_.color.lutStrength=0.0f;
refreshColorTables();
- veyra::log::warn("color-grade","referenced lut unavailable; colour grade continues without it");
+ veyra::log::warn("color-grade",std::format("lut input space rejected space={} hdrContent={} name bytes={} (grade continues without the lookup)",space,hdrContent?1:0,desc_.color.lutNameString().size()));
+ }else{
+ colorLutNotice_.clear();
+ engine::ColorLutData lut;
+ const engine::ColorLutStore store(runtime::localDataDirectory());
+ if(store.resolve(desc_.color.lutNameString(),lut)&&lut.valid()&&setColorLut(lut.rgb.data(),unsigned(lut.size))){
+ // The name must be converted once: building the log argument
+ // from lutNameString().begin() and .end() created two
+ // different temporaries, so the range constructor computed a
+ // bogus distance and read past both buffers (crash in the LUT
+ // load path, reproduced by the GPU contract test).
+ veyra::log::info("color-grade",std::format("lut loaded name={} size={}",utf8Of(desc_.color.lutNameString()),lut.size));
+ }else{
+ desc_.color.lutStrength=0.0f;
+ refreshColorTables();
+ veyra::log::warn("color-grade","referenced lut unavailable; colour grade continues without it");
+ }
}
}
veyra::log::info("color-grade",std::format("stage enabled tables={}/{}/{} lutInputSpace={} lut={}",