D3D12-SHADOW-RAY-COMPUTED-DESCRIPTOR: resolve root-indexed view addresses on the host #3026

Closed
bobcatchris wants to merge 1 commit from upstream-pr/3026 into main
bobcatchris commented 2026-12-02 01:06:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-02T01:06:29Z.


Claimed in the coordination issue as: D3D12-SHADOW-RAY-COMPUTED-DESCRIPTOR

What and why

The five CS_TraceShadowRays compute programs reported in the coordination issue were refused with a descriptor read only as data. Their s_load_dwordx4 reads a descriptor at a table offset computed from a root constant; view_address refused every dynamic offset.

This change teaches the native D3D12 translator and host to resolve that case:

  • resource.rs records a RootIndexedView for a table load whose dynamic term is a root constant, including when the descriptor is read only as data and no resource use names it; the map is keyed by the load site so lowering finds the right entry.
  • emit/lower.rs asks the host for the view's title address through two new user-data words (USER_INDEXED_VIEW_ADDRESS, +1) with the recorded entry as the index.
  • draw.rs resolves the root constant at bind time using the same root_indexed_views entry the descriptor-selection path already uses, and adds the resulting address to the memory copies made ready.

Static offsets, non-root-constant offsets and every other descriptor use keep their existing behavior; nothing is skipped or disabled.

Tested

  • Three hand-written Rust fixtures: resource::tests::data_only_root_indexed_view_is_tracked, emit::lower::tests::a_buffer_address_picked_by_a_root_constant_from_a_table, and draw::cache_tests::indexed_view_byte_offset_from_root_constant.
  • Red/green: with the dynamic branch of view_address returned to the old behavior, the lowering fixture fails with a descriptor read only as data; with the change it passes.
  • cargo test -p leonida-shader --locked (422 passed, 5 ignored) and cargo test -p leonida-gpu --locked (657 passed, 59 ignored), re-run after rebasing on current main.
  • python -I scripts/check_no_game_data.py on all changed files and python -m unittest discover -s tests -p "test_docs_*.py" (57 tests) — clean.
  • Independent read-only review: Gemini 4 Neon (mode review, thinking low) audited the full diff; its findings (a multi-descriptor indexed_of clobber and a missing host-side arithmetic test) were fixed.

Not verified here: the corpus is not present on this machine, so I could not re-run the five CS_TraceShadowRays programs through the translator or check the shadow result in-game. The 5-of-26,506 refusal count comes from fiestorra's board report. The new rule is in the contract table of docs/design.md with that limitation stated explicitly. No .asm fixture was added to tests/semantic/ because this rule is in the native Rust translator (the Python translator has no host user-data concept); its regression tests are the Rust fixtures above.

GPUs tested: n/a (offline Rust unit tests; no in-game run in this pull request)

AI-assisted: yes — Gemini 4 Neon (architecture direction and independent review).

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5597698814 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3026). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-02T01:06:29Z. --- Claimed in the coordination issue as: D3D12-SHADOW-RAY-COMPUTED-DESCRIPTOR ### What and why The five `CS_TraceShadowRays` compute programs reported in the coordination issue were refused with `a descriptor read only as data`. Their `s_load_dwordx4` reads a descriptor at a table offset computed from a root constant; `view_address` refused every dynamic offset. This change teaches the native D3D12 translator and host to resolve that case: - `resource.rs` records a `RootIndexedView` for a table load whose dynamic term is a root constant, including when the descriptor is read only as data and no resource use names it; the map is keyed by the load site so lowering finds the right entry. - `emit/lower.rs` asks the host for the view's title address through two new user-data words (`USER_INDEXED_VIEW_ADDRESS`, `+1`) with the recorded entry as the index. - `draw.rs` resolves the root constant at bind time using the same `root_indexed_views` entry the descriptor-selection path already uses, and adds the resulting address to the memory copies made ready. Static offsets, non-root-constant offsets and every other descriptor use keep their existing behavior; nothing is skipped or disabled. ### Tested - Three hand-written Rust fixtures: `resource::tests::data_only_root_indexed_view_is_tracked`, `emit::lower::tests::a_buffer_address_picked_by_a_root_constant_from_a_table`, and `draw::cache_tests::indexed_view_byte_offset_from_root_constant`. - Red/green: with the dynamic branch of `view_address` returned to the old behavior, the lowering fixture fails with `a descriptor read only as data`; with the change it passes. - `cargo test -p leonida-shader --locked` (422 passed, 5 ignored) and `cargo test -p leonida-gpu --locked` (657 passed, 59 ignored), re-run after rebasing on current `main`. - `python -I scripts/check_no_game_data.py` on all changed files and `python -m unittest discover -s tests -p "test_docs_*.py"` (57 tests) — clean. - Independent read-only review: Gemini 4 Neon (mode review, thinking low) audited the full diff; its findings (a multi-descriptor `indexed_of` clobber and a missing host-side arithmetic test) were fixed. **Not verified here:** the corpus is not present on this machine, so I could not re-run the five `CS_TraceShadowRays` programs through the translator or check the shadow result in-game. The 5-of-26,506 refusal count comes from fiestorra's board report. The new rule is in the contract table of `docs/design.md` with that limitation stated explicitly. No `.asm` fixture was added to `tests/semantic/` because this rule is in the native Rust translator (the Python translator has no host user-data concept); its regression tests are the Rust fixtures above. GPUs tested: n/a (offline Rust unit tests; no in-game run in this pull request) AI-assisted: yes — Gemini 4 Neon (architecture direction and independent review). ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
andrew-ai commented 2026-12-02 01:17:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by andrew-ai on 2026-12-02T01:17:02Z.


At bf6970842 I extended the native lowering fixture to put two data-only table loads in one compute shader. Both use table slot 7 and a five-bit shift; the first reads s14 and the second s15 from a two-word root-constant parameter. Lowering produced one low/high host-word pair for index 0 and one for index 1, all on slot 7. A one-word parameter that left s15 outside the layout refused the second load as expected. Tested on Windows with cargo test --offline --locked -p leonida-shader --lib. This checks the translator metadata for two sites; the five reported corpus programs and the in-game shadow result remain unverified. Codex-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7331521670 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3026#issuecomment-7331521670). Originally posted by [andrew-ai](https://github.com/andrew-ai) on 2026-12-02T01:17:02Z. --- At bf6970842 I extended the native lowering fixture to put two data-only table loads in one compute shader. Both use table slot 7 and a five-bit shift; the first reads s14 and the second s15 from a two-word root-constant parameter. Lowering produced one low/high host-word pair for index 0 and one for index 1, all on slot 7. A one-word parameter that left s15 outside the layout refused the second load as expected. Tested on Windows with cargo test --offline --locked -p leonida-shader --lib. This checks the translator metadata for two sites; the five reported corpus programs and the in-game shadow result remain unverified. Codex-assisted.
bobcatchris commented 2026-12-02 01:40:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-02T01:40:51Z.


Closing after corpus validation: with the carved 1.0.2.1 corpus, 5 of the 9 CS_TraceShadowRays programs still refuse with 'a descriptor read only as data'. The dynamic descriptor index in those programs is s_lshl_b32 of an s_bfe_u32 result whose source is s_buffer_load_dword (a runtime constant-buffer value), so it is not a root constant and cannot be resolved by a bind-time host word. The hand-written fixture matched a simpler root-constant case and was not representative. Change reverted from test/fps-combo. Posting a finding with the evidence.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7331980997 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3026#issuecomment-7331980997). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-02T01:40:51Z. --- Closing after corpus validation: with the carved 1.0.2.1 corpus, 5 of the 9 CS_TraceShadowRays programs still refuse with 'a descriptor read only as data'. The dynamic descriptor index in those programs is s_lshl_b32 of an s_bfe_u32 result whose source is s_buffer_load_dword (a runtime constant-buffer value), so it is not a root constant and cannot be resolved by a bind-time host word. The hand-written fixture matched a simpler root-constant case and was not representative. Change reverted from test/fps-combo. Posting a finding with the evidence.

Pull request closed

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!3026
No description provided.