D3D12.X: a single presented plane in a packed float format goes through the compositor #3534
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3534"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by throny on 2026-11-30T16:00:49Z.
A title that presents a plane in a packed float format (
R11G11B10_FLOAT,R9G9B9E5_SHAREDEXP) got no picture for that present:swap_formatdid not know the format, sobackbuffer_likefiltered the plane out inpresent_nowand a single-plane present returned before anything was drawn. Such a plane now gets anR16G16B16A16_FLOATswap 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 toR16G16B16A16_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 usesplane_view_format.Compositor::can_draw(the checksrecordmade, moved out):present_nowasks it beforeensure_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.note_execute(the fallback for titles that do not callPresentX) keeps ignoring packed float targets, as before: there they are scene targets, not back buffers.compositor_converts_a_single_packed_float_plane(WARP): the format decision for both formats,can_drawfor a readable and aDENY_SHADER_RESOURCEplane, then anR11G11B10_FLOATplane of (1.0, 0.5, 0.25) drawn into anR16G16B16A16_FLOATtarget and read back.Tested
1d54e15e, no uncommitted changes.cargo test -p xcl --lib -j 4 -- compositor_converts_a_single_packed_float_plane --test-threads=2without the fix (test only): 0 passed, 1 failed (swap_format(R11G11B10_FLOAT): leftNone, rightSome(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_d16also fails onmain(9dfbe3ea), 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 onmain.SKIPPEDlines.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-inXCL_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 (
9dfbe3ea):this PR's head (
1d54e15e):Not tested
PresentXis not read, so the FP16 swap chain is read as linear scRGB: the brightness of a display-referred packed float plane is unverified.R9G9B9E5_SHAREDEXPplane: only the format decision is tested (the draw test usesR11G11B10_FLOAT).present_nowitself (it needs a window, a swap chain and a title queue): the test covers thecan_drawdecision it is made on, on WARP only.Compositor::record; whichever merges second needs a one-line rebase.AI use
main, ran the test suite and the smoke runs, and prepared this PR.🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-30T16:57:14Z.
Ran the packed-float compositor test and the
presentgroup at1d54e15eon 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.Both counts match the description at this exact head: the single packed-float plane conversion test and the 31 tests of the
presentgroup. 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_SHAREDEXPdraw, 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.
Imported from ivall/xcl. Originally posted by Gevroska on 2026-11-30T20:23:52Z.
@throny I tested both packed-float source formats on my RTX 3080 (driver 616.92) using
1d54e15ewith 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.R11G11B10_FLOATR9G9B9E5_SHAREDEXPThe 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 originalR11G11B10_FLOATWARP 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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:09:47Z.
merge-check
base:
b2b1f109d2head:
1d54e15edamerge: 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) IfCompositor::newfails, it is retried on every packed-float present (~1513). Fine:can_drawkeepsrecord'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
b2b1f109vs 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, ond0832e61, 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.
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T05:18:03Z.
merge-check claim
head:
1d54e15edaImported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T05:24:51Z.
merge-check
base:
d0832e614fhead:
1d54e15edamerge: 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
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T11:42:17Z.
Code review location:
crates/xcl/src/hle/d3d12x/present.rs; line 1469The overlay filter uses the raw PresentX plane index
i, not the plane's position after filtering, so a packed float plane is dropped whenever an earlier raw plane was rejected bybackbuffer_like, even though it would have become resolved[0]. If raw plane 0 is under 640x360 or in a formatswap_formatrejects, and raw plane 1 is a 1920x1080 R11G11B10_FLOAT scene, plane 1 is dropped because i == 1,resolvedends up empty and nothing is presented. That's the no-picture bug this PR sets out to fix. Checkingresolved.is_empty()instead ofi > 0would fix it.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T11:42:17Z.
Code review location:
crates/xcl/src/hle/d3d12x/present.rs; line 300Not certain about this one: a packed float plane now gets an R16G16B16A16_FLOAT swap chain, but no colour space is set on it, and the colour space the title names in PresentX is ignored, so DXGI reads the buffer as linear scRGB. A title presenting a display-referred (gamma-encoded) R11G11B10_FLOAT plane has 0.5 shown as linear 0.5 (about 0.73 sRGB) instead of sRGB 0.5, so the picture looks washed out. There's no SetColorSpace1 anywhere in
ensure_swapchain.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T11:42:17Z.
Review: COMMENTED
Review of
1d54e15e: 3 finding(s). 2 are inline. These are on lines outside the diff:crates/xcl/src/hle/d3d12x/present.rs:1505: When a packed float plane is first and overlays follow, the swap-chain format comes from plane 0 (FP16), so 8-bit sRGB-encoded UI overlays are sampled through UNORM views and written into a linear scRGB target with no conversion. Take a PresentX with [R11G11B10 scene, R8G8B8A8_UNORM_SRGB UI]. Before this PR the UI plane went into an 8-bit swap chain and looked right. Now its gamma-encoded values land in the FP16 chain as linear values and are blended in the wrong space, so the UI looks washed out and its edges blend wrongly. Sampling overlays through their SRGB view (or converting) when the target is FP16 would keep them correct.These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:11:49Z.
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
Imported from ivall/xcl. Originally posted by throny on 2026-12-02T18:43:02Z.
Thanks for the reviews. I checked each point against the code at
1d54e15eand am leaving the code as it is. Here is why for each one.1. No colour space on the R16G16B16A16_FLOAT swap chain (present.rs:300; Foniass's finding 1). This is right as a description:
present.rshas noSetColorSpace1and does not decode the colour space field of PresentX, so DXGI reads an FP16 chain as linear scRGB. That was already true onmainfor every R16G16B16A16_FLOAT plane (and an R10G10B10A2 plane gets no HDR10 colour space either). This PR gives packed float planes the same treatment. We have no title that presents R11G11B10 or R9G9B9E5 in hand, so we cannot tell whether its values are linear or display-encoded. Converting without knowing would be wrong for one of the two cases. Onmainsuch a present shows nothing, and with this PR it shows the picture, perhaps with the wrong tone. Choosing the colour space from what PresentX says is a separate change for all float and 10-bit planes, and I'd rather make it with a title that needs it.2. The overlay filter uses the raw plane index (present.rs:1469). This is deliberate, and the comment on that line says so: only the title's own plane 0 is taken in a packed float format. When raw plane 0 is rejected and plane 1 is packed float, nothing is shown, which is exactly what
maindoes for that present. So this is not a regression. It is a case the PR does not cover. In PresentX, planes after 0 are the overlay (UI) planes. Showing one of them alone, stretched over the whole window as the picture, would be a guess of its own. I'm happy to change this in a follow-up if a title shows it.3. 8-bit sRGB overlays over an FP16 swap chain (present.rs:1505, outside the diff). This is the same thing
mainalready does for an R16G16B16A16_FLOAT scene with an 8-bit UI plane: overlays are sampled throughswap_format's UNORM view whatever the target is. It has the same root as point 1. Decoding only the UI to linear while the scene plane stays as the title wrote it would mix encodings whenever the scene is display-encoded. That would be wrong in a new way rather than right. So it belongs in the colour-space change. Onmain, by the way,[R11G11B10 scene, 8-bit UI]showed the UI plane alone, without the scene.No code changed, so the head is still
1d54e15e.AI use: Claude Code (Claude Opus 5.5).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.