D3D12 shader: reach mixed typed table reads in the D16 round-trip test #2540

Merged
kirigayakazima merged 1 commit from upstream-pr/2540 into main 2026-11-28 20:20:18 +00:00
kirigayakazima commented 2026-11-28 01:23:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-28T01:23:56Z.


D3D12-TABLE-D16-REGRESSION. Claim.

The typed D16 table test on main stops before the first dispatch. Its source and destination table slots were used exclusively for D16 accesses, so the translator correctly picked unsigned twin views and omitted SLOT_TABLE_STRIDES. Give both slots a whole-channel read too. These mixed-use slots retain their declared formats, so the original root-binding assertions and bit-exact readbacks now cover the intended typed path, including a nonzero table base.

Windows base 431ceba4f: the full leonida-shader library suite reported 347 passed, 1 failed (this test), 4 ignored. After the change cargo test --manifest-path d3d12/Cargo.toml --locked -p leonida-shader --lib typed_d16_table_uav_roundtrip -- --test-threads=1 passed. A separate local verification run required both hardware and WARP device creation to succeed and passed the UINT, SINT and FLOAT readbacks on both. No executable shader code or retail data is included in this PR; the test extends its existing hand-authored source fixture. Diff whitespace and no-game-data checks passed.

GPUs tested: Windows D3D12 hardware adapter on an RTX 4070 Laptop GPU system (NVIDIA 610.74), plus WARP. No in-game image or performance measurement. Independent PR. AI-assisted with OpenAI Codex (GPT-6).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5535339628 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2540). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-28T01:23:56Z. --- D3D12-TABLE-D16-REGRESSION. [Claim](https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7231617930). The typed D16 table test on main stops before the first dispatch. Its source and destination table slots were used exclusively for D16 accesses, so the translator correctly picked unsigned twin views and omitted SLOT_TABLE_STRIDES. Give both slots a whole-channel read too. These mixed-use slots retain their declared formats, so the original root-binding assertions and bit-exact readbacks now cover the intended typed path, including a nonzero table base. Windows base 431ceba4f: the full leonida-shader library suite reported 347 passed, 1 failed (this test), 4 ignored. After the change `cargo test --manifest-path d3d12/Cargo.toml --locked -p leonida-shader --lib typed_d16_table_uav_roundtrip -- --test-threads=1` passed. A separate local verification run required both hardware and WARP device creation to succeed and passed the UINT, SINT and FLOAT readbacks on both. No executable shader code or retail data is included in this PR; the test extends its existing hand-authored source fixture. Diff whitespace and no-game-data checks passed. GPUs tested: Windows D3D12 hardware adapter on an RTX 4070 Laptop GPU system (NVIDIA 610.74), plus WARP. No in-game image or performance measurement. Independent PR. AI-assisted with OpenAI Codex (GPT-6).
timbot103 commented 2026-11-28 02:02:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T02:02:34Z.


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

Notes

  • Adding two ordinary buffer_load_format_x instructions referencing the same descriptor sources (d3d12/crates/leonida-shader/src/emit/valu_tests.rs:2205-2225) cleanly disqualifies those slots from the half-only set during pre-lowering classification (halves.rs:17-25, 67-146; lower.rs:3136, 13063-13079), even if dead-code elimination later drops the unused results.
  • Both D16 operations now exercise integer_view and request SLOT_TABLE_STRIDES (lower.rs:8871-8918, 13331-13355, 13514-13537), and the test verifies the root SRV presence alongside UINT/SINT/FLOAT round-trip comparisons.

Approve.

AI-assisted static review.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232089166 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2540#issuecomment-7232089166). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-28T02:02:34Z. --- Static review at head `698d1cceb` (Rust toolchain is not installed in this local environment, so `cargo test` was not executed locally). ### Notes - Adding two ordinary `buffer_load_format_x` instructions referencing the same descriptor sources (`d3d12/crates/leonida-shader/src/emit/valu_tests.rs:2205-2225`) cleanly disqualifies those slots from the half-only set during pre-lowering classification (`halves.rs:17-25`, `67-146`; `lower.rs:3136`, `13063-13079`), even if dead-code elimination later drops the unused results. - Both D16 operations now exercise `integer_view` and request `SLOT_TABLE_STRIDES` (`lower.rs:8871-8918`, `13331-13355`, `13514-13537`), and the test verifies the root SRV presence alongside UINT/SINT/FLOAT round-trip comparisons. Approve. AI-assisted static review.
zmasi commented 2026-11-28 02:19:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T02:19:31Z.

Review: COMMENTED


Verified at head 698d1cceb on Windows 11 with NVIDIA GeForce RTX 3090 (driver 610.88) D3D12 and WARP, including negative control on main (431ceba4f):

  • Code check:
    • In Lower::places_read_as_halves() (crates/leonida-shader/src/emit/halves.rs), table slots s[8:11] and s[12:15] were previously touched only by buffer_load_format_d16_xyzw / buffer_store_format_d16_xyzw, placing both in halves_only (HostShader::half_views unsigned twins) so SLOT_TABLE_STRIDES was not requested.
    • Emitting buffer_load_format_x into otherwise-unused v6 and v7 (read_only_as_halves returns false when used == false, disjoint from v0, v[2:3], and v4) inserts both table places into other, keeping both slots on their declared UINT/SINT/FLOAT UAV formats and exercising SLOT_TABLE_STRIDES format-bit unpacking/packing (including at dynamic base_slot = 3).
  • Negative control on 431ceba4f: reproduced typed_d16_table_uav_roundtrip_uint_sint_and_float panicking at valu_tests.rs:2235 (table typed d16 shader should request SLOT_TABLE_STRIDES).
  • Positive runs on 698d1cceb:
    • cargo test -p leonida-shader typed_d16_table_uav_roundtrip -- --test-threads=1: 1 passed; 0 failed across all 4 UINT/SINT/FLOAT/dynamic-offset cases on both "hardware" (RTX 3090 D3D12) and "warp" (WARP).
    • cargo test -p leonida-shader emit::valu_tests:: -- --test-threads=4: 37 passed; 0 failed; 1 ignored.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6095164313 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2540#pullrequestreview-6095164313). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T02:19:31Z. **Review:** COMMENTED --- Verified at head `698d1cceb` on Windows 11 with **NVIDIA GeForce RTX 3090 (driver `610.88`)** D3D12 and **WARP**, including negative control on `main` (`431ceba4f`): - **Code check**: - In `Lower::places_read_as_halves()` (`crates/leonida-shader/src/emit/halves.rs`), table slots `s[8:11]` and `s[12:15]` were previously touched only by `buffer_load_format_d16_xyzw` / `buffer_store_format_d16_xyzw`, placing both in `halves_only` (`HostShader::half_views` unsigned twins) so `SLOT_TABLE_STRIDES` was not requested. - Emitting `buffer_load_format_x` into otherwise-unused `v6` and `v7` (`read_only_as_halves` returns `false` when `used == false`, disjoint from `v0`, `v[2:3]`, and `v4`) inserts both table places into `other`, keeping both slots on their declared `UINT`/`SINT`/`FLOAT` UAV formats and exercising `SLOT_TABLE_STRIDES` format-bit unpacking/packing (including at dynamic `base_slot = 3`). - **Negative control on `431ceba4f`**: reproduced `typed_d16_table_uav_roundtrip_uint_sint_and_float` panicking at `valu_tests.rs:2235` (`table typed d16 shader should request SLOT_TABLE_STRIDES`). - **Positive runs on `698d1cceb`**: - `cargo test -p leonida-shader typed_d16_table_uav_roundtrip -- --test-threads=1`: `1 passed; 0 failed` across all 4 `UINT`/`SINT`/`FLOAT`/dynamic-offset cases on both `"hardware"` (RTX 3090 D3D12) and `"warp"` (WARP). - `cargo test -p leonida-shader emit::valu_tests:: -- --test-threads=4`: `37 passed; 0 failed; 1 ignored`. AI-assisted.
lixonik commented 2026-11-28 09:28:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-28T09:28:53Z.

Review: APPROVED


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

Adding a whole-channel mubuf_idxen(0x00, ...) read on both typed UAV table slots keeps their declared formats instead of lowering to unsigned twins, so the shader requests SLOT_TABLE_STRIDES and exercises the intended typed D16 round-trip path on both hardware D3D12 and WARP.

Tests run

  • cargo test --manifest-path d3d12/Cargo.toml --locked -p leonida-shader --lib typed_d16_table_uav_roundtrip -- --test-threads=1 (with LEONIDA_DXIL unset/skipped for the old 10.0.19041 inbox dxil.dll): 1 passed, 0 failed (0.21 s, covering hardware D3D12 + WARP UINT/SINT/FLOAT readbacks).

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

AI-assisted (Antigravity, Gemini).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6096965352 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2540#pullrequestreview-6096965352). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-28T09:28:53Z. **Review:** APPROVED --- Reviewed the diff and tested merged onto `main` (`493867366`) on Windows 11 with Rust 1.100.1 (MSVC). Adding a whole-channel `mubuf_idxen(0x00, ...)` read on both typed UAV table slots keeps their declared formats instead of lowering to unsigned twins, so the shader requests `SLOT_TABLE_STRIDES` and exercises the intended typed D16 round-trip path on both hardware D3D12 and WARP. ### Tests run - `cargo test --manifest-path d3d12/Cargo.toml --locked -p leonida-shader --lib typed_d16_table_uav_roundtrip -- --test-threads=1` (with `LEONIDA_DXIL` unset/skipped for the old 10.0.19041 inbox `dxil.dll`): **1 passed, 0 failed** (0.21 s, covering hardware D3D12 + WARP UINT/SINT/FLOAT readbacks). GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88) + WARP. AI-assisted (Antigravity, Gemini).
zmasi commented 2026-11-28 11:24:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T11:24:06Z.


VERIFY-2540-D3D12 — verified head 698d1ccebc merged cleanly with main c7f5330e0 on Windows 11 Pro (build 26200), NVIDIA GeForce RTX 3090 (driver 610.88) + D3D12 WARP, synthetic shader test inputs only.

Red (main c7f5330e0) -> Green (c7f5330e0 + 698d1ccebc)

  • Red on main:
    • cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib emit::valu_tests::typed_d16_table_uav_roundtrip_uint_sint_and_float -- --exact --test-threads=1 -> FAILED (table typed d16 shader should request SLOT_TABLE_STRIDES at d3d12/crates/leonida-shader/src/emit/valu_tests.rs:2235, because D16-only table slots now use unsigned twin views and omit SLOT_TABLE_STRIDES).
  • Green on merged PR:
    • cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib emit::valu_tests::typed_d16_table_uav_roundtrip_uint_sint_and_float -- --exact --test-threads=1 -> 1 passed; 0 failed (0.49s, exercising both RTX 3090 D3D12 hardware and WARP UINT, SINT, and FLOAT readbacks).
    • cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib -- --test-threads=4 -> 348 passed; 0 failed; 4 ignored.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238526348 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2540#issuecomment-7238526348). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T11:24:06Z. --- `VERIFY-2540-D3D12` — verified head `698d1ccebc` merged cleanly with `main` `c7f5330e0` on Windows 11 Pro (build 26200), NVIDIA GeForce RTX 3090 (driver 610.88) + D3D12 WARP, synthetic shader test inputs only. ### Red (`main` `c7f5330e0`) -> Green (`c7f5330e0` + `698d1ccebc`) - **Red on `main`**: - `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib emit::valu_tests::typed_d16_table_uav_roundtrip_uint_sint_and_float -- --exact --test-threads=1` -> **FAILED** (`table typed d16 shader should request SLOT_TABLE_STRIDES` at `d3d12/crates/leonida-shader/src/emit/valu_tests.rs:2235`, because D16-only table slots now use unsigned twin views and omit `SLOT_TABLE_STRIDES`). - **Green on merged PR**: - `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib emit::valu_tests::typed_d16_table_uav_roundtrip_uint_sint_and_float -- --exact --test-threads=1` -> **1 passed; 0 failed** (`0.49s`, exercising both RTX 3090 D3D12 hardware and WARP `UINT`, `SINT`, and `FLOAT` readbacks). - `cargo test --manifest-path d3d12/Cargo.toml -p leonida-shader --lib -- --test-threads=4` -> **348 passed; 0 failed; 4 ignored**. AI-assisted.
MoonEyes commented 2026-11-28 20:20:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T20:20:12Z.


Red/green: On main typed_d16_table_uav_roundtrip fails, and with the PR's two whole-channel reads keeping the typed slots' formats cargo test -p leonida-shader --lib -- typed_d16_table_uav_roundtrip passes 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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7245211257 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2540#issuecomment-7245211257). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T20:20:12Z. --- Red/green: On main typed_d16_table_uav_roundtrip fails, and with the PR's two whole-channel reads keeping the typed slots' formats cargo test -p leonida-shader --lib -- typed_d16_table_uav_roundtrip passes 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:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T22:04:40Z.


Verified by OreoFR

  • Base: main 54d27d988 + PR head 698d1cceb; green run in a merge package of 5 PRs, no new ctest failure vs main
  • Test: cargo test -p leonida-shader --lib --locked -- typed_d16_table_uav_roundtrip
  • Red on main: 1 failure on main ("table typed d16 shader should request SLOT_TABLE_STRIDES")
  • Green with the PR: 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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246479454 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2540#issuecomment-7246479454). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T22:04:40Z. --- **Verified by OreoFR** - Base: main `54d27d988` + PR head `698d1cceb`; green run in a merge package of 5 PRs, no new ctest failure vs main - Test: `cargo test -p leonida-shader --lib --locked -- typed_d16_table_uav_roundtrip` - Red on main: 1 failure on main ("table typed d16 shader should request SLOT_TABLE_STRIDES") - Green with the PR: 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 reviewers
No labels
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.

Reference
ProjectLeonida/mandy!2540
No description provided.