Present: a single R11G11B10_FLOAT or R9G9B9E5 plane is drawn into the FP16 swap chain, not dropped #1837

Manually merged
github merged 3 commits from github-bot/gh-1837 into main 2026-11-29 08:21:49 +00:00 AGit
Owner

@⁠upipibi on GitHub · 2026-11-29 00:43 UTC · original
upipibi:fix/present-packed-float → main · +359 −10 · 2 files · 3 commits · merged 2026-11-29 08:16 UTC

Depends on #1709. The branch's first commit is #1709's (101Leafy), cherry-picked onto current main f9dfb76 so this applies; only the last two commits are this PR's.

Fixes: no issue reports this (see below).

What it changes

swap_format (crates/victory-gpu/src/host.rs) has no swap chain family for DXGI_FORMAT_R11G11B10_FLOAT (26) or
DXGI_FORMAT_R9G9B9E5_SHAREDEXP (67). #1709 lets two planes compose into an FP16 back buffer when the scene has no
family, but a plane presented on its own still stops at "cannot present this format", and that frame is never shown.

On top of #1709 this PR:

  • gives such a plane the same FP16 fallback, if it is sampleable (compose::view accepts it: 2D, one slice, one
    sample, no DENY_SHADER_RESOURCE);
  • draws it with a single-plane pass of the compositor (compose.rs, ps_single, made by Composer::single): the
    plane is sampled, alpha is set to one, and nothing is clamped. Composer::record gets the plane twice and the
    second copy is unread. The Presenter keeps this composer in its own single slot, so the two-plane composer is
    untouched;
  • returns None with a warning if that composer cannot be made or recorded, as before, because the plane cannot be
    copied into the swap chain.

The single composer is made once, after the resize block (after its settle_now), and only while its slot is
empty. It is never replaced or cleared while the presenter lives, and drop_presenter settles before dropping it.
So the drop-before-settle point UwUCammie raised on #1709 (descriptor heaps freed while queued presents still use
them, and a second creation) does not apply to this slot.

If #1709 changes (for example to move its composer creation after the resize), I will rebase this on top.

The two-plane shader is not reused for this because its clean/saturate clamps to [0, 1]. A copy into the FP16
swap chain (formats 9..=14) keeps values above one, and so does this pass.

Linear-colour caveat: like the existing 9..=14 copy, the FP16 swap chain is linear and no transfer function is
applied. A plane that holds display-encoded values looks the same as it would through that copy.

Commit 1 also adds a test-only hook in present_planes (present_seen, #[cfg(test)] only). It reads back the back
buffer before the panel, notice and menu are drawn. The tree had no present-path test harness. The hook does not
change non-test builds.

How it was tested

  • GPU and profile: RTX 3070, driver 616.56, Windows 11 (10.0.26100), rustc 1.98.1. Presenter unit test only, no
    title run: no game files used.

  • Test host::packed_present_tests::packed_float_single_planes_are_presented:

    • It presents five frames: RGBA8 control, R11G11B10_FLOAT, R9G9B9E5_SHAREDEXP, RGBA8, R9G9B9E5. The swap chain
      format changes between them.
    • It checks the back buffer's size and format and all 5,120 pixels.
    • Packed quadrants (0.5, 2, 4), (4, 0.5, 2), (2, 4, 0.5) and black must come out as the exact halves, with alpha
      1.0. The RGBA8 control must be 255, 0, 0, 255.
  • Base: main f9dfb76 with #1709 (32dedce) on top. WARP runs use VICTORY_D3D12_WARP=1 and
    --features diagnostics; the test prints which adapter it ran on.

  • Before (f9dfb76 + #1709 + the test commit only), on hardware and on WARP: frame 0 (R8G8B8A8_UNORM) presented
    Some(false) and read back. Frame 1 (R11G11B10_FLOAT) presented None, nothing read back:
    frame 1 (R11G11B10_FLOAT) was not presented, FAILED.

  • After (this branch): every frame presented Some(false) and read back. All 5,120 pixels matched, 3/3 on hardware
    and 3/3 on WARP.

  • For shader changes, the wave sizes tested: n/a (presenter)

  • cargo test -p victory-gpu --lib --locked:

    Run This branch Base (f9dfb76 + #1709)
    default 590 passed, 0 failed, 44 ignored 589 passed, 0 failed, 44 ignored
    --features diagnostics 644 passed, 0 failed, 44 ignored 643 passed, 0 failed, 44 ignored

    The one extra test is the new one.

  • cargo clippy -p victory-gpu --all-targets --locked, with and without diagnostics: no findings on the changed
    lines. The only victory-gpu findings are the existing drop(presenter) lines in present_planes (#1459/#1645
    address them). -D warnings stops earlier, in victory-shader, on main.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1709, #1727,
    #1645, #1459, #1668, #1265, #1801, #605
    • Overlap: #1727 (HDR10 output) rewrites the same swap chain format block in present_planes. #1645 and #1459
      change the two-plane drop(presenter) fallbacks next to it. Whichever merges second needs a small rebase there.
    • #1709 (two planes in the scene's own format, FP16 fallback, Composer::format()): this PR builds on it and adds
      only the single-plane case it leaves out.
    • #1668, #1265, #1801 and #605 change compose.rs (shader source or composer setup). This PR adds one entry point
      and does not change ps.
    • The triage map #1138 lists no present or swap_format change for these formats. No issue reports it.

Credit: the approach is TaynanGT/Vice-Tay#365's (pass a single sampleable plane through the compositor when DXGI
cannot present its format; its description measures R11G11B10_FLOAT frames presented by the title). This version
is adapted to this tree's compositor, with an unclamped pass instead of the SDR one. The upstream version is
Marvisak/VIctory#3784; the per-pixel test with values above one is andrewpozdnakov7-jpg's extension there,
credited as co-author on the test commit.

AI use: written with Claude Code (Claude Opus 5.5) and reviewed before submission. Tested as above.

🤖 Generated with Claude Code

**@⁠upipibi** on GitHub · 2026-11-29 00:43 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1837) `upipibi:fix/present-packed-float` → `main` · +359 −10 · 2 files · 3 commits · merged 2026-11-29 08:16 UTC Depends on #1709. The branch's first commit is #1709's (101Leafy), cherry-picked onto current main f9dfb76 so this applies; only the last two commits are this PR's. Fixes: no issue reports this (see below). ## What it changes `swap_format` (`crates/victory-gpu/src/host.rs`) has no swap chain family for DXGI_FORMAT_R11G11B10_FLOAT (26) or DXGI_FORMAT_R9G9B9E5_SHAREDEXP (67). #1709 lets two planes compose into an FP16 back buffer when the scene has no family, but a plane presented on its own still stops at `"cannot present this format"`, and that frame is never shown. On top of #1709 this PR: - gives such a plane the same FP16 fallback, if it is sampleable (`compose::view` accepts it: 2D, one slice, one sample, no DENY_SHADER_RESOURCE); - draws it with a single-plane pass of the compositor (`compose.rs`, `ps_single`, made by `Composer::single`): the plane is sampled, alpha is set to one, and nothing is clamped. `Composer::record` gets the plane twice and the second copy is unread. The Presenter keeps this composer in its own `single` slot, so the two-plane composer is untouched; - returns `None` with a warning if that composer cannot be made or recorded, as before, because the plane cannot be copied into the swap chain. The `single` composer is made once, after the resize block (after its `settle_now`), and only while its slot is empty. It is never replaced or cleared while the presenter lives, and `drop_presenter` settles before dropping it. So the drop-before-settle point UwUCammie raised on #1709 (descriptor heaps freed while queued presents still use them, and a second creation) does not apply to this slot. If #1709 changes (for example to move its composer creation after the resize), I will rebase this on top. The two-plane shader is not reused for this because its `clean`/`saturate` clamps to [0, 1]. A copy into the FP16 swap chain (formats 9..=14) keeps values above one, and so does this pass. Linear-colour caveat: like the existing 9..=14 copy, the FP16 swap chain is linear and no transfer function is applied. A plane that holds display-encoded values looks the same as it would through that copy. Commit 1 also adds a test-only hook in `present_planes` (`present_seen`, `#[cfg(test)]` only). It reads back the back buffer before the panel, notice and menu are drawn. The tree had no present-path test harness. The hook does not change non-test builds. ## How it was tested - GPU and profile: RTX 3070, driver 616.56, Windows 11 (10.0.26100), rustc 1.98.1. Presenter unit test only, no title run: no game files used. - Test `host::packed_present_tests::packed_float_single_planes_are_presented`: - It presents five frames: RGBA8 control, R11G11B10_FLOAT, R9G9B9E5_SHAREDEXP, RGBA8, R9G9B9E5. The swap chain format changes between them. - It checks the back buffer's size and format and all 5,120 pixels. - Packed quadrants (0.5, 2, 4), (4, 0.5, 2), (2, 4, 0.5) and black must come out as the exact halves, with alpha 1.0. The RGBA8 control must be 255, 0, 0, 255. - Base: main f9dfb76 with #1709 (32dedce) on top. WARP runs use `VICTORY_D3D12_WARP=1` and `--features diagnostics`; the test prints which adapter it ran on. - Before (f9dfb76 + #1709 + the test commit only), on hardware and on WARP: frame 0 (R8G8B8A8_UNORM) presented `Some(false)` and read back. Frame 1 (R11G11B10_FLOAT) presented `None`, nothing read back: `frame 1 (R11G11B10_FLOAT) was not presented`, FAILED. - After (this branch): every frame presented `Some(false)` and read back. All 5,120 pixels matched, 3/3 on hardware and 3/3 on WARP. - For shader changes, the wave sizes tested: n/a (presenter) - `cargo test -p victory-gpu --lib --locked`: | Run | This branch | Base (f9dfb76 + #1709) | |---|---|---| | default | 590 passed, 0 failed, 44 ignored | 589 passed, 0 failed, 44 ignored | | `--features diagnostics` | 644 passed, 0 failed, 44 ignored | 643 passed, 0 failed, 44 ignored | The one extra test is the new one. - `cargo clippy -p victory-gpu --all-targets --locked`, with and without diagnostics: no findings on the changed lines. The only victory-gpu findings are the existing `drop(presenter)` lines in `present_planes` (#1459/#1645 address them). `-D warnings` stops earlier, in victory-shader, on main. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1709, #1727, #1645, #1459, #1668, #1265, #1801, #605 - Overlap: #1727 (HDR10 output) rewrites the same swap chain format block in `present_planes`. #1645 and #1459 change the two-plane `drop(presenter)` fallbacks next to it. Whichever merges second needs a small rebase there. - #1709 (two planes in the scene's own format, FP16 fallback, `Composer::format()`): this PR builds on it and adds only the single-plane case it leaves out. - #1668, #1265, #1801 and #605 change `compose.rs` (shader source or composer setup). This PR adds one entry point and does not change `ps`. - The triage map #1138 lists no present or `swap_format` change for these formats. No issue reports it. Credit: the approach is TaynanGT/Vice-Tay#365's (pass a single sampleable plane through the compositor when DXGI cannot present its format; its description measures R11G11B10_FLOAT frames presented by the title). This version is adapted to this tree's compositor, with an unclamped pass instead of the SDR one. The upstream version is Marvisak/VIctory#3784; the per-pixel test with values above one is andrewpozdnakov7-jpg's extension there, credited as co-author on the test commit. AI use: written with Claude Code (Claude Opus 5.5) and reviewed before submission. Tested as above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
An R11G11B10_FLOAT or R9G9B9E5_SHAREDEXP plane presented alone is never
shown: swap_format has no swap chain for them. The test presents an RGBA8
control and both packed formats across swap chain format changes and checks
every pixel the present put into the back buffer (5,120 of them), read back
through a test-only hook in present_planes.

On main the RGBA8 control is presented and R11G11B10_FLOAT is not
("frame 1 (R11G11B10_FLOAT) was not presented").

Ported from Marvisak/VIctory#3784; the per-pixel, per-quadrant checks with
values above one are andrewpozdnakov7-jpg's extension there.

Co-authored-by: andrewpozdnakov7-jpg <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
#1709 composes two planes in the scene's own format and falls back to an
FP16 swap chain when swap_format has none, but a single plane in one of
these formats still warned "cannot present this format" and was never
shown. Such a plane, if sampleable, now takes the same FP16 fallback and is
drawn by a single-plane pass of the compositor (compose.rs, ps_single: the
plane sampled, alpha one, not clamped). Like the copy of the 16-bit float
family into its FP16 swap chain, the result is linear: no transfer function
is applied.

Depends on #1709. Port of Marvisak/VIctory#3784.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 00:44:57 +00:00
github manually merged commit 7ced570d95 into main 2026-11-29 08:21:49 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!1837
No description provided.