GPU: make fence signaling monotonic, clamp sampler enums, and add unit tests #932

Open
opened 2026-11-26 04:14:23 +00:00 by github-bot · 2 comments
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 14:18 UTC · original

Summary

Fixes 2 real bugs in crates/victory-gpu/src/fence.rs and crates/victory-gpu/src/sampler.rs and adds 11 deterministic synthetic unit tests.

Because external PR creation is currently restricted (collaborators_only), the CI-green branch is ready on my fork for cherry-pick / review:

  • Branch: geiyiliyabumo/VIctory@test/gpu-fence-and-sampler
  • Commit: geiyiliyabumo/VIctory@370c61b (based on main ffe310e)

Changes

  • crates/victory-gpu/src/fence.rs:
    • Fixed signal using store (which allowed a lower signal value to move a D3D12 fence backwards) to use fetch_max(value, Ordering::AcqRel).
    • Added 5 unit tests (fence:: 6/6 PASS): monotonic signaling, creation flags & GPU address, COM interfaces/refcount, all 5 vtable slots, and Windows event waiters.
  • crates/victory-gpu/src/sampler.rs:
    • Clamped decoded D3D12_COMPARISON_FUNC (1..=8) and D3D12_TEXTURE_ADDRESS_MODE (1..=5) enum words so out-of-range title descriptors do not cause host CreateSampler to silently drop the descriptor.
    • Added 6 unit tests (sampler:: 7/7 PASS): filter bits, comparison/reduction encoding, comparison & anisotropy clamping, LOD/bias/border, and address modes.

Verification (Windows 11 x64 MSVC)

  • rustfmt --edition 2024 --check: PASS
  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings (default + --features diagnostics): PASS (0 warnings)
  • cargo test -p victory-gpu --locked -- fence:: (6/6 PASS) & -- sampler:: (7/7 PASS)

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 14:18 UTC · [original](https://github.com/Marvisak/VIctory/issues/932) ### Summary Fixes 2 real bugs in `crates/victory-gpu/src/fence.rs` and `crates/victory-gpu/src/sampler.rs` and adds 11 deterministic synthetic unit tests. Because external PR creation is currently restricted (`collaborators_only`), the CI-green branch is ready on my fork for cherry-pick / review: - **Branch**: `geiyiliyabumo/VIctory@test/gpu-fence-and-sampler` - **Commit**: `geiyiliyabumo/VIctory@370c61b` (based on `main` `ffe310e`) ### Changes - **`crates/victory-gpu/src/fence.rs`**: - Fixed `signal` using `store` (which allowed a lower signal value to move a D3D12 fence backwards) to use `fetch_max(value, Ordering::AcqRel)`. - Added 5 unit tests (`fence::` **6/6 PASS**): monotonic signaling, creation flags & GPU address, COM interfaces/refcount, all 5 vtable slots, and Windows event waiters. - **`crates/victory-gpu/src/sampler.rs`**: - Clamped decoded `D3D12_COMPARISON_FUNC` (`1..=8`) and `D3D12_TEXTURE_ADDRESS_MODE` (`1..=5`) enum words so out-of-range title descriptors do not cause host `CreateSampler` to silently drop the descriptor. - Added 6 unit tests (`sampler::` **7/7 PASS**): filter bits, comparison/reduction encoding, comparison & anisotropy clamping, LOD/bias/border, and address modes. ### Verification (Windows 11 x64 MSVC) - `rustfmt --edition 2024 --check`: **PASS** - `cargo xtask policy`: **PASS** (`154 files ok`) - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` (default + `--features diagnostics`): **PASS** (0 warnings) - `cargo test -p victory-gpu --locked -- fence::` (**6/6 PASS**) & `-- sampler::` (**7/7 PASS**) *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:23 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-24 14:25 UTC · original

Native D3D12 permits fence values to decrease. With WARP on Windows 10, signals 5 → 2 left GetCompletedValue() at 2. A new event for 4 stayed pending until the next signal of 4. D3D12 fence semantics

The VIctory regression test failed on 370c61b: the same signals left the value at 5. The follow-up restores the latest signal value and checks that an event registered after a rewind waits for the next qualifying signal. Fix and regression test

The commit is directly on 370c61b. After the fix, all 6 fence tests and 64 GPU diagnostics tests passed, with 1 existing benchmark ignored. Clippy and the asset policy check passed. AI-assisted.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-24 14:25 UTC · [original](https://github.com/Marvisak/VIctory/issues/932#issuecomment-7134360370) Native D3D12 permits fence values to decrease. With WARP on Windows 10, signals `5 → 2` left `GetCompletedValue()` at 2. A new event for 4 stayed pending until the next signal of 4. [D3D12 fence semantics](https://learn.microsoft.com/en-us/windows/win32/direct3d12/user-mode-heap-synchronization) The VIctory regression test failed on `370c61b`: the same signals left the value at 5. The follow-up restores the latest signal value and checks that an event registered after a rewind waits for the next qualifying signal. [Fix and regression test](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/3780ed782057f5894d7f6fb6cb956ea7cc87c02a) The commit is directly on `370c61b`. After the fix, all 6 fence tests and 64 GPU diagnostics tests passed, with 1 existing benchmark ignored. Clippy and the asset policy check passed. AI-assisted.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:57 UTC · original

Automated triage for the maintainers.

Neither change is needed as described:

  • Fence: signal in crates/victory-gpu/src/fence.rs stores the value as given. That matches native D3D12, where a fence's value may go down: the comment above shows WARP leaving GetCompletedValue() at 2 after signals 5 then 2. With fetch_max the regression test there fails, so the current behaviour is the correct one.
  • Sampler: address modes outside 1..=5 already fall back to CLAMP on main (address_mode in crates/victory-gpu/src/sampler.rs, from PR #474). The comparison function is passed through only when the comparison reduction is selected. A title descriptor with an out-of-range value there hasn't been shown.

The new unit tests could still be useful. Pull requests are open to everyone again if you want to offer them on their own.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:57 UTC · [original](https://github.com/Marvisak/VIctory/issues/932#issuecomment-7155329861) <!-- victory-issue-triage v1 verdict=answered seen=2026-11-24T14:25:48Z at=2026-11-25T06:57:09Z --> Automated triage for the maintainers. Neither change is needed as described: - **Fence:** `signal` in `crates/victory-gpu/src/fence.rs` stores the value as given. That matches native D3D12, where a fence's value may go down: the comment above shows WARP leaving `GetCompletedValue()` at 2 after signals 5 then 2. With `fetch_max` the regression test there fails, so the current behaviour is the correct one. - **Sampler:** address modes outside `1..=5` already fall back to `CLAMP` on `main` (`address_mode` in `crates/victory-gpu/src/sampler.rs`, from PR #474). The comparison function is passed through only when the comparison reduction is selected. A title descriptor with an out-of-range value there hasn't been shown. The new unit tests could still be useful. Pull requests are open to everyone again if you want to offer them on their own. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#932
No description provided.