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

phase-1 work: P1.0a fence timeline sole-owner hardening, regressions pass

Veyra Goal Agentc8ace1413ead
diff --git a/include/veyra/gfx/CommandSlotRing.h b/include/veyra/gfx/CommandSlotRing.h
index 621169e7..68736fec 100644
--- a/include/veyra/gfx/CommandSlotRing.h
+++ b/include/veyra/gfx/CommandSlotRing.h
@@ -17,6 +17,10 @@ using ComPtr = Microsoft::WRL::ComPtr<T>;
// command allocator, recycled command list, fence value and two timestamp
// query indices. A frame only ever waits on the fence of the slot it is about
// to reuse, never on the frame it just submitted.
+//
+// Fence ownership: this ring is the ONLY signaler on the shared fence
+// timeline handed in via initialize(); the device context waits but never
+// signals, so fence values stay strictly monotonic.
class CommandSlotRing {
public:
CommandSlotRing() = default;
diff --git a/include/veyra/gfx/D3D12DeviceContext.h b/include/veyra/gfx/D3D12DeviceContext.h
index 2de495b9..4e8bf2e4 100644
--- a/include/veyra/gfx/D3D12DeviceContext.h
+++ b/include/veyra/gfx/D3D12DeviceContext.h
@@ -55,9 +55,11 @@ public:
ID3D12Fence* fence() const { return fence_.Get(); }
HANDLE fenceEvent() const { return fenceEvent_; }
uint64_t fenceCompletedValue() const { return fence_->GetCompletedValue(); }
- uint64_t nextFenceValue() const { return nextFenceValue_; }
- uint64_t signalNextFenceValue(); // Signal(queue) with ++nextFenceValue_
+ // Fence-timeline ownership: CommandSlotRing is the ONLY component allowed
+ // to Signal this fence. The device context provides the fence/event and
+ // waits; a second independent counter here previously risked duplicate or
+ // non-monotonic values once Evaluate loops arrive (Phase 1 Reviewer P2).
const AdapterInfo& adapter() const { return adapterInfo_; }
const std::string& featureLevelString() const { return featureLevel_; }
uint32_t commandSlotCount() const { return commandSlotCount_; }
@@ -84,7 +86,6 @@ private:
ComPtr<ID3D12CommandQueue> queue_;
ComPtr<ID3D12Fence> fence_;
HANDLE fenceEvent_ = nullptr;
- uint64_t nextFenceValue_ = 1;
AdapterInfo adapterInfo_{};
std::string featureLevel_;
diff --git a/loop/BACKLOG.md b/loop/BACKLOG.md
index 23906408..5b62c02b 100644
--- a/loop/BACKLOG.md
+++ b/loop/BACKLOG.md
@@ -18,7 +18,7 @@ Phase 0 gate:以 Playbook 第 16 节 Phase 0 为准。未完成 P0.9 禁止开
## Phase 1 — Feature 18 native harness(锁定)
-- [ ] P1.0a(Reviewer P2 加固项,不降低任何门槛): 在接入 Evaluate 循环前把 ID3D12Fence 时间线计数器收敛为单一 owner(ring 从 device context 派生 fence 值或明确所有权注释),避免 Phase 1 起重复/非单调 fence 值。
+- [x] P1.0a(Reviewer P2 加固项,不降低任何门槛): 在接入 Evaluate 循环前把 ID3D12Fence 时间线计数器收敛为单一 owner(ring 从 device context 派生 fence 值或明确所有权注释),避免 Phase 1 起重复/非单调 fence 值。(2026-09-02:移除 context 冗余计数器,ring 为唯一 signaler,双 preset+device-info 回归通过。)
- [ ] P1.1 先建立 phase1 gate 和确定性 RGBA8 测试帧/输出统计。
- [ ] P1.2 封装 NGX Core、parameter block、DLSSNR runtime 和严格逆序 RAII。
- [ ] P1.3 实现受隔离、可关闭的 caller-name 兼容层;禁止 patch DLL。
diff --git a/loop/JOURNAL.md b/loop/JOURNAL.md
index 8cf9a6ea..4147647f 100644
--- a/loop/JOURNAL.md
+++ b/loop/JOURNAL.md
@@ -281,6 +281,29 @@ Result:
---
+## Cycle 010 — P1.0a fence 时间线单一 owner
+
+### Before
+
+- Phase: 1
+- 唯一任务: 落实 Reviewer P2:移除 D3D12DeviceContext 中未使用的 nextFenceValue_/signalNextFenceValue(与 CommandSlotRing 各自从 1 起算的双计数器),在两处头文件明确 CommandSlotRing 是该 fence 时间线的唯一 signaler;重建并回归 device-info。
+- 可证伪假设: 若移除影响现有行为,device-info/构建将失败。
+- 预计修改文件: include/veyra/gfx/{D3D12DeviceContext.h,CommandSlotRing.h}、src/gfx/D3D12DeviceContext.cpp。
+- 快速检查命令: `scripts/build.ps1 -Preset x64-debug` → 0;`veyra_runtime_probe.exe --device-info` → 0。
+- 预期新增证据: 双 preset 构建 + device-info 回归通过,fence 计数器只剩 ring 一处。
+
+### After
+
+- 实际修改: D3D12DeviceContext.h 移除 nextFenceValue_/nextFenceValue()/signalNextFenceValue();两处头文件注明 CommandSlotRing 是共享 fence 时间线唯一 signaler;shutdown 不再依赖已删除计数器(slot 排空由 ring.shutdown 负责)。
+- 实际命令与 exit code: `build.ps1 -Preset x64-debug` → 0;`--device-info` → PASS;`-Preset x64-release` → 0。
+- 新证据/日志路径: 回归输出(上)。
+- 失败 fingerprint: 无。
+- 是否有进展,依据: 是——Reviewer P2 落实,fence 计数器唯一化,行为无回归。
+- STATE/BACKLOG 更新: cycle.completed=10;BACKLOG P1.0a → DONE。
+- 下一唯一动作: P1.1 创建 fail-closed scripts/gates/phase1.ps1 + 确定性 RGBA8 测试帧契约;并行下载 NGX SDK 310.7。
+
+---
+
复制下面模板开始每个新 cycle。必须先填 Before,再改代码;完成后填 After。
## Cycle NNN — 简短任务名
diff --git a/loop/STATE.json b/loop/STATE.json
index 862ef638..909bda33 100644
--- a/loop/STATE.json
+++ b/loop/STATE.json
@@ -76,14 +76,14 @@
}
],
"cycle": {
- "completed": 9,
+ "completed": 10,
"maximum": 80,
"sameFailureAttempts": 0,
"maximumSameFailureAttempts": 3,
"noProgressCycles": 0,
"maximumNoProgressCycles": 5
},
- "currentTask": "P1.0a: converge the ID3D12Fence timeline to a single owner before the Phase 1 Evaluate loop (Reviewer P2), then P1.1 phase1 gate + deterministic RGBA8 test frames.",
+ "currentTask": "P1.1: create fail-closed scripts/gates/phase1.ps1 encoding the Phase 1 thresholds (Create success, 300/300 evaluates, non-black/non-constant output, parameter-hash variation, release/shutdown stability) plus the deterministic RGBA8 test-frame contract; NGX SDK 310.7 downloading in background.",
"lastGate": {
"name": "phase0",
"status": "passed",
@@ -96,6 +96,6 @@
"lastGoodCommit": "1fb7afa5779a6c6a0a585d4ecf18a640260a2fcf",
"openP0P1Findings": [],
"blockers": [],
- "nextAction": "Start Phase 1: P1.0a fence ownership hardening, then P1.1 phase1 gate; NGX SDK 310.7 acquisition per Playbook 3.2 into third_party_local (gitignored).",
- "updatedAt": "2026-09-02T21:30:00+08:00"
+ "nextAction": "Write phase1 gate (fail-closed), then P1.2 NGX core + adapter with the staged SDK headers.",
+ "updatedAt": "2026-09-02T21:35:00+08:00"
}
diff --git a/src/gfx/D3D12DeviceContext.cpp b/src/gfx/D3D12DeviceContext.cpp
index c9174ff8..1b190351 100644
--- a/src/gfx/D3D12DeviceContext.cpp
+++ b/src/gfx/D3D12DeviceContext.cpp
@@ -251,9 +251,8 @@ void D3D12DeviceContext::shutdown()
if (!initialized_) {
return;
}
- if (fence_ != nullptr && fenceEvent_ != nullptr) {
- (void)waitForFenceValue(nextFenceValue_ - 1, 5000);
- }
+ // Slot work is drained by CommandSlotRing::shutdown(); the context only
+ // owns the fence/event lifetime (ring is the sole signaler).
if (fenceEvent_ != nullptr) {
CloseHandle(fenceEvent_);
fenceEvent_ = nullptr;
@@ -266,16 +265,6 @@ void D3D12DeviceContext::shutdown()
veyra::log::info("gfx", "device context shutdown complete");
}
-uint64_t D3D12DeviceContext::signalNextFenceValue()
-{
- const uint64_t value = nextFenceValue_++;
- const HRESULT result = queue_->Signal(fence_.Get(), value);
- if (FAILED(result)) {
- veyra::log::error("gfx", std::format("fence signal failed hr={}", veyra::hresultString(result)));
- }
- return value;
-}
-
bool D3D12DeviceContext::waitForFenceValue(uint64_t value, uint32_t timeoutMs)
{
if (fence_->GetCompletedValue() >= value) {