D3D12: anchor the placed-view regression to its backing buffer #2538

Merged
leonida/mandy
kirigayakazima merged 1 commit from codex/d3d12-descriptor-view-backing into main 2026-11-28 20:20:46 +00:00

Pull request successfully merged and closed

kirigayakazima commented 2026-11-28 01:20:08 +00:00

D3D12-DESCRIPTOR-VIEW-BACKING-TEST. Claim.

The placed-view test assumes its 456-byte structured element starts exactly one element into a backing buffer. It supplied only loose process memory. Aligning start to 4 KiB does not give the host window that origin, so the shared-buffer assertion could fail with the default LEONIDA_STRUCTURED_BYTES=0. Register a 4 KiB backing range for the existing fixture and release the registration before its memory drops, including on a panic. The same raw/structured resource-width and copy-span assertions still exercise the production path.

On Windows at 431ceba4f, running the single test separately failed with STRUCTURED_BYTES=0 and passed with =1. On this branch the single test passed in separate processes with each setting (cargo test --manifest-path d3d12/Cargo.toml --locked -p leonida-gpu --lib views_off_their_elements_get_a_copy_of_their_bytes -- --test-threads=1). In a local combined checkout with #2537 the full GPU library suite passed: 483 passed, 46 ignored. Diff whitespace and no-game-data checks passed.

GPUs tested: Windows system with RTX 4070 Laptop GPU, driver 610.74. Synthetic descriptor test; retail rendering was not measured. Independent of #2537. AI-assisted with OpenAI Codex (GPT-6).

D3D12-DESCRIPTOR-VIEW-BACKING-TEST. [Claim](https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7231574267). The placed-view test assumes its 456-byte structured element starts exactly one element into a backing buffer. It supplied only loose process memory. Aligning start to 4 KiB does not give the host window that origin, so the shared-buffer assertion could fail with the default LEONIDA_STRUCTURED_BYTES=0. Register a 4 KiB backing range for the existing fixture and release the registration before its memory drops, including on a panic. The same raw/structured resource-width and copy-span assertions still exercise the production path. On Windows at 431ceba4f, running the single test separately failed with STRUCTURED_BYTES=0 and passed with =1. On this branch the single test passed in separate processes with each setting (`cargo test --manifest-path d3d12/Cargo.toml --locked -p leonida-gpu --lib views_off_their_elements_get_a_copy_of_their_bytes -- --test-threads=1`). In a local combined checkout with #2537 the full GPU library suite passed: 483 passed, 46 ignored. Diff whitespace and no-game-data checks passed. GPUs tested: Windows system with RTX 4070 Laptop GPU, driver 610.74. Synthetic descriptor test; retail rendering was not measured. Independent of #2537. AI-assisted with OpenAI Codex (GPT-6).
timbot103 commented 2026-11-28 02:02:35 +00:00

Static review at head 243e536bd (Rust toolchain is not installed in this local environment, so cargo test was not executed locally).

Notes

  • Anchoring the placed-view test to a live 4 KiB range registered against a 64 KiB backing allocation (d3d12/crates/leonida-gpu/src/descriptor/host.rs:6405-6421) eliminates window-grid alignment drift in loose shadow lookups (shadow.rs:5913-5927, 6033-6068, 6125-6136), and the RAII guard unregisters the same key before the backing allocation drops (including on unwind).
  • The offset assertions (8 vs. 16/32 vs. 456) now deterministically test exact-sized copy selection vs. backing reuse across both descriptor creation and refresh.

Approve.

AI-assisted static review.

Static review at head `243e536bd` (Rust toolchain is not installed in this local environment, so `cargo test` was not executed locally). ### Notes - Anchoring the placed-view test to a live 4 KiB range registered against a 64 KiB backing allocation (`d3d12/crates/leonida-gpu/src/descriptor/host.rs:6405-6421`) eliminates window-grid alignment drift in loose shadow lookups (`shadow.rs:5913-5927`, `6033-6068`, `6125-6136`), and the RAII guard unregisters the same key before the backing allocation drops (including on unwind). - The offset assertions (8 vs. 16/32 vs. 456) now deterministically test exact-sized copy selection vs. backing reuse across both descriptor creation and refresh. Approve. AI-assisted static review.
zmasi left a comment
No description provided.
Verified at head `243e536bd` on Windows 11 with **NVIDIA GeForce RTX 3090 (driver `610.88`)** D3D12 (where `raw_views() == 0` on the 1M-descriptor tier) and **WARP** (`--features diagnostics`, `LEONIDA_D3D12_WARP=1`), including negative control on `main` (`431ceba4f`): - **Code & drop-order check**: - Without a registered backing buffer at `start`, `shadow::find(start + 456, 4 * 456)` resolved a loose-memory window whose cell origin is `WINDOW`-aligned; since `4096 % 456 == 448 != 0`, `(start - window_origin) + 456` was off-element (`!offset.is_multiple_of(456)`) for 56 of 57 4 KiB page offsets inside a cell, causing `off_elements` to request `shadow::exact` even under `LEONIDA_STRUCTURED_BYTES=0`. - Registering `[start, start + 4096)` covers every view range tested (`max end = 32 + 4 * 456 = 1,856`, `456 + 4 * 456 = 2,280 <= 4,096` within the 64 KiB `memory` allocation), anchors `shadow.offset(start + 456)` to `456` (`1 * 456`), and declares `_backing` after `memory` so `Backing::drop` calls `shadow::unregister` before `memory` is freed (including on unwind). - **Negative control on `431ceba4f` (`LEONIDA_STRUCTURED_BYTES=0`, RTX 3090)**: reproduced the panic at `descriptor/host.rs:6457` (`copy.span().0 == start + 456`). - **Positive runs on `243e536bd`** (`views_off_their_elements_get_a_copy_of_their_bytes`): - RTX 3090 D3D12, `LEONIDA_STRUCTURED_BYTES=0` (`else` branch: stays on backing buffer copy): `1 passed; 0 failed`. - RTX 3090 D3D12, `LEONIDA_STRUCTURED_BYTES=1` (`raw_views() == 0 && structured_bytes()` branch: gets exact `[start + 456, +1824)` copy): `1 passed; 0 failed`. - WARP (`--features diagnostics`, `LEONIDA_D3D12_WARP=1`), `LEONIDA_STRUCTURED_BYTES=0` and `=1`: `1 passed; 0 failed` in both modes. AI-assisted.
lixonik approved these changes 2026-11-28 09:20:48 +00:00
lixonik left a comment

Reviewed the diff and tested merged onto main (493867366) on Windows 11 with Rust 1.100.1 (MSVC).

Registering a 4 KiB backing range via crate::shadow::register with a Drop guard cleanly anchors the placed-view fixture for both LEONIDA_STRUCTURED_BYTES=0 and =1.

Tests run

  • cargo test --manifest-path d3d12/Cargo.toml --locked -p leonida-gpu --lib views_off_their_elements_get_a_copy_of_their_bytes -- --test-threads=1:
    • LEONIDA_STRUCTURED_BYTES=0: 1 passed, 0 failed (0.23 s).
    • LEONIDA_STRUCTURED_BYTES=1: 1 passed, 0 failed (0.21 s).

GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88).

AI-assisted (Antigravity, Gemini).

Reviewed the diff and tested merged onto `main` (`493867366`) on Windows 11 with Rust 1.100.1 (MSVC). Registering a 4 KiB backing range via `crate::shadow::register` with a `Drop` guard cleanly anchors the placed-view fixture for both `LEONIDA_STRUCTURED_BYTES=0` and `=1`. ### Tests run - `cargo test --manifest-path d3d12/Cargo.toml --locked -p leonida-gpu --lib views_off_their_elements_get_a_copy_of_their_bytes -- --test-threads=1`: - `LEONIDA_STRUCTURED_BYTES=0`: **1 passed, 0 failed** (0.23 s). - `LEONIDA_STRUCTURED_BYTES=1`: **1 passed, 0 failed** (0.21 s). GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88). AI-assisted (Antigravity, Gemini).
zmasi commented 2026-11-28 11:24:07 +00:00

VERIFY-2538-D3D12 — verified head 243e536bd8 merged cleanly with main c7f5330e0 on Windows 11 Pro (build 26200), NVIDIA GeForce RTX 3090 (driver 610.88), synthetic descriptor test inputs only.

Red (main c7f5330e0) -> Green (c7f5330e0 + 243e536bd8)

  • Red on main:
    • LEONIDA_STRUCTURED_BYTES=0 cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib descriptor::host::tests:: -- --test-threads=1 -> FAILED (45 passed; 1 failed; 1 ignored: descriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes panicked at d3d12/crates/leonida-gpu/src/descriptor/host.rs:6457 with assertion 'left != right' failed: its buffer's copy whenever start lands on one of the 15 non-64-KiB-aligned 4 KiB pages inside a loose 64 KiB host window, so (start % 65536 + 456) % 456 != 0).
  • Green on merged PR:
    • LEONIDA_STRUCTURED_BYTES=0 cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib descriptor::host::tests:: -- --test-threads=1 -> 46 passed; 0 failed; 1 ignored (0.85s).
    • LEONIDA_STRUCTURED_BYTES=0 and LEONIDA_STRUCTURED_BYTES=1 isolated runs (--exact --test-threads=1) -> 1 passed; 0 failed in both modes.

AI-assisted.

`VERIFY-2538-D3D12` — verified head `243e536bd8` merged cleanly with `main` `c7f5330e0` on Windows 11 Pro (build 26200), NVIDIA GeForce RTX 3090 (driver 610.88), synthetic descriptor test inputs only. ### Red (`main` `c7f5330e0`) -> Green (`c7f5330e0` + `243e536bd8`) - **Red on `main`**: - `LEONIDA_STRUCTURED_BYTES=0 cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib descriptor::host::tests:: -- --test-threads=1` -> **FAILED** (`45 passed; 1 failed; 1 ignored`: `descriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes` panicked at `d3d12/crates/leonida-gpu/src/descriptor/host.rs:6457` with `assertion 'left != right' failed: its buffer's copy` whenever `start` lands on one of the 15 non-64-KiB-aligned 4 KiB pages inside a loose 64 KiB host window, so `(start % 65536 + 456) % 456 != 0`). - **Green on merged PR**: - `LEONIDA_STRUCTURED_BYTES=0 cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib descriptor::host::tests:: -- --test-threads=1` -> **46 passed; 0 failed; 1 ignored** (`0.85s`). - `LEONIDA_STRUCTURED_BYTES=0` and `LEONIDA_STRUCTURED_BYTES=1` isolated runs (`--exact --test-threads=1`) -> **1 passed; 0 failed** in both modes. AI-assisted.
MoonEyes commented 2026-11-28 20:20:43 +00:00

Red/green: On main the views_off_their_elements test fails because its placed views have no shared backing buffer, and with the PR cargo test -p leonida-gpu --lib -- views_off_their_elements passes (2 OK) on Windows 11 at OreoFR's (RTX 4070).
Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.

Red/green: On main the views_off_their_elements test fails because its placed views have no shared backing buffer, and with the PR cargo test -p leonida-gpu --lib -- views_off_their_elements passes (2 OK) on Windows 11 at OreoFR's (RTX 4070). Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.
OreoFR commented 2026-11-28 22:04:34 +00:00

Verified by OreoFR

  • Base: main 54d27d988 + PR head 243e536bd; green run in a merge package of 5 PRs, no new ctest failure vs main
  • Test: cargo test -p leonida-gpu --lib --locked -- views_off_their_elements
  • Red on main: 1 failure on main (views_off_their_elements_get_a_copy_of_their_bytes, "its buffer's copy")
  • Green with the PR: 2 OK
  • Verdict: READY (test-only PR: main is the red)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

**Verified by OreoFR** - Base: main `54d27d988` + PR head `243e536bd`; green run in a merge package of 5 PRs, no new ctest failure vs main - Test: `cargo test -p leonida-gpu --lib --locked -- views_off_their_elements` - Red on main: 1 failure on main (views_off_their_elements_get_a_copy_of_their_bytes, "its buffer's copy") - Green with the PR: 2 OK - Verdict: READY (test-only PR: main is the red) - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
Sign in to join this conversation.
No description provided.