D3D12.X: stencil views get a uint T# format, so shaders load them as integers #2790
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2790
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2790"
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?
@MacieGx on GitHub · 2026-11-26 13:16 UTC · original
MacieGx:d3d12x/stencil-view-uint→main· +121 −9 · 2 files · 1 commits · openA console view of a stencil plane reaches the PC as X24_TYPELESS_G8_UINT or X32_TYPELESS_G8X24_UINT. Neither is in the GFX10 format table, so
view_shape_descgave the view's T# format 0, and translated shaders take an image's class from that format (img_cls): 0 is the float class. Animage_loadof a stencil view was therefore a float load of a UINT view, which D3D12 leaves undefined. Stencil views now get the T# format 8_UINT, the uint class. Part of #505.The newer retail title of #505 reads stencil from compute: the G-buffer depth's stencil holds the material ids that
CS_GenerateMaterialMasksclassifies, and the stencil of a D16S8 mask buffer is read by the material tiles, the tile light loop and the final gather.What is in it
crates/xcl/src/hle/d3d12x/real.rs:view_tsharp_format(stencil view formats -> 8_UINT, the rest as before), used byview_shape_desc(SRVs and UAVs) and by the null-view paths of SRVs and UAVs (a null stencil view gets the uint class too; found by @retrope13 in review); a unit test that the T# of a stencil view has a uint format and the depth view of the same buffer stays float; a GPU test that a translatedimage_loadof a stencil view returns the stencil values.crates/xcl/src/gpu/recomp/runner.rs: a test texture in a stencil view format is a depth-stencil buffer whose stencil plane holds the data, with its SRV on plane 1 (for the GPU test).Tested
stable-x86_64-pc-windows-msvc; the targeted runs below in debug, the full suite in release.cargo test -p xcl --lib -- srv_tsharp --test-threads=4: 2 passed, 0 failed, 0 ignored. Withview_shape_descback togfx10_format(f).unwrap_or(0)the new unit test fails (left: (0, 0),right: (5, 4)for X24_TYPELESS_G8_UINT).cargo test -p xcl --lib -- gpu_image_load_of_a_stencil_view --test-threads=4: 1 passed. It passes on this card without the fix too: NVIDIA's float load of the UINT view happens to return the stencil bits. That is the undefined case, so the unit test above is the one that pins the fix.cargo test -p xcl --lib -- hle::d3d12x::real gpu::dxil::msaa_tests gpu::dxil::ops_tests gpu::recomp::tests --test-threads=4(every test that uses the runner's test textures): 259 passed, 0 failed, 17 ignored; SKIPPEDgpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64).cargo build --release --workspace && cargo test --release --workspace --no-fail-fast -- --test-threads=4on7253d5b: 1433 passed, 4 failed, 47 ignored. The 4 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3(CreateComputePipelineState: out of memory (0x8007000E)), which fail onmainas well. SKIPPED (the same as onmain): 21 "no wave64", 3 refused by the per-lane form,heap_window_out_of_memory_falls_back_to_the_switch_form,pso_measurement_compiles_an_exact_synthetic_record.main+ open PRs + lab work, not this branch) the same mapping behind a switch was run in the newer retail title: in the first run with it the prison cell's walls were lit where they had been near black. Over the later runs with it the picture and the speed varied from run to run, and those runs also had a lab change this PR does not include (stencil views give their green component as the first), so they are not evidence for this PR alone. The change rests on the D3D12 rule above and the tests.Regression run
main:
this PR:
Not tested
first_plane * subresources + k, notfirst_plane + k(noted by @retrope13; no test uses that case).AI use
🤖 Generated with Claude Code
@retrope13 on GitHub · 2026-11-26 13:32 UTC · original
Independent Ada Lovelace (RTX 4060 Laptop 8 GB) + Intel UHD Graphics verification and diff review of
#2790(ccb14f7f) againstmain(b49be183): full debug suite green (0 failures) + one null-SRV review note. No title was run.Tested
32.0.16.2140, wave32),XCL_ADAPTER=NVIDIA32.0.101.7092),XCL_ADAPTER=Intel26300.9818),rustc 1.100.0(stable-x86_64-pc-windows-msvc), Windows SDK10.0.26100.0DXC1.9.2602.17.XCL_ADAPTER=NVIDIA, debug):cargo test --locked -p xcl --lib -- srv_tsharp gpu_image_load_of_a_stencil_view --test-threads=4 --nocapture: 3 passed, 0 failed (gpu_image_load_of_a_stencil_view_gives_the_stencilexecuted and passed on wave32; not skipped).cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4):main(b49be183): 1435 passed, 0 failed, 47 ignored#2790(ccb14f7f): 1437 passed, 0 failed, 47 ignored (+2 new tests, 0 failures)XCL_ADAPTER=Intel, debug):cargo test --locked -p xcl --lib -- srv_tsharp gpu_image_load_of_a_stencil_view --test-threads=4 --nocapture: 3 passed, 0 failed (gpu_image_load_of_a_stencil_view_gives_the_stencilreportedSKIPPED: no wave64on Intel UHD).hle::d3d12x::real,gpu::dxil::msaa_tests,gpu::dxil::ops_tests,gpu::recomp::tests): 259 passed, 0 failed, 17 ignored (wave64 GPU tests skipped on Intel UHD as expected).Code Review Notes (
b49be183..ccb14f7f)crates/xcl/src/hle/d3d12x/real.rs:2310): When a title creates a null stencil SRV (CreateShaderResourceView(NULL, &desc)withDXGI_FORMAT_X24_TYPELESS_G8_UINTorDXGI_FORMAT_X32_TYPELESS_G8X24_UINT), line 2310 still usescrate::gpu::desc::gfx10_format(v.Format).unwrap_or(0)instead ofview_tsharp_format(v.Format). That leaves a null stencil SRV's T# with format0(float class) instead of8_UINT(5, uint class). Switching line 2310 (and optionally the parallel null-UAV fallback at line 2678 for consistency) toview_tsharp_format(v.Format)would cover null stencil descriptors too.crates/xcl/src/gpu/recomp/runner.rs:305,365):GetCopyableFootprints(&rd, first_plane(t), subs, ...)andSubresourceIndex: first_plane(t) + k as u32are correct forTexDim::D2(t.depth == 1, as documented onTestTexture). Just a heads-up in case a future test passesTexDim::D2Array(t.depth > 1) with a stencil format: D3D12's plane-1 subresource index forMipLevels == 1isfirst_plane(t) * subs + k as u32rather thanfirst_plane(t) + k as u32.Not Tested
#[ignore]/SKIPPEDtests.AI disclosure: Antigravity (Gemini 4 Neon, XHigh) ran the builds/tests, reviewed the diff, and drafted this report.
@Prime1997 on GitHub · 2026-11-26 13:41 UTC · original · reviewed
Good within the tested scope; retain for integration. At clean head
ccb14f7f653d823876a5411b67d3049cc6c43a58, the integer stencil T# mapping passed both selected checks: 2 passed, 0 failed, 0 ignored, 0 skipped.hle::d3d12x::real::pso_blend_and_tsharp_tests::srv_tsharp_of_a_stencil_view_has_a_uint_format.hle::d3d12x::real::pso_blend_and_tsharp_tests::gpu_image_load_of_a_stencil_view_gives_the_stencilpassed the 8x8 D24S8 stencil-plane readback.Built with
cargo test --locked --offline -p xcl --lib --no-run --message-format=json --target-dir <isolated-target>; each selected exact filter ran separately with--exact --test-threads=1 --nocapture. Windows 11 Pro 26200, i5-10400, 32 GiB RAM, Rust 1.100.0 MSVC debug, private DXC 1.9.2609.5. The device fixture emitted no skip, but its log does not identify the actual adapter or establish InfoQueue coverage, so I am not presenting its pass as independently attributed NVIDIA validation.The CPU result supports the R8_UINT classification; the device result covers one D24S8 image load. D32S8, stencil arrays, general rendering, the whole suite and retail regression remain untested. This is a bounded functional result, not merge certification.
AI use: Codex (GPT-6) reviewed source, ran the selected tests and verified raw results. Optional temporary Discord for coordinating contributor work, testing and comparing results.
@DarkPanda69 on GitHub · 2026-11-26 13:51 UTC · original · edited 2026-11-26 14:24 UTC
Update for head
7253d5b: same result. Applied onmainb49be18,cargo test -p xcl --lib -- stencil --nocapturegives 3 passed, 0 failed, 0 SKIPPED (both new tests among them) and thed3d12x::filter 256 passed, 0 failed, on both the RX 9070 XT and the RTX 3060.AMD and wave32-only run (both listed as untested): the new tests pass on an RX 9070 XT and on an RTX 3060, which runs 32-lane waves only. Nothing else changes in the GPU suite.
Head
ccb14f7applied onmainb49be18, debug, Windows 11 Pro 26200, card chosen withXCL_ADAPTER:gpu_image_load_of_a_stencil_view_gives_the_stencil --nocapture: ok, no SKIPPED, on the RX 9070 XT (RDNA4, 32.0.32029.2010) and on the RTX 3060 (32.0.16.1088). The test takes the card through xcl's runner.srv_tsharp_of_a_stencil_view_has_a_uint_format: ok on both.cargo test -p xcl --lib -- gpu:: --test-threads=4onmainand with the PR: no result changes on either card (the new tests are underhle::d3d12x). RX 9070 XT 708 passed, 2 failed (#2115, the same onmain); RTX 3060 710 passed, 0 failed.Not tested: Intel, the title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@SzczepanGrela on GitHub · 2026-11-26 13:53 UTC · original · edited 2026-11-26 14:29 UTC
Updated for
7253d5b8: RX 9070 / Wine null-descriptor hook regression and both stencil GPU readbacks.Tested
7253d5b8d560d4a53ad9e30dc85660c19f0f574aversus previous PR headccb14f7f653d823876a5411b67d3049cc6c43a58. This follow-up uses the previous PR head as its control. Upstream main remainsb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7.8293130ebe370b1+(local asserts-disabled build), DXC/DXIL 1.9.2602.17, Rust 1.97.1, releasex86_64-pc-windows-gnu.XCL_REQUIRE_GPU=wave64,XCL_NETWORK=0, private enabled caches,XCL_UMA_MB=64,XCL_COHERENT_MB=64. Windows libtest binaries invoked through GE-Proton Wine with--nocapture.Local fixtures and source verification
The complete archive delta from
ccb14f7fis exactly the two null-SRV/null-UAV format calls changing toview_tsharp_format. Both source copies retain their original production code and upstream tests, with identical local#[cfg(test)]additions:0x80..0xbfinstead of0x40..0x7f, across all 64 lanes. Both are D2, one slice, plane 1.null_stencil_srv_uav_hooks_write_uint_tsharp, calling the actualdev_create_srv_xanddev_create_uav_xhooks with null resources for each stencil view format. It reads back the shadow descriptor and checks its format/class, index and 1x1 dimensions. Owned recording callbacks replace the downstream PC API calls; this tests hook metadata and forwarding, with no native null-UAV GPU execution. The callback checks require 4 SRV calls, 2 UAV calls, all 6 with null resources and non-null descriptors.Removing the shared test additions reconstructs the exact original source bytes on each side. Source inventories and executable hashes were checked after execution.
Results
Filter
hle::d3d12x::real::pso_blend_and_tsharp_tests::, three fresh serial processes plus one--test-threads=4process per revision/backend:ccb14f7f, each invocation7253d5b8, each invocationXCL_DIRECT_DXIL=0XCL_DIRECT_DXIL=1The only previous-head failure is the final class assertion in the new null-hook test. It records all four combinations before asserting:
Descriptor indices are 0, 2, 4, 6 and dimensions 1x1 on both revisions. Callback-forwarding assertions pass on both. The four combinations have the same results in all eight module invocations per revision; the hook metadata test itself is independent of translator backend.
Both real GPU stencil readbacks and the existing stencil/depth class assertions pass on both revisions through both backends. Additional ordinary R32_UINT store/readback control,
gpu::recomp::tests::gpu_image_load_reads_a_store_of_the_same_dispatch --exact, passes 1/0/0 per revision/backend. All 20 process summaries and 64 null-hook records were independently re-read. No runtime skips or ignored tests in these selections.The earlier
ccb14f7fversus main comparison remains valid: head 6/0/0 versus main control 5/1/0 per module invocation, with the uint descriptor-class assertion as the sole main-control failure. That control included the PR's runner stencil-upload support and test fixtures. Both stencil GPU readbacks passed on both revisions.Not tested
Native GPU execution of null stencil SRV/UAV descriptors, stencil arrays/MSAA GPU readback, graphics-stage sampling, forced Wave32 split mode, native Windows, full workspace suite, retail behavior, smoke workloads, performance or FPS. No retail-impact conclusion from these synthetic checks.
AI use
OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the source delta, added the local test fixtures, ran and independently verified the paired evidence, and drafted this update. Publication authorized by the account owner.
ccb14f7f65to7253d5b8d5@MacieGx on GitHub · 2026-11-26 14:02 UTC · original
Thanks @retrope13, @DarkPanda69 and @SzczepanGrela for the runs on Ada / Intel, AMD RX 9070 XT / RTX 3060 and RX 9070 under Wine.
@retrope13's first point was right: the null SRV / UAV paths still gave a stencil view the float class. Fixed in the head now,
7253d5b(both paths useview_tsharp_format; the full suite and a new regression run are in the description). The second point, the plane-1 index for a 2-D array, is noted under Not tested, since no test uses that case. Your runs were onccb14f7; the change since is those two lines.AI use: Claude Code (Claude Opus 5.5).
@Aniseto on GitHub · 2026-11-26 14:32 UTC · original
Ran the stencil-view tests at
7253d5b:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
All three pass here. The GPU test reads stencil values through a translated
image_loadon the real adapter. As the description notes, that GPU test also passes on NVIDIA without the fix (the float load of a UINT view happens to return the bits there), so the unit test asserting the uint T# format is the one that pins the change.What this adds: the author tested an RTX 5080 16 GB with the same driver. This is a second Blackwell host; the thread has no report from another machine.
Not tested: the full workspace suite, a paired 60 s smoke run, a retail title, AMD and Intel GPUs, 2-D array stencil views, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 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.
@Decodere on GitHub · 2026-11-26 14:46 UTC · original
Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2790 at
7253d5b8d560d4a53ad9e30dc85660c19f0f574a(exact parentorigin/mainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7). Measurements and targeted test results only; not a full source review.Setup
7956 MiBreported by D3D12), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200rustc 1.100.0 (0ef1bc386 2026-11-09), DXC1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)title: 29640639viascripts/smoke.ps1 -Seconds 60(XCL_NETWORK=0 XCL_ACTIVITY=1, default flags, no input)Targeted RTX 4060 release unit tests (
7253d5b8)cargo test --release -p xcl --lib srv_tsharp_of_a_stencil_view_has_a_uint_format -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, exit0).cargo test --release -p xcl --lib gpu_image_load_of_a_stencil_view_gives_the_stencil -- --nocapture: 1 passed, 0 failed, 0 ignored (0.31 s, ran live on RTX 4060 with DXC1.9.2609.5,0skipped, exit0).cargo test --release -p xcl --lib hle::d3d12x::real::pso_blend_and_tsharp_tests:: -- --test-threads=4: 5 passed, 0 failed, 0 ignored (0.23 s,0skipped, exit0).cargo test --release -p xcl --lib hle::d3d12x::real:: -- --test-threads=4: 62 passed, 0 failed, 0 ignored (0.60 s,0skipped, exit0).Observations
image_loadtests (srv_tsharp_of_a_stencil_view_has_a_uint_formatcovering explicit + null SRV/UAV stencil paths, and live RTX 4060gpu_image_load_of_a_stencil_view_gives_the_stencil) and all 62hle::d3d12x::real::tests passed cleanly in--releaseon exact head7253d5b8with0skips.exit: 0x0,1533frames shown,60 60 60steady-state presents per 2 s,0device removals,0crashes,14010 MBpeak commit vs parentb49be183's14018 MB/1518frames).Paired 60 s RTX 4060 smoke (
b49be183vs7253d5b8)Parent
origin/main(b49be183):PR #2790 head (
7253d5b8):Limits of coverage
7253d5b8(only targetedpso_blend_and_tsharp_tests::andhle::d3d12x::real::release tests plus paired quiet 60 s smoke).RTX 4060, Ada, default translator backend) on native Windows 11; no AMD, Intel, or Wine/Linux run on this host.AI use
Ran the targeted release unit tests and paired quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts and smoke blocks were taken directly from
cargo testandscripts/smoke.ps1outputs.@tiagonleal on GitHub · 2026-11-26 15:07 UTC · original
Suite on RTX 5070 Ti (Windows 11) at
7253d5b8: 1433 passed, 4 failed (the fuzz out-of-memory ones, same onmain); both new tests passTested
7253d5b8d560d4a53ad9e30dc85660c19f0f574a(parentmainb49be183), clean detached worktree, built as is, debug. PR open and head unchanged when I started.cargo build --workspace: ok.cargo test --workspace --no-fail-fast -- --test-threads=4: 1433 passed, 4 failed, 47 ignored.SKIPPED: 21 "no wave64", 3 wave32 per-lane forms refused (f16 arithmetic, f16 packed, f32 conversions), 1heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3, eachCreateComputePipelineState: Not enough memory resources are available to complete this operation. (0x8007000E). They fail the same way onmainb49be183(cargo test -p xcl --lib gpu::dxil::fuzz_tests::fuzz_validate_and_gpu: 0 passed, 4 failed).cargo test -p xcl --lib -- srv_tsharp gpu_image_load_of_a_stencil_view --nocapture --test-threads=1: 3 passed, 0 failed (srv_tsharp_of_a_stencil_view_has_a_uint_format,gpu_image_load_of_a_stencil_view_gives_the_stencil,srv_tsharp_populates_base_level_and_msaa_last_level). The GPU test ran; it was not skipped.Not tested
AI use
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.