Skip to content

D3D12.X: a single presented plane in a packed float format goes through the compositor - #3534

Open
throny wants to merge 1 commit into
xcl-dev:mainfrom
throny:present-packed-float-pr
Open

throny wants to merge 1 commit into
xcl-dev:mainfrom
throny:present-packed-float-pr

Conversation

@throny

@throny throny commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

A title that presents a plane in a packed float format (R11G11B10_FLOAT, R9G9B9E5_SHAREDEXP) got no picture for that present: swap_format did not know the format, so backbuffer_like filtered the plane out in present_now and a single-plane present returned before anything was drawn. Such a plane now gets an R16G16B16A16_FLOAT swap chain and goes through the compositor's draw (the path that already scales a sub-rect plane and blends overlay planes), because a copy cannot change the format.

What is in it

  • crates/xcl/src/hle/d3d12x/present.rs:
    • swap_format: the two packed float formats map to R16G16B16A16_FLOAT.
    • plane_view_format / needs_conversion (new, private): the format the compositor samples a plane in, and whether a plane has to be drawn instead of copied.
    • needs_compositor: true for a single full-rect plane that needs conversion; the compositor's SRV uses plane_view_format.
    • Compositor::can_draw (the checks record made, moved out): present_now asks it before ensure_swapchain. A packed float plane the compositor cannot draw (no compositor, no pipeline, a plane no view can read) is not presented and warns once: no resize to a float swap chain, no undefined buffer on screen, as before this change.
    • Only the title's first plane is taken in a packed float format. As an overlay such a plane is left out, as before, so presents whose first plane is not packed float are unchanged.
    • note_execute (the fallback for titles that do not call PresentX) keeps ignoring packed float targets, as before: there they are scene targets, not back buffers.
    • Test compositor_converts_a_single_packed_float_plane (WARP): the format decision for both formats, can_draw for a readable and a DENY_SHADER_RESOURCE plane, then an R11G11B10_FLOAT plane of (1.0, 0.5, 0.25) drawn into an R16G16B16A16_FLOAT target and read back.

Tested

  • Hardware: NVIDIA GeForce RTX 4080 16 GB, driver 621.40, Intel i9-12900K, Windows 11 Pro 10.0.26300, rustc 1.100.0 (0ef1bc386 2026-11-09), debug. Head commit 1d54e15, no uncommitted changes.
  • cargo test -p xcl --lib -j 4 -- compositor_converts_a_single_packed_float_plane --test-threads=2 without the fix (test only): 0 passed, 1 failed (swap_format(R11G11B10_FLOAT): left None, right Some(R16G16B16A16_FLOAT)).
  • cargo test -p xcl --lib -j 12 -- present, with the fix: 31 passed, 0 failed, 0 ignored.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 2885 passed, 2 failed, 51 ignored. The two failures:
    • gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16 also fails on main (9dfbe3e), run alone.
    • gpu::recomp::dxc::cache_tests::concurrent_cache_misses_compile_once ("cached-only waited 285.6092ms for the compile", a timing check under the suite's load) passes when run alone on this branch and on main.
  • 24 SKIPPED lines. no wave64 (21, this GPU is wave32 only):
    gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole, gpu::recomp::lower::tests::{a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu}, gpu::recomp::lower_dxil::tests::* (a_per_lane_2d_or_3d_group_runs_on_the_gpu, bridged_dpp, const_and_null_mask_operands, f16 arithmetic and packed, f32 arithmetic / compares / conversions / rounding / three-source / transcendentals, f64, integer arithmetic and carries, mask_ff0_and_flbit), gpu::recomp::tests::{gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware}.
    Others: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap (no heap windows, opt-in XCL_HEAP_WINDOWS=1), shaders::tests::pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache: Windows Developer Mode is required).

Regression run (scripts/smoke.ps1 -Game <title folder>, same title, 60 s)

main (9dfbe3e):

xcl-smoke v1
commit: 9dfbe3ea6653a9c76ef3ea0d66187a4b5407483b
gpu: NVIDIA GeForce RTX 4080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1626 (PresentX 1626)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16011 MB

this PR's head (1d54e15):

xcl-smoke v1
commit: 1d54e15edab452f794e814208f6806372b79e561
gpu: NVIDIA GeForce RTX 4080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1643 (PresentX 1643)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15622 MB

Not tested

  • No title that presents a packed float plane was run: the conversion is covered by the WARP test only, not by a real swap chain or a title's packed-float plane on screen.
  • How the picture looks on screen. No colour space is set on the swap chain and the one the title names for the plane in PresentX is not read, so the FP16 swap chain is read as linear scRGB: the brightness of a display-referred packed float plane is unverified.
  • Drawing an R9G9B9E5_SHAREDEXP plane: only the format decision is tested (the draw test uses R11G11B10_FLOAT).
  • The early return in present_now itself (it needs a window, a swap chain and a title queue): the test covers the can_draw decision it is made on, on WARP only.
  • A packed float plane as an overlay (plane 1 and up) is still left out. A packed float first plane under other overlays is now drawn with them (before, it was left out and the overlays were shown alone); no test or title run covers that.
  • AMD / wave64 hardware; the retail title's own output beyond the 60 s smoke run.
  • Overlaps D3D12.X: preserve concrete sRGB plane formats in PresentX compositor SRVs #2537 (open), which changes the same SRV format line in Compositor::record; whichever merges second needs a one-line rebase.

AI use

  • Claude Code: Claude Fable 5.2 wrote the code and the test, Claude Opus 5.5 reviewed it; Claude Sonnet 5.5 rebased it onto main, ran the test suite and the smoke runs, and prepared this PR.

🤖 Generated with Claude Code

A title that presents a plane in R11G11B10_FLOAT or R9G9B9E5_SHAREDEXP got
no picture for that present: swap_format did not know the format, so
backbuffer_like filtered the plane out in present_now and a single-plane
present returned before anything was drawn.

Such a plane now gets an R16G16B16A16_FLOAT swap chain and goes through
the compositor's draw, because a copy cannot change the format. A packed
float plane the compositor cannot draw (no compositor, no pipeline, no
readable view) is not presented and warns once. Only the first plane is
taken in a packed float format; overlays and note_execute are unchanged.

Test compositor_converts_a_single_packed_float_plane (WARP) fails without
the fix (swap_format(R11G11B10_FLOAT) returned None) and passes with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 30, 2026
@Aniseto

Aniseto commented Nov 30, 2026

Copy link
Copy Markdown

Ran the packed-float compositor test and the present group at 1d54e15e on an NVIDIA Blackwell desktop part with 16 GB of VRAM.

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, DXC 1.9.2609.5, debug build, XCL_ADAPTER=NVIDIA, detached worktree at the exact PR head, no local patches.

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib -j 4 -- compositor_converts_a_single_packed_float_plane --test-threads=2
1 passed; 0 failed; 0 ignored; 2769 filtered out      (exit 0)

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib -j 12 -- present
31 passed; 0 failed; 0 ignored; 2739 filtered out     (exit 0)

Both counts match the description at this exact head: the single packed-float plane conversion test and the 31 tests of the present group. The device used here is the NVIDIA adapter with driver 621.40 and 16 GB of VRAM, while the description's draw test was recorded on WARP; the test selects its own device, and it passed here.

Not tested: the full workspace suite, a title that presents a packed float plane, the R9G9B9E5_SHAREDEXP draw, the overlay path, native wave64 hosts, AMD and Intel GPUs, Wine, release profile, game data.

AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

@Gevroska

Copy link
Copy Markdown

@throny I tested both packed-float source formats on my RTX 3080 (driver 616.92) using 1d54e15e with a test-only extension. For each format, I drew an 8×8 two-stripe pattern through the compositor, waited for the GPU fence, and checked every FP16 output component.

Source format RTX 3080 readback
R11G11B10_FLOAT 64/64 pixels matched
R9G9B9E5_SHAREDEXP 64/64 pixels matched

The two stripes came back as RGBA (1.0, 0.5, 0.25, 1.0) and (0.5, 1.0, 0.25, 1.0) for both formats. The original R11G11B10_FLOAT WARP control also passed 64/64. This covers offscreen conversion on a physical adapter. I didn’t test swapchain presentation or establish whether the retail game supplies either format.

I used Codex GPT-6.2 Sol to extend and run the fixture. A separate GPT-6.2 Sol agent checked the source and saved results. Codex GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

@Foniass

Foniass commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: b2b1f10
head: 1d54e15
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2903 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (present.rs, +115/-12). It only changes what a title runs when its first PresentX plane is R11G11B10_FLOAT or R9G9B9E5_SHAREDEXP (on main such a present shows nothing, since swap_format returns None). Findings: (1) the plane is drawn into an R16G16B16A16_FLOAT swap chain without a colour space being set, so DWM reads it as linear scRGB; if the title's plane holds display-encoded values, or 8-bit UI planes are composed on top, the picture comes out washed out. Not checked on a title (the PR says so). (2) can_draw (~1512) needs every plane to be drawable, so one unreadable UI plane (e.g. DENY_SHADER_RESOURCE) drops the whole present; dropping just that plane would keep the scene. (3) If Compositor::new fails, it is retried on every packed-float present (~1513). Fine: can_draw keeps record's checks identical, the note_execute fallback is unchanged for other formats, and the test's packed bit patterns and half-float read-back are right; it runs on WARP and fails without the change. The smoke run below does not present a packed-float plane, so it does not reach the changed path.
performance: 60 s smoke of a retail title, main b2b1f10 vs this merge (15f36f98): 1671 -> 1676 frames shown (100 %; last presents per 2 s: 61 60 60), peak commit 17394 -> 18970 MB, 0 device removals, 0 crashes. No cost outside packed-float presents. (Rerun on current main, edited in place; the first run, on d0832e6, was 1516 -> 1665 frames and 18133 -> 17394 MB.)
verdict: safe to merge (it only adds a picture where main shows none; finding 1 is worth a look on a title that presents R11G11B10)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

@github-actions github-actions Bot added needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Dec 1, 2026
@brainhay5

Copy link
Copy Markdown

merge-check claim
head: 1d54e15

@brainhay5

Copy link
Copy Markdown

merge-check
base: d0832e6
head: 1d54e15
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 1 failed, 51 ignored; 29 SKIPPED lines
failing: test_title_runs_and_game_folder_is_untouched
review: automated overnight check — diff inspected for safety only (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no duplicate search performed; no line-by-line code review.
performance: not assessed beyond the suite.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017

@github-actions github-actions Bot added ready-to-merge Has 2 independent safe merge-checks on current head (#3041) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) ready-to-merge Has 2 independent safe merge-checks on current head (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants