feat: multi-lane pixel shader waves with SM 6.0 ballot and readlane (#68) #117
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!117
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/117/head"
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?
@Lewandox on GitHub · 2026-11-23 23:59 UTC · original
Lewandox:feat/ps-wave-ballot-readlane→main· +307 −17 · 4 files · 3 commits · closed without mergingSecond part of #68: adds multi-lane pixel shader wave support (ballot,
v_readlane_b32,v_readfirstlane_b32, and EXEC masks) in both the graphics reference interpreter and the HLSL SM 6.0 recompiler.Changes
PrototypeScarlett/emu/rdna2_exec_graphics.py: addsrun_pixel_wave(data, pixels, primitive, sgprs, memory)to execute a pixel shader across a wave32 of 1 to 32 pixels (EXEC_LO = (1 << n) - 1, per-lanev[0]/v[1]);run_pixelnow delegates to it.PrototypeScarlett/emu/rdna2_hlsl_graphics.py: auto-detects cross-lane operations (_uses_wave_ops, with explicitmulti_laneoverride) and emits HLSL SM 6.0 wave intrinsics (WaveGetLaneIndex(),WaveActiveBallot(bit).x,WaveReadLaneAt(value, other & 31u),s[126] = WaveActiveBallot(true).x) while keeping the lightweight single-lane path for plain pixel shaders.tests/test_rdna2_graphics_wave.py: verifiesrun_pixel_waveon 4 pixels withv_cmp_gt_f32(ballot),s_and_saveexec_b32,v_readlane_b32, andv_readfirstlane_b32, as well as SM 6.0 emission and single-lane preservation.README.mdanddocs/i18n/README.*.md: updated test count (555 -> 559).Local verification
.venv\Scripts\python.exe -m pytest tests/test_rdna2_graphics_wave.py tests/test_rdna2_graphics.py tests/test_rdna2_image.py tests/test_readme_sync.py -v: 19 passed, 7 skipped (dxc/anyxboxx_gpu_run.exenot installed locally)..venv\Scripts\python.exe -m ruff check --select W605,F,E9 PrototypeScarlett tests tools: All checks passed!No game, console, or SDK files used. AI-assisted contribution.
@Lewandox on GitHub · 2026-11-24 08:59 UTC · original
Added @gpu\ byte-for-byte comparison \ est_multi_lane_pixel_shader_with_divergent_exec_matches_interpreter\ in \ ests/test_rdna2_graphics_wave.py:
dna2_hlsl.py), divergent \EXEC\ (\s_and_saveexec_b32\ + \s_mov_b32 exec_lo), and \WaveReadLaneAt\ (\_readfirstlane_b32) on a full-screen quad, comparing every covered pixel against
un_pixel_wave\ byte for byte regardless of D3D12/WARP lane assignment.
@Lewandox on GitHub · 2026-11-24 10:42 UTC · original
Rebased onto \main\ (including #116/#118/#119/#123) and addressed all review points:
-1,-1), (3,-1), (-1,3)\, \ttr0.x\ in \[0.0, 2.5], so the \@Lewandox on GitHub · 2026-11-24 12:10 UTC · original
Rebased onto
main(b15d882) and addressed both blocking items in8a2dba3:ps_6_6(PIXEL_WAVE_MODELinrdna2_gpu.py), exclude helper lanes via!IsHelperLane()inWaveBallot32()(both initials[126]EXEC and every ballot) and guard pixel-record writes withif (!IsHelperLane()). Parametrized the@gputest over both a single oversized triangle and a two-triangle diagonal split (two_triangles) that exercises partially covered quads with real helper lanes.WaveBallot32()selects the 32-lane slice viaWaveGetLaneIndex() >> 5(b.x/b.y/b.z/b.w) andReadLane()offsets byWaveGetLaneIndex() & ~31u, preventing lanes 32–63 from aliasing onto 0–31 on wave64 hardware.CI (
lint+pytest) is green and the PR is ready for re-review.@KainanP on GitHub · 2026-11-24 13:20 UTC · original
Essai sur NVIDIA (RTX 4060 Laptop, pilote 32.0.16.1047, Windows 11), commit
8a2dba3, runtime compilé :Échec :
test_multi_lane_pixel_shader_lane_dependent_matches_interpreter[diagonal_split-verts1]Cause mesurée : le pilote NVIDIA met des pixels des deux triangles dans le même warp. En regroupant les enregistrements mrt1 par
(first_i, first_j, init_exec)sans la primitive :Le test regroupe les waves par
(primitive, first_i, first_j, init_exec): ce warp est coupé en deux, etrun_pixel_wave(..., primitive=1, exec_mask=0xFF1FFFFF)exécute les lignes 0-7 sans leurs pixels (v2 = 0, donc0.5 > v2vrai), alors que sur le GPU ces lignes portent les pixels du triangle 0 (v2 ≥ 0.5). D'où les 8 bits bas en trop dans le ballot attendu.Ce n'est donc pas une erreur de traduction du ballot, mais une hypothèse du test (et de
run_pixel_wave, une primitive par wave) que NVIDIA ne respecte pas. Pistes : une primitive par ligne dansrun_pixel_wave(la clé de regroupement n'aurait plus la primitive), ou, au minimum, sauter les warps à plusieurs primitives dans le test en le disant. Le script de diagnostic (reconstruction des warps depuis mrt1) est à disposition si utile.Le reste de la PR passe sur cette carte (les 6 autres tests, et toute la suite hors ce cas).
Essai et analyse faits avec l'aide d'une IA (Claude Code).
@Lewandox on GitHub · 2026-11-24 13:49 UTC · original
Fixed the multi-primitive warp issue reported by @KainanP and @LooperSalty on NVIDIA:
rdna2_exec_graphics.run_pixel_wave(PrototypeScarlett/emu/rdna2_exec_graphics.py):primitivenow accepts either a singleint(backward-compatible) or a per-lane mapping/sequence ({lane: prim}/[prim, ...])._interpolate()reads the parameter block for each active lane's own primitive (cached per primitive in the wave).tests/test_rdna2_graphics_wave.py:(first_i, first_j, init_exec)without splitting onprimitive, passingwave_primitives = {lane: prim, ...}intorun_pixel_wave(...)so multi-primitive NVIDIA warps (likeprim 0lanes 0–7 +prim 1lanes 8–28 indiagonal_split) are compared intact.test_run_pixel_wave_supports_per_lane_primitivescovering the exact multi-primitive warp ballot/readlane case on CPU.588tests. Will rebase once#139lands onmain.@KainanP on GitHub · 2026-11-24 14:06 UTC · original
Re-testé sur NVIDIA (RTX 4060 Laptop, pilote 32.0.16.1047, Windows 11), commit
fd510d3, runtime compilé :Le cas
diagonal_split(warp NVIDIA à deux primitives) passe maintenant. Merci pour la correction rapide.Essai fait avec l'aide d'une IA (Claude Code).
@Lewandox on GitHub · 2026-11-24 15:25 UTC · original
Rebased onto latest \main\ (\ecaf78) and synced all 8 READMEs to 655 tests. Ready to merge.
@minecraftafk072 on GitHub · 2026-11-24 18:32 UTC · original
Usage d'IA : essais lancés et résumés avec Claude Code (Claude Opus 5.5) sur ma machine.
Essai sur RDNA 2, RTX et WARP
PR à
03150d8, runtime de la PR compilé (VS Build Tools 2026, MSVC 14.52), Windows 26300.test_rdna2_graphics_wave.py(3 essais)1002:164e, pilote 31.0.24027.1012)fullscreen-verts0échoueLes 12 ignorés : Rust et TomBox non compilés dans ce checkout, la PR n'y touche pas.
Sur la Radeon, l'échec vient de la ligne 210,
assert len(lane2_values) > 1 or len(waves) == 1. La comparaison de la ligne 204 passe avant : les 64 pixels donnent les mêmes octets querun_pixel_wave. La traduction est donc juste ; c'est l'hypothèse du test sur la disposition des vagues qui ne tient pas sur AMD. La CI, sans GPU, passe par WARP et ne verra pas cet échec.Disposition mesurée des vagues de pixels
Chaque pixel écrit
WaveGetLaneCount()etWaveGetLaneIndex()bruts (patch local du HLSL de pixel généré, géométriefullscreendu test, 8×8) :Radeon :
WaveGetLaneCount() = 32, deux vagues matérielles empilées (lignes 0-3, puis 4-7, même motif) :RTX :
WaveGetLaneCount() = 32, deux vagues côte à côte (colonnes 0-3, puis 4-7, même motif) :WARP :
WaveGetLaneCount() = 4, seize vagues d'un quad.Avec les sommets
(-1,-1, r=0),(3,-1, r=2.5),(-1,3, r=0), attr0.x ne dépend que de x. Sur la Radeon, la ligne 2 tombe sur les pixels (0,1) et (0,5) : même x, donc les deux vagues lisent la même valeur (1.078125) etlane2_valuesn'a qu'un élément. Sur la RTX, elle tombe sur (0,1) et (4,1) : 1.078125 et 0.703125.Correctif proposé, essayé en local
Faire varier l'attribut avec y aussi, par exemple r = 1.0 au troisième sommet :
Avec ce seul changement,
test_rdna2_graphics_wave.pypasse 8/8 sur la Radeon, la RTX et WARP, 3 essais sur 3 chacun ;saw_divergencereste vrai.@Lewandox on GitHub · 2026-11-24 18:37 UTC · original
Thanks @minecraftafk072 for testing on RDNA 2, RTX 4070 Ti SUPER, and WARP and tracking down the vertical vs. horizontal wave layout difference!
Applied the
(-1.0, 3.0, 1.0)fix intests/test_rdna2_graphics_wave.pysoattr0.xvaries along bothxandyacross stacked RDNA 2 waves as well as side-by-side NVIDIA warps.@minecraftafk072 on GitHub · 2026-11-24 18:41 UTC · original
Usage d'IA : essais lancés et résumés avec Claude Code (Claude Opus 5.5) sur ma machine.
Confirmé à
212a418(runtime de la PR) :test_rdna2_graphics_wave.pypasse 8/8 sur la Radeon RDNA 2, la RTX 4070 Ti SUPER et WARP, 3 essais sur 3 chacun. Suite complète sur la Radeon : 644 passent, 12 ignorés (Rust et TomBox non compilés), plus aucun échec.@Cai-piroska on GitHub · 2026-11-24 21:42 UTC · original
Usage d'IA : essais et mesure faits avec Claude Code (Claude Opus 5.5) sur ma machine.
Essai à
6a1b3b8, runtime demain(8b466b1) compilé avec VS 2022 Build Tools, Windows 26300 : premier essai sur une carte qui exécute les pixel shaders en wave64, donc qui passe par la branche « wave > 32 lignes » deWaveBallot32(b.y) et deReadLane(& ~31u).Largeur mesurée dans le pixel shader du test
fullscreen(patch local :WaveGetLaneCount()etWaveGetLaneIndex()bruts écrits à la place dev[7]/v[8]dans l'enregistrement mrt1, 8×8 pixels) :WaveGetLaneCount()WaveGetLaneIndex()maxRésultats (2 essais chacun) :
test_rdna2_graphics_wave.pytests/test_rdna2*.pyL'échec sur la 3080 Ti est
test_extended_alu_matches_interpreter_on_gpu(v_rndne_f322.5 → 3.0, repli du pilote NVIDIA traité par #160), sans rapport avec cette PR. Les deux géométries (fullscreenetdiagonal_split, avec helper lanes) passent donc aussi avec des waves de 64 lignes.@Lewandox on GitHub · 2026-11-24 21:42 UTC · original
Rebased onto latest \main\ (\547bb2) and synced all 9 READMEs including \docs/i18n/README.ru.md\ (663 tests; \ est_readme_sync.py\ +
uff\ passing).
@minecraftafk072 on GitHub · 2026-11-24 22:32 UTC · original
Usage d'IA : essais lancés et résumés avec Claude Code (Claude Opus 5.5) sur ma machine.
Tête
a401ad3(base608cd4b), Windows 26300, dxc 1.9.2602.17, runtime demaincompilé (la PR ne touche pasruntime/).test_rdna2_graphics_wave.py1002:164e, pilote 31.0.24027.1012)6a1b3b8(648 passent, 12 ignorés) et9813756, rebasée surb547bb2(650 passent, 13 ignorés).@LooperSalty on GitHub · 2026-11-25 15:12 UTC · original
Closed by the maintainer during PR triage: this PR conflicts with
mainin code (PrototypeScarlett/emu/rdna2_hlsl_graphics.py) and the queue is being cleared now. You are welcome to reopen it once rebased onmain(keep main's1100+README line). Thanks for the work.@LooperSalty on GitHub · 2026-11-24 08:31 UTC · original · requested changes
Thanks for this. Two blocking points:
WaveActiveBallot,WaveReadLaneAt,WaveGetLaneIndex) never runs on GPU/WARP.tests/test_rdna2_graphics_wave.pycompares the interpreter with hand-written values and the HLSL only by string search. Please add a GPU test comparing the translated pixel shader withrun_pixel_wave, byte for byte.rdna2_hlsl_graphics.py(MULTI_LANE_REGISTERS/MULTI_LANE_HELPERS): D3D's lane order for a pixel shader is not the interpreter's pixel order; helper lanes count inWaveActiveBallot(true);s[126]is fed from a ballot instead of a real EXEC mask; and the ballot is not ANDed with EXEC. A GPU test with divergent EXEC would show whether these matter.Also: #119 edits the same
COMMON.format(...)calls intranslate_vertex/translate_pixel(wave_helpers=vsimages=ALU_HELPERS + ...), so whichever lands second needs a small rebase. CI is blocked by the deleted Leonida submodule until #120 is merged.🤖 Generated with Claude Code
@LooperSalty on GitHub · 2026-11-24 10:06 UTC · original · requested changes
Thanks for the GPU test. It passes here (RTX 4070 SUPER), but it cannot catch the cases I listed: the shader is lane-invariant (
v_readfirstlane_b32of a constant 1.0, thenv2 += 1.0), so every lane writes the same value whatever the lane order, the EXEC mask or the helper lanes.Could you make the GPU comparison depend on the lane?
v_readlane_b32of a lane other than 0 (e.g. lane 2) and the ballot result (v_cmp_*thens_and_saveexec_b32) into the output, with an input that differs per pixel;WaveActiveBallot(true)andWaveReadLaneAt; either exclude them (IsHelperLane(), SM 6.6) or document why the result cannot depend on them;s[126](EXEC) is built from the real active mask, ANDed with the ballot.The 32-pixel blocks in pixel order are not guaranteed to be the waves the driver forms; the comparison should only rely on values that are independent of that grouping, or read the lane index back from the GPU.
🤖 Generated with Claude Code
@LooperSalty on GitHub · 2026-11-24 11:39 UTC · original · requested changes
Review of #117 (multi-lane pixel waves, ballot and readlane). Changes requested.
Improved since the last round: the GPU test is now lane-dependent (per-pixel input, readlane of lane 2, ballot-narrowed EXEC), and it rebuilds the waves from the GPU's own lane index and initial EXEC, so it does not depend on the driver's grouping. Passing: 424 tests, the GPU test passes, ruff clean, README test count 584 matches.
Blocking:
translate_pixel("les quads entièrement couverts ... n'ont aucune helper lane") holds only for fully covered quads. The test uses one oversized triangle with no internal edge, so it never exercises a partially covered quad. On such a quad, D3D counts the helper lanes inWaveActiveBallot(true), sos[126] = WaveActiveBallot(true).xand any ballot include pixels that the interpreter does not have. Please either exclude them withIsHelperLane()(SM 6.6, check that the dxc of the Windows SDK accepts it), or add a GPU test with an internal edge (two triangles sharing a diagonal) and make it pass, or reject multi-lane shaders with a named error. A comment alone is not enough for rule 4.Ballotreads.x(lanes 0-31) and the lane index isWaveGetLaneIndex() & 31u. On a 64-lane wave, lanes 32-63 alias onto 0-31 and the ballot misses them. Guard it (for example againstWaveGetLaneCount()) or name the limitation and test it.The
t = active && condmasking on the ballot (EXEC combined with the ballot) is correct as written.🤖 Generated with Claude Code
@LooperSalty on GitHub · 2026-11-24 13:30 UTC · original · requested changes
Le test
test_multi_lane_pixel_shader_lane_dependent_matches_interpreter[diagonal_split-verts1]échoue de façon déterministe sur NVIDIA (RTX 4060 Laptop, pilote 32.0.16.1047) : 3 essais sur 3. Sur WARP, les 7 tests du fichier passent.Écart : pixel 0, primitive 1, lane 8.
mrt0[1]est un masque de ballot : 0xFF1FFF00 sur GPU contre 0xFF1FFFFF attendu. Les lanes 0 à 7 diffèrent, ce qui est cohérent avec l'analyse de KainanP : le pilote NVIDIA met des pixels des deux triangles dans une même wave, et la clé(primitive, first_i, first_j, init_exec)coupe alors cette wave en deux. (Le commentaire de KainanP donne 0xFF200000 / 0xFF2000FF : les bonnes valeurs hexadécimales sont celles ci-dessus.)À corriger : le test ne doit pas supposer qu'une wave appartient à une seule primitive. Soit
run_pixel_waveaccepte une primitive par lane, soit le test regroupe sans la primitive, soit il rejette explicitement les waves multi-primitives avec une assertion de couverture. Un test @gpu rouge sur une carte NVIDIA ne peut pas être fusionné.Autres points :
rdna2_hlsl_graphics.pyet le README entrent en conflit avec #139 (et le README avec toute la pile) : rebaser après la fusion de #139. Les autres points de la revue précédente sont traités dans le commit courant.@LooperSalty on GitHub · 2026-11-24 20:54 UTC · original · reviewed
Après la fusion de #162 (main
292079d),docs/i18n/README.ru.mdfait partie des traductions contrôlées partests/test_readme_sync.py. Une fois la branche rebasée sur main, ce test échoue (compteur de tests, vérifié en fusionnant main localement). Il faut reporter les mêmes changements dansREADME.ru.md(compteur à la valeur de cette PR) puis relancer pytest.@LooperSalty on GitHub · 2026-11-25 14:56 UTC · original · approved these changes
Re-tested at
dcd171aon NVIDIA GeForce RTX 4070 SUPER:tests/test_rdna2_graphics_wave.py8 passed (3/3 failure from my review is gone). Approving.Pull request closed