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++

E0: effect infrastructure for anti-aliasing and beauty (byte-identical colour slots)

Veyra Goal Agentf01bf4454471
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 724f4eba..4534dc46 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1098,6 +1098,12 @@ if(VEYRA_BUILD_QML_UI AND Qt6_FOUND)
# cannot ship without it. scripts/i18n/ builds it from the source strings.
qt_add_resources(veyra_qml_ui "veyra_i18n" PREFIX "/i18n" BASE "${CMAKE_CURRENT_SOURCE_DIR}/i18n" FILES i18n/catalog.json)
target_compile_features(veyra_qml_ui PRIVATE cxx_std_20)
+ # Every thread without an explicit size (UI, engine, export worker) reserves the
+ # image default. The 32-node EffectChain is 45 KB and the bridge, preset and
+ # engine frames hold several (2026-10-18: bridge constructor 400 KB,
+ # EngineController::run 385 KB), so 1 MB no longer leaves a safe margin.
+ # Reserve only: pages are committed as they are touched.
+ target_link_options(veyra_qml_ui PRIVATE /STACK:8388608)
# Qt6::CorePrivate only for QUnifiedTimer's slow mode behind --slow-animations.
target_link_libraries(veyra_qml_ui PRIVATE veyra_qml_bridge veyra_engine Qt6::CorePrivate dbghelp ole32)
@@ -1442,6 +1448,7 @@ target_link_options(veyra_hdr_tuning_tests PRIVATE /STACK:33554432)
target_link_libraries(veyra_hdr_color_tests PRIVATE veyra_engine)
add_executable(veyra WIN32 apps/veyra/main.cpp apps/veyra/ui/AppShell.cpp apps/veyra/ui/CapturePanel.cpp apps/veyra/ui/SubtitleOverlay.cpp apps/veyra/SettingsWindow.cpp apps/veyra/TelemetryWindow.cpp)
target_sources(veyra PRIVATE apps/veyra/ui/ScreenCapturePanel.cpp)
+ target_link_options(veyra PRIVATE /STACK:8388608) # same 32-node chain frames as veyra_qml_ui
add_executable(veyra_slider_reset_tests tests/integration/SliderResetTests.cpp apps/veyra/SettingsWindow.cpp)
target_compile_features(veyra_slider_reset_tests PRIVATE cxx_std_20)
target_compile_options(veyra_slider_reset_tests PRIVATE /utf-8)
diff --git a/apps/veyra/TelemetryWindow.cpp b/apps/veyra/TelemetryWindow.cpp
index 58032c25..8fde955f 100644
--- a/apps/veyra/TelemetryWindow.cpp
+++ b/apps/veyra/TelemetryWindow.cpp
@@ -12,7 +12,7 @@ namespace {
unsigned windowDpi=96;HWND window=nullptr;engine::EngineController* engine=nullptr;HFONT font=nullptr;std::wstring preview;
std::wstring wide(const std::string& s){int n=MultiByteToWideChar(CP_UTF8,0,s.data(),int(s.size()),nullptr,0);std::wstring r(n,0);MultiByteToWideChar(CP_UTF8,0,s.data(),int(s.size()),r.data(),n);return r;}
std::wstring value(std::optional<double> v){if(!v)return L"未能测量";std::wostringstream o;o<<std::fixed<<std::setprecision(3)<<*v;return o.str();}
-void refresh(){auto s=engine->snapshot();static constexpr std::array<const wchar_t*,size_t(diagnostics::GpuStage::Count)> names={L"上传/颜色转换",L"超分 SR",L"光流 GPU队列区间(含同步)",L"NR",L"NR变化量合成",L"FG 子帧1",L"FG 子帧2",L"FG 子帧3",L"FG 子帧4",L"FG 子帧5",L"FG批次",L"最终blit",L"RTX Video HDR",L"NR节点1",L"NR节点2",L"NR节点3",L"NR节点4",L"调色节点1",L"调色节点2",L"调色节点3",L"调色节点4",L"调色节点5",L"调色节点6"};std::wostringstream o;
+void refresh(){auto s=engine->snapshot();static constexpr const wchar_t* names[]={L"上传/颜色转换",L"超分 SR",L"光流 GPU队列区间(含同步)",L"NR",L"NR变化量合成",L"FG 子帧1",L"FG 子帧2",L"FG 子帧3",L"FG 子帧4",L"FG 子帧5",L"FG 子帧6",L"FG 子帧7",L"FG批次",L"最终blit",L"RTX Video HDR",L"NR节点1",L"NR节点2",L"NR节点3",L"NR节点4",L"调色节点1",L"调色节点2",L"调色节点3",L"调色节点4",L"调色节点5",L"调色节点6",L"抗锯齿节点1",L"抗锯齿节点2",L"美颜节点1",L"美颜节点2",L"美颜节点3",L"美颜节点4",L"美颜节点5",L"美颜节点6",L"美颜人脸检测"};static_assert(std::size(names)==size_t(diagnostics::GpuStage::Count),"one name per GPU stage");std::wostringstream o;
o<<L"GPU时间戳(毫秒);未执行不记作0。样本帧 "<<s.metrics.identity.sourceFrameId<<L" / epoch "<<s.metrics.identity.epoch<<L" / 设置版本 "<<s.metrics.identity.settingsRevision<<L"\r\n";
for(size_t i=0;i<s.metrics.gpu.size();++i){const auto& g=s.metrics.gpu[i];o<<names[i]<<L":"<<(g.state==diagnostics::SampleState::NotExecuted?L"未执行":g.state==diagnostics::SampleState::Pending?L"待GPU完成":value(g.milliseconds))<<L"\r\n";}
o<<L"\r\nCPU与调度(毫秒,独立于GPU):取帧 "<<value(s.metrics.decodeCpuMs)<<L" / 图提交 "<<value(s.metrics.submitCpuMs)<<L" / GPU就绪等待 "<<value(s.metrics.gpuWaitCpuMs)<<L"\r\n截止时间等待 "<<value(s.metrics.deadlineWaitCpuMs)<<L" / Present调用 "<<value(s.metrics.presentCpuMs)<<L"\r\n源帧 "<<s.metrics.sourceFrames<<L" / 有效生成 "<<s.metrics.validGenerated<<L" / 实际提交 "<<s.metrics.submitted<<L" / 过期补帧 "<<s.metrics.expired<<L"\r\n当前批次容量 "<<s.metrics.queueWatermark<<L"(上限4);采集入口容量1;采集丢弃 "<<s.captureDropped<<L"\r\n实际提交频率(最近1秒观察):"<<value(s.submissionFps)<<L"fps;实际显示扫描率/光子延迟:未测\r\n";
diff --git a/docs/EFFECTS_INFRA_AA_53_PLAN_2026-10-17.md b/docs/EFFECTS_INFRA_AA_53_PLAN_2026-10-17.md
index c71693b4..5fc055bd 100644
--- a/docs/EFFECTS_INFRA_AA_53_PLAN_2026-10-17.md
+++ b/docs/EFFECTS_INFRA_AA_53_PLAN_2026-10-17.md
@@ -60,5 +60,14 @@
2. `E0:` 效果器扩展基础(回归通过后建 `claude/effects-infra-20261017` 指向它,不再移动;后续修正用 `[E0-fix]` 前缀单独提交并记入 WORKLOG)。
3. `AA:` 抗锯齿(着色器、AntiAliasPass、图接入、桥接/QML/翻译、预设/会话/导出、许可、测试与报告)。
-## 7. 未验证项(预先声明)
+## 7. 进度
+
+### E0(2026-10-18,子会话额度用尽后由协调会话完成)
+- 实现与 3.1/3.2 一致,差异:槽判定接口名为 `EnhanceGraphDesc::slotOfStep(step)`(返回 `PassSlot`),图内槽列表为 `sourcePostPasses_/preNrPasses_/preSrPasses_/interNrPasses_[]/tailPasses_`(`SlotPass`);抗锯齿在本提交中由 `EnhanceGraphDesc::antiAliasExecutor=false` 拒绝执行、目录隐藏,美颜同样隐藏且不进入运行顺序。
+- 设置接点:`describeAntiAlias()`(图描述、图片与分块路径)、`applySettings` 结构变化重建/阈值类为统一量、导出冻结计数校验、预览计算队列与自动 NR 池及最近图缓存的准入排除抗锯齿、“重置本页”清空抗锯齿、桥接目录与 `addEffect` 拒绝隐藏类型、整链预设替换的类型排序包含新类型。
+- 32 节点使 `EffectChain` 22,416→45,584 字节;汇编清单统计的栈帧随之约翻倍(`QmlPlayerBridge` 构造 214→400 KB,`EngineController::run` 385 KB,`PresetLibrary::parse` 78→147 KB)。`veyra_qml_ui`(含界面、引擎与导出 worker 线程)与旧 `veyra` 链接 `/STACK:8388608`(只保留地址空间,按需提交);已核对 PE 头 8,388,608。
+- 旧 Win32 遥测阶段名表补齐:原表缺 `Fg6/Fg7` 两项(其后名称整体错位、末两项为空指针),现按枚举逐项对齐并以 `static_assert` 固定长度。
+- 验证:`veyra_effect_chain_tests` 全部通过(新增 E0 断言 33 条:默认无新节点、溢出拒绝、双实例往返与校验、重建规则、列表位置、节点 SourcePost/PreNr/PreSr/InterNr/Tail 与混合槽、美颜不入图、21 节点链);`veyra_preset_library_tests` 全部通过(新增 14 条:v14 独立文件且旧库字节不变、精确重载与应用、v13 头夹带新类型拒绝、未知新版本拒绝、18 节点链、会话 v9);`veyra_nr_model_settings_tests` 26/26;`veyra_ui_i18n_tests` 0 失败;调色切片回归 `slot_regression.py app-e0b … --compare golden-baseline.json` **12/12 逐字节相同**(`tests/claude-aa-53-20261017/slot-e0-final.json`)。
+
+## 8. 未验证项(预先声明)
AMD/Intel 实卡、用户 Switch 素材、长时间运行、光学延迟均不在本轮验证范围;本机 RTX 结果不外推其它硬件。
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 43c4e5e0..ce89ccda 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -9718,3 +9718,8 @@ final-audit.py pre已通过82旧树/94旧分支/509脏文件与main b571a44不
## 2026-10-17 E0 + #53 anti-aliasing: start (Claude sub-session, usage limit reached early)
Branch claude/aa-53-20261017 from main 26c0d61. Archive E:/项目/Veyra/archives/claude-aa-53-20261017 (start.json, verified source-before.bundle). Added AGENTS.md authorization, docs/EFFECTS_INFRA_AA_53_PLAN_2026-10-17.md and the test-only harness veyra_effect_slot_regression_tests (commit df8028a). Baseline on unmodified product code: fresh configure+compile 105 s (build/claude-aa-53-20261017); 12 configurations (list default, NR-first, 6 colours, two NR layers with protection, node pre-NR/pre-SR/inter-NR/tail, mixed SR-first and NR-first, SR-only tail, split NR) recorded twice with identical SHA-256 (tests/claude-aa-53-20261017/golden-baseline.json, real NR and DLSS SR on RTX 5070). No product code changed yet: E0 and the anti-aliasing effect are NOT implemented and claude/effects-infra-20261017 does not exist. Hand-over notes: C:/Users/123/AppData/Roaming/Claude/side-session-notes/local_089fcd60-31dd-4fd0-aac7-c63d8dc7d88a/aa-53-E0-handover-2026-10-17.md. Untracked include/veyra/engine/AntiAliasSettings.h is an unreferenced draft.
+
+## 2026-10-18 E0 effect infrastructure done (coordinating session took over after the sub-session's usage limit)
+- Implemented plan §3: EffectType AntiAliasing/Beauty (hidden), 32-node chains with explicit overflow refusal, AntiAliasSettings in chain/settings/presets (library v14 + session v9 in `.effects` files, older files untouched), export protocol 10, 64-bit GPU timer mask with AA/beauty stages, step-based insertion slots (`slotOfStep`, SourcePost slot) with the colour executor rewritten onto slot lists. Anti-aliasing stays refused (`antiAliasExecutor=false`) until the AA commit.
+- 32 nodes double EffectChain (22 KB -> 45 KB) and the stack frames that copy it (assembly listings: bridge constructor 214 -> 400 KB, EngineController::run 385 KB); veyra_qml_ui and veyra now link /STACK:8388608 (reserve only). Fixed the legacy Win32 telemetry name table, already misaligned on main (Fg6/Fg7 missing).
+- Verified (builds 25-39 s each, `tmp/claude-aa-53-20261017/tools/build.py`): effect chain tests all pass (33 new E0 checks), preset library tests all pass (14 new), NR model settings 26/26, i18n 0 failures, colour slot regression 12/12 byte-identical to the main baseline (`tests/claude-aa-53-20261017/slot-e0-final.json`, logs `logs/claude-aa-53-20261017/slot-regression-20261018-142129`).
diff --git a/include/veyra/diagnostics/EnhancementProcessingTime.h b/include/veyra/diagnostics/EnhancementProcessingTime.h
index 228fb90c..2a0a2216 100644
--- a/include/veyra/diagnostics/EnhancementProcessingTime.h
+++ b/include/veyra/diagnostics/EnhancementProcessingTime.h
@@ -15,8 +15,11 @@ inline std::optional<double> enhancementProcessingMs(const GpuFrameTiming& frame
if(frame.gpu[size_t(GpuStage::Color)].state!=SampleState::Measured)return {};
// Every NR layer marks the shared Nr slot, so it only holds the last layer;
// the per-layer spans carry the others (several layers read as one, 2026-10-02).
+ // Anti-aliasing and beauty run outside those spans: their own spans count.
constexpr GpuStage stages[]={GpuStage::Flow,GpuStage::Sr,GpuStage::Nr,GpuStage::NrLayer0,GpuStage::NrLayer1,
- GpuStage::NrLayer2,GpuStage::NrLayer3,GpuStage::Residual,GpuStage::FgBatch};
+ GpuStage::NrLayer2,GpuStage::NrLayer3,GpuStage::Residual,GpuStage::FgBatch,GpuStage::AaNode0,GpuStage::AaNode1,
+ GpuStage::BeautyNode0,GpuStage::BeautyNode1,GpuStage::BeautyNode2,GpuStage::BeautyNode3,GpuStage::BeautyNode4,
+ GpuStage::BeautyNode5,GpuStage::BeautyDetect};
struct Interval {uint64_t begin,end;};
std::array<Interval,std::size(stages)> intervals{};
size_t count=0;uint64_t frequency=0;
diff --git a/include/veyra/diagnostics/FrameMetrics.h b/include/veyra/diagnostics/FrameMetrics.h
index 753eb404..1f0266c5 100644
--- a/include/veyra/diagnostics/FrameMetrics.h
+++ b/include/veyra/diagnostics/FrameMetrics.h
@@ -9,14 +9,19 @@ namespace veyra::diagnostics {
// spans above; they are never merged into enhancementProcessingMs.
enum class GpuStage { Color, Sr, Flow, Nr, Residual, Fg1, Fg2, Fg3, Fg4, Fg5, Fg6, Fg7, FgBatch, Blit, VideoHdr,
NrLayer0, NrLayer1, NrLayer2, NrLayer3,
- ColorNode0, ColorNode1, ColorNode2, ColorNode3, ColorNode4, ColorNode5, Count };
+ ColorNode0, ColorNode1, ColorNode2, ColorNode3, ColorNode4, ColorNode5,
+ AaNode0, AaNode1,
+ BeautyNode0, BeautyNode1, BeautyNode2, BeautyNode3, BeautyNode4, BeautyNode5, BeautyDetect, Count };
static_assert(unsigned(GpuStage::Fg5)-unsigned(GpuStage::Fg1)==4);
static_assert(unsigned(GpuStage::FgBatch)>unsigned(GpuStage::Fg7));
-static_assert(unsigned(GpuStage::Count)<=32,"GpuTimer keeps one mask bit per stage");
-inline constexpr unsigned kTimedNrLayers=4,kTimedColorNodes=6;
+static_assert(unsigned(GpuStage::Count)<=64,"GpuTimer keeps one mask bit per stage");
+inline constexpr unsigned kTimedNrLayers=4,kTimedColorNodes=6,kTimedAaNodes=2,kTimedBeautyNodes=6;
// NR layers are indexed among EXECUTING layers; Color by parameter ordinal.
constexpr GpuStage nrLayerStage(unsigned layer){return GpuStage(unsigned(GpuStage::NrLayer0)+layer);}
constexpr GpuStage colorNodeStage(unsigned parameter){return GpuStage(unsigned(GpuStage::ColorNode0)+parameter);}
+// Anti-aliasing and beauty spans are indexed by parameter ordinal, like Color.
+constexpr GpuStage aaNodeStage(unsigned parameter){return GpuStage(unsigned(GpuStage::AaNode0)+parameter);}
+constexpr GpuStage beautyNodeStage(unsigned parameter){return GpuStage(unsigned(GpuStage::BeautyNode0)+parameter);}
enum class SampleState { NotExecuted, Pending, Measured, Unavailable };
enum class CpuStage { Decode, Submit, SlotWait, ReadyWait, DeadlineWait, Present, DecodedQueue, EnhancementDelayEstimate, Count };
enum class PairTiming { ArrivalInterval, GeneratedFromA, GeneratedFromB, Count };
diff --git a/include/veyra/diagnostics/GpuTimer.h b/include/veyra/diagnostics/GpuTimer.h
index ca5f2bff..26651c87 100644
--- a/include/veyra/diagnostics/GpuTimer.h
+++ b/include/veyra/diagnostics/GpuTimer.h
@@ -9,7 +9,7 @@ namespace veyra::diagnostics {
// No image readback, no CPU waits. Samples carry the identity they measured.
class GpuTimer {
static constexpr unsigned stages=unsigned(GpuStage::Count),slots=4,stride=stages*2;
- struct Pending{pipeline::FrameIdentity id;uint32_t mask=0;uint64_t fence=0;};
+ struct Pending{pipeline::FrameIdentity id;uint64_t mask=0;uint64_t fence=0;};
Microsoft::WRL::ComPtr<ID3D12QueryHeap> heap_;
Microsoft::WRL::ComPtr<ID3D12Resource> readback_;
std::array<Pending,slots> pending_{};uint64_t frequency_=0;int active_=-1;
@@ -27,7 +27,7 @@ public:
void collect(ID3D12Fence* fence){if(!readback_||!fence)return;const auto completed=fence->GetCompletedValue();
for(unsigned slot=0;slot<slots;++slot){auto& p=pending_[slot];if(!p.fence||p.fence>completed)continue;void* data=nullptr;D3D12_RANGE range{slot*stride*8,(slot+1)*stride*8};auto hr=readback_->Map(0,&range,&data);if(FAILED(hr)){log::error("gpu-timestamp",std::format("Map hr=0x{:X}",unsigned(hr)));p.fence=0;continue;}
FrameMetrics m;m.identity=p.id;auto values=static_cast<const uint64_t*>(data)+slot*stride;
- for(unsigned stage=0;stage<stages;++stage)if(p.mask&(1u<<stage)){auto& v=m.gpu[stage];v.begin=values[stage*2];v.end=values[stage*2+1];v.frequency=frequency_;if(v.end>=v.begin){v.state=SampleState::Measured;v.milliseconds=double(v.end-v.begin)*1000/frequency_;}else v.state=SampleState::Unavailable;
+ for(unsigned stage=0;stage<stages;++stage)if(p.mask&(1ull<<stage)){auto& v=m.gpu[stage];v.begin=values[stage*2];v.end=values[stage*2+1];v.frequency=frequency_;if(v.end>=v.begin){v.state=SampleState::Measured;v.milliseconds=double(v.end-v.begin)*1000/frequency_;}else v.state=SampleState::Unavailable;
if(log::verboseFrameLogs())log::info("gpu-timestamp",std::format("frame={} epoch={} revision={} stage={} begin={} end={} frequency={} ms={} (GPU queue timestamps)",p.id.sourceFrameId,p.id.epoch,p.id.settingsRevision,stage,v.begin,v.end,frequency_,v.milliseconds.value_or(-1)));
}
D3D12_RANGE written{0,0};readback_->Unmap(0,&written);if(p.fence>=lastCollectedFence_){last_=m;lastCollectedFence_=p.fence;}
@@ -42,8 +42,8 @@ public:
++skipped_;if((skipped_&(skipped_-1))==0)log::warn("gpu-timestamp",std::format("no free query slot; skipped={} frame={}",skipped_,id.sourceFrameId));
}
void identity(pipeline::FrameIdentity id){if(active_>=0)pending_[active_].id=id;}
- void mark(ID3D12GraphicsCommandList* list,GpuStage stage,bool end=false){if(active_<0)return;unsigned i=unsigned(stage);list->EndQuery(heap_.Get(),D3D12_QUERY_TYPE_TIMESTAMP,active_*stride+i*2+unsigned(end));if(end)pending_[active_].mask|=1u<<i;}
- void resolve(ID3D12GraphicsCommandList* list){if(active_<0)return;auto mask=pending_[active_].mask;for(unsigned i=0;i<stages;++i)if(mask&(1u<<i)){unsigned index=active_*stride+i*2;list->ResolveQueryData(heap_.Get(),D3D12_QUERY_TYPE_TIMESTAMP,index,2,readback_.Get(),index*8);}}
+ void mark(ID3D12GraphicsCommandList* list,GpuStage stage,bool end=false){if(active_<0)return;unsigned i=unsigned(stage);list->EndQuery(heap_.Get(),D3D12_QUERY_TYPE_TIMESTAMP,active_*stride+i*2+unsigned(end));if(end)pending_[active_].mask|=1ull<<i;}
+ void resolve(ID3D12GraphicsCommandList* list){if(active_<0)return;auto mask=pending_[active_].mask;for(unsigned i=0;i<stages;++i)if(mask&(1ull<<i)){unsigned index=active_*stride+i*2;list->ResolveQueryData(heap_.Get(),D3D12_QUERY_TYPE_TIMESTAMP,index,2,readback_.Get(),index*8);}}
void submitted(uint64_t fence){if(active_>=0)pending_[active_].fence=fence;active_=-1;}
const FrameMetrics& last()const{return last_;}
void recordCompleted(){recordCompleted_=true;}
diff --git a/include/veyra/engine/AntiAliasSettings.h b/include/veyra/engine/AntiAliasSettings.h
new file mode 100644
index 00000000..4c0d99b5
--- /dev/null
+++ b/include/veyra/engine/AntiAliasSettings.h
@@ -0,0 +1,96 @@
+#pragma once
+#include <cmath>
+#include <cstdint>
+#include <istream>
+#include <ostream>
+#include <string>
+
+namespace veyra::engine {
+// Spatial anti-aliasing effect (issue #53). One instance runs at source
+// resolution in front of any enlargement; a node chain may hold a second one
+// behind super resolution.
+inline constexpr uint32_t kMaxAntiAliasInstances = 2;
+
+enum class AntiAliasMethod : uint8_t { Fxaa = 0, Smaa = 1, Mlaa = 2 };
+// Experimental temporal accumulation on top of SMAA (captured frames cannot be
+// jittered, so these are the "no jitter" approximations of SMAA T2x / 4x).
+enum class AntiAliasTemporal : uint8_t { Off = 0, T2x = 1, X4 = 2 };
+
+// Quality tiers per method. FXAA: 0 medium (preset 3), 1 high (4), 2 ultra (5).
+// SMAA: 0 low, 1 medium, 2 high, 3 ultra. MLAA has no tiers.
+constexpr uint32_t antiAliasQualityCount(AntiAliasMethod method) {
+ return method == AntiAliasMethod::Fxaa ? 3u : method == AntiAliasMethod::Smaa ? 4u : 1u;
+}
+constexpr bool validAntiAliasMethod(AntiAliasMethod method) {
+ return method == AntiAliasMethod::Fxaa || method == AntiAliasMethod::Smaa || method == AntiAliasMethod::Mlaa;
+}
+
+struct AntiAliasSettings {
+ bool enabled = false;
+ AntiAliasMethod method = AntiAliasMethod::Smaa;
+ uint8_t quality = 2;
+ // MLAA only.
+ float mlaaThreshold = 0.08f; // perceptual luma difference that counts as an edge, 0.02 .. 0.30
+ float mlaaStrength = 1.0f; // 0 .. 1
+ // SMAA only, experimental, default off.
+ AntiAliasTemporal temporal = AntiAliasTemporal::Off;
+ float historyWeight = 0.5f; // 0 .. 0.95
+ float historyRejection = 8.0f; // 0 .. 32
+ bool operator==(const AntiAliasSettings&) const = default;
+
+ // Untouched defaults: the list chain then carries no anti-aliasing node at all, so
+ // presets and sessions saved without it keep their older format version.
+ bool configured() const { return *this != AntiAliasSettings{}; }
+ bool usesMlaaParameters() const { return method == AntiAliasMethod::Mlaa; }
+ bool usesTemporal() const { return method == AntiAliasMethod::Smaa && temporal != AntiAliasTemporal::Off; }
+ // The values that matter to the running effect: a disabled instance and the
+ // parameters of a method that is not selected compare equal to the defaults.
+ AntiAliasSettings active() const {
+ if (!enabled) return {};
+ AntiAliasSettings value = *this;
+ const AntiAliasSettings defaults;
+ if (!usesMlaaParameters()) { value.mlaaThreshold = defaults.mlaaThreshold; value.mlaaStrength = defaults.mlaaStrength; }
+ if (method == AntiAliasMethod::Mlaa) value.quality = 0;
+ if (!usesTemporal()) {
+ value.temporal = AntiAliasTemporal::Off;
+ value.historyWeight = defaults.historyWeight;
+ value.historyRejection = defaults.historyRejection;
+ }
+ return value;
+ }
+ // Anything that changes which shaders or textures exist needs a graph
+ // rebuild; thresholds and history weights are uniform-only.
+ bool sameStructure(const AntiAliasSettings& other) const {
+ const auto a = active(), b = other.active();
+ return a.enabled == b.enabled && a.method == b.method && a.quality == b.quality && a.temporal == b.temporal;
+ }
+ std::string validate() const {
+ if (!validAntiAliasMethod(method)) return "invalid anti-aliasing method";
+ if (quality >= antiAliasQualityCount(method)) return "invalid anti-aliasing quality";
+ if (!std::isfinite(mlaaThreshold) || mlaaThreshold < 0.02f || mlaaThreshold > 0.30f) return "MLAA threshold out of range";
+ if (!std::isfinite(mlaaStrength) || mlaaStrength < 0.0f || mlaaStrength > 1.0f) return "MLAA strength out of range";
+ if (temporal != AntiAliasTemporal::Off && temporal != AntiAliasTemporal::T2x && temporal != AntiAliasTemporal::X4)
+ return "invalid temporal anti-aliasing mode";
+ if (temporal != AntiAliasTemporal::Off && method != AntiAliasMethod::Smaa) return "temporal anti-aliasing requires SMAA";
+ if (!std::isfinite(historyWeight) || historyWeight < 0.0f || historyWeight > 0.95f) return "temporal history weight out of range";
+ if (!std::isfinite(historyRejection) || historyRejection < 0.0f || historyRejection > 32.0f) return "temporal history rejection out of range";
+ return {};
+ }
+};
+
+// Preset library v14 / chain session v9: one appended block per anti-aliasing node.
+inline void writeAntiAlias(std::ostream& out, const AntiAliasSettings& a) {
+ out << (a.enabled ? 1 : 0) << ' ' << int(a.method) << ' ' << int(a.quality) << ' ' << a.mlaaThreshold << ' ' << a.mlaaStrength
+ << ' ' << int(a.temporal) << ' ' << a.historyWeight << ' ' << a.historyRejection;
+}
+inline bool readAntiAlias(std::istream& in, AntiAliasSettings& a) {
+ int enabled = 0, method = 0, quality = 0, temporal = 0;
+ if (!(in >> enabled >> method >> quality >> a.mlaaThreshold >> a.mlaaStrength >> temporal >> a.historyWeight >> a.historyRejection)) return false;
+ if (enabled < 0 || enabled > 1 || method < 0 || method > 2 || quality < 0 || quality > 255 || temporal < 0 || temporal > 2) return false;
+ a.enabled = enabled != 0;
+ a.method = static_cast<AntiAliasMethod>(method);
+ a.quality = static_cast<uint8_t>(quality);
+ a.temporal = static_cast<AntiAliasTemporal>(temporal);
+ return a.validate().empty();
+}
+} // namespace veyra::engine
diff --git a/include/veyra/engine/EffectChain.h b/include/veyra/engine/EffectChain.h
index 2b64cb8f..1c24640a 100644
--- a/include/veyra/engine/EffectChain.h
+++ b/include/veyra/engine/EffectChain.h
@@ -19,7 +19,9 @@ namespace veyra::engine {
// The structure is additive for now: EnhancementSettings remains the runtime
// input, and toChain()/fromChain() convert between the two. Later engine work
// (multi-NR, ordered executor, node mode) consumes the chain directly.
-inline constexpr uint32_t kMaxChainNodes = 16;
+// 32 since the effect-chain extension (anti-aliasing, beauty): a full list chain is
+// 6 colours + SR + 4 NR + protection + 2 anti-aliasing + 6 beauty + HDR + FG = 22.
+inline constexpr uint32_t kMaxChainNodes = 32;
enum class EffectType : uint8_t {
Color = 0, // tone/LUT grade
@@ -28,6 +30,8 @@ enum class EffectType : uint8_t {
Protection, // keeps NR out of chosen rectangles
VideoHdr, // SDR -> HDR conversion
FrameGeneration, // must be the last node
+ AntiAliasing, // spatial anti-aliasing (#53): same size, repeatable, before RTX Video HDR
+ Beauty, // face restore + skin smoothing: same size, repeatable (reserved, hidden)
Count
};
constexpr uint32_t effectTypeCount = uint32_t(EffectType::Count);
@@ -39,6 +43,8 @@ constexpr std::string_view effectTypeName(EffectType type) {
case EffectType::Protection: return "protection";
case EffectType::VideoHdr: return "video-hdr";
case EffectType::FrameGeneration: return "frame-generation";
+ case EffectType::AntiAliasing: return "aa";
+ case EffectType::Beauty: return "beauty";
case EffectType::Count: break;
}
return "unknown";
@@ -71,6 +77,7 @@ struct ChainNode {
ProtectionSettings protection{};
ColorSettings color{};
VideoHdrSettings videoHdr{};
+ AntiAliasSettings aa{};
bool operator==(const ChainNode&) const = default;
};
@@ -88,6 +95,9 @@ struct EffectChain {
// Non-stage settings that still belong to a job description (they were in
// EnhancementSettings before and stay there; copied here for completeness).
bool fgStrictAdmission = false;
+ // toChain() ran out of nodes: validateChain() refuses the chain instead of a
+ // stage being dropped silently.
+ bool overflow = false;
bool operator==(const EffectChain&) const = default;
// Counts nodes of one type, regardless of enabled state.
@@ -278,6 +288,8 @@ struct EffectInfo {
bool justBeforeLast = false;
bool changesResolution = false;
bool experimental = false;
+ // Known to the engine and the file formats but not offered by the UI yet.
+ bool hidden = false;
};
const EffectInfo& effectInfo(EffectType type);
const std::array<EffectInfo, effectTypeCount>& effectCatalog();
diff --git a/include/veyra/engine/EnhancementSettings.h b/include/veyra/engine/EnhancementSettings.h
index d5a5807a..0458470b 100644
--- a/include/veyra/engine/EnhancementSettings.h
+++ b/include/veyra/engine/EnhancementSettings.h
@@ -9,9 +9,13 @@
#include "veyra/pipeline/ResolutionPlan.h"
#include "veyra/source/CaptureBuffer.h"
#include "veyra/engine/ColorSettings.h"
+#include "veyra/engine/AntiAliasSettings.h"
namespace veyra::engine {
inline constexpr uint32_t kMaxColorInstances = 6;
inline constexpr uint32_t kMaxNrInstances = 4;
+// Beauty nodes (face restore + skin smoothing). Reserved by the effect-chain
+// extension; the effect itself is not available yet (hidden in the catalog).
+inline constexpr uint32_t kMaxBeautyInstances = 6;
// Anti-flicker route for the NR temporal pass. The tiers come from Magpie's
// DLSSNRTemporal (GPL-3.0, commit 3841698): see shaders/NrTemporal.hlsl.
// Off - no temporal accumulation at all.
@@ -343,6 +347,11 @@ struct EnhancementSettings {
// Fixed capacity preserves the export shared-memory POD contract.
std::array<ColorSettings,kMaxColorInstances-1> additionalColors{};
uint32_t additionalColorCount=0;
+ // Spatial anti-aliasing (#53). Instance zero is the list card; a node chain may
+ // hold a second instance. Fixed capacity for the export shared-memory POD.
+ AntiAliasSettings antiAlias;
+ std::array<AntiAliasSettings,kMaxAntiAliasInstances-1> additionalAntiAlias{};
+ uint32_t additionalAntiAliasCount=0;
// Stage-5 output stabiliser (anti-flicker). Holds the previous output where
// the source has not visibly changed. 0 is off, and off is the default: the
// graph then skips the dispatch entirely, so a build with this feature
@@ -401,6 +410,9 @@ struct EnhancementSettings {
for(size_t i=0;i<active.additionalColors.size();++i)
if(i>=additionalColorCount||!additionalColors[i].enabled)active.additionalColors[i]={};
if(!videoHdr.enabled)active.videoHdr=defaults.videoHdr;
+ active.antiAlias=antiAlias.active();
+ for(size_t i=0;i<active.additionalAntiAlias.size();++i)
+ active.additionalAntiAlias[i]=i<additionalAntiAliasCount?additionalAntiAlias[i].active():AntiAliasSettings{};
if(nrHoldStrength==0)active.nrHoldTolerance=defaults.nrHoldTolerance;
if(!hdrCurve.enabled){
active.hdrCurve=defaults.hdrCurve;
@@ -454,6 +466,11 @@ struct EnhancementSettings {
}
video.videoHdr=target.videoHdr;
video.videoHdr.enabled=videoHdr.enabled;
+ // Anti-aliasing thresholds and history weights are uniforms; the method,
+ // tier and temporal mode decide which passes exist.
+ if(video.antiAlias.sameStructure(target.antiAlias))video.antiAlias=target.antiAlias;
+ for(size_t i=0;i<additionalAntiAlias.size();++i)
+ if(video.additionalAntiAlias[i].sameStructure(target.additionalAntiAlias[i]))video.additionalAntiAlias[i]=target.additionalAntiAlias[i];
return video==target;
}
void rejectVideoRequest(const EnhancementSettings& attempted,const EnhancementSettings& previous) {
@@ -524,6 +541,10 @@ struct EnhancementSettings {
if(additionalColorCount>additionalColors.size())return "too many color instances";
for(uint32_t i=0;i<additionalColorCount;++i)
if(auto error=additionalColors[i].validate();!error.empty())return error;
+ if(auto error=antiAlias.validate();!error.empty())return error;
+ if(additionalAntiAliasCount>additionalAntiAlias.size())return "too many anti-aliasing instances";
+ for(uint32_t i=0;i<additionalAntiAliasCount;++i)
+ if(auto error=additionalAntiAlias[i].validate();!error.empty())return error;
if(!pipeline::validNrSizePolicy(nrPolicy))return "invalid NR size policy";
if(flow<FlowQuality::Performance||flow>FlowQuality::Quality||content<ContentRate::Transport||content>ContentRate::Capture60To30)return "invalid flow/content mode";
return {};
diff --git a/include/veyra/engine/ExportFeaturePolicy.h b/include/veyra/engine/ExportFeaturePolicy.h
index f2c04e06..21434b8d 100644
--- a/include/veyra/engine/ExportFeaturePolicy.h
+++ b/include/veyra/engine/ExportFeaturePolicy.h
@@ -12,7 +12,8 @@ constexpr pipeline::NrSizePolicy exportNrSizePolicy(NrRuntime runtime) {
inline EnhancementSettings freezeExportSettings(EnhancementSettings settings) {
// Preserve invalid counts for the caller's validation; normalization must
// not turn a corrupt settings transaction into an apparently valid one.
- if(settings.nrLayerCount>settings.nrLayers.size()||settings.additionalColorCount>settings.additionalColors.size())return settings;
+ if(settings.nrLayerCount>settings.nrLayers.size()||settings.additionalColorCount>settings.additionalColors.size()||
+ settings.additionalAntiAliasCount>settings.additionalAntiAlias.size())return settings;
settings.nrPolicy=exportNrSizePolicy(settings.nrRuntime);
for(uint32_t i=0;i<settings.nrLayerCount&&i<settings.nrLayers.size();++i)
settings.nrLayers[i].sizePolicy=exportNrSizePolicy(settings.nrLayers[i].runtime);
diff --git a/include/veyra/engine/GraphDescription.h b/include/veyra/engine/GraphDescription.h
index 4afaa62b..27d0dcce 100644
--- a/include/veyra/engine/GraphDescription.h
+++ b/include/veyra/engine/GraphDescription.h
@@ -37,6 +37,14 @@ inline void describeNrLayers(const EnhancementSettings& settings,pipeline::Enhan
// Stage selection for one graph build. Preview and export used to fill the
// EnhanceGraphDesc in five separate places with slightly different formulas;
// every build now goes through describeStages() so the rules live in one spot.
+// Anti-aliasing by parameter ordinal. An ordinal the settings do not hold is the
+// disabled default, so a description never carries a stale instance.
+inline void describeAntiAlias(const EnhancementSettings& settings,pipeline::EnhanceGraphDesc& desc){
+ desc.antiAlias[0]=settings.antiAlias;
+ for(uint32_t i=1;i<kMaxAntiAliasInstances;++i)
+ desc.antiAlias[i]=i-1<settings.additionalAntiAliasCount?settings.additionalAntiAlias[i-1]:AntiAliasSettings{};
+}
+
struct StageRequest {
bool nr=false,sr=false,fg=false;
uint32_t fgMultiplier=2;
@@ -57,7 +65,8 @@ inline pipeline::ResolutionPlan describeStages(const StageRequest& request,const
pipeline::EnhanceGraphDesc& desc) {
desc.fixedExecutionPlan.reset();desc.fixedExecutionPlanError.clear();
desc.runtimeNodeOrder=request.nodeOrder!=nullptr;
- if(savedSettings.nrLayerCount>savedSettings.nrLayers.size()||savedSettings.additionalColorCount>savedSettings.additionalColors.size()){
+ if(savedSettings.nrLayerCount>savedSettings.nrLayers.size()||savedSettings.additionalColorCount>savedSettings.additionalColors.size()||
+ savedSettings.additionalAntiAliasCount>savedSettings.additionalAntiAlias.size()){
desc.fixedExecutionPlanError="too many runtime chain instances";return {};
}
std::optional<EnhancementSettings> exportSettings;
@@ -119,6 +128,7 @@ inline pipeline::ResolutionPlan describeStages(const StageRequest& request,const
desc.color=settings.color;
desc.additionalColors=settings.additionalColors;
desc.additionalColorCount=settings.additionalColorCount;
+ describeAntiAlias(settings,desc);
desc.videoHdr=settings.videoHdr;
// Custom: static HDR output tuning (present blit curve + display metadata).
desc.hdrCurve=settings.hdrCurve;
diff --git a/include/veyra/engine/RecentGraphCache.h b/include/veyra/engine/RecentGraphCache.h
index df3a2bd8..7a4d7703 100644
--- a/include/veyra/engine/RecentGraphCache.h
+++ b/include/veyra/engine/RecentGraphCache.h
@@ -44,14 +44,15 @@ public:
}
static bool eligible(const pipeline::EnhanceGraphDesc& desc){
return desc.enableNr&&!desc.enableSr&&!desc.enableFg&&!desc.hdrInput&&!desc.hdrOutput&&!desc.videoHdr.enabled&&!desc.color.enabled&&desc.additionalColorCount==0&&
- desc.nrHoldStrength==0&&!desc.noFeatures&&!desc.noNgx&&!desc.stillImage&&!desc.nrAutoPoolLayer&&
+ !desc.antiAliasActive()&&desc.nrHoldStrength==0&&!desc.noFeatures&&!desc.noNgx&&!desc.stillImage&&!desc.nrAutoPoolLayer&&
currentNrRuntime(desc.nrRuntime)==NrRuntime::Ampere&&!desc.nrTemporal&&desc.nrLayersModel.size()<=1&&
std::none_of(desc.nrLayersTemporal.begin(),desc.nrLayersTemporal.end(),[](bool value){return value;})&&
!desc.runtimeNodeOrder&&(!desc.fixedExecutionPlan||(
desc.fixedExecutionPlan->stepCount==1&&desc.fixedExecutionPlan->steps[0].type==EffectType::NrEnhance));
}
static bool effectsOff(const pipeline::EnhanceGraphDesc& desc){
- return !desc.enableNr&&!desc.enableSr&&!desc.enableFg&&!desc.videoHdr.enabled&&!desc.color.enabled&&desc.additionalColorCount==0;
+ return !desc.enableNr&&!desc.enableSr&&!desc.enableFg&&!desc.videoHdr.enabled&&!desc.color.enabled&&desc.additionalColorCount==0&&
+ !desc.antiAliasActive();
}
static std::string label(const Key& key){
return std::format("{}x{}:{}x{}:{}x{}:runtime{}:file{}:mtime{}",key.sourceWidth,key.sourceHeight,
diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.h
index b81fed80..96403f9c 100644
--- a/include/veyra/pipeline/EnhanceGraph.h
+++ b/include/veyra/pipeline/EnhanceGraph.h
@@ -165,6 +165,15 @@ struct EnhanceGraphDesc {
// in order on RGBA16F textures; never on a CPU copy of a video frame.
std::array<engine::ColorSettings,engine::kMaxColorInstances-1> additionalColors{};
uint32_t additionalColorCount=0;
+ // Spatial anti-aliasing by parameter ordinal (0 = list card / first node). Only
+ // instances with a step in fixedExecutionPlan run; the settings carry the values.
+ std::array<engine::AntiAliasSettings,engine::kMaxAntiAliasInstances> antiAlias{};
+ // The anti-aliasing executor is compiled into this build (EnhanceGraph).
+ static constexpr bool antiAliasExecutor=false;
+ bool antiAliasActive() const {
+ for(const auto& a:antiAlias)if(a.enabled)return true;
+ return false;
+ }
// Production builders compile once and use this plan for NR resource
// sizes and node tail Color routing after the fixed base block. This is
// NOT an arbitrary-order GPU dispatcher. Direct
@@ -233,7 +242,40 @@ struct EnhanceGraphDesc {
return nrBeforeSr?Extent{sourceWidth,sourceHeight}:Extent{workWidth,workHeight};
}
bool finalNrAfterSr() const { return !nrBeforeSr||splitNrAcrossSr(); }
- bool preSrColor(uint32_t parameter) const {
+ // ---- insertion slots -------------------------------------------------------
+ // Same-size passes (Color, anti-aliasing, beauty) run in one of these slots, in
+ // plan order. A node chain places each step by its neighbours, with the exact
+ // rules the Color-only slots had, a neighbouring same-size pass of any kind
+ // counting as contiguous. List mode places them by type. Ingress is the fused /
+ // in-place grade of the input conversion (Color only); SourcePost runs right
+ // after it at source size, before any enlargement or NR.
+ enum class PassSlot : uint8_t { None, Ingress, SourcePost, PreSr, PreNr, InterNr, Tail };
+ static constexpr bool samePass(engine::EffectType type){
+ return type==engine::EffectType::Color||type==engine::EffectType::AntiAliasing||type==engine::EffectType::Beauty;
+ }
+ uint32_t planStepOf(engine::EffectType type,uint32_t parameter) const {
+ if(!fixedExecutionPlan)return engine::kMaxChainNodes;
+ const auto& plan=*fixedExecutionPlan;
+ for(uint32_t i=0;i<plan.stepCount&&i<plan.steps.size();++i)
+ if(plan.steps[i].type==type&&plan.steps[i].parameterIndex==parameter)return i;
+ return engine::kMaxChainNodes;
+ }
+ // A node-chain step in front of every SR / NR / protection step. Anti-aliasing
+ // and beauty there run at source size after the input conversion; a Color there
+ // joins them once a non-Color pass precedes it (it cannot be fused before it).
+ bool sourcePostStep(uint32_t s) const {
+ if(!runtimeNodeOrder||!fixedExecutionPlan)return false;
+ using engine::EffectType;
+ const auto& plan=*fixedExecutionPlan;bool afterPass=false;
+ for(uint32_t i=0;i<plan.stepCount&&i<plan.steps.size();++i){
+ const auto type=plan.steps[i].type;
+ if(type==EffectType::SuperResolution||type==EffectType::NrEnhance||type==EffectType::Protection)return false;
+ if(i==s)return samePass(type)&&(type!=EffectType::Color||afterPass);
+ if(samePass(type)&&type!=EffectType::Color)afterPass=true;
+ }
+ return false;
+ }
+ bool preSrStep(uint32_t s) const {
if(!runtimeNodeOrder||!fixedExecutionPlan||!nrBeforeSr)return false;
using engine::EffectType;
const auto& plan=*fixedExecutionPlan;
@@ -242,17 +284,17 @@ struct EnhanceGraphDesc {
const auto& step=plan.steps[i];
if(step.type==EffectType::SuperResolution)return false;
if(step.type==EffectType::NrEnhance)afterNr=true;
- if(step.type!=EffectType::Color||step.parameterIndex!=parameter)continue;
- if(!afterNr)return false;
+ if(i!=s)continue;
+ if(!samePass(step.type)||!afterNr)return false;
for(uint32_t j=i+1;j<plan.stepCount&&j<plan.steps.size();++j){
if(plan.steps[j].type==EffectType::SuperResolution)return true;
- if(plan.steps[j].type!=EffectType::Color)break;
+ if(!samePass(plan.steps[j].type))break;
}
return false;
}
return false;
}
- bool preNrColor(uint32_t parameter) const {
+ bool preNrStep(uint32_t s) const {
if(!runtimeNodeOrder||!fixedExecutionPlan||(nrBeforeSr&&!splitNrAcrossSr()))return false;
using engine::EffectType;
bool afterSr=false;
@@ -260,18 +302,18 @@ struct EnhanceGraphDesc {
const auto& step=fixedExecutionPlan->steps[i];
if(step.type==EffectType::NrEnhance&&afterSr)return false;
if(step.type==EffectType::SuperResolution)afterSr=true;
- if(step.type!=EffectType::Color||step.parameterIndex!=parameter)continue;
- if(!afterSr)return false;
+ if(i!=s)continue;
+ if(!samePass(step.type)||!afterSr)return false;
for(uint32_t j=i+1;j<fixedExecutionPlan->stepCount&&j<fixedExecutionPlan->steps.size();++j)
if(fixedExecutionPlan->steps[j].type==EffectType::NrEnhance)return true;
return false;
}
return false;
}
- // Compact NR resource ordinal consuming this grade. Only a contiguous
- // NR -> [Protection] -> Color(s) -> NR segment is admitted here.
+ // Compact NR resource ordinal consuming this step. Only a contiguous
+ // NR -> [Protection] -> same-size pass(es) -> NR segment is admitted here.
// Crossing SR needs a separate boundary, not a relaxed rank check.
- uint32_t interNrColorTarget(uint32_t parameter) const {
+ uint32_t interNrStepTarget(uint32_t s) const {
if(!runtimeNodeOrder||!fixedExecutionPlan)return engine::kMaxNrInstances;
using engine::EffectType;
const auto& plan=*fixedExecutionPlan;
@@ -279,31 +321,28 @@ struct EnhanceGraphDesc {
for(uint32_t i=0;i<plan.stepCount&&i<plan.steps.size();++i){
const auto& step=plan.steps[i];
if(step.type==EffectType::NrEnhance)afterNr=true;
- else if(step.type!=EffectType::Color&&
+ else if(!samePass(step.type)&&
!(step.type==EffectType::Protection&&interNrProtectionTarget()<engine::kMaxNrInstances))afterNr=false;
- if(step.type!=EffectType::Color||step.parameterIndex!=parameter)continue;
- if(!afterNr)return engine::kMaxNrInstances;
+ if(i!=s)continue;
+ if(!samePass(step.type)||!afterNr)return engine::kMaxNrInstances;
for(uint32_t j=i+1;j<plan.stepCount&&j<plan.steps.size();++j){
const auto& next=plan.steps[j];
if(next.type==EffectType::NrEnhance)return next.resourceIndex;
- if(next.type!=EffectType::Color)break;
+ if(!samePass(next.type))break;
}
return engine::kMaxNrInstances;
}
return engine::kMaxNrInstances;
}
- bool nodeColor(uint32_t parameter) const {
- return preNrColor(parameter)||preSrColor(parameter)||tailColor(parameter)||interNrColorTarget(parameter)<engine::kMaxNrInstances;
- }
- bool tailColor(uint32_t parameter) const {
+ bool tailStep(uint32_t s) const {
if(!runtimeNodeOrder||!fixedExecutionPlan)return false;
using engine::EffectType;
bool afterBase=false;
for(uint32_t i=0;i<fixedExecutionPlan->stepCount&&i<fixedExecutionPlan->steps.size();++i){
const auto& step=fixedExecutionPlan->steps[i];
if(step.type==EffectType::SuperResolution||step.type==EffectType::NrEnhance||step.type==EffectType::Protection)afterBase=true;
- if(step.type!=EffectType::Color||step.parameterIndex!=parameter)continue;
- if(!afterBase)return false;
+ if(i!=s)continue;
+ if(!samePass(step.type)||!afterBase)return false;
for(uint32_t j=i+1;j<fixedExecutionPlan->stepCount&&j<fixedExecutionPlan->steps.size();++j){
const auto type=fixedExecutionPlan->steps[j].type;
if(type==EffectType::SuperResolution||type==EffectType::NrEnhance||type==EffectType::Protection)return false;
@@ -312,6 +351,44 @@ struct EnhanceGraphDesc {
}
return false;
}
+ // Where a plan step runs. `interTarget` receives the NR resource of an InterNr step.
+ bool sourcePostActive() const {
+ if(!fixedExecutionPlan)return false;
+ for(uint32_t i=0;i<fixedExecutionPlan->stepCount&&i<fixedExecutionPlan->steps.size();++i)
+ if(slotOfStep(i)==PassSlot::SourcePost)return true;
+ return false;
+ }
+ PassSlot slotOfStep(uint32_t s,uint32_t* interTarget=nullptr) const {
+ using engine::EffectType;
+ if(!fixedExecutionPlan||s>=fixedExecutionPlan->stepCount||s>=fixedExecutionPlan->steps.size())return PassSlot::None;
+ const auto type=fixedExecutionPlan->steps[s].type;
+ if(!samePass(type))return PassSlot::None;
+ if(!runtimeNodeOrder){
+ // List mode: the grade is fused into the input conversion, anti-aliasing
+ // follows at source size, beauty follows the whole NR group.
+ if(type==EffectType::Color)return PassSlot::Ingress;
+ if(type==EffectType::AntiAliasing)return PassSlot::SourcePost;
+ return nrBeforeSr?PassSlot::PreSr:PassSlot::Tail;
+ }
+ if(sourcePostStep(s))return PassSlot::SourcePost;
+ if(preNrStep(s))return PassSlot::PreNr;
+ if(preSrStep(s))return PassSlot::PreSr;
+ if(const auto target=interNrStepTarget(s);target<engine::kMaxNrInstances){if(interTarget)*interTarget=target;return PassSlot::InterNr;}
+ if(tailStep(s))return PassSlot::Tail;
+ return type==EffectType::Color?PassSlot::Ingress:PassSlot::None;
+ }
+ // Color wrappers (parameter ordinal), as before.
+ bool preSrColor(uint32_t parameter) const { return preSrStep(planStepOf(engine::EffectType::Color,parameter)); }
+ bool preNrColor(uint32_t parameter) const { return preNrStep(planStepOf(engine::EffectType::Color,parameter)); }
+ uint32_t interNrColorTarget(uint32_t parameter) const { return interNrStepTarget(planStepOf(engine::EffectType::Color,parameter)); }
+ bool tailColor(uint32_t parameter) const { return tailStep(planStepOf(engine::EffectType::Color,parameter)); }
+ bool sourcePostColor(uint32_t parameter) const { return sourcePostStep(planStepOf(engine::EffectType::Color,parameter)); }
+ // A Color that runs as a node pass (its own texture) instead of the fused /
+ // in-place input grade.
+ bool nodeColor(uint32_t parameter) const {
+ return preNrColor(parameter)||preSrColor(parameter)||tailColor(parameter)||sourcePostColor(parameter)||
+ interNrColorTarget(parameter)<engine::kMaxNrInstances;
+ }
std::string_view validateFixedExecutionPlan() const {
if(!fixedExecutionPlanError.empty())return fixedExecutionPlanError;
if(!fixedExecutionPlan)return {};
@@ -331,6 +408,19 @@ struct EnhanceGraphDesc {
const auto& step=plan.steps[i];const auto type=size_t(step.type);
if(type>=counts.size())return "unknown fixed execution stage";
int rank=int(type);
+ if(step.type==EffectType::AntiAliasing){
+ if(step.parameterIndex>=antiAlias.size()||!antiAlias[step.parameterIndex].enabled)
+ return "anti-aliasing parameter index/enabled mismatch";
+ if(!antiAliasExecutor)return "anti-aliasing is not available in this build";
+ }
+ if(step.type==EffectType::Beauty)return "beauty nodes are not available in this build";
+ // Same-size passes take the rank of the slot they run in.
+ PassSlot passSlot=PassSlot::None;
+ if(samePass(step.type)){
+ passSlot=slotOfStep(i);
+ if(passSlot==PassSlot::None)return "same-size node position is not supported by the fixed dispatcher";
+ if(step.type!=EffectType::Color)rank=0; // list mode / source-size slot; node slots below
+ }
if(nrBeforeSr){
if(step.type==EffectType::NrEnhance)rank=1;
if(step.type==EffectType::Protection)rank=2;
@@ -338,14 +428,15 @@ struct EnhanceGraphDesc {
}
if(runtimeNodeOrder){
if(step.type==EffectType::Protection&&interProtection)rank=nrBeforeSr?1:2;
- if(step.type==EffectType::Color){
- if(step.parameterIndex>additionalColorCount||step.parameterIndex>=engine::kMaxColorInstances||
- !(step.parameterIndex?additionalColors[step.parameterIndex-1].enabled:color.enabled))
- return "node Color parameter index/enabled mismatch";
- if(tailColor(step.parameterIndex))rank=4;
- else if(preNrColor(step.parameterIndex))rank=2;
- else if(preSrColor(step.parameterIndex))rank=3;
- else if(interNrColorTarget(step.parameterIndex)<engine::kMaxNrInstances)rank=nrBeforeSr?1:2;
+ if(step.type==EffectType::Color&&
+ (step.parameterIndex>additionalColorCount||step.parameterIndex>=engine::kMaxColorInstances||
+ !(step.parameterIndex?additionalColors[step.parameterIndex-1].enabled:color.enabled)))
+ return "node Color parameter index/enabled mismatch";
+ if(samePass(step.type)){
+ if(passSlot==PassSlot::Tail)rank=4;
+ else if(passSlot==PassSlot::PreNr)rank=2;
+ else if(passSlot==PassSlot::PreSr)rank=3;
+ else if(passSlot==PassSlot::InterNr)rank=nrBeforeSr?1:2;
}
if(step.type==EffectType::VideoHdr)rank=5;
if(step.type==EffectType::FrameGeneration)rank=6;
@@ -357,11 +448,11 @@ struct EnhanceGraphDesc {
}
if(step.type==EffectType::SuperResolution){rank=3;afterSr=true;}
if(step.type==EffectType::NrEnhance)rank=afterSr?4:1;
- if(step.type==EffectType::Color){
- if(tailColor(step.parameterIndex))rank=6;
- else if(preNrColor(step.parameterIndex))rank=4;
- else if(preSrColor(step.parameterIndex))rank=2;
- else if(interNrColorTarget(step.parameterIndex)<engine::kMaxNrInstances)rank=afterSr?4:1;
+ if(samePass(step.type)){
+ if(passSlot==PassSlot::Tail)rank=6;
+ else if(passSlot==PassSlot::PreNr)rank=4;
+ else if(passSlot==PassSlot::PreSr)rank=2;
+ else if(passSlot==PassSlot::InterNr)rank=afterSr?4:1;
}
if(step.type==EffectType::VideoHdr)rank=7;
if(step.type==EffectType::FrameGeneration)rank=8;
@@ -610,7 +701,7 @@ public:
const std::wstring& colorLutNotice() const { return colorLutNotice_; }
// True when the colour stage exists in this graph (master switch on and not
// neutral). The encoder uses it to dither its 8/10-bit conversion output.
- bool colorGradeActive() const { return colorActive_||additionalColorActiveCount_!=0||tailColorActiveCount_!=0||preNrColorActiveCount_!=0||preSrColorActiveCount_!=0||interNrColorActiveCount_!=0; }
+ bool colorGradeActive() const { return colorActive_||additionalColorActiveCount_!=0||tailColorActiveCount_!=0||preNrColorActiveCount_!=0||preSrColorActiveCount_!=0||interNrColorActiveCount_!=0||sourcePostColorActiveCount_!=0; }
// Effective dither step for the 8/10-bit output paths (0 = no dither).
float outputDitherStep() const;
// Isolated diagnostics only: existing constant guidance, borrowed lifetime.
@@ -788,22 +879,38 @@ private:
// resource ordinal. Only enabled non-ingress nodes allocate resources.
std::array<std::unique_ptr<ColorGradeInstance>,engine::kMaxColorInstances> nodeColorInstances_{};
std::array<ComPtr<ID3D12Resource>,engine::kMaxColorInstances> nodeColorOutputs_{};
- unsigned tailColorActiveCount_=0,preNrColorActiveCount_=0,preSrColorActiveCount_=0,interNrColorActiveCount_=0;
+ unsigned tailColorActiveCount_=0,preNrColorActiveCount_=0,preSrColorActiveCount_=0,interNrColorActiveCount_=0,sourcePostColorActiveCount_=0;
+ // Same-size passes per insertion slot, in plan order (EnhanceGraphDesc::slotOfStep).
+ // Each pass reads the previous pass's output; the slot output is the last one.
+ struct SlotPass {uint32_t step=0;engine::EffectType type=engine::EffectType::Color;uint32_t parameter=0;ID3D12Resource* output=nullptr;};
+ std::vector<SlotPass> sourcePostPasses_,preSrPasses_,preNrPasses_,tailPasses_;
+ std::array<std::vector<SlotPass>,engine::kMaxNrInstances> interNrPasses_{};
+ ID3D12Resource* sourcePostOutput_=nullptr; // source size, after the input conversion
+ bool slotPassesActive() const {
+ if(!sourcePostPasses_.empty()||!preSrPasses_.empty()||!preNrPasses_.empty()||!tailPasses_.empty())return true;
+ for(const auto& passes:interNrPasses_)if(!passes.empty())return true;
+ return false;
+ }
+ ID3D12Resource* chainSlotViews(const std::vector<SlotPass>& passes,ID3D12Resource* input,const char* where);
+ bool dispatchSlotPasses(ID3D12GraphicsCommandList* list,const std::vector<SlotPass>& passes,unsigned slot,
+ const char* where,bool log);
bool tailColorExecutionLogged_=false,preNrColorExecutionLogged_=false;
bool preSrColorExecutionLogged_=false;
bool interNrColorExecutionLogged_=false;
+ bool sourcePostExecutionLogged_=false;
ID3D12Resource* tailColorOutput_=nullptr; // borrowed from nodeColorOutputs_
ID3D12Resource* preNrColorOutput_=nullptr;
ID3D12Resource* preSrColorOutput_=nullptr;
std::array<ID3D12Resource*,engine::kMaxNrInstances> interNrColorOutputs_{};
- ID3D12Resource* nrBaseInput() const { return desc_.nrBeforeSr?srcRgba_.Get():(preNrColorOutput_?preNrColorOutput_:workRgba_.Get()); }
+ ID3D12Resource* sourceStageOutput() const { return sourcePostOutput_?sourcePostOutput_:srcRgba_.Get(); }
+ ID3D12Resource* nrBaseInput() const { return desc_.nrBeforeSr?sourceStageOutput():(preNrColorOutput_?preNrColorOutput_:workRgba_.Get()); }
ID3D12Resource* preSrBaseInput() const {
if(preSrProtectionRgba_)return preSrProtectionRgba_.Get();
const auto before=desc_.nrBeforeSrLayerCount();
return desc_.splitNrAcrossSr()&&before<=nrInstances_.size()?nrInstances_[before-1]->fullTarget():residualRgba_.Get();
}
ID3D12Resource* srStageInput() const {
- return preSrColorOutput_?preSrColorOutput_:(desc_.nrBeforeSr?preSrBaseInput():srcRgba_.Get());
+ return preSrColorOutput_?preSrColorOutput_:(desc_.nrBeforeSr?preSrBaseInput():sourceStageOutput());
}
ID3D12Resource* nrLayerBase(size_t layer) const {
if(layer<interNrColorOutputs_.size()&&interNrColorOutputs_[layer])return interNrColorOutputs_[layer];
diff --git a/src/engine/EffectChain.cpp b/src/engine/EffectChain.cpp
index 52703b33..12a8b517 100644
--- a/src/engine/EffectChain.cpp
+++ b/src/engine/EffectChain.cpp
@@ -14,6 +14,9 @@ constexpr std::array<EffectInfo, effectTypeCount> kCatalog{{
{EffectType::Protection, effectTypeName(EffectType::Protection), "NR 保护区域", 1, false, false, false, false, false},
{EffectType::VideoHdr, effectTypeName(EffectType::VideoHdr), "RTX Video HDR", 1, false, false, true, false, false},
{EffectType::FrameGeneration, effectTypeName(EffectType::FrameGeneration), "补帧", 1, false, true, false, false, false},
+ // Hidden until their executors ship; the engine and file formats already know them.
+ {EffectType::AntiAliasing, effectTypeName(EffectType::AntiAliasing), "抗锯齿", kMaxAntiAliasInstances, true, false, false, false, false, true},
+ {EffectType::Beauty, effectTypeName(EffectType::Beauty), "美颜", kMaxBeautyInstances, true, false, false, false, false, true},
}};
} // namespace
@@ -228,7 +231,7 @@ uint32_t removeLegacyNodeProtection(EffectChain& chain, int* selectedNr, int* se
}
ChainValidation validateChain(const EffectChain& chain) {
- if (chain.nodeCount > kMaxChainNodes) return {false, "链路节点过多"};
+ if (chain.nodeCount > kMaxChainNodes || chain.overflow) return {false, "链路节点过多"};
std::array<uint32_t, effectTypeCount> seen{};
uint32_t lastEnabled = kMaxChainNodes; // index of the last enabled node
for (uint32_t i = 0; i < chain.nodeCount; ++i) {
@@ -290,19 +293,27 @@ EffectChain toChain(const EnhancementSettings& settings) {
chain.mode = ChainMode::List;
chain.fgStrictAdmission = settings.fgStrictAdmission;
chain.fgMultiplier = std::max(2u, settings.multiplier);
- auto append = [&chain](EffectType type, bool enabled) -> ChainNode& {
- ChainNode& node = chain.nodes[chain.nodeCount < kMaxChainNodes ? chain.nodeCount : kMaxChainNodes - 1];
- if (chain.nodeCount < kMaxChainNodes) ++chain.nodeCount;
+ // A full chain never overwrites its last node: it is flagged, and validateChain()
+ // refuses it, instead of a stage disappearing (the old 16-node chain did that).
+ ChainNode spill;
+ auto append = [&chain, &spill](EffectType type, bool enabled) -> ChainNode& {
+ if (chain.nodeCount >= kMaxChainNodes) { chain.overflow = true; spill = ChainNode{}; return spill; }
+ ChainNode& node = chain.nodes[chain.nodeCount++];
node = ChainNode{};
node.type = type;
node.enabled = enabled;
return node;
};
// List order is the product order: colour (fused into the ingest shader),
- // SR, NR layers, protection, Video HDR, frame generation.
+ // anti-aliasing (source size), SR, NR layers, protection, Video HDR, frame generation.
append(EffectType::Color, settings.color.enabled).color = settings.color;
for(uint32_t i=0;i<std::min(settings.additionalColorCount,kMaxColorInstances-1);++i)
append(EffectType::Color,settings.additionalColors[i].enabled).color=settings.additionalColors[i];
+ // Untouched anti-aliasing adds no node, so older presets keep their layout.
+ if(settings.antiAlias.configured()||settings.additionalAntiAliasCount)
+ append(EffectType::AntiAliasing,settings.antiAlias.enabled).aa=settings.antiAlias;
+ for(uint32_t i=0;i<std::min(settings.additionalAntiAliasCount,kMaxAntiAliasInstances-1);++i)
+ append(EffectType::AntiAliasing,settings.additionalAntiAlias[i].enabled).aa=settings.additionalAntiAlias[i];
{
ChainNode& sr = append(EffectType::SuperResolution, settings.sr);
// SR has no payload of its own yet: its inputs live in the settings
@@ -338,7 +349,7 @@ std::optional<ChainRuntimeOrder> runtimeOrder(const EffectChain& chain) {
ChainValidation restoreRuntimeOrder(const EnhancementSettings& settings, const ChainRuntimeOrder& order,
EffectChain& output) {
if (order.nodeCount > kMaxChainNodes || settings.nrLayerCount > kMaxNrInstances ||
- settings.additionalColorCount >= kMaxColorInstances)
+ settings.additionalColorCount >= kMaxColorInstances || settings.additionalAntiAliasCount >= kMaxAntiAliasInstances)
return {false, "运行节点顺序或实例数量无效"};
const auto source = toChain(settings);
EffectChain restored;
@@ -359,7 +370,8 @@ ChainValidation restoreRuntimeOrder(const EnhancementSettings& settings, const C
if (used[i]) continue;
const auto& node = source.nodes[i];
if (node.enabled || (node.type == EffectType::NrEnhance && settings.nrLayerCount) ||
- (node.type == EffectType::Color && settings.additionalColorCount))
+ (node.type == EffectType::Color && settings.additionalColorCount) ||
+ (node.type == EffectType::AntiAliasing && settings.additionalAntiAliasCount))
return {false, "运行节点顺序遗漏实例参数"};
}
const auto valid = validateChain(restored);
@@ -375,6 +387,10 @@ void fromChain(const EffectChain& chain, EnhancementSettings& settings) {
settings.additionalColors = {};
settings.additionalColorCount = 0;
bool firstColor = true;
+ settings.antiAlias = {};
+ settings.additionalAntiAlias = {};
+ settings.additionalAntiAliasCount = 0;
+ bool firstAntiAlias = true;
settings.sr = false;
settings.nr = false;
settings.nrLayers = {};
@@ -436,6 +452,19 @@ void fromChain(const EffectChain& chain, EnhancementSettings& settings) {
case EffectType::FrameGeneration:
settings.multiplier = node.enabled ? std::max(2u, chain.fgMultiplier) : 1;
break;
+ case EffectType::AntiAliasing:
+ if(firstAntiAlias){
+ settings.antiAlias=node.aa;
+ settings.antiAlias.enabled=node.enabled;
+ firstAntiAlias=false;
+ }else if(settings.additionalAntiAliasCount<settings.additionalAntiAlias.size()){
+ auto& aa=settings.additionalAntiAlias[settings.additionalAntiAliasCount++];
+ aa=node.aa;
+ aa.enabled=node.enabled;
+ }
+ break;
+ case EffectType::Beauty: // reserved: no executor or settings yet
+ break;
case EffectType::Count:
break;
}
@@ -492,11 +521,13 @@ ChainValidation compileChainExecutionPlan(const EffectChain& chain, const ChainE
if (chain.mode == ChainMode::Node) {
for (uint32_t i = 0; i < chain.nodeCount; ++i) append(i);
} else {
+ // Anti-aliasing always runs at source size, ahead of any enlargement; beauty
+ // follows the whole NR group (with its protection), ahead of SR when NR goes first.
const std::array<EffectType, effectTypeCount> order = nrFirst
- ? std::array{EffectType::Color, EffectType::NrEnhance, EffectType::Protection,
- EffectType::SuperResolution, EffectType::VideoHdr, EffectType::FrameGeneration}
- : std::array{EffectType::Color, EffectType::SuperResolution, EffectType::NrEnhance,
- EffectType::Protection, EffectType::VideoHdr, EffectType::FrameGeneration};
+ ? std::array{EffectType::Color, EffectType::AntiAliasing, EffectType::NrEnhance, EffectType::Protection,
+ EffectType::Beauty, EffectType::SuperResolution, EffectType::VideoHdr, EffectType::FrameGeneration}
+ : std::array{EffectType::Color, EffectType::AntiAliasing, EffectType::SuperResolution, EffectType::NrEnhance,
+ EffectType::Protection, EffectType::Beauty, EffectType::VideoHdr, EffectType::FrameGeneration};
for (const auto type : order)
for (uint32_t i = 0; i < chain.nodeCount; ++i)
if (chain.nodes[i].type == type) append(i);
@@ -657,6 +688,11 @@ bool requiresGraphRebuild(const EnhancementSettings& savedPrevious, const Enhanc
if (previous.color.lutNameString() != next.color.lutNameString()) return true;
// The LUT's input space changes which table the colour stage binds.
if (previous.color.lutInputSpace != next.color.lutInputSpace) return true;
+ // Anti-aliasing: method, tier and temporal mode decide the passes and textures.
+ if(previous.additionalAntiAliasCount!=next.additionalAntiAliasCount)return true;
+ if(!previous.antiAlias.sameStructure(next.antiAlias))return true;
+ for(uint32_t i=0;i<std::min(next.additionalAntiAliasCount,kMaxAntiAliasInstances-1);++i)
+ if(!previous.additionalAntiAlias[i].sameStructure(next.additionalAntiAlias[i]))return true;
if(previous.additionalColorCount!=next.additionalColorCount)return true;
for(uint32_t i=0;i<std::min(next.additionalColorCount,kMaxColorInstances-1);++i){
const auto& a=previous.additionalColors[i];
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index b3685551..b70d7680 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -758,7 +758,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
const bool admitted=(tested||(autoRequested&&automatic==desc.nrLayersSizePolicy.begin()&&selected.settings.activeAutoNrLayerCount()==1))&&
!nrAutoPoolUnavailable&&selected.settings.activeNrLayerCount()<=2&&
!isCapture&&!isImage&&desc.enableNr&&!desc.enableSr&&!desc.enableFg&&
- !desc.hdrWorking()&&!desc.videoHdr.enabled&&!desc.color.enabled&&!desc.additionalColorCount&&!desc.runtimeNodeOrder&&desc.nrHoldStrength==0&&
+ !desc.hdrWorking()&&!desc.videoHdr.enabled&&!desc.color.enabled&&!desc.additionalColorCount&&!desc.antiAliasActive()&&!desc.runtimeNodeOrder&&desc.nrHoldStrength==0&&
currentNrRuntime(desc.nrRuntime)==NrRuntime::Ampere&&desc.opticalFlowBackend==OpticalFlowBackend::Nvidia&&
desc.nrMotion==MotionSource::OpticalFlow&&
nvidiaAdapter&&ctx.adapter().deviceId==0x2f04&&desc.workWidth==1920&&desc.workHeight==1080&&
diff --git a/src/engine/EngineControllerImage.cpp b/src/engine/EngineControllerImage.cpp
index 911ced76..cc8ba40c 100644
--- a/src/engine/EngineControllerImage.cpp
+++ b/src/engine/EngineControllerImage.cpp
@@ -1,4 +1,5 @@
#include "veyra/engine/EngineController.h"
+#include "veyra/engine/GraphDescription.h"
#include "veyra/engine/TiledImageProcessor.h"
#include "veyra/engine/VideoPresenter.h"
#include "veyra/gfx/CommandSlotRing.h"
@@ -67,6 +68,7 @@ void EngineController::runLargeImage(HWND window,const sink::RgbaImage& original
pipeline::EnhanceGraphDesc desc;desc.enableNr=requested.nr;desc.nrRuntime=requested.nrRuntime;desc.noFeatures=!requested.nr;
desc.model=requested.model;desc.nrTemporal=requested.nrTemporal;desc.residual=requested.residual;desc.protection=requested.protection;desc.color=requested.color;desc.settingsRevision=requested.revision;
desc.additionalColors=requested.additionalColors;desc.additionalColorCount=requested.additionalColorCount;
+ describeAntiAlias(requested,desc);
desc.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();
sink::RgbaImage candidate;TiledImageProcessor::Stats stats;
status(L"正在分块增强大图,保留完整输出尺寸…");
diff --git a/src/engine/ExportJobManager.cpp b/src/engine/ExportJobManager.cpp
index 344a8319..03e3cf67 100644
--- a/src/engine/ExportJobManager.cpp
+++ b/src/engine/ExportJobManager.cpp
@@ -30,7 +30,7 @@ struct Shared {
// chain is fixed-capacity and trivially copyable, so it can cross the
// process boundary; a worker that sees another version refuses the job
// instead of reading a mismatched layout.
- DWORD signature=magic,version=9,bytes=sizeof(Shared); // 9: per-NR performance model in the immutable snapshot
+ DWORD signature=magic,version=10,bytes=sizeof(Shared); // 10: 32-node chain with anti-aliasing / beauty payloads
EnhancementSettings settings;
EffectChain chain;
wchar_t input[32768]{},output[32768]{},temporary[32768]{};
@@ -254,7 +254,7 @@ int runExportWorker(HANDLE mapping){
if(!s){log::error("export-worker",std::format("mapping failed win32={}",GetLastError()));CloseHandle(mapping);return 1;}
auto reject=[&](const wchar_t* reason){
log::error("export-worker",utf8(reason));
- if(s->signature==magic&&s->version==9&&s->bytes==sizeof(Shared)){
+ if(s->signature==magic&&s->version==10&&s->bytes==sizeof(Shared)){
if(InterlockedCompareExchange(&s->messageLock,1,0)==0){
wcsncpy_s(s->message,reason,_TRUNCATE);
InterlockedExchange(&s->messageLock,0);
@@ -263,7 +263,7 @@ int runExportWorker(HANDLE mapping){
}
UnmapViewOfFile(s);CloseHandle(mapping);return 1;
};
- if(s->signature!=magic||s->version!=9||s->bytes!=sizeof(Shared))return reject(L"导出任务通信协议不匹配");
+ if(s->signature!=magic||s->version!=10||s->bytes!=sizeof(Shared))return reject(L"导出任务通信协议不匹配");
if(const auto error=s->settings.validate();!error.empty()){
log::error("export-worker",std::format("invalid frozen settings: {}",error));
return reject(L"导出任务的增强参数无效,请查看任务日志中的具体参数错误");
diff --git a/src/engine/PresetLibrary.cpp b/src/engine/PresetLibrary.cpp
index f6df79c7..740a6014 100644
--- a/src/engine/PresetLibrary.cpp
+++ b/src/engine/PresetLibrary.cpp
@@ -93,6 +93,7 @@ void PresetLibrary::addBuiltins() {
bool PresetLibrary::load() {
error_.clear();
addBuiltins();
+ const auto directEffects=std::filesystem::path(path_).concat(L".effects");
const auto directNr=std::filesystem::path(path_).concat(L".nr-model");
const auto directDlss=std::filesystem::path(path_).concat(L".dlss-sr");
const auto directHdr=std::filesystem::path(path_).concat(L".hdr-output");
@@ -124,6 +125,9 @@ bool PresetLibrary::load() {
const auto nrPath=std::filesystem::path(path_).concat(L".nr-model");
if(std::filesystem::exists(directNr))path_=directNr;
else if(std::filesystem::exists(nrPath))path_=nrPath;
+ const auto effectsPath=std::filesystem::path(path_).concat(L".effects");
+ if(std::filesystem::exists(directEffects))path_=directEffects;
+ else if(std::filesystem::exists(effectsPath))path_=effectsPath;
if (!std::filesystem::exists(path_)) return true;
std::error_code ec;
const auto size = std::filesystem::file_size(path_, ec);
@@ -218,6 +222,9 @@ bool PresetLibrary::save() {
// Match PresetStore: never replace a valid file with one our reader rejects.
if (!parse(data, checked, checkedDefault, error_)) return false;
// Opting into a new model must leave the older build's library intact.
+ // v14 (anti-aliasing / beauty nodes, chains past 16 nodes) gets its own file too.
+ if(data.starts_with("VEYRA_PRESET_LIBRARY 14")&&!path_.wstring().ends_with(L".effects"))path_=std::filesystem::path(path_).concat(L".effects");
+ if(!path_.wstring().ends_with(L".effects")){
if(data.starts_with("VEYRA_PRESET_LIBRARY 13")&&!path_.wstring().ends_with(L".nr-model"))path_=std::filesystem::path(path_).concat(L".nr-model");
if(!path_.wstring().ends_with(L".nr-model")){
if(data.starts_with("VEYRA_PRESET_LIBRARY 12")&&!path_.wstring().ends_with(L".dlss-sr"))path_=std::filesystem::path(path_).concat(L".dlss-sr");
@@ -239,6 +246,7 @@ bool PresetLibrary::save() {
}
}
}
+ }
std::error_code ec;
std::filesystem::create_directories(path_.parent_path(), ec);
const auto temporary = std::filesystem::path(path_).concat(L".tmp");
@@ -507,10 +515,11 @@ ChainValidation PresetLibrary::applyToEditor(const PresetEntry& entry, NodeEdito
const auto rank = [](const ChainNode& n) {
switch (n.type) {
case EffectType::Color: return 0;
- case EffectType::SuperResolution: return 1;
- case EffectType::NrEnhance: return 2;
- case EffectType::VideoHdr: return 3;
- default: return 4;
+ case EffectType::AntiAliasing: return 1;
+ case EffectType::SuperResolution: return 2;
+ case EffectType::NrEnhance: case EffectType::Beauty: return 3;
+ case EffectType::VideoHdr: return 4;
+ default: return 5;
}
};
std::stable_sort(nodes.nodes.begin(), nodes.nodes.begin() + nodes.nodeCount,
@@ -671,7 +680,14 @@ std::string PresetLibrary::encodeEntries(const std::vector<PresetEntry>& entries
const bool nrModel=std::any_of(entries_.begin(),entries_.end(),[&](const auto& e){
return oldModel(e.chain)||(e.nodeConfiguration&&(oldModel(e.nodeConfiguration->chain)||
(e.nodeConfiguration->editor&&oldModel(e.nodeConfiguration->editor->nodes))));});
- const int version=std::max(minimumVersion, nrModel?13:dlss?12:tuning?11:flow?10:correctionExtended?9:correction?8:vfg?7:rendering?6:globals?5:editor?4:layerSizes?3:multi?2:1);
+ // v14: anti-aliasing / beauty nodes, or a chain longer than the old 16 nodes.
+ const auto effectNodes=[](const EffectChain& chain){
+ return chain.nodeCount>16||std::any_of(chain.nodes.begin(),chain.nodes.begin()+chain.nodeCount,[](const auto& n){
+ return n.type==EffectType::AntiAliasing||n.type==EffectType::Beauty;});};
+ const bool effects=std::any_of(entries_.begin(),entries_.end(),[&](const auto& e){
+ return effectNodes(e.chain)||(e.nodeConfiguration&&(effectNodes(e.nodeConfiguration->chain)||
+ (e.nodeConfiguration->editor&&effectNodes(e.nodeConfiguration->editor->nodes))));});
+ const int version=std::max(minimumVersion, effects?14:nrModel?13:dlss?12:tuning?11:flow?10:correctionExtended?9:correction?8:vfg?7:rendering?6:globals?5:editor?4:layerSizes?3:multi?2:1);
o << "VEYRA_PRESET_LIBRARY " << version << '\n' << std::quoted(utf8(defaultName_)) << ' ' << entries_.size() << '\n';
for (const auto& e : entries_) {
o << std::quoted(utf8(e.name)) << ' ' << std::quoted(utf8(e.note)) << ' '
@@ -702,6 +718,10 @@ std::string PresetLibrary::encodeEntries(const std::vector<PresetEntry>& entries
writeColorSettings(o, n.color, utf8(n.color.lutNameString()));
o << ' ';
}
+ if (version>=14 && n.type == EffectType::AntiAliasing) {
+ writeAntiAlias(o, n.aa);
+ o << ' ';
+ }
}
o << ' ';
writeColorSettings(o, e.color, utf8(e.color.lutNameString()));
@@ -736,7 +756,7 @@ bool PresetLibrary::parse(const std::string& data, std::vector<PresetEntry>& out
std::string magic, quoted;
int version = 0;
size_t count = 0;
- const int allowedVersion=maxVersion>0?std::min(maxVersion,13):13;
+ const int allowedVersion=maxVersion>0?std::min(maxVersion,14):14;
if (!(in >> magic >> version) || magic != "VEYRA_PRESET_LIBRARY" || version < 1 || version > allowedVersion) { error = L"预设库格式或版本不支持"; return false; }
if (!(in >> std::quoted(quoted) >> count) || count > 64) { error = L"预设库条目数非法"; return false; }
def = wide(quoted);
@@ -779,7 +799,8 @@ bool PresetLibrary::parse(const std::string& data, std::vector<PresetEntry>& out
if (r.left > r.right) { std::swap(r.left, r.right); r.ellipse = true; }
}
if (!(in >> hdrEnabled >> node.videoHdr.contrast >> node.videoHdr.saturation >> node.videoHdr.middleGray >> node.videoHdr.peakNits)) { error = L"预设库 HDR 字段损坏"; return false; }
- if (type < 0 || type >= int(EffectType::Count) || enabled < 0 || enabled > 1 || !validNrRuntime(static_cast<NrRuntime>(runtime)) ||
+ if (type < 0 || type >= int(EffectType::Count) || (version < 14 && type >= int(EffectType::AntiAliasing)) ||
+ enabled < 0 || enabled > 1 || !validNrRuntime(static_cast<NrRuntime>(runtime)) ||
temporal < 0 || temporal > 1 || lowLatency < 0 || lowLatency > 1 || protEnabled < 0 || protEnabled > 1 || hdrEnabled < 0 || hdrEnabled > 1) {
error = L"预设库节点取值超出范围"; return false;
}
@@ -805,6 +826,9 @@ bool PresetLibrary::parse(const std::string& data, std::vector<PresetEntry>& out
error = L"预设库节点调色参数损坏"; return false;
}
}
+ if (version >= 14 && node.type == EffectType::AntiAliasing && !readAntiAlias(in, node.aa)) {
+ error = L"预设库节点抗锯齿参数损坏"; return false;
+ }
}
in >> std::ws;
std::string lut;
@@ -883,7 +907,12 @@ std::string ChainSessionStore::encode(const ChainSession& session) {
return n.type==EffectType::NrEnhance&&!n.nr.model.performance;});};
const bool nrModel=std::any_of(session.configurations.begin(),session.configurations.end(),[&](const auto& c){
return oldModel(c.chain)||(c.editor&&oldModel(c.editor->nodes));});
- const int version = nrModel?8:dlss?7:tuning?6:vfg?5:rendering?4:editor ? (editor->globals ? 3 : 2) : 1;
+ const auto effectNodes=[](const EffectChain& chain){
+ return chain.nodeCount>16||std::any_of(chain.nodes.begin(),chain.nodes.begin()+chain.nodeCount,[](const auto& n){
+ return n.type==EffectType::AntiAliasing||n.type==EffectType::Beauty;});};
+ const bool effects=std::any_of(session.configurations.begin(),session.configurations.end(),[&](const auto& c){
+ return effectNodes(c.chain)||(c.editor&&effectNodes(c.editor->nodes));});
+ const int version = effects?9:nrModel?8:dlss?7:tuning?6:vfg?5:rendering?4:editor ? (editor->globals ? 3 : 2) : 1;
out << "VEYRA_CHAIN_SESSION " << version << '\n' << int(session.active) << ' ' << session.initialized[0] << ' ' << session.initialized[1];
if(version>=4)out<<' '<<bool(editor);out<<'\n';
std::vector<PresetEntry> entries;
@@ -937,7 +966,7 @@ bool ChainSessionStore::decode(const std::string& data, ChainSession& session, b
std::istringstream in(data); in.imbue(std::locale::classic());
std::string magic, body; int version = 0, active = 0, list = 0, node = 0;
if (!(in >> magic >> version >> active >> list >> node) || magic != "VEYRA_CHAIN_SESSION" ||
- (version < 1 || version > 8) || active < 0 || active > 1 || list != 1 || node < 0 || node > 1) return false;
+ (version < 1 || version > 9) || active < 0 || active > 1 || list != 1 || node < 0 || node > 1) return false;
int hasEditor=version>=2?1:0;
if(version>=4&&(!(in>>hasEditor)||hasEditor<0||hasEditor>1))return false;
ChainSession parsed; parsed.active = ChainMode(active); parsed.initialized = {true, node != 0};
@@ -952,7 +981,7 @@ bool ChainSessionStore::decode(const std::string& data, ChainSession& session, b
}
if (!(in >> std::quoted(body))) return false;
std::vector<PresetEntry> entries; std::wstring def, error;
- if (!PresetLibrary::parse(body, entries, def, error, nullptr, true, version>=8?13:11) || entries.size() != 2 || !def.empty()) return false;
+ if (!PresetLibrary::parse(body, entries, def, error, nullptr, true, version>=9?14:version>=8?13:11) || entries.size() != 2 || !def.empty()) return false;
for (size_t i = 0; i < entries.size(); ++i) {
if (entries[i].kind != ChainMode(i)) return false;
parsed.configurations[i].chain = entries[i].chain;
@@ -986,7 +1015,7 @@ bool ChainSessionStore::decode(const std::string& data, ChainSession& session, b
}
if (!(in >> std::quoted(body))) return false;
entries.clear(); def.clear(); error.clear();
- if (!PresetLibrary::parse(body, entries, def, error, nullptr, true, version>=8?13:11) || entries.size() != 1 ||
+ if (!PresetLibrary::parse(body, entries, def, error, nullptr, true, version>=9?14:version>=8?13:11) || entries.size() != 1 ||
!def.empty() || entries[0].kind != ChainMode::Node || entries[0].chain.nodeCount != count) return false;
editor->nodes = std::move(entries[0].chain);
for (uint32_t i = 0; i < count; ++i) {
@@ -1003,6 +1032,7 @@ bool ChainSessionStore::decode(const std::string& data, ChainSession& session, b
}
bool ChainSessionStore::load(ChainSession& session) {
+ const auto directEffects=std::filesystem::path(path_).concat(L".effects");
const auto directNr=std::filesystem::path(path_).concat(L".nr-model");
const auto directDlss=std::filesystem::path(path_).concat(L".dlss-sr");
error_.clear();
@@ -1032,6 +1062,9 @@ bool ChainSessionStore::load(ChainSession& session) {
const auto nrPath=std::filesystem::path(path_).concat(L".nr-model");
if(std::filesystem::exists(directNr,ec))path_=directNr;
else if(std::filesystem::exists(nrPath,ec))path_=nrPath;
+ const auto effectsPath=std::filesystem::path(path_).concat(L".effects");
+ if(std::filesystem::exists(directEffects,ec))path_=directEffects;
+ else if(std::filesystem::exists(effectsPath,ec))path_=effectsPath;
const bool exists = std::filesystem::exists(path_, ec);
if (!exists && !ec) return true;
const auto size = std::filesystem::file_size(path_, ec);
@@ -1061,6 +1094,8 @@ bool ChainSessionStore::save(const ChainSession& session) {
const auto data = encode(session);
ChainSession checked;
if (!decode(data, checked)) { error_ = L"模式会话编码校验失败,未保存"; return false; }
+ if(data.starts_with("VEYRA_CHAIN_SESSION 9")&&!path_.wstring().ends_with(L".effects"))path_=std::filesystem::path(path_).concat(L".effects");
+ if(!path_.wstring().ends_with(L".effects")){
if(data.starts_with("VEYRA_CHAIN_SESSION 8")&&!path_.wstring().ends_with(L".nr-model"))path_=std::filesystem::path(path_).concat(L".nr-model");
if(!path_.wstring().ends_with(L".nr-model")){
if(data.starts_with("VEYRA_CHAIN_SESSION 7")&&!path_.wstring().ends_with(L".dlss-sr"))path_=std::filesystem::path(path_).concat(L".dlss-sr");
@@ -1082,6 +1117,7 @@ bool ChainSessionStore::save(const ChainSession& session) {
}
}
}
+ }
std::error_code ec;
if (!path_.parent_path().empty()) std::filesystem::create_directories(path_.parent_path(), ec);
if (ec) { error_ = L"模式会话目录无法创建"; return false; }
diff --git a/src/engine/PreviewGpuSession.cpp b/src/engine/PreviewGpuSession.cpp
index ed4ec163..cfdcc038 100644
--- a/src/engine/PreviewGpuSession.cpp
+++ b/src/engine/PreviewGpuSession.cpp
@@ -25,6 +25,7 @@ bool PreviewGpuSession::requestAllowed(const EnhancementSettings& settings){
return settings.validate().empty()&&(settings.nr||settings.sr)&&settings.multiplier==1&&
currentNrRuntime(settings.nrRuntime)==NrRuntime::Ampere&&settings.activeNrLayerCount()<=1&&!settings.activeAutoNrLayerCount()&&
!settings.videoHdr.enabled&&!settings.color.enabled&&settings.additionalColorCount==0&&
+ !settings.antiAlias.enabled&&settings.additionalAntiAliasCount==0&&
(settings.videoSrQuality==0||settings.videoSrQuality==4);
}
bool PreviewGpuSession::computeAllowed(const gfx::AdapterInfo& adapter,const pipeline::EnhanceGraphDesc& desc){
@@ -37,7 +38,7 @@ bool PreviewGpuSession::computeAllowed(const gfx::AdapterInfo& adapter,const pip
desc.nrRuntime==NrRuntime::Original&&desc.nrLayersExtent.size()==2&&
desc.nrLayersExtent[0]==pipeline::Extent{1920,1080}&&desc.nrLayersExtent[1]==pipeline::Extent{1920,1080}&&
!desc.nrBeforeSr&&!desc.runtimeNodeOrder&&!desc.hdrInput&&!desc.hdrOutput&&!desc.videoHdr.enabled&&
- !desc.color.enabled&&!desc.additionalColorCount&&!desc.nrHoldStrength&&
+ !desc.color.enabled&&!desc.additionalColorCount&&!desc.antiAliasActive()&&!desc.nrHoldStrength&&
!desc.nrTemporal&&std::none_of(desc.nrLayersTemporal.begin(),desc.nrLayersTemporal.end(),[](bool enabled){return enabled;})&&
desc.opticalFlowBackend==OpticalFlowBackend::Nvidia&&desc.enableFg&&
desc.frameGenerationBackend==FrameGenerationBackend::Dlss&&(desc.fgMultiplier==2||desc.fgMultiplier==3);
diff --git a/src/engine/TiledImageProcessor.cpp b/src/engine/TiledImageProcessor.cpp
index 26a2ef28..7db59d4d 100644
--- a/src/engine/TiledImageProcessor.cpp
+++ b/src/engine/TiledImageProcessor.cpp
@@ -61,6 +61,9 @@ bool TiledImageProcessor::process(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotR
// (or a nonempty additional chain) before the first tile is processed.
tileSettings.color=desc.color;tileSettings.additionalColors=desc.additionalColors;
tileSettings.additionalColorCount=desc.additionalColorCount;
+ tileSettings.antiAlias=desc.antiAlias[0];
+ for(uint32_t i=1;i<kMaxAntiAliasInstances;++i)
+ if(desc.antiAlias[i].configured()){tileSettings.additionalAntiAlias[i-1]=desc.antiAlias[i];tileSettings.additionalAntiAliasCount=i;}
for(auto& q:tileSettings.protection.regions){
// A rectangle clipped to the tile is the same rectangle; an ellipse
// clipped would be a different ellipse, so it keeps its full box.
diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cpp
index 93555ca0..1a5ae23f 100644
--- a/src/pipeline/EnhanceGraph.cpp
+++ b/src/pipeline/EnhanceGraph.cpp
@@ -338,37 +338,86 @@ bool EnhanceGraph::createAdditionalColorResources(){
}
bool EnhanceGraph::createNodeColorResources(){
- tailColorActiveCount_=preNrColorActiveCount_=preSrColorActiveCount_=interNrColorActiveCount_=0;
- preSrColorOutput_=nullptr;
+ using PassSlot=EnhanceGraphDesc::PassSlot;
+ tailColorActiveCount_=preNrColorActiveCount_=preSrColorActiveCount_=interNrColorActiveCount_=sourcePostColorActiveCount_=0;
+ preSrColorOutput_=preNrColorOutput_=sourcePostOutput_=nullptr;
interNrColorOutputs_={};
- if(!desc_.runtimeNodeOrder||!desc_.fixedExecutionPlan)return true;
+ sourcePostPasses_.clear();preSrPasses_.clear();preNrPasses_.clear();tailPasses_.clear();
+ for(auto& passes:interNrPasses_)passes.clear();
+ if(!desc_.fixedExecutionPlan)return true;
const auto& plan=*desc_.fixedExecutionPlan;
for(uint32_t i=0;i<plan.stepCount;++i){
const auto& step=plan.steps[i];
- if(step.type!=engine::EffectType::Color||!desc_.nodeColor(step.parameterIndex))continue;
+ uint32_t target=engine::kMaxNrInstances;
+ const auto where=desc_.slotOfStep(i,&target);
+ // Ingress: the fused / in-place grade of the input conversion (createColorResources).
+ if(where==PassSlot::None||where==PassSlot::Ingress)continue;
const auto parameter=step.parameterIndex;
- const auto& settings=parameter?desc_.additionalColors[parameter-1]:desc_.color;
- auto& instance=nodeColorInstances_[parameter];
- instance=std::make_unique<ColorGradeInstance>();
- if(!instance->initialize(context_.device(),ring_.slotCount()))return false;
- instance->refresh(settings);
- if(settings.hasLut()){
- const bool mismatch=desc_.hdrWorking()?settings.lutInputSpace==engine::ColorSettings::kLutInputSrgb:settings.lutInputSpace==engine::ColorSettings::kLutInputPq;
- engine::ColorLutData lut;
- const engine::ColorLutStore store(runtime::localDataDirectory());
- if(mismatch||!store.resolve(settings.lutNameString(),lut)||!lut.valid()||!instance->setLut(context_.device(),lut.rgb.data(),unsigned(lut.size))){
- colorLutNotice_+=std::format(L" 调色实例 {} LUT 未加载:{};其他调色继续。",parameter+1,mismatch?L"输入空间不匹配":L"资源不可用");
- veyra::log::warn("color-grade",std::format("node instance={} lut rejected mismatch={} name={}",parameter,mismatch,utf8Of(settings.lutNameString())));
+ SlotPass pass{i,step.type,parameter,nullptr};
+ if(step.type==engine::EffectType::Color){
+ const auto& settings=parameter?desc_.additionalColors[parameter-1]:desc_.color;
+ auto& instance=nodeColorInstances_[parameter];
+ instance=std::make_unique<ColorGradeInstance>();
+ if(!instance->initialize(context_.device(),ring_.slotCount()))return false;
+ instance->refresh(settings);
+ if(settings.hasLut()){
+ const bool mismatch=desc_.hdrWorking()?settings.lutInputSpace==engine::ColorSettings::kLutInputSrgb:settings.lutInputSpace==engine::ColorSettings::kLutInputPq;
+ engine::ColorLutData lut;
+ const engine::ColorLutStore store(runtime::localDataDirectory());
+ if(mismatch||!store.resolve(settings.lutNameString(),lut)||!lut.valid()||!instance->setLut(context_.device(),lut.rgb.data(),unsigned(lut.size))){
+ colorLutNotice_+=std::format(L" 调色实例 {} LUT 未加载:{};其他调色继续。",parameter+1,mismatch?L"输入空间不匹配":L"资源不可用");
+ veyra::log::warn("color-grade",std::format("node instance={} lut rejected mismatch={} name={}",parameter,mismatch,utf8Of(settings.lutNameString())));
+ }
}
+ nodeColorOutputs_[parameter]=makeTexture(context_.device(),step.output.width,step.output.height,DXGI_FORMAT_R16G16B16A16_FLOAT,true);
+ if(!nodeColorOutputs_[parameter])return false;
+ pass.output=nodeColorOutputs_[parameter].Get();
+ if(where==PassSlot::PreNr)++preNrColorActiveCount_;
+ else if(where==PassSlot::PreSr)++preSrColorActiveCount_;
+ else if(where==PassSlot::InterNr)++interNrColorActiveCount_;
+ else if(where==PassSlot::SourcePost)++sourcePostColorActiveCount_;
+ else ++tailColorActiveCount_;
+ }else{
+ veyra::log::error("graph",std::format("no executor for same-size {} step={}",engine::effectTypeName(step.type),i));
+ return false;
}
- nodeColorOutputs_[parameter]=makeTexture(context_.device(),step.output.width,step.output.height,DXGI_FORMAT_R16G16B16A16_FLOAT,true);
- if(!nodeColorOutputs_[parameter])return false;
- if(desc_.preNrColor(parameter)){++preNrColorActiveCount_;preNrColorOutput_=nodeColorOutputs_[parameter].Get();}
- else if(desc_.preSrColor(parameter)){++preSrColorActiveCount_;preSrColorOutput_=nodeColorOutputs_[parameter].Get();}
- else if(const auto target=desc_.interNrColorTarget(parameter);target<engine::kMaxNrInstances){
- ++interNrColorActiveCount_;interNrColorOutputs_[target]=nodeColorOutputs_[parameter].Get();
+ if(where==PassSlot::SourcePost)sourcePostPasses_.push_back(pass);
+ else if(where==PassSlot::PreNr)preNrPasses_.push_back(pass);
+ else if(where==PassSlot::PreSr)preSrPasses_.push_back(pass);
+ else if(where==PassSlot::InterNr&&target<interNrPasses_.size())interNrPasses_[target].push_back(pass);
+ else tailPasses_.push_back(pass);
+ }
+ if(!sourcePostPasses_.empty())sourcePostOutput_=sourcePostPasses_.back().output;
+ if(!preNrPasses_.empty())preNrColorOutput_=preNrPasses_.back().output;
+ if(!preSrPasses_.empty())preSrColorOutput_=preSrPasses_.back().output;
+ for(size_t target=0;target<interNrPasses_.size();++target)
+ if(!interNrPasses_[target].empty())interNrColorOutputs_[target]=interNrPasses_[target].back().output;
+ return true;
+}
+
+// Binds one slot's passes in plan order: each reads the previous output.
+ID3D12Resource* EnhanceGraph::chainSlotViews(const std::vector<SlotPass>& passes,ID3D12Resource* input,const char* where){
+ const auto& plan=*desc_.fixedExecutionPlan;
+ for(const auto& pass:passes){
+ const auto& step=plan.steps[pass.step];
+ if(pass.type==engine::EffectType::Color)nodeColorInstances_[pass.parameter]->createViews(context_.device(),stager_,input,pass.output);
+ input=pass.output;
+ veyra::log::info("node-dispatch",std::format("{} {} step={} parameter={} resource={} input={}x{} output={}x{}",
+ where,engine::effectTypeName(pass.type),pass.step,pass.parameter,step.resourceIndex,step.input.width,step.input.height,step.output.width,step.output.height));
+ }
+ return input;
+}
+
+bool EnhanceGraph::dispatchSlotPasses(ID3D12GraphicsCommandList* list,const std::vector<SlotPass>& passes,unsigned slot,const char* where,bool log){
+ const auto& plan=*desc_.fixedExecutionPlan;
+ for(const auto& pass:passes){
+ const auto& step=plan.steps[pass.step];
+ if(pass.type==engine::EffectType::Color){
+ gpuTimer_.mark(list,diagnostics::colorNodeStage(pass.parameter));
+ if(!nodeColorInstances_[pass.parameter]->dispatch(list,tracker_,slot,step.output.width,step.output.height,desc_.hdrWorking()))return false;
+ gpuTimer_.mark(list,diagnostics::colorNodeStage(pass.parameter),true);
}
- else ++tailColorActiveCount_;
+ if(log)veyra::log::info("node-dispatch",std::format("recorded {} {} step={} parameter={} resource={}",where,engine::effectTypeName(pass.type),pass.step,pass.parameter,step.resourceIndex));
}
return true;
}
@@ -593,7 +642,7 @@ bool EnhanceGraph::createResources()
upFsrSrZeroMotion_=makeUploadBuffer(context_.device(),fsrSrDepthPitch_*srcH_);
if(!upFsrSrDepth_||!upFsrSrZeroMotion_)return false;
}
- const bool directBase=!srEnabled_&&srcW_==workW_&&srcH_==workH_&&!desc_.splitNrAcrossSr();
+ const bool directBase=!srEnabled_&&srcW_==workW_&&srcH_==workH_&&!desc_.splitNrAcrossSr()&&!desc_.sourcePostActive();
workRgba_=directBase?srcRgba_:makeTexture(context_.device(),workW_,workH_,DXGI_FORMAT_R16G16B16A16_FLOAT,true);
const bool anyColor=desc_.color.enabled||std::any_of(desc_.additionalColors.begin(),desc_.additionalColors.begin()+desc_.additionalColorCount,[](const auto& s){return s.enabled;});
for(unsigned i=0;i<2;++i){sourceReferences_[i]=makeTexture(context_.device(),srcW_,srcH_,DXGI_FORMAT_R16G16B16A16_FLOAT,false);baseReferences_[i]=(directBase&&!anyColor)?sourceReferences_[i]:makeTexture(context_.device(),workW_,workH_,DXGI_FORMAT_R16G16B16A16_FLOAT,false);if(!sourceReferences_[i]||!baseReferences_[i])return false;}
@@ -1647,45 +1696,14 @@ bool EnhanceGraph::createViews()
stager_.stageSrv(resource, &srv, pass.heap.Get(), slot);
};
- if(preNrColorActiveCount_){
- auto* input=workRgba_.Get();
- const auto& plan=*desc_.fixedExecutionPlan;
- for(uint32_t i=0;i<plan.stepCount;++i){
- const auto& step=plan.steps[i];
- if(step.type!=engine::EffectType::Color||!desc_.preNrColor(step.parameterIndex))continue;
- auto* output=nodeColorOutputs_[step.parameterIndex].Get();
- nodeColorInstances_[step.parameterIndex]->createViews(context_.device(),stager_,input,output);
- input=output;
- veyra::log::info("node-dispatch",std::format("pre-NR Color step={} parameter={} resource={} input={}x{} output={}x{}",
- i,step.parameterIndex,step.resourceIndex,step.input.width,step.input.height,step.output.width,step.output.height));
- }
- }
- if(interNrColorActiveCount_){
- const auto& plan=*desc_.fixedExecutionPlan;
- for(size_t layer=1;layer<nrInstances_.size();++layer){
- auto* input=interNrProtectionRgba_&&layer==desc_.interNrProtectionTarget()?interNrProtectionRgba_.Get():nrInstances_[layer-1]->fullTarget();
- for(uint32_t i=0;i<plan.stepCount;++i){
- const auto& step=plan.steps[i];
- if(step.type!=engine::EffectType::Color||desc_.interNrColorTarget(step.parameterIndex)!=layer)continue;
- auto* output=nodeColorOutputs_[step.parameterIndex].Get();
- nodeColorInstances_[step.parameterIndex]->createViews(context_.device(),stager_,input,output);
- input=output;
- veyra::log::info("node-dispatch",std::format("inter-NR Color step={} parameter={} resource={} beforeNR={} input={}x{} output={}x{}",
- i,step.parameterIndex,step.resourceIndex,layer,step.input.width,step.input.height,step.output.width,step.output.height));
- }
- }
- }
- if(preSrColorActiveCount_){
- auto* input=preSrBaseInput();
- const auto& plan=*desc_.fixedExecutionPlan;
- for(uint32_t i=0;i<plan.stepCount;++i){
- const auto& step=plan.steps[i];
- if(step.type!=engine::EffectType::Color||!desc_.preSrColor(step.parameterIndex))continue;
- auto* output=nodeColorOutputs_[step.parameterIndex].Get();
- nodeColorInstances_[step.parameterIndex]->createViews(context_.device(),stager_,input,output);
- input=output;
- }
+ if(!sourcePostPasses_.empty())(void)chainSlotViews(sourcePostPasses_,srcRgba_.Get(),"source-size");
+ if(!preNrPasses_.empty())(void)chainSlotViews(preNrPasses_,workRgba_.Get(),"pre-NR");
+ for(size_t layer=1;layer<nrInstances_.size()&&layer<interNrPasses_.size();++layer){
+ if(interNrPasses_[layer].empty())continue;
+ auto* input=interNrProtectionRgba_&&layer==desc_.interNrProtectionTarget()?interNrProtectionRgba_.Get():nrInstances_[layer-1]->fullTarget();
+ (void)chainSlotViews(interNrPasses_[layer],input,"inter-NR");
}
+ if(!preSrPasses_.empty())(void)chainSlotViews(preSrPasses_,preSrBaseInput(),"pre-SR");
stagedSrv(srcRgba_.Get(), DXGI_FORMAT_R16G16B16A16_FLOAT, blitPass_, 15);
// Layer 0 downsamples the stage input; later layers downsample the previous
// layer's result, so each gets its own slot-0 source.
@@ -1880,18 +1898,8 @@ bool EnhanceGraph::createViews()
}
if (viewsUav) makeUav(context_.device(), workRgba_.Get(), DXGI_FORMAT_R16G16B16A16_FLOAT, cpu(blitPass_, 1));
auto* finalInput=nrEnabled_&&desc_.finalNrAfterSr()?residualRgba_.Get():(preNrColorOutput_?preNrColorOutput_:workRgba_.Get());
- if(tailColorActiveCount_){
- const auto& plan=*desc_.fixedExecutionPlan;
- for(uint32_t i=0;i<plan.stepCount;++i){
- const auto& step=plan.steps[i];
- if(step.type!=engine::EffectType::Color||!desc_.tailColor(step.parameterIndex))continue;
- auto& instance=*nodeColorInstances_[step.parameterIndex];
- auto* output=nodeColorOutputs_[step.parameterIndex].Get();
- instance.createViews(context_.device(),stager_,finalInput,output);
- finalInput=output;
- veyra::log::info("node-dispatch",std::format("tail Color step={} parameter={} resource={} input={}x{} output={}x{}",
- i,step.parameterIndex,step.resourceIndex,step.input.width,step.input.height,step.output.width,step.output.height));
- }
+ if(!tailPasses_.empty()){
+ finalInput=chainSlotViews(tailPasses_,finalInput,"tail");
tailColorOutput_=finalInput;
}
if (viewsTex) stagedSrv(finalInput, DXGI_FORMAT_R16G16B16A16_FLOAT, blitPass_, 2);
@@ -1956,7 +1964,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
desc_.nrRuntime==engine::NrRuntime::Original&&!desc_.enableSr&&!desc_.enableFg&&
!srEnabled_&&!fgEnabled_&&!desc_.videoHdr.enabled&&!desc_.hdrInput&&!desc_.hdrOutput&&
!colorGradeActive()&&!tailColorActiveCount_&&!preNrColorActiveCount_&&
- !preSrColorActiveCount_&&!interNrColorActiveCount_&&desc_.nrHoldStrength==0&&
+ !preSrColorActiveCount_&&!interNrColorActiveCount_&&!slotPassesActive()&&desc_.nrHoldStrength==0&&
(!hardwareSurface||!hardwareSurface->present())&&
!GetEnvironmentVariableW(L"VEYRA_TEST_DISABLE_PAUSED_NR_RESIDUAL_REUSE",nullptr,0);
const bool reusePausedNr=pausedEligible&&pausedNrCacheValid_&&pausedNrResidualOnly_&&
@@ -2357,19 +2365,26 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
gpuTimer_.mark(list,GpuStage::Color,true);
if (desc_.stageMark) desc_.stageMark("yuv");
cpuTrace.mark("color");
+ if(!sourcePostPasses_.empty()){
+ if(!dispatchSlotPasses(list,sourcePostPasses_,slot,"source-size",!sourcePostExecutionLogged_))return false;
+ tracker_.transition(list,sourcePostOutput_,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ sourcePostExecutionLogged_=true;
+ if (desc_.stageMark) desc_.stageMark("source-size-pass");
+ cpuTrace.mark("sourcePass");
+ }
auto runVideoSr=[&]()->bool{
gpuTimer_.mark(list,GpuStage::Sr);
tracker_.transition(list,videoSrInput_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
const float enc[8]={uintBits(srcW_),uintBits(srcH_),uintBits(srcW_),uintBits(srcH_),desc_.hdrWorking()?3.0f:1.0f,0,0,0};
- blitPass_.bind(list,enc,gpuHandleOf(blitPass_,desc_.nrBeforeSr?18:0).ptr,gpuHandleOf(blitPass_,16).ptr);list->Dispatch((srcW_+15)/16,(srcH_+15)/16,1);tracker_.uavBarrier(list,videoSrInput_.Get());
+ blitPass_.bind(list,enc,gpuHandleOf(blitPass_,desc_.nrBeforeSr||sourcePostOutput_?18:0).ptr,gpuHandleOf(blitPass_,16).ptr);list->Dispatch((srcW_+15)/16,(srcH_+15)/16,1);tracker_.uavBarrier(list,videoSrInput_.Get());
tracker_.transition(list,videoSrInput_.Get(),D3D12_RESOURCE_STATE_COMMON);tracker_.transition(list,videoSrOutput_.Get(),D3D12_RESOURCE_STATE_COMMON);
if(!videoSrBackend_->evaluate(list,videoSrInput_.Get(),videoSrOutput_.Get(),desc_.videoSrQuality)){failedBackend_=engine::FailedBackend::Sr;return false;}
tracker_.uavBarrier(list,videoSrOutput_.Get());tracker_.transition(list,videoSrOutput_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);tracker_.transition(list,workRgba_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
const float dec[8]={uintBits(workW_),uintBits(workH_),uintBits(workW_),uintBits(workH_),-1,0,0,0};
if(desc_.hdrWorking()){
tracker_.transition(list,videoSrInput_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
- hdrVideoSrPass_.bind(list,dec,gpuHandleOf(hdrVideoSrPass_,desc_.nrBeforeSr?4:0).ptr,gpuHandleOf(hdrVideoSrPass_,3).ptr);
+ hdrVideoSrPass_.bind(list,dec,gpuHandleOf(hdrVideoSrPass_,desc_.nrBeforeSr||sourcePostOutput_?4:0).ptr,gpuHandleOf(hdrVideoSrPass_,3).ptr);
}else blitPass_.bind(list,dec,gpuHandleOf(blitPass_,17).ptr,gpuHandleOf(blitPass_,1).ptr);list->Dispatch((workW_+15)/16,(workH_+15)/16,1);tracker_.uavBarrier(list,workRgba_.Get());tracker_.transition(list,workRgba_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
++metrics_.srEvaluateCount;gpuTimer_.mark(list,GpuStage::Sr,true);
return true;
@@ -2585,18 +2600,11 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
cpuTrace.mark("sr");
return true;};
auto runBoundaryColor=[&](bool beforeSr)->bool{
- if(beforeSr?preSrColorActiveCount_:preNrColorActiveCount_){
+ const auto& passes=beforeSr?preSrPasses_:preNrPasses_;
+ if(!passes.empty()){
auto& logged=beforeSr?preSrColorExecutionLogged_:preNrColorExecutionLogged_;
- const auto& plan=*desc_.fixedExecutionPlan;
- for(uint32_t i=0;i<plan.stepCount;++i){
- const auto& step=plan.steps[i];
- if(step.type!=engine::EffectType::Color||!(beforeSr?desc_.preSrColor(step.parameterIndex):desc_.preNrColor(step.parameterIndex)))continue;
- gpuTimer_.mark(list,diagnostics::colorNodeStage(step.parameterIndex));
- if(!nodeColorInstances_[step.parameterIndex]->dispatch(list,tracker_,slot,step.output.width,step.output.height,desc_.hdrWorking()))return false;
- gpuTimer_.mark(list,diagnostics::colorNodeStage(step.parameterIndex),true);
- if(!logged)veyra::log::info("node-dispatch",std::format("recorded {} Color step={} parameter={} resource={}",beforeSr?"pre-SR":"pre-NR",i,step.parameterIndex,step.resourceIndex));
- if(desc_.stageMark)desc_.stageMark(beforeSr?"pre-sr-color":"pre-nr-color");
- }
+ if(!dispatchSlotPasses(list,passes,slot,beforeSr?"pre-SR":"pre-NR",!logged))return false;
+ if(desc_.stageMark)desc_.stageMark(beforeSr?"pre-sr-color":"pre-nr-color");
logged=true;
}
return true;};
@@ -2687,17 +2695,9 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
auto* layer = nrInstances_[layerIndex].get();
const uint32_t sourceW=layer->fullWidth(),sourceH=layer->fullHeight();
if ((layer->handle() == nullptr && !layer->amd) || !layer->enabled) continue;
- if(interNrColorActiveCount_){
- const auto& plan=*desc_.fixedExecutionPlan;
- for(uint32_t i=0;i<plan.stepCount;++i){
- const auto& step=plan.steps[i];
- if(step.type!=engine::EffectType::Color||desc_.interNrColorTarget(step.parameterIndex)!=layerIndex)continue;
- gpuTimer_.mark(list,diagnostics::colorNodeStage(step.parameterIndex));
- if(!nodeColorInstances_[step.parameterIndex]->dispatch(list,tracker_,slot,step.output.width,step.output.height,desc_.hdrWorking()))return false;
- gpuTimer_.mark(list,diagnostics::colorNodeStage(step.parameterIndex),true);
- if(!interNrColorExecutionLogged_)veyra::log::info("node-dispatch",std::format("recorded inter-NR Color step={} parameter={} resource={} afterNR={} beforeNR={}",i,step.parameterIndex,step.resourceIndex,layerIndex-1,layerIndex));
- if(desc_.stageMark)desc_.stageMark("inter-nr-color");
- }
+ if(size_t(layerIndex)<interNrPasses_.size()&&!interNrPasses_[layerIndex].empty()){
+ if(!dispatchSlotPasses(list,interNrPasses_[layerIndex],slot,"inter-NR",!interNrColorExecutionLogged_))return false;
+ if(desc_.stageMark)desc_.stageMark("inter-nr-color");
}
const uint32_t nrW=layer->width(),nrH=layer->height();
ID3D12Resource* stageInput = nrLayerBase(layerIndex);
@@ -2845,7 +2845,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
if (layerIndex + 1 < nrInstances_.size()) compositeNrLayer(layerIndex);
if(desc_.splitNrAcrossSr()&&desc_.stageMark)desc_.stageMark("nr-layer");
}
- if(interNrColorActiveCount_)interNrColorExecutionLogged_=true;
+ if(std::any_of(interNrPasses_.begin(),interNrPasses_.end(),[](const auto& passes){return !passes.empty();}))interNrColorExecutionLogged_=true;
}
if (desc_.stageMark) desc_.stageMark("nr");
cpuTrace.mark("nr");
@@ -2905,17 +2905,9 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
if(!desc_.splitNrAcrossSr()&&!runBoundaryColor(true))return false;
if(desc_.nrBeforeSr&&!desc_.splitNrAcrossSr()&&!runSr())return false;
- if(tailColorActiveCount_){
- const auto& plan=*desc_.fixedExecutionPlan;
- for(uint32_t i=0;i<plan.stepCount;++i){
- const auto& step=plan.steps[i];
- if(step.type!=engine::EffectType::Color||!desc_.tailColor(step.parameterIndex))continue;
- gpuTimer_.mark(list,diagnostics::colorNodeStage(step.parameterIndex));
- if(!nodeColorInstances_[step.parameterIndex]->dispatch(list,tracker_,slot,step.output.width,step.output.height,desc_.hdrWorking()))return false;
- gpuTimer_.mark(list,diagnostics::colorNodeStage(step.parameterIndex),true);
- if(!tailColorExecutionLogged_)veyra::log::info("node-dispatch",std::format("recorded tail Color step={} parameter={} resource={} after SR/NR/protection",i,step.parameterIndex,step.resourceIndex));
- if(desc_.stageMark)desc_.stageMark("tail-color");
- }
+ if(!tailPasses_.empty()){
+ if(!dispatchSlotPasses(list,tailPasses_,slot,"tail",!tailColorExecutionLogged_))return false;
+ if(desc_.stageMark)desc_.stageMark("tail-color");
tailColorExecutionLogged_=true;
cpuTrace.mark("tailColor");
}
@@ -3257,6 +3249,10 @@ bool EnhanceGraph::applySettings(const engine::EnhancementSettings& s){
const auto& a=s.additionalColors[i];const auto& b=desc_.additionalColors[i];
if(a.enabled!=b.enabled||(a.enabled&&(a.lutName!=b.lutName||a.lutInputSpace!=b.lutInputSpace)))return false;
}
+ // Anti-aliasing method, quality tier and temporal mode choose shaders and
+ // textures (rebuild); the MLAA threshold / strength and history weights are uniforms.
+ engine::describeAntiAlias(s,nextNr);
+ for(unsigned i=0;i<engine::kMaxAntiAliasInstances;++i)if(!nextNr.antiAlias[i].sameStructure(desc_.antiAlias[i]))return false;
if(s.videoHdr.enabled!=desc_.videoHdr.enabled)return false;
// Output stabiliser: its pass is allocated at build time, so on/off rebuilds; strength and
// tolerance are uniforms. Neither used to reach a running graph (field report
@@ -3298,6 +3294,7 @@ bool EnhanceGraph::applySettings(const engine::EnhancementSettings& s){
if(nodeColorInstances_[i+1])nodeColorInstances_[i+1]->refresh(s.additionalColors[i]);
}
}
+ desc_.antiAlias=nextNr.antiAlias;
desc_.contentRate=s.content;desc_.model=s.model;desc_.residual=s.residual;desc_.protection=s.protection;desc_.settingsRevision=s.revision;
desc_.nrHoldStrength=s.nrHoldStrength;desc_.nrHoldTolerance=s.nrHoldTolerance;
desc_.nrLayersModel=std::move(nextNr.nrLayersModel);
@@ -3339,16 +3336,11 @@ void EnhanceGraph::setNrEnabled(bool on)
// Live colour edits also call this setter. Keep the final blit bound
// to the tail, rather than silently bypassing every downstream grade.
// A genuine NR bypass changes only the first tail pass's input.
- if(wasEnabled!=nrEnabled_){
- const auto& plan=*desc_.fixedExecutionPlan;
- for(uint32_t i=0;i<plan.stepCount;++i){
- const auto& step=plan.steps[i];
- if(step.type!=engine::EffectType::Color||!desc_.tailColor(step.parameterIndex))continue;
- nodeColorInstances_[step.parameterIndex]->createViews(context_.device(),stager_,
- nrEnabled_&&desc_.finalNrAfterSr()?residualRgba_.Get():(preNrColorOutput_?preNrColorOutput_:workRgba_.Get()),
- nodeColorOutputs_[step.parameterIndex].Get());
- break;
- }
+ if(wasEnabled!=nrEnabled_&&!tailPasses_.empty()){
+ const auto& first=tailPasses_.front();
+ auto* input=nrEnabled_&&desc_.finalNrAfterSr()?residualRgba_.Get():(preNrColorOutput_?preNrColorOutput_:workRgba_.Get());
+ if(first.type==engine::EffectType::Color)
+ nodeColorInstances_[first.parameter]->createViews(context_.device(),stager_,input,first.output);
}
return;
}
@@ -3526,7 +3518,10 @@ void EnhanceGraph::shutdown()
yuvPass_ = ComputePass{};
for(auto i=additionalColorInstances_.rbegin();i!=additionalColorInstances_.rend();++i)i->reset();
for(auto i=nodeColorInstances_.rbegin();i!=nodeColorInstances_.rend();++i)i->reset();
- nodeColorOutputs_={};tailColorActiveCount_=preNrColorActiveCount_=preSrColorActiveCount_=interNrColorActiveCount_=0;
+ nodeColorOutputs_={};tailColorActiveCount_=preNrColorActiveCount_=preSrColorActiveCount_=interNrColorActiveCount_=sourcePostColorActiveCount_=0;
+ sourcePostPasses_.clear();preSrPasses_.clear();preNrPasses_.clear();tailPasses_.clear();
+ for(auto& passes:interNrPasses_)passes.clear();
+ sourcePostOutput_=nullptr;
preSrColorOutput_=nullptr;preSrColorExecutionLogged_=false;
interNrColorOutputs_={};interNrColorExecutionLogged_=false;
tailColorOutput_=preNrColorOutput_=nullptr;tailColorExecutionLogged_=preNrColorExecutionLogged_=false;
diff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cpp
index f4c79af7..936d2d7c 100644
--- a/src/ui/QmlPlayerBridge.cpp
+++ b/src/ui/QmlPlayerBridge.cpp
@@ -2121,6 +2121,7 @@ void QmlPlayerBridge::resetCurrentPage() {
s.protection = engine::ProtectionSettings{};
s.color = engine::ColorSettings{};
s.additionalColors = {}; s.additionalColorCount = 0;
+ s.antiAlias = engine::AntiAliasSettings{}; s.additionalAntiAlias = {}; s.additionalAntiAliasCount = 0;
s.videoHdr = engine::VideoHdrSettings{};
const auto before=impl_->chain; const auto selected=impl_->selectedNr;
const auto oldLayout = impl_->layout;
@@ -5600,7 +5601,7 @@ QString QmlPlayerBridge::nrAutoSelectionReason(int index) const {
}
if(first!=index||count>2||otherAuto)return tr("自动 NR 仅支持一至两层列表的第一层");
if(impl_->chain.mode!=engine::ChainMode::List||engine::currentNrRuntime(s.nrRuntime)!=engine::NrRuntime::Ampere||s.sr||s.multiplier>1||temporal||
- s.nrHoldStrength>0||s.color.enabled||s.additionalColorCount||s.videoHdr.enabled||
+ s.nrHoldStrength>0||s.color.enabled||s.additionalColorCount||s.antiAlias.enabled||s.additionalAntiAliasCount||s.videoHdr.enabled||
s.opticalFlowBackend!=engine::OpticalFlowBackend::Nvidia||s.nrMotion!=engine::MotionSource::OpticalFlow||snapshot.capture||snapshot.image||snapshot.sourceHdr||
(snapshot.sourceWidth&& (snapshot.sourceWidth!=1920||snapshot.sourceHeight!=1080)))
return tr("需 1080p SDR 文件、SF 和 NVIDIA 光流;关闭超分、补帧、抗闪烁、调色及 HDR");
@@ -5669,6 +5670,7 @@ bool QmlPlayerBridge::setNrLayerParameter(int index,const QString& key,double va
QVariantList QmlPlayerBridge::effectCatalog() const {
QVariantList out;
for (const auto& info : engine::effectCatalog()) {
+ if (info.hidden) continue;
if (impl_->chain.mode == engine::ChainMode::Node && info.type == engine::EffectType::Protection) continue;
if (impl_->chain.mode == engine::ChainMode::Node && info.type == engine::EffectType::FrameGeneration) {
for(const auto& choice : fgBackendChoices()) {
@@ -6845,7 +6847,7 @@ int QmlPlayerBridge::addEffect(const QString& type) {
const engine::EffectInfo* info = nullptr;
for (const auto& item : engine::effectCatalog())
if ((fg && item.type == engine::EffectType::FrameGeneration) || utf8Of(item.id) == type) info = &item;
- if (!info || info->type == engine::EffectType::Protection) {
+ if (!info || info->hidden || info->type == engine::EffectType::Protection) {
emit notice(tr("节点模式不支持该效果类型"), true); return -1;
}
auto& c = impl_->chain;
@@ -6921,7 +6923,7 @@ int QmlPlayerBridge::addEffect(const QString& type) {
engine::EffectType wanted = engine::EffectType::NrEnhance;
bool found = false;
for (const auto& info : engine::effectCatalog()) {
- if (utf8Of(info.id) == type) {
+ if (!info.hidden && utf8Of(info.id) == type) {
wanted = info.type;
found = true;
break;
diff --git a/tests/unit/EffectChainTests.cpp b/tests/unit/EffectChainTests.cpp
index 037d8d81..0dd37115 100644
--- a/tests/unit/EffectChainTests.cpp
+++ b/tests/unit/EffectChainTests.cpp
@@ -1055,6 +1055,173 @@ static void testNativeVideoSrPolicy(){
check(!d.enableSr,"DLSS SR keeps skipping a source already at the target");
}
+// E0 (2026-10-18): anti-aliasing / beauty effect types, chains past 16 nodes and
+// the same-size insertion slots shared with Color.
+__declspec(noinline) void testAntiAliasSettingsChain() {
+ using namespace veyra;
+ using namespace veyra::engine;
+ const EnhancementSettings plain;
+ auto chain = std::make_unique<EffectChain>(toChain(plain));
+ check(chain->countOf(EffectType::AntiAliasing) == 0 && chain->countOf(EffectType::Beauty) == 0 && !chain->overflow,
+ "E0: untouched settings add no anti-aliasing or beauty node");
+ check(effectInfo(EffectType::AntiAliasing).hidden != pipeline::EnhanceGraphDesc::antiAliasExecutor &&
+ effectInfo(EffectType::Beauty).hidden, "E0: the catalog hides effects whose executor is not built");
+ chain->overflow = true;
+ check(!validateChain(*chain).accepted, "E0: an overflowing chain is refused instead of losing its last node");
+
+ auto s = std::make_unique<EnhancementSettings>(populated());
+ s->antiAlias.enabled = true; s->antiAlias.method = AntiAliasMethod::Fxaa; s->antiAlias.quality = 1;
+ s->additionalAntiAliasCount = 1;
+ auto& second = s->additionalAntiAlias[0];
+ second.enabled = false; second.method = AntiAliasMethod::Mlaa; second.quality = 0;
+ second.mlaaThreshold = 0.12f; second.mlaaStrength = 0.6f;
+ check(s->validate().empty(), "E0: two anti-aliasing instances validate");
+ *chain = toChain(*s);
+ uint32_t lastColor = 0, firstAa = chain->nodeCount, sr = chain->nodeCount;
+ for (uint32_t i = 0; i < chain->nodeCount; ++i) {
+ const auto type = chain->nodes[i].type;
+ if (type == EffectType::Color) lastColor = i;
+ if (type == EffectType::AntiAliasing && firstAa == chain->nodeCount) firstAa = i;
+ if (type == EffectType::SuperResolution) sr = i;
+ }
+ check(chain->countOf(EffectType::AntiAliasing) == 2 && lastColor < firstAa && firstAa + 2 == sr &&
+ chain->nodes[firstAa].enabled && !chain->nodes[firstAa + 1].enabled && validateChain(*chain).accepted,
+ "E0: the list chain keeps both instances between the grades and SR");
+ auto back = std::make_unique<EnhancementSettings>();
+ fromChain(*chain, *back);
+ check(back->antiAlias == s->antiAlias && back->additionalAntiAliasCount == 1 && back->additionalAntiAlias[0] == second,
+ "E0: anti-aliasing instances round-trip through the chain");
+
+ auto bad = std::make_unique<EnhancementSettings>(*s);
+ bad->antiAlias.quality = 3;
+ check(!bad->validate().empty(), "E0: an FXAA tier past ultra is rejected");
+ *bad = *s; bad->antiAlias.temporal = AntiAliasTemporal::T2x;
+ check(!bad->validate().empty(), "E0: temporal accumulation requires SMAA");
+ *bad = *s; bad->additionalAntiAliasCount = kMaxAntiAliasInstances;
+ check(!bad->validate().empty(), "E0: a third anti-aliasing instance is rejected");
+ *bad = *s; bad->additionalAntiAlias[0].mlaaThreshold = 0.5f;
+ check(!bad->validate().empty(), "E0: an MLAA threshold out of range is rejected even while switched off");
+
+ EnhancementSettings a; a.antiAlias.enabled = true; a.antiAlias.method = AntiAliasMethod::Mlaa; a.antiAlias.quality = 0;
+ auto b = a; b.antiAlias.mlaaThreshold = 0.2f; b.antiAlias.mlaaStrength = 0.5f;
+ check(!requiresGraphRebuild(a, b) && a.sameVideoConfiguration(b), "E0: MLAA threshold and strength are live uniforms");
+ b = a; b.antiAlias.method = AntiAliasMethod::Smaa; b.antiAlias.quality = 1;
+ check(requiresGraphRebuild(a, b) && !a.sameVideoConfiguration(b), "E0: changing the anti-aliasing method rebuilds");
+ b = a; b.antiAlias.enabled = false;
+ check(requiresGraphRebuild(a, b), "E0: switching anti-aliasing off rebuilds");
+ b = a; b.additionalAntiAliasCount = 1;
+ check(requiresGraphRebuild(a, b), "E0: adding an anti-aliasing instance rebuilds");
+ auto off = a; off.antiAlias.enabled = false; b = off; b.antiAlias.method = AntiAliasMethod::Fxaa;
+ check(!requiresGraphRebuild(off, b), "E0: edits of a switched-off instance do not rebuild");
+
+ // List mode: the instance reaches the description and runs at source size.
+ auto listSettings = std::make_unique<EnhancementSettings>();
+ listSettings->nr = true; listSettings->sr = true; listSettings->antiAlias = a.antiAlias;
+ StageRequest request; request.width = 1280; request.height = 720; request.nr = true; request.sr = true;
+ auto desc = std::make_unique<pipeline::EnhanceGraphDesc>();
+ describeStages(request, *listSettings, *desc);
+ check(desc->fixedExecutionPlanError.empty() && desc->fixedExecutionPlan && desc->antiAlias[0] == a.antiAlias &&
+ desc->antiAlias[1] == AntiAliasSettings{} && desc->antiAliasActive(), "E0: describeStages carries the anti-aliasing instance");
+ uint32_t aaStep = kMaxChainNodes;
+ if (desc->fixedExecutionPlan)
+ for (uint32_t i = 0; i < desc->fixedExecutionPlan->stepCount; ++i)
+ if (desc->fixedExecutionPlan->steps[i].type == EffectType::AntiAliasing) aaStep = i;
+ check(aaStep < kMaxChainNodes && desc->fixedExecutionPlan->steps[aaStep].output == pipeline::Extent{1280, 720} &&
+ desc->slotOfStep(aaStep) == pipeline::EnhanceGraphDesc::PassSlot::SourcePost,
+ "E0: list anti-aliasing runs at source size right after the input conversion");
+ const auto error = desc->validateFixedExecutionPlan();
+ check(pipeline::EnhanceGraphDesc::antiAliasExecutor ? error.empty() : error == "anti-aliasing is not available in this build",
+ "E0: an enabled instance is refused until its executor is built");
+ auto inactive = std::make_unique<EnhancementSettings>(*listSettings); inactive->antiAlias.enabled = false;
+ describeStages(request, *inactive, *desc);
+ check(desc->validateFixedExecutionPlan().empty() && !desc->antiAliasActive(),
+ "E0: a switched-off instance adds no step and no refusal");
+}
+
+__declspec(noinline) void testSameSizeSlots() {
+ using namespace veyra;
+ using namespace veyra::engine;
+ using Slot = pipeline::EnhanceGraphDesc::PassSlot;
+ const auto describe = [](const std::vector<EffectType>& types, bool sr, pipeline::EnhanceGraphDesc& desc) {
+ auto chain = std::make_unique<EffectChain>(); chain->mode = ChainMode::Node;
+ for (const auto type : types) {
+ auto& node = chain->nodes[chain->nodeCount++]; node.type = type; node.enabled = true;
+ if (type == EffectType::Color) node.color.enabled = true;
+ if (type == EffectType::AntiAliasing) { node.aa.enabled = true; node.aa.method = AntiAliasMethod::Smaa; node.aa.quality = 1; }
+ }
+ auto settings = std::make_unique<EnhancementSettings>(); fromChain(*chain, *settings);
+ const auto order = runtimeOrder(*chain);
+ StageRequest request; request.width = 640; request.height = 360; request.sr = sr; request.nodeOrder = &*order;
+ request.nr = std::find(types.begin(), types.end(), EffectType::NrEnhance) != types.end();
+ describeStages(request, *settings, desc);
+ };
+ const auto step = [](const pipeline::EnhanceGraphDesc& desc, EffectType type, uint32_t parameter) {
+ return desc.planStepOf(type, parameter);
+ };
+ const auto refusedOrValid = [](const pipeline::EnhanceGraphDesc& desc) {
+ const auto error = desc.validateFixedExecutionPlan();
+ return pipeline::EnhanceGraphDesc::antiAliasExecutor ? error.empty() : error == "anti-aliasing is not available in this build";
+ };
+ auto desc = std::make_unique<pipeline::EnhanceGraphDesc>();
+ describe({EffectType::AntiAliasing, EffectType::SuperResolution, EffectType::NrEnhance}, true, *desc);
+ check(desc->fixedExecutionPlanError.empty() && desc->slotOfStep(step(*desc, EffectType::AntiAliasing, 0)) == Slot::SourcePost &&
+ refusedOrValid(*desc), "E0 slots: AA -> SR -> NR runs anti-aliasing at source size");
+ describe({EffectType::SuperResolution, EffectType::AntiAliasing, EffectType::NrEnhance}, true, *desc);
+ check(desc->slotOfStep(step(*desc, EffectType::AntiAliasing, 0)) == Slot::PreNr && refusedOrValid(*desc),
+ "E0 slots: SR -> AA -> NR uses the pre-NR slot");
+ describe({EffectType::NrEnhance, EffectType::AntiAliasing, EffectType::SuperResolution}, true, *desc);
+ check(desc->nrBeforeSr && desc->slotOfStep(step(*desc, EffectType::AntiAliasing, 0)) == Slot::PreSr && refusedOrValid(*desc),
+ "E0 slots: NR -> AA -> SR uses the pre-SR slot");
+ describe({EffectType::SuperResolution, EffectType::NrEnhance, EffectType::AntiAliasing}, true, *desc);
+ check(desc->slotOfStep(step(*desc, EffectType::AntiAliasing, 0)) == Slot::Tail && refusedOrValid(*desc),
+ "E0 slots: SR -> NR -> AA uses the tail slot");
+ describe({EffectType::NrEnhance, EffectType::AntiAliasing, EffectType::NrEnhance}, false, *desc);
+ uint32_t target = kMaxNrInstances;
+ check(desc->slotOfStep(step(*desc, EffectType::AntiAliasing, 0), &target) == Slot::InterNr && target == 1 && refusedOrValid(*desc),
+ "E0 slots: NR -> AA -> NR binds to the next NR resource");
+ describe({EffectType::Color, EffectType::AntiAliasing, EffectType::SuperResolution, EffectType::NrEnhance}, true, *desc);
+ check(desc->slotOfStep(step(*desc, EffectType::Color, 0)) == Slot::Ingress && !desc->nodeColor(0) &&
+ desc->slotOfStep(step(*desc, EffectType::AntiAliasing, 0)) == Slot::SourcePost,
+ "E0 slots: a leading grade stays fused; the following anti-aliasing runs at source size");
+ describe({EffectType::AntiAliasing, EffectType::Color, EffectType::SuperResolution, EffectType::NrEnhance}, true, *desc);
+ check(desc->slotOfStep(step(*desc, EffectType::Color, 0)) == Slot::SourcePost && desc->sourcePostColor(0) && desc->nodeColor(0),
+ "E0 slots: a grade behind anti-aliasing cannot be fused and runs as a source-size pass");
+ describe({EffectType::SuperResolution, EffectType::AntiAliasing, EffectType::Color, EffectType::AntiAliasing}, true, *desc);
+ check(desc->slotOfStep(step(*desc, EffectType::AntiAliasing, 0)) == Slot::Tail && desc->slotOfStep(step(*desc, EffectType::Color, 0)) == Slot::Tail &&
+ desc->slotOfStep(step(*desc, EffectType::AntiAliasing, 1)) == Slot::Tail && desc->antiAlias[1].enabled,
+ "E0 slots: mixed same-size passes after SR share the tail slot in order");
+ describe({EffectType::SuperResolution, EffectType::NrEnhance, EffectType::Beauty}, true, *desc);
+ check(!desc->fixedExecutionPlanError.empty(), "E0: beauty nodes do not reach the graph in this build");
+ // Color-only chains keep their existing slots (also covered byte-for-byte by the slot regression).
+ describe({EffectType::NrEnhance, EffectType::Color, EffectType::SuperResolution, EffectType::Color}, true, *desc);
+ check(desc->validateFixedExecutionPlan().empty() && desc->preSrColor(0) && desc->tailColor(1) && !desc->sourcePostActive(),
+ "E0 slots: Color-only node chains keep the pre-SR and tail grades");
+}
+
+__declspec(noinline) void testWideChains() {
+ using namespace veyra::engine;
+ auto chain = std::make_unique<EffectChain>(); chain->mode = ChainMode::Node;
+ const auto add = [&](EffectType type, uint32_t count) {
+ for (uint32_t i = 0; i < count; ++i) {
+ auto& node = chain->nodes[chain->nodeCount++]; node = ChainNode{}; node.type = type; node.enabled = true;
+ if (type == EffectType::Color) node.color.enabled = true;
+ }
+ };
+ add(EffectType::Color, kMaxColorInstances); add(EffectType::AntiAliasing, kMaxAntiAliasInstances);
+ add(EffectType::SuperResolution, 1); add(EffectType::NrEnhance, kMaxNrInstances); add(EffectType::Beauty, kMaxBeautyInstances);
+ add(EffectType::VideoHdr, 1); add(EffectType::FrameGeneration, 1);
+ check(chain->nodeCount == 21 && validateChain(*chain).accepted, "E0: the widest node chain (21 nodes) validates");
+ auto plan = std::make_unique<ChainExecutionPlan>();
+ check(compileChainExecutionPlan(*chain, {{640, 360}, EnhancementSettings{}.srTarget, false, false, false}, *plan).accepted &&
+ plan->stepCount >= 20 && plan->stepCount <= kMaxChainNodes, "E0: a 21-node chain compiles every step");
+ auto extra = std::make_unique<EffectChain>(*chain);
+ extra->nodes[extra->nodeCount++].type = EffectType::Beauty;
+ check(!validateChain(*extra).accepted, "E0: a seventh beauty node is refused");
+ const auto order = runtimeOrder(*chain);
+ check(order && order->nodeCount == 21 && order->types[20] == EffectType::FrameGeneration,
+ "E0: the runtime order transports every node of a wide chain");
+}
+
int main() {
{
using namespace veyra;using namespace veyra::engine;
@@ -1124,6 +1291,9 @@ int main() {
testNodePreSrProtectionDescription();
testNodeInterNrProtectionDescription();
testNativeVideoSrPolicy();
+ testAntiAliasSettingsChain();
+ testSameSizeSlots();
+ testWideChains();
std::printf(failures ? "effect chain: %d FAILURES\n" : "effect chain: all checks passed\n", failures);
return failures ? 1 : 0;
}
diff --git a/tests/unit/PresetLibraryTests.cpp b/tests/unit/PresetLibraryTests.cpp
index 679067f9..ce46c0c7 100644
--- a/tests/unit/PresetLibraryTests.cpp
+++ b/tests/unit/PresetLibraryTests.cpp
@@ -1100,7 +1100,88 @@ __declspec(noinline) void testDlssSrModels() {
ChainSessionStore finalReader(sessionPath);
check(finalReader.load(*restored)&&*restored==*session,"DLSS session: saved K wins over old M/L choices");
}
+// E0 (2026-10-18): library v14 / session v9 carry anti-aliasing nodes and chains
+// past 16 nodes in their own files; older readers keep their bytes.
+__declspec(noinline) void testEffectNodeStorage() {
+ const auto path = scratch(L"effects-library.v1");
+ const auto sidecar = std::filesystem::path(path).concat(L".effects");
+ std::filesystem::remove(sidecar);
+ PresetLibrary writer(path); writer.setIncludeBuiltins(false);
+ auto old = std::make_unique<PresetEntry>(); old->name = L"before effects"; old->chain = toChain(sample());
+ check(writer.load() && writer.put(*old), "effects storage: seed a library without anti-aliasing");
+ const auto original = readBytes(path);
+ check(!original.starts_with("VEYRA_PRESET_LIBRARY 14") && !std::filesystem::exists(sidecar),
+ "effects storage: untouched anti-aliasing keeps the older format");
+ auto settings = sample();
+ settings.antiAlias.enabled = true; settings.antiAlias.method = AntiAliasMethod::Mlaa; settings.antiAlias.quality = 0;
+ settings.antiAlias.mlaaThreshold = 0.15f; settings.antiAlias.mlaaStrength = 0.7f;
+ auto entry = std::make_unique<PresetEntry>(); entry->name = L"anti-aliased"; entry->chain = toChain(settings);
+ check(writer.put(*entry), "effects storage: save an anti-aliasing chain");
+ check(readBytes(path) == original && readBytes(sidecar).starts_with("VEYRA_PRESET_LIBRARY 14\n"),
+ "effects storage: v14 goes to its own file and keeps the older library intact");
+ {
+ PresetLibrary reader(path); reader.setIncludeBuiltins(false);
+ check(reader.load() && reader.entries().size() == 2 && reader.entries()[1].chain == entry->chain,
+ "effects storage: anti-aliasing parameters reload exactly");
+ auto applied = sample(); PresetLibrary::apply(reader.entries()[1], applied);
+ check(applied.antiAlias == settings.antiAlias, "effects storage: applying the chain restores anti-aliasing");
+ auto plain = sample(); PresetLibrary::apply(reader.entries()[0], plain);
+ check(plain.antiAlias == AntiAliasSettings{}, "effects storage: an older chain applies without anti-aliasing");
+ }
+ // A v13 header cannot smuggle the new node type; a newer version is refused outright.
+ auto downgraded = readBytes(sidecar);
+ downgraded.replace(0, std::string("VEYRA_PRESET_LIBRARY 14").size(), "VEYRA_PRESET_LIBRARY 13");
+ const auto downgradedPath = scratch(L"effects-downgraded.v1");
+ { std::ofstream f(downgradedPath, std::ios::binary); f << downgraded; }
+ {
+ PresetLibrary reader(downgradedPath); reader.setIncludeBuiltins(false);
+ check(!reader.load() || reader.entries().empty(), "effects storage: anti-aliasing nodes under a v13 header are refused");
+ }
+ auto future = readBytes(sidecar);
+ future.replace(0, std::string("VEYRA_PRESET_LIBRARY 14").size(), "VEYRA_PRESET_LIBRARY 15");
+ const auto futurePath = scratch(L"effects-future.v1");
+ { std::ofstream f(futurePath, std::ios::binary); f << future; }
+ {
+ PresetLibrary reader(futurePath); reader.setIncludeBuiltins(false);
+ check(!reader.load() || reader.entries().empty(), "effects storage: an unknown newer version is refused");
+ }
+ // A node chain past the old 16-node limit.
+ auto wide = std::make_unique<PresetEntry>(); wide->name = L"wide nodes"; wide->kind = ChainMode::Node;
+ wide->chain.mode = ChainMode::Node;
+ const auto add = [&](EffectType type, uint32_t count) {
+ for (uint32_t i = 0; i < count; ++i) {
+ auto& node = wide->chain.nodes[wide->chain.nodeCount++]; node.type = type; node.enabled = true;
+ node.viewX = float(wide->chain.nodeCount) * 10.0f;
+ if (type == EffectType::Color) { node.color.enabled = true; node.color.exposure = 0.1f * float(i); }
+ if (type == EffectType::AntiAliasing) { node.aa.enabled = true; node.aa.method = AntiAliasMethod(i % 3); node.aa.quality = 0; }
+ }
+ };
+ add(EffectType::Color, kMaxColorInstances); add(EffectType::AntiAliasing, kMaxAntiAliasInstances);
+ add(EffectType::SuperResolution, 1); add(EffectType::NrEnhance, kMaxNrInstances); add(EffectType::Beauty, 3);
+ add(EffectType::VideoHdr, 1); add(EffectType::FrameGeneration, 1);
+ check(wide->chain.nodeCount == 18 && writer.put(*wide), "effects storage: save an 18-node chain");
+ {
+ PresetLibrary reader(path); reader.setIncludeBuiltins(false);
+ check(reader.load() && reader.entries().size() == 3 && reader.entries()[2].chain == wide->chain,
+ "effects storage: an 18-node chain reloads exactly");
+ }
+
+ const auto sessionPath = scratch(L"effects-session.v1");
+ std::filesystem::remove(std::filesystem::path(sessionPath).concat(L".effects"));
+ auto session = std::make_unique<ChainSession>(ChainSession::initial(sample()));
+ ChainSessionStore sessions(sessionPath);
+ check(sessions.save(*session), "effects session: save the older format first");
+ const auto rollback = readBytes(sessionPath);
+ session->configurations[0].chain = toChain(settings);
+ check(sessions.save(*session) && readBytes(sessionPath) == rollback &&
+ readBytes(std::filesystem::path(sessionPath).concat(L".effects")).starts_with("VEYRA_CHAIN_SESSION 9"),
+ "effects session: v9 goes to its own file beside the older session");
+ auto restored = std::make_unique<ChainSession>();
+ ChainSessionStore reopened(sessionPath);
+ check(reopened.load(*restored) && *restored == *session, "effects session: anti-aliasing round-trips through the session");
+}
int main() {
+ testEffectNodeStorage();
testDlssSrModels();
testFlowStorage();
testFlowApplication();