Recompiler: a pixel shader's ordered section uses rasterizer ordered views #1709
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!1709
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@Alexr03 on GitHub · 2026-11-24 19:31 UTC · original
Alexr03:feature/ordered-pixel-shading→main· +225 −15 · 5 files · 1 commits · draftA 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.@DavidM1911 on GitHub · 2026-11-24 22:18 UTC · original
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!
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.