Repository navigation
Conversation
…-oom dxil: eliminate giant-shader IR and CFG blowup in FormatLoad and multi-window memory
`vgpr_uses` took an image instruction's registers from the operand tables, which give the largest case: a 3-D address with every modifier and four data registers. It missed the addresses in the NSA dwords (VADDRA, VADDRB, ...) and a compare-swap's compare value (VDATA + 1), took a G16 sample's address as shorter than the translators read it, took an atomic's data as written only (and written without GLC too), and claimed data registers that DMASK and D16 leave alone. Its callers act on those registers: the direct DXIL VS sets up the initial VGPRs it lists (vertex and instance id, fetched attributes), the HLSL path bounds its movrel switches with them, `xcl shaders` reports the inputs a program reads from them, and the per-lane form of xcl-dev#1745 passes exactly them to xcl-dev#1426's lowering, which refuses an instruction that reads another: every image instruction with NSA addresses. `vgpr_uses` now counts them as `recomp::emit` and `dxil::lower_image` read them: the address dwords from the opcode's modifiers, DIM and A16, at VADDR and the registers after it or VADDR then the NSA bytes; the data from DMASK, D16, TFE/LWE, GLC and the opcode. `dxil::lower_image` read VDATA + 1 for every atomic; it reads it for a compare-swap only now. In xcl-dev#1745's per-lane form (at 3ca3633), a sweep of every IMAGE_* instruction over DIM, A16, D16, DMASK, GLC and sequential or scattered NSA addresses through the per-lane compute lowering: 6562 of 28032 cases refused for a register not passed before (6130 NSA, 288 compare-swap, 144 G16), none after, and no case that lowered before refused. Assisted-by: Claude Code (Claude Opus 5.5, xhigh)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rdna2::vgpr_usestook an image instruction's registers from the operand tables, which give the largest case: a 3-D address with every modifier, and four data registers. That gets several things wrong:VDATA + 1);It now counts what
recomp::emitanddxil::lower_imageread. Fixes xcl-dev#885. Part of xcl-dev#1269.On
main, these callers act on the registers:dxil/kernel.rs→setup_vertex).max_vgpr, as Recompiler: VGPR tracking misses non-sequential MIMG address registers xcl-dev/xcl#885 describes).xcl shadersreports a program's inputs from them.The per-lane form in xcl-dev#1745 passes exactly these registers to xcl-dev#1426's lowering, so without this it refuses every image instruction with NSA addresses. The per-lane tests are a follow-up on top of xcl-dev#1745.
This overlaps draft xcl-dev#886 (also
Fixes #885), which counts every encoded NSA byte, padding included, and leaves the data registers as they are. This PR counts the address dwords and the data registers exactly, and its tests cover NSA1, NSA2, NSA3 and the v255 bound.What is in it
Recompiler: image instructions name the registers they usecrates/xcl/src/gpu/rdna2.rs:mimg_vgpr_usesandmimg_address_dwords, and the testsimage_register_usesandimage_address_counts_reach_the_operand_tables.crates/xcl/src/gpu/dxil/lower_image.rs: an atomic readsVDATA + 1for a compare-swap only.Tested
Setup:
cargo build --workspace && cargo test --workspace -- --test-threads=4:main4178e88: 891 passed, 0 failed, 42 ignored (lib: 842 / 0 / 22).SKIPPED GPU tests, the same 4 on both runs:
gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windowsshaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required)image_register_usesfails without the change. For a 2-D load with DMASK 0x5, it gets([3, 4, 5, 6], [14, 15, 16, 17])where([3, 4], [14, 15])is expected.image_address_counts_reach_the_operand_tableschecks the address count of every image instruction against the operand tables.On Recompiler: a per-lane form for the direct DXIL backend (XCL_PER_LANE) xcl-dev/xcl#1745's per-lane form (at 3ca3633), a sweep sent every
IMAGE_*instruction through the per-lane compute lowering, over DIM, A16, D16, DMASK, GLC and sequential or scattered NSA addresses:The follow-up's GPU tests compare loads and samples with NSA and sequential addresses, D16, a store, a gather, resinfo, GLC atomics and BVH with NSA addresses against the HLSL path.
Regression run
scripts/smoke.ps1with-Xclpointing at that worktree'sxcl.exemain's frames and 103.8 % of its peak commit, with no device removal or crash.main4178e88:This PR's head
8ec49c0:XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PRESS_A_AT=20, network offmain's frames and 102.9 % of its peak commit.main4178e88, 180 s:This PR's head
8ec49c0, 180 s:Not tested
main's world-load stall (Roadmap: retail title past world load xcl-dev/xcl#1833).main-side effects listed above come from reading the code, not from a run. I have no title with a VS that reads its inputs only as NSA addresses, or with a movrel past them.vgpr_usesfollows the translators, andimage_address_counts_reach_the_operand_tablespins the difference.AI use
Mirror of xcl-dev#1797 (auto-synced, do not edit).