Repository navigation
asahi: use disjoint staging banks for 2D-array samples and texel fetches - #752
Conversation
|
Review at 7fef5b0. Note: this is a scheduling change, not a fix. 2D_ARRAY samples and fetches used to be pinned to staging bank 0, so each one waited for the one before. The logic holds up: the layer goes to bank+6 and the compare value to bank+4 relative to the chosen bank,
|
7fef5b0 to
942f1fd
Compare
|
@RyanTheTide Thanks for the detailed review — R2 is pushed at
Host assert-enabled CI ( Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
|
Re-review at 942f1fd (998425c + 942f1fd), compared with 7fef5b0. Read only; I did not build or run the host tests at this head. The code reads correctly to me. The caller predicate and the emitter predicate agree on every admitted 2D-array shape, the sample span is 8 for all of them so the 8-half alignment holds, G18G still takes its own sample and fetch emitters, and AGX2 never reaches this file. What is still open is hardware evidence: the PR body is unchanged from 7fef5b0 (it names a test that no longer exists and lists no result at 942f1fd), so everything new in this push has host unit tests only. Status of the six points from the first review:
Remaining requests:
No chip gates or env knobs added; the We can run the AGX3B rows from 1 to 3 on an M4 Pro (G16S) here and post them. Assisted-by: LLM (Claude:Opus 5.5) |
Allow consecutive 2D-array texture samples (including shadow PCF, gathers, immediate offsets, immediate bias/LOD, and compute/vertex forms) and immediate-LOD 2D-array texel fetches to allocate disjoint 8-half staging banks on both AGX3B and AGX3C instead of serializing through fixed bank 0. In agx3_allocate_staging(), every span == 8 allocation now aligns to 8 halves rather than 4 on AGX3B as well as AGX3C so consecutive 8-half banks stay disjoint and satisfy PACK_SMPIR's bank alignment. This also 8-aligns the existing AGX3B vertex 3D and 2D-array relocations, which previously used 4-half alignment. In agx3_emit_texture_fetch(), immediate-LOD 2D-array fetches allocate one 8-half bank per scoreboard slot (6 on AGX3B, 8 on AGX3C) up to the f19 <= 60 bound and stage their layer into staging_coord + 6. Bank retirement on AGX3B now uses agx3_retire_wait_on(I->src[0], bank_retire | wait_mask) rather than the r0 identity carrier so bank wrap cannot race an unrelated in-flight write to r0, and clears wait_mask after that carrier so staging_wait does not emit a redundant second wait through r0. This bank_retire carrier applies to every AGX3B fetch taking the bank_retire path, including consecutive multisample fetches and register-LOD fetches (max_banks == 1), plain 2D fetches past the ring, and 16-bit coordinate fetches (whose half-word carrier form waits slot 6 as well). Plain 2D AGX3B fetch bank count is left unchanged here and widened in a separate follow-up commit. Signed-off-by: Diljit Singh <hey@djdev.me>
Allow plain 2D texel fetches on AGX3B to allocate up to 6 disjoint 8-half staging banks (bounded by f19 <= 60, matching AGX3B's 6 scoreboard slots) before retiring and wrapping, unifying plain_banks with the 2D-array fetch ring. Signed-off-by: Diljit Singh <hey@djdev.me>
942f1fd to
f014065
Compare
|
Thanks for the thorough R2 review,
Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
|
Verified on Apple M5 Pro (
|
|
MacBook Neo (
PR body updated with these exact-head Neo addendum results. Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
|
Review at f014065. What changed since 942f1fd (I rebuilt the old R2 pair on the same base, Status of the six R2 points:
New issues: none. Both commits carry only the author's Signed-off-by, and there are no chip gates or env knobs. Verdict: APPROVE. Still owed: the second AGX3B SoC row (M4 Pro G16S: the readback probe and the bank_retire CTS groups at f014065). That one is on us, since we offered to run it, and we will post it here. |
|
@RyanTheTide Confirmed: |
|
J616s (M4 Pro, G16S) row at f014065. This is the second AGX3B SoC row. Base 4c0b010 (the PR's merge base) vs head f014065 as private overlays on one boot (kernel Vulkan CTS 1.4.7.1, the 14 groups from the PR body (21,974 cases): 5,942 Pass / 16,032 NotSupported / 0 Fail on both arms, 0 changed cases.
(Sub-groups overlap with the full texelfetch group. The total counts each case once.) Multi-op readback probe (GL, same compiler path). The standalone Vulkan probe from the Neo and M5 rows isn't in the tree, so this row uses piglit
Result: 10/10 pass on base and on head, 2 rounds each. The negative controls, which make one op read a stale layer (op 6 reads layer 0 in the 8-op fetch, op 7 reads layer 1 in the 12-op wrap), fail as expected (observed Health: 0 GPU fault, recovery or firmware-crash kernel lines, 0 AVC, 0 failed units, kernel unchanged. Assisted-by: LLM (Claude:Opus 5.5) |
|
Merged into Gates verified at exact head
Assisted-by: LLM (Google:Gemini 4 Neon) |
Use disjoint AGX3 staging banks for
2D_ARRAYtexture samples and texel fetches, and widen the AGX3B plain2Dtexel-fetch staging ring from 2 to 6 banks.Motivation
On AGX3 (
AGX3B/G17P,G16GandAGX3C/G17G,G17S,G17C),2D_ARRAYtexture samples and immediate-LOD texel fetches previously forced staging coordinates onto bank 0, serializing every consecutive2D_ARRAYsample/fetch behind a scoreboard retire wait on bank 0 even when independent taps can overlap in flight (such as PCF shadow-array sampling and multi-layer texel fetch loops).In addition, AGX3B plain
2Dtexel fetches used only 2 staging banks (plain_banks = 2), capping in-flight plain-2D texel fetch overlap at 2 rather than the 6 8-half banks available in the AGX3B staging file (0..47, bounded byf19 <= 60).Commits
7144b33efbc6—asahi: use disjoint staging banks for 2D-array samples and texel fetches2D_ARRAYtexture_sample(including shadow PCF, gathers, immediate offsets, immediate bias/LOD, and compute/vertex forms withoutg17p_uniform_dma) and immediate-LOD2D_ARRAYtexture_loadcoordinates across disjoint 8-half staging banks on bothAGX3B(up to 6 banks, matching 6 scoreboard slots) andAGX3C(up to 8 banks, matching 8 scoreboard slots), while keeping register-addressed descriptor/sampler operands on bank 0.span == 8allocation inagx3_allocate_staging()to 8 halves onAGX3Bas well asAGX3C(also 8-aligning existing AGX3B vertex 3D and2D_ARRAYrelocations).agx3_retire_wait_on(emission, enc, I->src[0], bank_retire | wait_mask)forbank_retireonAGX3B(matchingAGX3C) and clearswait_mask = 0afterward sostaging_waitdoes not emit a redundant second wait throughr0. Documented in the commit message that this applies to every AGX3B fetch takingbank_retire(consecutive multisample fetches, register-LOD fetches, plain 2D fetches past the ring, and 16-bit coordinate fetches).src/asahi/compiler/test/test-agx3-pack-binary.cpp):AGX3PackBinary.TextureSample2DArrayShadowUsesDisjointBanks(staging + encodedSMPcoord = bankassertions)AGX3PackBinary.TextureSample2DArrayRegisterOperandStaysOnBankZeroAGX3PackBinary.TextureSample2DArrayNewShapesRelocate(staging + encodedSMPcoord = bankassertions across all 7 shapes onAGX3B&AGX3C)AGX3PackBinary.TextureSample2DArrayBankOutOfStepWithSlot(2D gradient sample on slot 1 holding halves0..15, followed by 2D-array samples on slots 2 & 3 encodingSMPwithcoord = 16and24)AGX3PackBinary.TextureFetch2DArrayUsesDisjointBanksAndWrapsAGX3PackBinary.TextureFetch2DArrayBankRetireAvoidsR0AGX3PackBinary.TextureFetchBankRetireClearsWaitMaskf014065e27b5—asahi: expand AGX3B plain 2D texel fetch staging ring from 2 to 6 banksplain_banksonAGX3Bfrom 2 to 6 (bounded byf19 <= 60, matching AGX3B's 6 scoreboard slots).AGX3PackBinary.TextureFetchPlain2DUsesSixBanksOnAGX3B.Verification (Exact R3 Head
f014065e27b5)DEFAULT_BRANCH=aurora-wip bash .github/aurora/agent-policy.sh pr HEAD->PR is clean.-Db_ndebug=false, Fedora x86_64,ICD git-f014065e27):meson test --suite asahi:233/233PASS (0Fail /0Timeout /0Skipped)meson test --suite poly:5/5PASS (0Fail)Apple A18 Pro G17P B1, kernel7.3.0-41.fc44.aurora.aarch64,ICD git-f014065e27):64x64 = 4,096px/case, distinct per-layer weights,9/9PASS,0mismatches,max_err = 0across36,864pixels):fetch_2d_array_8_wrap(8 live2D_ARRAYtexelFetchcalls wrapping the 6-bank AGX3B ring)sample_2d_array_9_wrap(9 live2D_ARRAYtexturecalls wrapping the 6-bank ring)shadow_2d_array_9_wrap(9 live2D_ARRAYshadow PCF samples wrapping the 6-bank ring)fetch_plain_2d_8_wrap(8 live plain2DtexelFetchcalls exercising Commit 2's 6-bank ring + wrap)offset_2d_array_4,shoff_2d_array_4,gather_2d_array_4,biaslod_2d_array_4grad_fetch_2d_array_7(textureGradholding halves0..15ahead of 72D_ARRAYfetches sobank_retire != 0runs)AGX_MESA_DEBUG=shaderson device: confirmed 8/9 post-RA texture ops allocated across disjoint banks0, 8, 16, 24, 32, 40with wrap andbank_retirewaits.5,992Pass /16,048NotSupported /0Fail across22,040cases in 14 groups):638Pass /1,014NotSupported /0Fail):dEQP-VK.glsl.texture_functions.texelfetch.*2darray*:16Pass /8NotSupported /0Fail (24)dEQP-VK.glsl.texture_functions.texture.*2darray*:26Pass /12NotSupported /0Fail (38)dEQP-VK.texture.shadow.*2d_array*:192Pass /576NotSupported /0Fail (768)dEQP-VK.texture.filtering.2d_array.*:404Pass /418NotSupported /0Fail (822)2D_ARRAYsample groups (798Pass /954NotSupported /0Fail):dEQP-VK.glsl.texture_gather.*2d_array*:564Pass /846NotSupported /0Fail (1,410)dEQP-VK.glsl.texture_functions.textureoffset.*2darray*:130Pass /60NotSupported /0Fail (190)dEQP-VK.glsl.texture_functions.texturelod.*2darray*:16Pass /8NotSupported /0Fail (24)dEQP-VK.glsl.texture_functions.texturelodoffset.*2darray*:80Pass /40NotSupported /0Fail (120)dEQP-VK.glsl.texture_functions.texture.*2darray*bias*:8Pass /0NotSupported /0Fail (8)bank_retire/ plain-2D / multisample fetch groups (4,556Pass /14,080NotSupported /0Fail):dEQP-VK.glsl.texture_functions.texelfetch.*sampler2d_*:16Pass /8NotSupported /0Fail (24)dEQP-VK.glsl.texture_functions.texelfetch.*(full group):64Pass /32NotSupported /0Fail (96)dEQP-VK.texture.multisample.*:0Pass /10NotSupported /0Fail (10)dEQP-VK.renderpasses.renderpass2.depth_stencil_resolve.*:4,295Pass /13,822NotSupported /0Fail (18,117)dEQP-VK.image.load_store.*2d_array*:181Pass /208NotSupported /0Fail (389)gpubench-vkexact-head interleaved ABBA (4 rounds vsaurora-wip7248af95852,valid=trueon all runs):render.shadow(fmt=d32f,mode=depth_only, CRCc0fb9993exact):depth=1:1984.13 -> 1824.82 us(-8.03%wall;gpu_us:1803.54 -> 1656.83 us,-8.13%)depth=2:1644.74 -> 1497.01 us(-8.98%wall;gpu_us:1830.36 -> 1687.17 us,-7.82%)render.shadow(fmt=d16,mode=depth_only, CRCc0fb9993exact):depth=1:1366.12 -> 1282.05 us(-6.15%wall;gpu_us:1293.79 -> 1220.69 us,-5.65%)depth=2:1136.36 -> 1063.83 us(-6.38%wall;gpu_us:1321.68 -> 1244.33 us,-5.85%)compress.bw(kind=array,valid=true):depth=1:556.17 -> 551.88 us(-0.77%wall;-1.58%GPU)depth=2:388.57 -> 382.61 us(-1.53%wall;-0.49%GPU)kfaults_delta = 0(45 -> 45),avc_delta = 0.Still to run
AGX3C/G17S): hardware verification of 9-case multi-op readback probe + CTS groups at exact R3 headf014065e27b5(queued).G16S): reviewer-side hardware verification of items 1–3 at exact R3 headf014065e27b5.Assisted-by: LLM (Antigravity:Gemini 4 Neon)