Repository navigation
agx: take the long AGX3B SMP form for coordinate banks past 60 - #1223
Conversation
AGX3B's 14-byte immediate-descriptor SMP form can only name coordinate staging banks 0..60. Each 2D-array comparison sample claims its own eight-half bank, so the ninth tap of a 3x3 PCF kernel on a sampler2DArrayShadow relocates to bank 64, agx3_bind_compose() refuses the short form, and the whole fragment shader fails closed. That is gpubench-gl render.shadow on G17P: every draw with the PCF program was dropped (lit_cells_bad=200/200). The 20-byte ep4 form carries the full bank field. Apple's linked pipelines stage at banks 84..152 with it, and sparse samples already use it with immediate descriptors. When the short form cannot encode the operands, take the long one, as AGX3C's compact comparison, gather and query forms already escalate. Also name the SMP encoding when it is what refuses: the refusal used to surface only as the caller's line, which reads like an operand-shape gate. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
J773g (M4 Mac mini, G16G B0, AGX3B, second generation) at All arms are release overlays built natively on the Mac, on the stock kernel GL,
On base, Mesa reports: VK CTS at 2 workers, 6,253 shadow cases:
VK control, gpubench-vk
The depth_only d2 ratio comes from one outlier run (B1 452.49); the other three agree within 1 %. GPU health: 0 faults, 0 recoveries and |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 8f620bc2aea6039a8016e03bafb93a93144e01c8
Blockers: none
Checked:
- Fallback shape.
agx3_tex_encode_sample()only tries ep4 after ep3 has refused, and only on AGX3B with an immediate-descriptor (ep3) sample. Shaders that encoded before get the same bytes. The binder refuses a form that leaves an override field unconsumed or fails a predicate (agx3_bind_compose()->agx3_compose_known()), so the 20-byte form cannot silently drop the shadow, layer, LOD, offset or wait operands that the 14-byte form carried. A refusal still fails closed. - Bank edges, from
agx3b_tables.txtform smp 3 14/form smp 4 20. Field 19 has bit 0 pinned to 0 in both forms. ep3 deposits bits 1..5, so it holds even banks 0..62. ep4 adds bits 6..12. Banks 61 and 63 are refused by both forms, as they were before, so no odd bank can now encode. Bank 62 still takes the short form, and 64 is the first bank to take the long one. (Non-blocking nit: the comment says "0..60". 62 also fits the short form. A test row at 62 asserting 14 bytes would pin the edge.) - Length handling. SMP bytes are appended to the emission dynarray as returned, and nothing in the packer assumes a fixed 14-byte SMP size.
- Decode coverage. Both new tests decode the long form back through
agx3_decode(&agx3b_table, ...)and check field 19 and the other operand fields. - Tests fail without the fix. I reverted the
agx3_tex_core.chunk on the merged tree and rebuilt.agx3_tex_corethen fails at line 1390 (the encode of bank 64), andAGX3PackBinary.TextureSample2DArrayShadowPcfReachesBank64fails. With the hunk restored, both pass. - NO-GATES. The new condition keys on the ISA encoding (
AGX_ISA_ENCODING_AGX3B, which selects the encoding table), not on a chip id. AGX3C and AGX3D paths are untouched. - Merge and local gate. The head merges cleanly onto
aurora-wipa97571c6b2839. The drm-shim build of that merge (x86,-Dbuild-tests=true, asahi + poly suites) passes 338/338, the same as the tip ata97571c6. - Hardware rows at this exact head: J700 (G17P, AGX3B) in the body, and J773g (G16G, AGX3B, other generation) in the comment. The change only reaches AGX3B.
Evidence
- Merged tree
42e4479b=a97571c6+8f620bc2:meson test --suite asahi --suite poly, Ok 338, Fail 0. - Mutation (ep4 fallback reverted):
FAIL line 1390: agx3_tex_encode_sample(AGX_ISA_ENCODING_AGX3B, &d, long_form, &long_len). gtest:[ FAILED ] AGX3PackBinary.TextureSample2DArrayShadowPcfReachesBank64, other bank tests OK. - Table rows:
form smp 3 14 ... 19[0+1]=0 19[6+4]=0 19[10+3]=0 ... 19[1+3]>0.8 19[4+2]>1.8;form smp 4 20 ... 19[0+1]=0 ... 19[1+3]>0.8 19[4+2]>1.8 19[6+7]>8.0.
What: On AGX3B (G17P), a run of 2D-array shadow samples whose staging bank goes past 60 no longer fails the whole shader. The packer now uses the 20-byte SMP form when the 14-byte form cannot name the bank. This fixes
gpubench-gl render.shadow, whose 3x3 PCF fragment had every draw dropped.Tested: On J700 (Neo, stock 7.3.0-41, isolated Mesa kits, no reboot):
render.shadow --verifyfails 6/6 on the base and passes 6/6 with the fix. The VK and GL shadow CTS runs on the fix had no new failures. Unit tests fail before and pass after. Fedora CI passes 217/0. There were 0 GPU faults and 0 AVC denials.Risk: two-way; blast: neo (AGX3B only). The new path runs only where the old code refused to encode, so shaders that already compiled get the same bytes.
Not yet: none.
Details
Root cause
render.shadow's receiver shader samples asampler2DArrayShadownine times (3x3 PCF, implicit LOD, constant reference). It uses immediate texture and sampler indices. Each 2D-array comparison claims its own eight-half sampler-private bank (X/Y at +0/+2, reference at +4, layer at +6), so the taps land on banks 0, 8, ..., 64.On AGX3B,
agx3_tex_encode_sample()picks endpoint 3, the 14-byte form, for immediate descriptors. That form's coordinate-bank field only reaches 60. For the ninth tap,agx3_bind_compose()refuses it.agx3_emit_texture_sample()then returns false without naming a gate, so the refusal shows up only as the caller's line (texture_sample ... lod=0 dim=3, dim 3 =2d_array). The whole fragment program is marked unusable and its draws are skipped (lit_cells_bad=200/200).Sweeping the encoder over banks 0..252 shows:
Fix
agx3_tex_core.c: on AGX3B, if the ep3 compose fails, try ep4. AGX3C's compact comparison, gather and query forms already step up to a longer form the same way. The 20-byte form is grounded:test_linked_staging_witnesses).agx3_pack_binary.c: when the SMP encoding itself refuses, reportno SMP form for coord=halfN slot=S, so this class of refusal names itself.Tests
test-agx3-tex-core.ctest_sample_upper_coordinate_banks: for 2D, array, shadow and shadow-array samples, bank 60 stays 14 bytes. Banks 64..252 encode in 20 bytes, decode back to the same bank, and keep the other fields unchanged.test-agx3-pack-binary.cppTextureSample2DArrayShadowPcfReachesBank64: nine G17P fragment 2D-array shadow taps pack. Staging is 72 halves, the last reference is staged at bank 68, and a 20-byte SMP names bank 64.texture_sample at line 5233, no SMP form for coord=half64 slot=4. With the fix, both pass.render.shadow, compiled through gallium on the G17P drm-shim, reproduced the J700 refusal on the base (sames0=reg48.discard x3,s5=reg4.discard). With the fix it links and draws with no refusal.Evidence
Hardware: J700 MacBook Neo (G17P B1, AGX3B), Fedora 44, stock kernel
7.3.0-41.fc44.aurora.aarch64(stock.shidentical before and after), SELinux enforcing, system Mesa untouched. The arms ran in the same boot as isolated overlays (LD_LIBRARY_PATH+ EGL/VK ICD JSONs) underneohw.fd2cb725134(aurora-wip): kit sha256342522da...8f620bc2aea: kit sha256f3546b26...rig/fedora-mbuild.sh, cross,neo-gl-vk.opts.gl_wave2build from aurora-silicon/gpubench that the Neo GL-gaps rows use.gpubench-gl --test render.shadow --verify --depths 1lit_cells_bad=200/200(PCF FS refused)ASAHI_MESA_DEBUG=verifywith alpha_test on the fix: ok, crc 7be9463a = expected, no driver messages.Timing,
render.shadow mode=depth_only, ABBA, 3x250 ms runs, us/submit (median):The base is not doing the same work: it skips the PCF receiver draw because the program could not be encoded. The fix's number is the first real measurement of this workload. Shaders that compiled before are not affected: the long form is tried only after the short one is refused.
CTS on the fix arm
dEQP-VK.texture.shadow.{2d,2d_array}.*plusdEQP-VK.glsl.texture_functions.{texture,texturelod,textureoffset}.sampler2d[array]shadow*: 1546 cases, 394 Pass, 1152 NotSupported, 0 Fail, 0 recoveries.KHR-GL46.ext_texture_shadow_lod.*(glcts 1.4.7.1, pbuffer): 15/16 on both arms. The one failure,texture.sampler2darrayshadow_vertex, is already on the base: identical image difference 0.124546 on both arms, 3/3 runs each, no packer refusal on either. It is a separate vertex-stage issue and this change does not touch it.Health over every slot: 0 kernel GPU-side lines, 0 driver warnings, 0 AVC denials, 0 failed units, no leftover processes, staging removed.
Fedora CI (
rig/fedora-mesaci.sh 8f620bc2aea, asahi suite): 217/0.The PR merges cleanly onto the current aurora-wip tip (only one unrelated hunk in
agx3_pack_binary.cchanged there).