Decode packed 16-bit BGR targets in diagnostic captures #909

Open
Yoshi-233 wants to merge 2 commits from upstream-pr/910 into main
Yoshi-233 commented 2026-11-25 12:27:04 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Yoshi-233 on 2026-11-25T12:27:04Z.


The diagnostic target dumper skips a readback when its host format is B5G6R5_UNORM, B5G5R5A1_UNORM, or B4G4R4A4_UNORM. Decode the packed little-endian words into the RGB dump's 8-bit channels, including the sixth green bit in B5G6R5. The dump uses opaque output like the existing byte-color path.

Verification

The Windows diagnostics test reproduced the skipped dump on main. On this branch all three capture tests passed in the native Windows victory-gpu test binary with the diagnostics feature.

The new test uses a synthetic 2×2 target in each format. It checks red, green, blue and a mixed color, sets the alpha bits differently across pixels, and puts an extra word between rows. The repository asset-policy check passed.

After main advanced to a253706, the same three Windows tests and the full asset-policy check also passed on GitHub's test merge f098a10.

Windows D3D12 capture comparison

I uploaded synthetic textures, read them back, and decoded the resulting PNGs. For each of the three formats, the large fixture sampled every one of the 65,536 packed words once. Two smaller fixtures (129×5 and 1×1) exercised padded and short rows. All nine PNGs were byte-identical on the RTX 4070 Ti SUPER at 9bf4a0f and on NVIDIA, Intel UHD 770, and WARP at the tested merge f098a10. Every decoded RGB pixel matched nearest-integer UNORM expansion.

A separate typed-shader readback using round(Texture2D.Load(...) * 255) exposed a hardware rounding detail. On both physical GPUs, up to one 8-bit step differed from the PNG in 23,200 of 65,536 B5G6R5 pixels and 21,632 of 65,536 B5G5R5A1 pixels. A 5-bit channel value of 3 gave 24 on those GPUs and 25 in the PNG. WARP matched the PNG for all three formats, and every adapter matched it for B4G4R4A4. These comparisons cover RGB. The diagnostic PNG uses opaque alpha.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6604455563 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/910). Originally posted by [Yoshi-233](https://github.com/Yoshi-233) on 2026-11-25T12:27:04Z. --- The diagnostic target dumper skips a readback when its host format is B5G6R5_UNORM, B5G5R5A1_UNORM, or B4G4R4A4_UNORM. Decode the packed little-endian words into the RGB dump's 8-bit channels, including the sixth green bit in B5G6R5. The dump uses opaque output like the existing byte-color path. ## Verification The Windows diagnostics test reproduced the skipped dump on main. On this branch all three capture tests passed in the native Windows `victory-gpu` test binary with the `diagnostics` feature. The new test uses a synthetic 2×2 target in each format. It checks red, green, blue and a mixed color, sets the alpha bits differently across pixels, and puts an extra word between rows. The repository asset-policy check passed. After main advanced to `a253706`, the same three Windows tests and the full asset-policy check also passed on GitHub's test merge `f098a10`. ## Windows D3D12 capture comparison I uploaded synthetic textures, read them back, and decoded the resulting PNGs. For each of the three formats, the large fixture sampled every one of the 65,536 packed words once. Two smaller fixtures (129×5 and 1×1) exercised padded and short rows. All nine PNGs were byte-identical on the RTX 4070 Ti SUPER at `9bf4a0f` and on NVIDIA, Intel UHD 770, and WARP at the tested merge `f098a10`. Every decoded RGB pixel matched nearest-integer UNORM expansion. A separate typed-shader readback using `round(Texture2D.Load(...) * 255)` exposed a hardware rounding detail. On both physical GPUs, up to one 8-bit step differed from the PNG in 23,200 of 65,536 B5G6R5 pixels and 21,632 of 65,536 B5G5R5A1 pixels. A 5-bit channel value of 3 gave 24 on those GPUs and 25 in the PNG. WARP matched the PNG for all three formats, and every adapter matched it for B4G4R4A4. These comparisons cover RGB. The diagnostic PNG uses opaque alpha.
avt0m4t48 commented 2026-11-25 13:06:02 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by avt0m4t48 on 2026-11-25T12:39:42Z.


I independently checked the packed-color conversion at 9bf4a0f and GitHub's test merge f098a10 on a253706.

  • The standalone Linux CPU harness used the exact conversion and PNG code from each revision. Both the original PR parent (f85101b) and current base returned None for all three packed formats while passing the existing CRC and UNORM/XR-bias tests and the byte-format controls. The PR head and test merge each passed all seven tests.
  • For each format (DXGI 85, 86, 115), a synthetic 256×256 buffer with a 768-byte row pitch exercised every possible 16-bit word, including every alpha-bit combination in the alpha-bearing formats. All 196,608 RGBA pixels per revision matched a separate bit-field and UNORM reference. I also independently decoded the PNGs, checked their CRCs and every sampled RGB pixel, and confirmed that all three PNGs were byte-identical between the head and test merge.
  • The test merge passed cargo check --locked --offline --target x86_64-pc-windows-msvc -p victory-gpu --all-targets --features diagnostics,blake3/pure with Rust 1.98.1 on Linux.

The fixture stores the little-endian word (25173 * i + 13849) mod 65536 at each raster index i. This check used synthetic data throughout. Native Windows linking and D3D12 texture readback remain outside this verification.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7162680955 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/910#issuecomment-7162680955). Originally posted by [avt0m4t48](https://github.com/avt0m4t48) on 2026-11-25T12:39:42Z. --- I independently checked the packed-color conversion at `9bf4a0f` and GitHub's test merge `f098a10` on `a253706`. - The standalone Linux CPU harness used the exact conversion and PNG code from each revision. Both the original PR parent (`f85101b`) and current base returned `None` for all three packed formats while passing the existing CRC and UNORM/XR-bias tests and the byte-format controls. The PR head and test merge each passed all seven tests. - For each format (DXGI 85, 86, 115), a synthetic 256×256 buffer with a 768-byte row pitch exercised every possible 16-bit word, including every alpha-bit combination in the alpha-bearing formats. All 196,608 RGBA pixels per revision matched a separate bit-field and UNORM reference. I also independently decoded the PNGs, checked their CRCs and every sampled RGB pixel, and confirmed that all three PNGs were byte-identical between the head and test merge. - The test merge passed `cargo check --locked --offline --target x86_64-pc-windows-msvc -p victory-gpu --all-targets --features diagnostics,blake3/pure` with Rust 1.98.1 on Linux. The fixture stores the little-endian word `(25173 * i + 13849) mod 65536` at each raster index `i`. This check used synthetic data throughout. Native Windows linking and D3D12 texture readback remain outside this verification.
Yoshi-233 commented 2026-11-26 02:08:42 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Yoshi-233 on 2026-11-26T01:21:13Z.


Updated this PR to current main (c9092ec) at eebfc93. The new frame-shot code calls capture::to_rgba from another module. I kept its upstream visibility and added formats 85, 86 and 115 to shot::shows. Resolving only the textual conflict would have left all three formats silently filtered out before readback.

I checked the change on Linux with Rust 1.98.1 and synthetic data:

  • Compared the actual shot predicate with the actual decoder for format codes 0 through 191. With the original main predicate and the PR decoder, only 85, 86 and 115 disagreed. With the updated predicate all 192 decisions matched.
  • For each packed format, a padded 257×256 image covered all 65,536 possible 16-bit words. There was no padding after the last row. Every RGBA pixel matched an independent bit-field and floating-point UNORM reference, and reading the generated RGB PNGs back with Pillow reproduced every RGB byte. All four extracted capture/shot unit tests passed.
  • cargo check --locked --target x86_64-pc-windows-gnu -p victory-gpu --all-targets --features diagnostics,blake3/pure passed. The full repository asset check reports the same 11 violations on main and this revision. This rerun did not exercise live Windows D3D12 readback through the new shot entry point.
<!-- greyfinch-sync:fxceless/victory-fork:comment:7179688823 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/910#issuecomment-7179688823). Originally posted by [Yoshi-233](https://github.com/Yoshi-233) on 2026-11-26T01:21:13Z. --- Updated this PR to current main (`c9092ec`) at `eebfc93`. The new frame-shot code calls `capture::to_rgba` from another module. I kept its upstream visibility and added formats 85, 86 and 115 to `shot::shows`. Resolving only the textual conflict would have left all three formats silently filtered out before readback. I checked the change on Linux with Rust 1.98.1 and synthetic data: - Compared the actual shot predicate with the actual decoder for format codes 0 through 191. With the original main predicate and the PR decoder, only 85, 86 and 115 disagreed. With the updated predicate all 192 decisions matched. - For each packed format, a padded 257×256 image covered all 65,536 possible 16-bit words. There was no padding after the last row. Every RGBA pixel matched an independent bit-field and floating-point UNORM reference, and reading the generated RGB PNGs back with Pillow reproduced every RGB byte. All four extracted capture/shot unit tests passed. - `cargo check --locked --target x86_64-pc-windows-gnu -p victory-gpu --all-targets --features diagnostics,blake3/pure` passed. The full repository asset check reports the same 11 violations on main and this revision. This rerun did not exercise live Windows D3D12 readback through the new shot entry point.
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/910:upstream-pr/910'
git switch 'upstream-pr/910'

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/910'
git switch 'upstream-pr/910'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/910'
git switch 'upstream-pr/910'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/910'
git switch 'main'
git merge --squash 'upstream-pr/910'
git switch 'main'
git merge --ff-only 'upstream-pr/910'
git switch 'main'
git merge 'upstream-pr/910'
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
fxceless/victory-fork!909
No description provided.