gpu(device),shader(native): log 0x1c8/0x218 loose pipeline parts and build 0x218 pipelines via VICTORY_LOOSE_PIPELINES=1 #117

Merged
Androtim merged 1 commit from upstream-pr/117 into main 2026-11-29 14:33:20 +00:00
Androtim commented 2026-11-29 12:31:32 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T12:31:32Z.


Summary

  • Parse and log loose shader parts and metadata passed to device methods 0x1c8 and 0x218 in crates/victory-gpu/src/device.rs and crates/victory-shader/src/native.rs.
  • Repackage loose compute parts into DXBC containers via crates/victory-shader/src/dxbc.rs and crates/victory-shader/src/lib.rs, and build 0x218 compute pipelines when VICTORY_LOOSE_PIPELINES=1 (off by default).
  • Includes unit tests loose_compute_parts_make_a_container and loose_metadata_reads_both_versions.
  • Adapted from VIctory commit 9a02d21d (GPL-3.0).

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy -> asset policy: 303 files ok
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib --locked -- native:: -> test result: ok. 18 passed; 0 failed; 0 ignored
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib --locked -- dxbc:: -> test result: ok. 2 passed; 0 failed; 0 ignored
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib --locked -- device:: -> test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 550 filtered out; finished in 0.25s
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings -> 0 warnings
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics --locked -- -D warnings -> 0 warnings
<!-- greyfinch-sync:Androtim/MiniVI:issue:5550728192 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/117). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T12:31:32Z. --- ## Summary - Parse and log loose shader parts and metadata passed to device methods `0x1c8` and `0x218` in `crates/victory-gpu/src/device.rs` and `crates/victory-shader/src/native.rs`. - Repackage loose compute parts into `DXBC` containers via `crates/victory-shader/src/dxbc.rs` and `crates/victory-shader/src/lib.rs`, and build `0x218` compute pipelines when `VICTORY_LOOSE_PIPELINES=1` (off by default). - Includes unit tests `loose_compute_parts_make_a_container` and `loose_metadata_reads_both_versions`. - Adapted from `VIctory` commit `9a02d21d` (GPL-3.0). ## Verification - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy` -> `asset policy: 303 files ok` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib --locked -- native::` -> `test result: ok. 18 passed; 0 failed; 0 ignored` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib --locked -- dxbc::` -> `test result: ok. 2 passed; 0 failed; 0 ignored` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib --locked -- device::` -> `test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 550 filtered out; finished in 0.25s` - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings` -> `0 warnings` - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics --locked -- -D warnings` -> `0 warnings`
Androtim commented 2026-11-29 13:03:36 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T13:03:36Z.


Automated triage for the maintainers (not an approval).

Verdict: needs-gpu-test · CI (check): passing

Technical Review

CI is passing, and the logic, bounds checks, and unit tests look solid.

Verified details:

  • crates/victory-shader/src/native.rs:
    • Extracts records() cleanly from fspx_program() with unchanged 0x41/0x42/0x43 handling.
    • loose_metadata() validates version (2 or 3), minimum header length (from), and declared size via checked_add before parsing records.
    • loose_compute() validates the 0x1c-byte register packet, computes the thread-group product in u64 (avoiding overflow) and enforces 1..=1024 with non-zero PACKET_RSRC2, slices code safely with code.get(..dwords * 4), synthesizes the FSPX kind7 metadata and container, and round-trip validates it with fspx_program(&fspx)? before wrapping in dxbc::build(&[(FourCC::ACCC, &fspx)]).
    • Unit tests (loose_metadata_reads_both_versions, loose_compute_parts_make_a_container, loose_metadata_and_compute_reject_short_metadata, loose_compute_rejects_overflowing_thread_product) cover both versions and malformed/overflowing inputs.
  • crates/victory-gpu/src/device.rs:
    • unknown_pipeline<SLOT> keeps the default path safe (VICTORY_LOOSE_PIPELINES=1 is opt-in, off by default), bounds kernel reads to <= 1 MiB via crate::host::read_into, and logs only on the first 4 and power-of-two calls.
    • When VICTORY_LOOSE_PIPELINES=1 is set on slot 0x218, the local #[repr(C)] Head struct matches pipeline::ComputeHead (root: This, stage: Bytecode { code: *const u8, size: usize } in crates/victory-gpu/src/pipeline.rs), and container remains live across the pipeline::create_compute call (which copies the container bytes).

Minor non-blocking note:

  • In loose_compute, dwords * 4 is safe on 64-bit targets (u32 as usize * 4), though dwords.checked_mul(4) would make it target-width agnostic.

Because this touches GPU device pipeline creation (0x1c8/0x218) and shader container synthesis, a quick real-GPU smoke test (both default and with VICTORY_LOOSE_PIPELINES=1) is recommended before merging.


Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7256258461 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/117#issuecomment-7256258461). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T13:03:36Z. --- <!-- minivi-triage v1 head=4b7cd964f19a5bd1a2c9aaf2ac825246eec998e9 verdict=needs-gpu-test ci=passing at=2026-11-29T14:09:30Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Technical Review CI is passing, and the logic, bounds checks, and unit tests look solid. **Verified details:** - **`crates/victory-shader/src/native.rs`**: - Extracts `records()` cleanly from `fspx_program()` with unchanged `0x41`/`0x42`/`0x43` handling. - `loose_metadata()` validates version (`2` or `3`), minimum header length (`from`), and declared size via `checked_add` before parsing records. - `loose_compute()` validates the `0x1c`-byte register packet, computes the thread-group product in `u64` (avoiding overflow) and enforces `1..=1024` with non-zero `PACKET_RSRC2`, slices code safely with `code.get(..dwords * 4)`, synthesizes the FSPX `kind7` metadata and container, and round-trip validates it with `fspx_program(&fspx)?` before wrapping in `dxbc::build(&[(FourCC::ACCC, &fspx)])`. - Unit tests (`loose_metadata_reads_both_versions`, `loose_compute_parts_make_a_container`, `loose_metadata_and_compute_reject_short_metadata`, `loose_compute_rejects_overflowing_thread_product`) cover both versions and malformed/overflowing inputs. - **`crates/victory-gpu/src/device.rs`**: - `unknown_pipeline<SLOT>` keeps the default path safe (`VICTORY_LOOSE_PIPELINES=1` is opt-in, off by default), bounds kernel reads to `<= 1 MiB` via `crate::host::read_into`, and logs only on the first 4 and power-of-two calls. - When `VICTORY_LOOSE_PIPELINES=1` is set on slot `0x218`, the local `#[repr(C)] Head` struct matches `pipeline::ComputeHead` (`root: This`, `stage: Bytecode { code: *const u8, size: usize }` in `crates/victory-gpu/src/pipeline.rs`), and `container` remains live across the `pipeline::create_compute` call (which copies the container bytes). **Minor non-blocking note:** - In `loose_compute`, `dwords * 4` is safe on 64-bit targets (`u32 as usize * 4`), though `dwords.checked_mul(4)` would make it target-width agnostic. Because this touches GPU device pipeline creation (`0x1c8`/`0x218`) and shader container synthesis, a quick real-GPU smoke test (both default and with `VICTORY_LOOSE_PIPELINES=1`) is recommended before merging. --- _Generated with Antigravity CLI (`agy`)._
Androtim commented 2026-11-29 13:12:15 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T13:12:15Z.


Addressed the \minivi-triage\ findings at $sha117\ (rebased onto \origin/main\ \1d0ca527):

  1. Short loose metadata slice panic guard (\crates/victory-shader/src/native.rs\ \loose_metadata): reject buffers shorter than \ rom\ (\if meta.len() < from) before checking \u32_at(meta, 4)? as usize\ with \checked_add(head) != Some(meta.len()), guaranteeing \m.records <= meta.len()\ before \loose_compute\ slices &meta[m.records..].
  2. Thread-group product overflow guard (\crates/victory-shader/src/native.rs\ \loose_compute): compute the 3D thread-group product in \u64\ before validating \ hreads == 0 || threads > 1024.
  3. Regression tests: added \loose_metadata_and_compute_reject_short_metadata\ (covering v2 lengths \
<!-- greyfinch-sync:Androtim/MiniVI:comment:7256364221 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/117#issuecomment-7256364221). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T13:12:15Z. --- Addressed the \minivi-triage\ findings at \$sha117\ (rebased onto \origin/main\ \1d0ca527\): 1. **Short loose metadata slice panic guard (\crates/victory-shader/src/native.rs\ \loose_metadata\):** reject buffers shorter than \ rom\ (\if meta.len() < from\) before checking \u32_at(meta, 4)? as usize\ with \checked_add(head) != Some(meta.len())\, guaranteeing \m.records <= meta.len()\ before \loose_compute\ slices \&meta[m.records..]\. 2. **Thread-group product overflow guard (\crates/victory-shader/src/native.rs\ \loose_compute\):** compute the 3D thread-group product in \u64\ before validating \ hreads == 0 || threads > 1024\. 3. **Regression tests:** added \loose_metadata_and_compute_reject_short_metadata\ (covering v2 lengths \
Androtim commented 2026-11-29 14:33:16 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T14:33:16Z.


Automated RTX 4060 Ti 8 GB Wave 3 A/B hardware verification passed (playtest/wave3 vs origin/main c7ed150 — 5/5 A/B gates PASS):

  • Hardware cargo test (RTX 4060 Ti): victory-gpu 542 passed, 0 failed (36 ignored); victory-shader 323 passed, 0 Wave 3 regressions (the 3 PSV0 validation failures in emit::rect::tests and emit::barycentric_tests also fail identically on origin/main c7ed150).
  • Automated 45s in-world A/B (scripts/verify-world.ps1, DLSS Quality + golden autosave):
    • FPS: median 10.25 fps vs 10.7 fps baseline (min FPS improved 6.9 vs 4.2, preparing 45.35 ms vs 50.3 ms)
    • Stability: 0 crashes / 0 DRED / 0 untranslated shaders
    • VRAM: max 5948 MB vs 6073 MB (-125 MB, 0 MB over budget)
    • Texture backlog: final_waiting=5487 vs 7350 (-1863); no room for new ones 38 vs 43
    • Residency stalls: mapped_rate=20.95 ms/s vs 37.22 ms/s (-44%)
    • Visual check: Clean rendered frames (frame-10645.png, frame-10669.png), luma 82.77 vs 23.2, edge energy 2.27 vs 1.81, magenta 0.0%.
<!-- greyfinch-sync:Androtim/MiniVI:comment:7257393137 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/117#issuecomment-7257393137). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T14:33:16Z. --- Automated RTX 4060 Ti 8 GB Wave 3 A/B hardware verification passed (`playtest/wave3` vs `origin/main` `c7ed150` — **5/5 A/B gates PASS**): - **Hardware `cargo test` (RTX 4060 Ti):** `victory-gpu` **542 passed, 0 failed** (36 ignored); `victory-shader` **323 passed, 0 Wave 3 regressions** (the 3 PSV0 validation failures in `emit::rect::tests` and `emit::barycentric_tests` also fail identically on `origin/main` `c7ed150`). - **Automated 45s in-world A/B (`scripts/verify-world.ps1`, DLSS Quality + golden autosave):** - **FPS:** median `10.25 fps` vs `10.7 fps` baseline (min FPS improved **`6.9`** vs `4.2`, preparing **`45.35 ms`** vs `50.3 ms`) - **Stability:** **0** crashes / **0** DRED / **0** untranslated shaders - **VRAM:** max **`5948 MB`** vs `6073 MB` (**-125 MB**, `0 MB` over budget) - **Texture backlog:** `final_waiting=5487` vs `7350` (**-1863**); `no room for new ones` `38` vs `43` - **Residency stalls:** `mapped_rate=20.95 ms/s` vs `37.22 ms/s` (**-44%**) - **Visual check:** Clean rendered frames (`frame-10645.png`, `frame-10669.png`), luma `82.77` vs `23.2`, edge energy `2.27` vs `1.81`, magenta `0.0%`.
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
Androtim/MiniVI!117
No description provided.