Decode RGB9E5 in diagnostic PNG captures #2586

Open
DoubleD17 wants to merge 1 commit from upstream-pr/2588 into main
DoubleD17 commented 2026-11-25 16:18:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DoubleD17 on 2026-11-25T16:18:43Z.


The diagnostic capture path skips DXGI format 67 (R9G9B9E5_SHAREDEXP) because the converter has no decoder for it. Decode the three 9-bit RGB mantissas and their shared exponent before applying the existing diagnostic color scale. The change preserves the new RGBA8 statistics on main.

On Windows x64 with Rust 1.98.1 MSVC, cargo test --offline --locked -p victory-gpu --features diagnostics --lib capture:: passed 2/3 on main with the same fixture and 3/3 on 6ff69a38e445206b0cb9f3abc1eb876c8a70ba83. The cases cover shared-exponent changes across padded rows and an R32_UINT grayscale control. The asset policy check passed. A prior independent D3D12 WARP check observed format 67 and a 256-byte row pitch for 1×2 typed textures with no flags, render-target flags, and UAV flags. That check covers texture creation and footprint layout. The CPU test reaches the RGBA buffer passed to the PNG encoder.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6608721326 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2588). Originally posted by [DoubleD17](https://github.com/DoubleD17) on 2026-11-25T16:18:43Z. --- The diagnostic capture path skips DXGI format 67 (R9G9B9E5_SHAREDEXP) because the converter has no decoder for it. Decode the three 9-bit RGB mantissas and their shared exponent before applying the existing diagnostic color scale. The change preserves the new RGBA8 statistics on main. On Windows x64 with Rust 1.98.1 MSVC, `cargo test --offline --locked -p victory-gpu --features diagnostics --lib capture::` passed 2/3 on main with the same fixture and 3/3 on `6ff69a38e445206b0cb9f3abc1eb876c8a70ba83`. The cases cover shared-exponent changes across padded rows and an R32_UINT grayscale control. The asset policy check passed. A prior independent D3D12 WARP check observed format 67 and a 256-byte row pitch for 1×2 typed textures with no flags, render-target flags, and UAV flags. That check covers texture creation and footprint layout. The CPU test reaches the RGBA buffer passed to the PNG encoder. AI-assisted.
cloph-dsp commented 2026-11-25 18:02:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T17:06:47Z.


Independent verification (claim on #1633, comment 7168884733), Windows/MSVC, Rust/Cargo 1.100.0, no game data, AI-assisted (Hy4 flash).

At the current head cb11b4c the reported clippy site already uses the suggested form: crates/victory-gpu/src/capture.rs:875 is rgba.as_chunks::<4>().0, so the original chunks_exact_to_as_chunks failure is already addressed in the PR. The only current check run is check = pass (https://github.com/Marvisak/VIctory/actions/runs/45658864591/job/139362911132).

Local results:

  • cargo check --locked -p victory-gpu --all-targets --all-features — finished cleanly; only pre-existing deprecation warnings in object.rs (fetch_update).
  • cargo test --locked -p victory-gpu --features diagnostics --lib rgb9e5_tests -- --test-threads=1 — 1 passed / 199 filtered.
  • cargo test --locked -p victory-gpu --features diagnostics --lib capture::tests::crc_matches_the_png_check_value -- --exact --test-threads=1 — 1 passed / 199 filtered.
  • Negative control on origin/main 13f91ca: the rgb9e5 test does not exist (0 tests for the same filter).

Limitation: this machine's cargo 1.100.0 is a direct binary with no clippy component and no rustup, so I could not rerun strict clippy locally; the compile check and CI green status are the evidence. No files changed, no competing PR.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169022506 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2588#issuecomment-7169022506). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-25T17:06:47Z. --- Independent verification (claim on #1633, comment 7168884733), Windows/MSVC, Rust/Cargo 1.100.0, no game data, AI-assisted (Hy4 flash). At the current head cb11b4c the reported clippy site already uses the suggested form: `crates/victory-gpu/src/capture.rs:875` is `rgba.as_chunks::<4>().0`, so the original `chunks_exact_to_as_chunks` failure is already addressed in the PR. The only current check run is `check` = pass (https://github.com/Marvisak/VIctory/actions/runs/45658864591/job/139362911132). Local results: - `cargo check --locked -p victory-gpu --all-targets --all-features` — finished cleanly; only pre-existing deprecation warnings in `object.rs` (`fetch_update`). - `cargo test --locked -p victory-gpu --features diagnostics --lib rgb9e5_tests -- --test-threads=1` — 1 passed / 199 filtered. - `cargo test --locked -p victory-gpu --features diagnostics --lib capture::tests::crc_matches_the_png_check_value -- --exact --test-threads=1` — 1 passed / 199 filtered. - Negative control on `origin/main` 13f91ca: the rgb9e5 test does not exist (0 tests for the same filter). Limitation: this machine's cargo 1.100.0 is a direct binary with no clippy component and no rustup, so I could not rerun strict clippy locally; the compile check and CI green status are the evidence. No files changed, no competing PR.
Marvisak commented 2026-11-25 23:06:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:19:56Z.


Automated triage for the maintainers.

Merge candidate (small, diagnostics only). capture::to_rgba returned None for format 67 (R9G9B9E5_SHAREDEXP), so captures of such targets had no PNG. The new arm decodes it as the public DXGI format defines it: three 9-bit mantissas scaled by 2^(e - 15 - 9), with the 5-bit exponent in bits 27..31. I checked the test values by hand: 0x81010100 gives (1, 0.5, 0.25), and the expected bytes follow from the existing max scaling. No other arm covers 67, and no open PR adds the same thing.

CI: check passing. Merges cleanly into current main. A recommendation to look at it, not an approval.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176229355 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2588#issuecomment-7176229355). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:19:56Z. --- <!-- victory-triage v1 head=cb11b4c1b79cf81ac37a3f8bc19090add5ce6e61 verdict=merge-candidate at=2026-11-25T22:19:40Z --> Automated triage for the maintainers. **Merge candidate (small, diagnostics only).** `capture::to_rgba` returned `None` for format 67 (`R9G9B9E5_SHAREDEXP`), so captures of such targets had no PNG. The new arm decodes it as the public DXGI format defines it: three 9-bit mantissas scaled by `2^(e - 15 - 9)`, with the 5-bit exponent in bits 27..31. I checked the test values by hand: `0x81010100` gives (1, 0.5, 0.25), and the expected bytes follow from the existing max scaling. No other arm covers 67, and no open PR adds the same thing. CI: `check` passing. Merges cleanly into current `main`. A recommendation to look at it, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
steven-seagull27 commented 2026-11-27 00:37:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-27T00:37:35Z.


I put together a small follow-up on top of cb11b4c for diagnosing buffers where the producer explicitly packs RGB9E5 into an R32_UINT resource. With VICTORY_DUMP_RGB9E5_TARGETS=2,7, the target dumper keeps the normal PNG and writes an additional -as-rgb9e5 PNG for those two indices if their format is R32_UINT. It reuses your format-67 decoder. The default R32_UINT output stays grayscale. Follow-up commit

I tested the native grayscale and optional color outputs against the same 2×2 pitched buffer containing pure red, green, blue and black. The four capture tests pass on Windows x64 with cargo test --locked -p victory-gpu --features diagnostics --lib capture::. This can land separately after #2588.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7206616789 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2588#issuecomment-7206616789). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-27T00:37:35Z. --- I put together a small follow-up on top of `cb11b4c` for diagnosing buffers where the producer explicitly packs RGB9E5 into an `R32_UINT` resource. With `VICTORY_DUMP_RGB9E5_TARGETS=2,7`, the target dumper keeps the normal PNG and writes an additional `-as-rgb9e5` PNG for those two indices if their format is R32_UINT. It reuses your format-67 decoder. The default R32_UINT output stays grayscale. [Follow-up commit](https://github.com/steven-seagull27/VIctory/commit/735eb84240cd3e7e1fc2a2a606f33d41e3ecaf7e) I tested the native grayscale and optional color outputs against the same 2×2 pitched buffer containing pure red, green, blue and black. The four capture tests pass on Windows x64 with `cargo test --locked -p victory-gpu --features diagnostics --lib capture::`. This can land separately after #2588.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2588:upstream-pr/2588'
git switch 'upstream-pr/2588'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2588'
git switch 'upstream-pr/2588'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2588'
git switch 'upstream-pr/2588'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2588'
git switch 'main'
git merge --squash 'upstream-pr/2588'
git switch 'main'
git merge --ff-only 'upstream-pr/2588'
git switch 'main'
git merge 'upstream-pr/2588'
git push origin 'main'
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
Marvisak/VIctory!2586
No description provided.