Skip to content

leonida-gpu: read the pipeline stream of the title unaligned (D3D12-GPU-PIPELINE-BYTECODE-ALIGNMENT) - #2632

Merged
MoonEyes merged 4 commits into
ProjectLeonida:mainfrom
imShangLi:fix/d3d12-gpu-pipeline-bytecode-alignment
Nov 30, 2026
Merged

MoonEyes merged 4 commits into
ProjectLeonida:mainfrom
imShangLi:fix/d3d12-gpu-pipeline-bytecode-alignment

Conversation

@imShangLi

@imShangLi imShangLi commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D12-GPU-PIPELINE-BYTECODE-ALIGNMENT

Depends on: #2569 (same file and test module; the current diff applies cleanly, but the branches may overlap if #2569 lands first)

Fixes: none

What and why

create_stream reads the title-owned StreamDesc and each shader Bytecode through aligned Rust references. The title chooses these buffer addresses and need not align them. Read both with read_unaligned() and add an odd-address stream regression test.

Tested

Prior measured branch result on Windows 11 / Rust 1.98.1, base cc0f662a70b6e6e561692f56342b5a7df3831bd7:

  • New test a_stream_at_an_odd_address_yields_its_shaders aborts on pristine main at pipeline.rs:1185 with a misaligned pointer dereference and passes with the change.
  • cargo test --package leonida-gpu --lib --locked --offline: pristine 536 passed; 1 failed; 47 ignored; patched 537 passed; 1 failed; 47 ignored.
  • The remaining descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in failure is also red on pristine main on the AMD Radeon 780M host.
  • Clippy findings were identical before and after, with none in pipeline.rs.
  • Current branch has latest main merged and still changes only d3d12/crates/leonida-gpu/src/pipeline.rs (+77/-5).

GPUs tested: AMD Radeon 780M for the prior host test run; no game files or GPU workload used by the new regression.

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly
  • One topic
  • No game data, keys or decryption
  • No new translator rule

Independent verification

  • Native Windows 11 Pro + AMD Radeon RX 7900 XTX (driver 32.0.32029.2010), Rust 1.98.
  • Fast-forward cleanly onto current main; zero conflicts.
  • cargo test -p leonida-gpu --lib -- --test-threads=4: 550 passed; 0 failed; 47 ignored.
  • python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/pipeline.rs: PASS.
  • Current CI: translator/viewer/no-game-data/change-scope pass; the remaining semantic failure is the upstream baseline test_interp_computed_ij_fallback.

@bobcatchris

Copy link
Copy Markdown
Contributor

Independent verification on native Windows 11 Pro (10.0.26200) + AMD Radeon RX 7900 XTX (gfx1100, driver 32.0.32029.2010, Rust 1.98):

  • Fast-forward cleanly onto main (720bd3b4e..eddf401a2) — zero conflicts.
  • cargo test -p leonida-gpu --lib -- --test-threads=4 — 550 passed; 0 failed; 47 ignored (13.06s), including the new unaligned pipeline stream unit tests.
  • python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/pipeline.rs — PASS.

AI-assisted: Antigravity (Gemini 4 Neon)

@imShangLi

Copy link
Copy Markdown
Contributor Author

CI note: the remaining semantic-tests (ubuntu-latest) failure is test_interp_computed_ij_fallback, the same upstream baseline failure observed on the previous PR/base. This PR changes only d3d12/crates/leonida-gpu/src/pipeline.rs; translator-tests, viewer-tests, no-game-data, and change-scope pass.

Independent native Windows verification is already recorded above: 550 passed / 0 failed on RX 7900 XTX.

AI-assisted: yes.

@imShangLi

Copy link
Copy Markdown
Contributor Author

@MoonEyes ready for maintainer review when convenient. Independent RX 7900 XTX verification is 550 passed / 0 failed; the only red CI is the known upstream semantic baseline. AI-assisted: yes.

@OreoFR

OreoFR commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Verified by OreoFR

  • PR head eddf401a2f1d578c676c612f176eaf288064476b, merged with --no-ff onto main 060c4716046d8c17f5a124d9ae9d56cc0070c225: clean, no conflict.
  • Windows 11 Pro / RTX 4070 Laptop / NVIDIA 621.40 (no GPU used), stable Rust, --locked.
  • Crate tested: leonida-gpu. cargo test -p leonida-gpu --locked on the merge: 550/550 passed, 0 failed, 47 ignored (doc-test targets 0/0). a_stream_at_an_odd_address_yields_its_shaders passes.
  • Red: same merge with the create_stream change restored to main and the new test kept: the test binary aborts, pipeline.rs:1185 "misaligned pointer dereference: address must be a multiple of 0x8" (exit 0xc0000409). Red to green seen; this is the first red recorded by someone other than the author.
  • Clippy: cargo clippy -p leonida-gpu --locked -- -D warnings stops on lints that are already on main in crates this PR does not touch (leonida-shader emit/lower.rs, emit/bitcode/opt.rs; leonida-lua input.rs, memory.rs). Without -D warnings, no lint points at pipeline.rs. Nothing new from this PR.
  • Rebase on [integration] PageMirror, GPU detile, async queue & RDNA2->SPIR-V performance stack (INTEGRATION-PERF-CPU-GPU-R6) #2566 needed: no (the merge result merges cleanly with the [integration] PageMirror, GPU detile, async queue & RDNA2->SPIR-V performance stack (INTEGRATION-PERF-CPU-GPU-R6) #2566 head eade9562c).
  • Diff read: StreamDesc and each shader Bytecode are now copied with read_unaligned(), which matches the subobject kind read and host::GraphicsState::read, which already read unaligned. On Windows the test also runs the graphics.read path at the odd address. The PR says it may overlap runtime, d3d12: memory leak fixes from one sweep (RT-LEAK-SWEEP) #2569 in the same file; one of them will need a rebase after the other lands.
  • Verdict: READY. Ready to merge per the maintainers' plan.

This verification was AI-assisted (Claude Code, oreofr-agent).

@imShangLi

Copy link
Copy Markdown
Contributor Author

Updated head c33baf89 with latest main (4014af7f), which includes the merged semantic baseline fix #2633. This should clear the previous test_interp_computed_ij_fallback CI failure without changing this PR's one-file diff.

AI-assisted: yes.

@MoonEyes

Copy link
Copy Markdown
Collaborator

Verified: independent Windows checks pass, including 550 leonida-gpu tests; a red-on-main / green-on-PR misaligned-pointer regression was confirmed, and CI/no-game-data are green. Ready for merge.

@MoonEyes
MoonEyes merged commit 5583b6a into ProjectLeonida:main Nov 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants