Repository navigation
Model M on RDNA 4: Swin pm kernels to 192 VGPRs, post_tf 8-byte loads (-3.5 % frame, byte-identical) - #280
Merged
Conversation
RWByteAddressBuffer.Load2 / Load4 at a computed offset is known to be 4-byte aligned only, so the driver split every history tap and the A8 feature pair into single-dword loads (227 global_load_b32 per pass). The history and A8 are the runtime's own allocations (256-byte aligned) and every offset formed on them is a multiple of 8, so clearing the address's low 3 bits changes no address and lets RADV issue global_load_b64 (gfx1201: 79 b32 + 74 b64, VGPRs unchanged at 84). The colour input is left as it was: its pointer can come from the caller. RX 9070 XT (RADV, owner's vkd3d-proton pair, 1706x960 -> 2560x1440, synthetic seed 1, 4 interleaved rounds, ~220 full-clock frames per arm): post_tf 615.8 -> 595.9 us median (-3.2 %), no other kernel moved. Same bytes: 279 of 279 dumped buffers (3 sizes), the original-filter port on a model with output taps (93 of 93 per size), and the game route's direct kernels (12 of 12 output frames); a 16-byte mask (wrong for odd columns) is caught (45 of 279, 11 of 12). gfx1100 (no-card compile): 235 -> 161 memory instructions, VGPRs 84 -> 96 (still 8 waves per SIMD, LDS-bound as before); RX 7900 XT card check pending. Signed-off-by: Jonathan Shin <85975340+j0nsh1n@users.noreply.github.com>
swin_block_c96_pm_nc / _rev_nc (enc2's block with enc1's patch merge) now build with SW_GELU_LATE0=3, the existing switch that issues every group's GELU table loads after W1 of the next group (the default of swin_c64w2.hlsl). With swin_block.hlsl's c96 default (0), RADV's compiler (Mesa ACO, the route Proton players use) needs 194 registers before scheduling at the MLP's next-group W1, 2 over the 192 that keep two 256-lane workgroups per CU (compute with LDS runs in CU mode). ACO then schedules for one workgroup per CU and ends at 256 VGPRs. With the switch it stays at 192 (+27 instructions). RX 9070 XT (RADV, owner's vkd3d-proton pair, 1706x960 -> 2560x1440, synthetic seed 1, 4 interleaved rounds, ~220 full-clock frames per arm): swin_block_c96_pm_rev_nc 259.8 -> 194.0 us median (min 224 -> 189; it no longer wanders frame to frame), no other kernel moved. Same bytes: 279 of 279 dumped buffers (3 sizes), 93 of 93 per size with an output-filter model, 12 of 12 game-route output frames. The DXIL here is byte-identical to the one timed. gfx1100 (no-card compile, RDNA 3 shortcut): 256 VGPRs as before, spilled VGPRs 5 -> 0; RX 7900 XT card check pending. Signed-off-by: Jonathan Shin <85975340+j0nsh1n@users.noreply.github.com>
…8-byte aligned The D3D12 post_tf ports read the A8 features and the history with 8-byte loads whose address has its low 3 bits cleared (post.hlsl ld64_a8 / ld128_a8). That is the requested address only when both pointers are 8-byte aligned: the runtime passes its own allocations (256-byte aligned), but an interior pointer such as A + 4 or hist[cur] + 4 would be read 4 bytes early, silently. In builds with WG_DEV_DIAGNOSTICS the runtime now checks both before every post_tf launch (the ordinary and the motion-at-output form) and fails naming the pointer (post_tf_align.h); release builds have none of it. Tests (clean.tests.test_post_tf_align, host compiler, no GPU): each pointer at base + 1, 2, 4 and 6 is refused naming it; null, 8- and 256-byte aligned pointers pass; source pins require one check right before each post_tf launch with the pointers that launch passes, both inside WG_DEV_DIAGNOSTICS. Red with the check weakened to 4 bytes, with a pointer left out of the list, and with the motion-at-output call removed; green restored. Release runtime (llvm-mingw, no WG_DEV_*): 0 of 366,036 disassembled instruction lines differ from main's, strings identical, the DLLs differ only in the PE timestamp. The developer runtime ran aligned Model M frames on an RX 9070 XT with the same bytes as the release one. Signed-off-by: Jonathan Shin <85975340+j0nsh1n@users.noreply.github.com>
This was referenced Nov 19, 2026
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.
Two exact speed-ups for Model M on the RX 9070 XT (gfx1201, RADV through vkd3d-proton), plus a developer-build check. Output bytes are unchanged.
swin_block_c96_pm_rev_ncneeded 194 VGPRs at its peak. RADV runs these kernels in CU mode, where two 256-lane workgroups per CU need 192 or fewer, so the compiler planned for one workgroup per CU and used up to 256. Turning on the existing late GELU-table switch for this kernel (already the default in the c64 kernel) brings it to 192: 260 -> 194 us. On RDNA 3 the no-card compile shows spills going from 5 to 0.post_tfreads the history taps and A8 features as 8-byte loads instead of single dwords: 616 -> 596 us. About a third of this kernel's time on gfx1201 is the dependent history reads. On RDNA 3 the no-card compile shows 84 -> 96 VGPRs, still at full occupancy, and fewer memory instructions.post_tflaunch whose A8 or history pointer is not 8-byte aligned, with a clear message. Release builds compile to the same code as main. New tests:test_post_tf_align(C++ and Python). Each test goes red when the check is weakened, a pointer is dropped or a call is removed.Whole M frame on the 9070 XT, profiler off: 2.447 -> 2.365 ms median. Runs were interleaved against main at the same full shader clock, with the clock recorded per frame. The model is synthetic (seed 1).
Byte identity: all of Model M's buffers at three sizes match main on gfx1201, including the direct kernels and the motion-at-output forms (buffer and direct, plain and native-AA). A deliberately broken kernel is caught in every case.
Not tested yet: RDNA 3 on the card. The no-card compiles and estimates are neutral or better, and the card check waits until I have the RX 7900 XT in the machine again.
Checklist
Signed-off-by:line (DCO 1.1).REUSE.toml.