Recompiler: a pixel shader's ordered section uses rasterizer ordered views #1699
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1709"
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 Alexr03 on 2026-11-24T19:31:44Z.
A pixel shader with an ordered section (POPS) writes
HW_REG_POPS_PACKER, waits until the earlier pixels at its position have left, then reads and writes its images. The translation lets the wait pass at once ("no ROV ordering yet – known limitation" inemit.rsandHANDOFF.md), so overlapping primitives race. Ten pixel shaders of a retail game's pack do this: after the wait, three image loads and five stores to the same three images at the pixel's position.This is the first of three parts: the translation and its tests, off by default (
Options::ordered_views; nothing sets it at a title's run, so no title's shaders change). Next: D3D12.X turns it on where the device hasROVsSupportedand gives those pipelines the root signature below; then the README.With the option, image loads and stores from the write of the register on go through
RasterizerOrderedTexture*views of the UAV descriptor. The loads too: through the SRV they are not ordered.The views come from a descriptor table, not
ResourceDescriptorHeap. XCL's other views are taken from the heap, and that was the first form tried here. It is not in this PR, because on NVIDIA it cannot be used:RasterizerOrderedTexture2D<uint4> R = ResourceDescriptorHeap[1]makes the draw fail withDXGI_ERROR_DEVICE_HUNG(0x887A0006; the test's D3D12 device is lost – "device removed" in D3D12's terms – and its process ends with the error). One triangle is enough. RTX 5080, driver 32.0.16.2124.nvlddmkmevent 153 ("Error occurred on GPUID") at each such run – and event 13, "Graphics SM Warp Exception: MMU Fault", in some of the earlier ones – and the desktop flickered during them.RWTexture2Dinstead runs, with no driver event, before and after a failing run.CreateGraphicsPipelineStateaccepts it; the AMD driver runs it and orders it.From an unbounded array in a table over the same heap the ordered view works on both. So
pso::abi_root_signature_orderedadds one parameter (6), a table to set to the heap's start, andTranslation::ordered_viewssays a pipeline needs it.That this is a driver fault and not a form D3D12 forbids is a conclusion from the four points above. It was not run under the D3D12 debug layer, and no statement in the specification was looked up either way.
Measured, 64 triangles over a 16² target in one draw, each pixel adding one to its texel, the value the last triangle reads (63 when ordered):
main)ResourceDescriptorHeap(not in this PR)The RTX 5080 has no number in the second row because nothing can be read back: the draw that would give it ends with
DXGI_ERROR_DEVICE_HUNG, so the target is never copied out.What is in it
Recompiler: a pixel shader's ordered section uses rasterizer ordered viewscrates/xcl/src/gpu/recomp/mod.rs:Options::ordered_views,Translation::ordered_views.crates/xcl/src/gpu/recomp/emit.rs: the pc of the firstHW_REG_POPS_PACKERwrite (pre-scan);image_load/image_storeafter it through the ordered arrays (xcl_ord<dim>_<f|u|i>, register u0 of space 2 + 3 · dimension + class), declared for the dimensions used.image_load_mip, multisampled loads and image atomics stay as they are.crates/xcl/src/gpu/recomp/pso.rs:abi_root_signature_ordered(not called by the runtime yet).crates/xcl/src/gpu/recomp/runner.rs(test runner):ordered_views()fromROVsSupported; a test texture withALLOW_UNORDERED_ACCESSgets its UAV at 2·i + 1; the draws' root signature has the table.crates/xcl/src/gpu/recomp/tests.rs:ordered_section_images_are_rasterizer_ordered_views(the HLSL with and without the option; no GPU) andgpu_ps_ordered_section_orders_overlapping_triangles(the draw above; skips with "no ordered views").emit.rsis part of the translator source id, so translation caches rebuild once.Tested
XCL_ADAPTER=radeon); Windows 11 Pro 26200, Rust 1.100.0, DXC 1.8.2502.11; tests in debug, regression runs in release.cargo test --workspace -- --test-threads=4on the RTX 5080, heada57a76c: 860 passed, 0 failed, 42 ignored.gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).gpu_ps_ordered_section_orders_overlapping_triangles: passes in 10 of 10 runs on each adapter before the rebase ontoc160d86and in 3 of 3 on each after it. With the option forced off in the runner it fails on both (pixel (0, 0): 0 on the RTX 5080, 8 on the Radeon).RWTexture2Dform: those gave 0 driver events each, it gave the error and twonvlddmkm153 events in the same seconds.rdna2::decode(not in the PR).Regression run
main:
PR:
The run does not reach the changed code: the option is off at a title's run.
Not tested
R32_UINT, which always can.XCL_DIRECT_DXIL): it has no ordered views.AI use
claude-mythos-5-2): found the shaders, wrote the change, the tests and this description, and ran the tests, the adapter comparison and the regression runs.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T22:18:54Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T08:00:52Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:33:07Z.
Triage (#1607) – head
a57a76cNo open or merged PR makes the same change. Main only detects
HW_REG_POPS_PACKERingpu/dxil/kernel.rs, and no HLSL path uses rasterizer ordered views.Note that the runtime never turns this on:
Options::ordered_viewsis only set byrunner::options, andpso::abi_root_signature_orderedis only used by the test runner. A follow-up has to set the option and bind the ordered root signature and its table for title pipelines.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.