fix: align appended vertex inputs for rectangle expansion #324

Open
github-bot wants to merge 1 commit from github-bot/gh-324 into main AGit
Owner

@⁠mauroalvare on GitHub · 2026-11-26 03:05 UTC · original
mauroalvare:codex/victory-rectangle-input-alignment → main · +210 −4 · 3 files · 1 commits · open

Change

Neptune's CPU fallback for rectangle draws uses GraphicsState::elements to locate the attributes for the synthesized fourth vertex. With R8G8_UINT followed by an appended R32G32_FLOAT, the fallback read the float pair at byte 2. D3D12's native input layout fetches that pair at byte 4, so the vertex shader saw the wrong attributes.

Use the input assembler's 1-, 2-, or 4-byte alignment for appended elements, with a cursor per slot and saturating offset arithmetic. This affects the CPU rectangle path in the D3D12 backend built by tools/lancer_victory.ps1. D3D12 input element documentation · Direct3D element alignment

The implementation adapts JFIREonFIRE's VIctory change and adds a GPU readback regression. The source and licence are recorded in THIRD_PARTY.md and the commit trailers. VIctory source commit

Verification

Base c4c93bdc413191a9dc909998d2d53080a3f0c880 and fix 7727e3f3ee7b5e3812c82e6d9a3299a730548e9c. On the base revision, apply just rectangle_input_tests.rs and its #[cfg(test)] module declaration from this PR. Run from third_party/victory. Leave VICTORY_D3D12_WARP unset for NVIDIA or set it to 1 for WARP.

cargo test --locked --offline -p victory-gpu --lib --features diagnostics pipeline::host::rectangle_input_tests::appended_rectangle_corner_reaches_the_vertex_shader -- --exact --nocapture --test-threads=1
Adapter Base Fix
GeForce RTX 5070 Ti, driver 621.40 offset 2, shader read (0.5, 0.75), failed offset 4, shader read (0.75, 1.0), passed
WARP, Microsoft Basic Render Driver offset 2, shader read (0.5, 0.75), failed offset 4, shader read (0.75, 1.0), passed

The exact dwords were [3f000000, 3f400000, 00000011] on the base and [3f400000, 3f800000, 00000011] on the fix. Both targeted runs on the fix reported 1 passed; 0 failed; 0 ignored and executed readback.

  • cargo test --locked --offline -p victory-gpu --lib --features diagnostics pipeline::host::rectangle_input_tests::appended_offsets_follow_their_own_input_slots -- --exact --test-threads=1 failed on the base with [0, 6, 1, 3, 8, 4] instead of [0, 6, 2, 4, 8, 8]. It passed with the fix and also covers the u32 limit on the CPU.
  • cargo test --locked --offline -p victory-gpu --lib --features diagnostics -- --test-threads=1 reported 198 passed, 3 failed, 3 ignored. The matching main baseline had 196 passed, 3 failed, 3 ignored. The same assertions failed in spans_say_the_next_start_and_the_lowest_level_viewed, warp_card_fetch_copies_flagged_pieces_to_their_slots, and warp_card_patch_writes_the_masked_bytes_and_no_others.
  • cargo test --locked --offline -p victory-loader --test load_probe reported 2 passed.
  • cargo build --locked --offline --release -p victory passed.
  • cargo xtask policy reported asset policy: 200 files ok.
  • cargo test --release --locked --offline --manifest-path rust/Cargo.toml reported 12 passed in total.
  • python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools reported All checks passed!.
  • python -m pytest -rs with ANYXBOXX_REQUIRE_RUNTIME=1 on Python 3.13.15 reported 1665 passed in 100.29s (0:01:40).

Oracle and test data

The fixture creates three padded vertices of one tilted rectangle. It passes the production input offsets to primitive::expand_rects, then draws a point with the synthesized corner using the native append-aligned input layout. The vertex shader writes the fetched coordinates and a control tag to a UAV for readback. The expected corner follows v0 + v2 - v1. The vertex data and shader are generated by the test.

Checklist

  • One change to the offsets used by CPU rectangle expansion.
  • The regression fails on the base and passes on the fix.
  • Commands, results and adapter evidence are recorded above.
  • Synthetic inputs and third-party attribution checked.

AI assistance was used for investigation, implementation, and verification with OpenAI Codex.

**@⁠mauroalvare** on GitHub · 2026-11-26 03:05 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/324) `mauroalvare:codex/victory-rectangle-input-alignment` → `main` · +210 −4 · 3 files · 1 commits · open ## Change Neptune's CPU fallback for rectangle draws uses `GraphicsState::elements` to locate the attributes for the synthesized fourth vertex. With `R8G8_UINT` followed by an appended `R32G32_FLOAT`, the fallback read the float pair at byte 2. D3D12's native input layout fetches that pair at byte 4, so the vertex shader saw the wrong attributes. Use the input assembler's 1-, 2-, or 4-byte alignment for appended elements, with a cursor per slot and saturating offset arithmetic. This affects the CPU rectangle path in the D3D12 backend built by `tools/lancer_victory.ps1`. [D3D12 input element documentation](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_input_element_desc) · [Direct3D element alignment](https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm) The implementation adapts JFIREonFIRE's VIctory change and adds a GPU readback regression. The source and licence are recorded in `THIRD_PARTY.md` and the commit trailers. [VIctory source commit](https://github.com/Marvisak/VIctory/commit/691236d606b9de8cbccfa8540e2b27ca6070f8ae) ## Verification Base `c4c93bdc413191a9dc909998d2d53080a3f0c880` and fix `7727e3f3ee7b5e3812c82e6d9a3299a730548e9c`. On the base revision, apply just `rectangle_input_tests.rs` and its `#[cfg(test)]` module declaration from this PR. Run from `third_party/victory`. Leave `VICTORY_D3D12_WARP` unset for NVIDIA or set it to `1` for WARP. ```powershell cargo test --locked --offline -p victory-gpu --lib --features diagnostics pipeline::host::rectangle_input_tests::appended_rectangle_corner_reaches_the_vertex_shader -- --exact --nocapture --test-threads=1 ``` | Adapter | Base | Fix | | --- | --- | --- | | GeForce RTX 5070 Ti, driver 621.40 | offset 2, shader read `(0.5, 0.75)`, failed | offset 4, shader read `(0.75, 1.0)`, passed | | WARP, Microsoft Basic Render Driver | offset 2, shader read `(0.5, 0.75)`, failed | offset 4, shader read `(0.75, 1.0)`, passed | The exact dwords were `[3f000000, 3f400000, 00000011]` on the base and `[3f400000, 3f800000, 00000011]` on the fix. Both targeted runs on the fix reported `1 passed; 0 failed; 0 ignored` and executed readback. - `cargo test --locked --offline -p victory-gpu --lib --features diagnostics pipeline::host::rectangle_input_tests::appended_offsets_follow_their_own_input_slots -- --exact --test-threads=1` failed on the base with `[0, 6, 1, 3, 8, 4]` instead of `[0, 6, 2, 4, 8, 8]`. It passed with the fix and also covers the `u32` limit on the CPU. - `cargo test --locked --offline -p victory-gpu --lib --features diagnostics -- --test-threads=1` reported 198 passed, 3 failed, 3 ignored. The matching main baseline had 196 passed, 3 failed, 3 ignored. The same assertions failed in `spans_say_the_next_start_and_the_lowest_level_viewed`, `warp_card_fetch_copies_flagged_pieces_to_their_slots`, and `warp_card_patch_writes_the_masked_bytes_and_no_others`. - `cargo test --locked --offline -p victory-loader --test load_probe` reported 2 passed. - `cargo build --locked --offline --release -p victory` passed. - `cargo xtask policy` reported `asset policy: 200 files ok`. - `cargo test --release --locked --offline --manifest-path rust/Cargo.toml` reported 12 passed in total. - `python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools` reported `All checks passed!`. - `python -m pytest -rs` with `ANYXBOXX_REQUIRE_RUNTIME=1` on Python 3.13.15 reported `1665 passed in 100.29s (0:01:40)`. ## Oracle and test data The fixture creates three padded vertices of one tilted rectangle. It passes the production input offsets to `primitive::expand_rects`, then draws a point with the synthesized corner using the native append-aligned input layout. The vertex shader writes the fetched coordinates and a control tag to a UAV for readback. The expected corner follows `v0 + v2 - v1`. The vertex data and shader are generated by the test. ## Checklist - [x] One change to the offsets used by CPU rectangle expansion. - [x] The regression fails on the base and passes on the fix. - [x] Commands, results and adapter evidence are recorded above. - [x] Synthetic inputs and third-party attribution checked. AI assistance was used for investigation, implementation, and verification with OpenAI Codex.
Match D3D12 input-assembler packing when the CPU fallback synthesizes
the fourth vertex of a rectangle. Keep offsets per input slot and
saturate the arithmetic at the u32 limit.

Verify the expanded corner by fetching one point with the native D3D12
input layout and reading its vertex shader output.

Source: Marvisak/VIctory 691236d606b9de8cbccfa8540e2b27ca6070f8ae
Co-authored-by: JFIREonFIRE <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:43:04 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/324/head:github-bot/gh-324'
git switch 'github-bot/gh-324'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-324'
git switch 'github-bot/gh-324'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-324'
git switch 'github-bot/gh-324'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-324'
git switch 'main'
git merge --squash 'github-bot/gh-324'
git switch 'main'
git merge --ff-only 'github-bot/gh-324'
git switch 'main'
git merge 'github-bot/gh-324'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.