Repository navigation
borealis,agx: lower color subpass input attachments to on-chip tile memory on AGX3 - #703
Conversation
|
Thanks, the Neo CRC-exact render.deferred rows and the fallback design (draw-time split whenever a kept input-attachment barrier meets a texture-path read) look good. Some scope and coverage questions before this goes in:
Assisted-by: LLM (Claude:Opus 5.5) |
|
Clean-room Apple M5 Pro (
1.
|
| Res | MSAA | Mode | Depth | aurora-wip (c0b51ef2) |
#703 (b29dfcfd) |
Speedup vs base | vs dram |
gpu_us (base -> #703) |
CRC-32 |
|---|---|---|---|---|---|---|---|---|---|
| 1080p | 4x | tile |
1 | 1,960.78 us | 555.56 us | 3.529x | 1.50x | 1,839.25 -> 545.67 us (3.37x) | 6dc74b48 EXACT |
| 1080p | 4x | tile |
2 | 1,652.89 us | 401.61 us | 4.116x | 1.65x | 1,749.71 -> 530.54 us (3.30x) | 6dc74b48 EXACT |
| 720p | 4x | tile |
1 | 921.66 us | 325.73 us | 2.829x | 1.33x | 924.83 -> 329.88 us (2.80x) | cd0ee709 EXACT |
| 720p | 4x | tile |
2 | 746.27 us | 187.44 us | 3.981x | 1.51x | 797.65 -> 241.44 us (3.30x) | cd0ee709 EXACT |
| 1080p | 1x | tile |
1 | 414.08 us | 347.22 us | 1.193x | 0.75x | 426.75 -> 354.58 us (1.20x) | 2cfe9a54 EXACT |
| 1080p | 1x | tile |
2 | 270.27 us | 210.75 us | 1.282x | 0.63x | 351.08 -> 262.92 us (1.34x) | 2cfe9a54 EXACT |
| 720p | 1x | tile |
1 | 260.42 us | 258.06 us | 1.009x | 0.76x | 283.67 -> 229.75 us (1.24x) | db6d5fea EXACT |
| 720p | 1x | tile |
2 | 137.17 us | 108.58 us | 1.263x | 0.72x | 169.38 -> 157.38 us (1.08x) | db6d5fea EXACT |
| 1080p | 4x | dram |
1 / 2 | 843.88 / 666.67 us | 833.33 / 664.45 us | 1.01x / 1.00x (ctrl) | — | 868.96->866.25 / 737.79->733.75 | 7c09507f EXACT |
| 720p | 4x | dram |
1 / 2 | 433.84 / 284.09 us | 431.97 / 283.29 us | 1.00x / 1.00x (ctrl) | — | 457.46->452.67 / 349.33->343.67 | 22db814d EXACT |
| 1080p | 1x | dram |
1 / 2 | 261.78 / 137.27 us | 261.44 / 133.07 us | 1.00x / 1.03x (ctrl) | — | 289.83->291.42 / 210.83->203.29 | 2cfe9a54 EXACT |
| 720p | 1x | dram |
1 / 2 | 195.50 / 77.88 us | 195.69 / 77.76 us | 1.00x / 1.00x (ctrl) | — | 216.50->215.54 / 154.38->155.33 | db6d5fea EXACT |
2. Vulkan CTS (deqp-vk 1.4.7.1) — Blocker Found: 30 Regressions on Cross-RT attachment_mapping_input_attachments*
CTS Group (G17S B1) |
Pass | Fail | NotSupported |
|---|---|---|---|
dEQP-VK.renderpasses.dynamic_rendering.primary_cmd_buff.local_read.* (53 total; baseline 47/0/6) |
32 | 15 | 6 |
dEQP-VK.renderpasses.dynamic_rendering.partial_secondary_cmd_buff.local_read.* |
19 | 0 | 6 |
dEQP-VK.renderpasses.dynamic_rendering.graphics_pipeline_library.local_read.* |
26 | 15 | 6 |
dEQP-VK.renderpasses.renderpass1.suballocation.*input_attachment* |
7 | 0 | 1 |
dEQP-VK.renderpasses.renderpass2.suballocation.*input_attachment* |
7 | 0 | 1 |
dEQP-VK.image.general_layout.input_attachment.* |
12 | 0 | 0 |
dEQP-VK.multiview.*input_attachments* |
40 | 0 | 0 |
dEQP-VK.pipeline.*.attachment_feedback_loop_layout.* (1,000/9,504 sample) |
124 | 0 | 876 |
Root Cause of the 30 Regressions (Tilebuffer WAR Hazard — Affects Both G17P & M5!)
All 15 failures in primary_cmd_buff.local_read.* (and the matching 15 in graphics_pipeline_library.local_read.*) are the CTS 1.4.7.1 attachment_mapping_input_attachments* tests (attachment_mapping_input_attachments{,_4,_6,_all*,_superset*}), which all pass on baseline (47 Pass / 0 Fail / 6 NotSupported).
In attachment_mapping_input_attachments, pColorAttachmentInputIndices = {1, 0, 2, 3} swaps RT 0 and RT 1, and frag1 executes:
outColor0 = subpassLoad(inColor0); // reads RT 1 (offset 0x4), writes RT 0 (offset 0x0)
outColor1 = subpassLoad(inColor1); // reads RT 0 (offset 0x0), writes RT 1 (offset 0x4)AGX_MESA_DEBUG=shaders shows a direct write-after-read (WAR) tilebuffer hazard — st_tile to RT 0 (#0x0) is emitted before ld_tile from RT 0 (#0x0), overwriting RT 0 before it is read:
wait_pix #0x8
r0l...r0h = ld_tile #255, _, xyzw, #0x4 ; reads RT 1 (GREEN)
...
wait_pix #0x4
st_tile ^r1l...r1h, #255, _, xyzw, #0x0 ; OVERWRITES RT 0 (offset 0x0) WITH GREEN!
r0l...r0h = ld_tile #255, _, xyzw, #0x0 ; READS RT 0 AFTER OVERWRITE (gets GREEN instead of BLUE)
...
st_tile ^r1l...r1h, #255, _, xyzw, #0x4 ; writes GREEN to RT 1 -> max diff (0, 1, 1, 0)
Ensuring all load_local_pixel_agx loads are scheduled / ordered strictly before any store_local_pixel_agx to the same (or any) tilebuffer attachment (e.g. preventing load_local_pixel_agx from sinking past store_local_pixel_agx or keeping load_local_pixel_agx non-reorderable relative to store_local_pixel_agx) should fix all 30 failures across both G17P and M5. Happy to re-verify on M5 Pro as soon as R2 is pushed!
Assisted-by: LLM (Antigravity:Gemini 4 Neon)
|
Pushed R2 at Changes in R2
Ready for M5 Pro CTS 1.4.7.1 re-verification and M4 mini ( Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
|
Re-verified Apple M5 Pro ( All 30 previously failing CTS 1.4.7.1
M5 Pro ( Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
|
Exact-head M4 hardware verification (
Assisted-by: LLM (Gemini:4 Neon) |
|
A18 Pro (MacBook Neo, Perf: on-chip tile memory works on G17P at R2. Deferred tile MSAA4 at 1080p gets 3.6x faster (11,018 -> 3,091 us at depth 1) and the non-tile rows don't move. CTS 1.4.7.1: identical to base per case, including all 60
Correction (edited): an earlier version of this comment said the new Method and raw numbers
Assisted-by: LLM (Claude:Opus 5.5) |
|
Thanks for running the independent MacBook Neo ( Pushed R3 (
Would love M4 Pro ( Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
|
Clean-room exact-head Apple M5 Pro (
Assisted-by: LLM (Google:Gemini 4 Neon) |
|
M4 Pro (MacBook Pro, T6040, G17P profile on the G17 runtime) row for R2 Perf: the tile path engages on the M4 Pro too. Deferred tile MSAA4 at 1080p gets 3.4-3.9x faster (2,857 -> 828 us at depth 1) with CRC-32 matching base. The DRAM-mode rows don't move. CTS 1.4.7.1: identical to base per case. All 60
Method
Assisted-by: LLM (Claude:Opus 5.5) |
986f71b to
9ffd7a2
Compare
|
Rebased onto current |
9ffd7a2 to
4708ad9
Compare
|
Rebased cleanly onto |
Add AGX3 compiler support for monolithic fragment shaders that read color tilebuffer attachments via load_local_pixel_agx (subpassLoad / VK_KHR_dynamic_rendering_local_read) on G17P (AGX3B) and M5 (AGX3C). - Add key.agx3_local_read to enable multi-block tile ordering and agx3_g17p_local_read_protocol() across arbitrary control flow and read-only partitions, while keeping existing inline-MRT and G18G paths unchanged. - Group single-sample entry-block LD_TILE instructions back-to-back and split single-sample colour class lifetimes so load-only pairs release (retiring their in-flight tile-load scoreboard slots, including shared AGX3B slot 6 reissues) ahead of lighting ALU and write/store-only pairs wait only before final stores. - Preserve per-sample register-mask LD_TILE/ST_TILE ordering and retire any incoming wait ahead of register-sample MSAA tile loads. - Cover single-sample, 4x MSAA, multi-block CFG, disjoint phase-split, load-only, and mixed 5-RT phase-split protocols in test-inline-mrt. Signed-off-by: Diljit Singh <hey@djdev.me>
… eligible Extend hk_barrier_classify() with color_input_local_read, color_attachment_count, and depth_stencil_writes so BY_REGION in-pass barriers targeting VK_ACCESS_2_INPUT_ATTACHMENT_READ_BIT stay on-chip within a single TBDR render pass when the caller confirms on-chip color local_read eligibility. Non-BY_REGION barriers, depth/stencil input-attachment barriers, aliasing attachments, spilled tilebuffers, and barriers combining color input-attachment reads with non-tile accesses continue to split the pass. Add unit coverage for all keep/split boundaries in test-hk-barrier. Signed-off-by: Diljit Singh <hey@djdev.me>
Lower Vulkan color subpass input attachment reads (both traditional render passes and VK_KHR_dynamic_rendering_local_read) to on-chip AGX3 tilebuffer loads (load_local_pixel_agx) in Borealis on G17P and M5. - Preserve a serialized pre-lowering fragment NIR payload and input attachment binding metadata for shaders using color subpassLoad (single-sample and per-sample MSAA), bumping the AGX3 shader binary version for cache invalidation. - At draw time, validate that bound input-attachment descriptors match the active render pass color attachments with compatible formats, layers, mip levels, identity swizzles, and sample counts, then compile and cache a monolithic AGX3 fragment program with tile-memory reads and inlined color epilog. - Enable color_input_local_read in hk_classify_pass_barrier() for eligible primary render passes and track kept_local_read_barrier so any subsequent draw that cannot use on-chip tile reads safely splits the pass to DRAM before issuing texture-backed reads. Signed-off-by: Diljit Singh <hey@djdev.me>
load_local_pixel_agx and store_local_pixel_agx access mutable on-chip tilebuffer memory. Marking them CAN_REORDER and allowing nir_opt_sink / nir_opt_move to sink load_local_pixel_agx let NIR move a tile load past a tile store to the same render target when local-read attachment mapping swaps render targets (e.g. pColorAttachmentInputIndices = {1, 0, 2, 3}), introducing a tilebuffer WAR hazard (30 CTS 1.4.7.1 failures across attachment_mapping_input_attachments*).
Remove CAN_REORDER from load_local_pixel_agx and store_local_pixel_agx and drop nir_intrinsic_load_local_pixel_agx from nir_opt_sink's can_sink_instr().
Signed-off-by: Diljit Singh <hey@djdev.me>
… tighten barrier tracking - Add a single feature-named capability predicate agx_chip_local_read_tilebuffer() in agx_chip.h admitting verified G16G (M4), G17P (A18 Pro / M4 Pro / M4 Max), and M5 (G17G/G17S/G17C) while leaving unverified G15* (M3) and G18G (M6) on the DRAM fallback path. - Route all Borealis and compiler local-read gates through agx_chip_local_read_tilebuffer() and remove the raw AGX_CHIP_G17P checks from hk_prepare_local_read_nir(). - Bump HK_CLASSIC_SHADER_BINARY_VERSION to 35 for G16G serialized local_read payloads. - Track used_local_read in hk_barrier_classify_ex() so kept_local_read_barrier is set only when the local-read rule actually kept the barrier (not on unrelated barriers that happen to carry INPUT_ATTACHMENT_READ). - Extend test-inline-mrt (G16G matrix, G15/G18 negative checks, and cross-RT swap load-before-store WAR regression) and test-hk-barrier (used_local_read precision and deferred draw-time fallback split). Signed-off-by: Diljit Singh <hey@djdev.me>
… generation Select on-chip local_read eligibility by ISA encoding and command-stream generation (HAL200/AGX3B and HAL300/AGX3C) instead of enumerating individual chips. This admits M4 Pro (G16S) and M4 Max (G16C) alongside G16G, G17P, and the M5 family without future chip-list edits, while keeping unverified G15 (M3) and AGX3D (G18G) on the DRAM fallback path. Pin the predicate in test-chip.c and add G16S/G16C coverage to test-inline-mrt. Signed-off-by: Diljit Singh <hey@djdev.me>
4708ad9 to
60974fa
Compare
|
Rebased onto |
joshuaswarren
left a comment
There was a problem hiding this comment.
Verdict: APPROVED at 60974fafd0.
Blockers: none.
Checked:
agx_chip_local_read_tilebuffer()now selects by(AGX3B && HAL200) || (AGX3C && HAL300)instead of theG16G || G17P || g17_m5chip list — newly admits G16S/G16C, which share the AGX3B/HAL200 pixel-class tilebuffer protocol. G15 (unverified) and G18G/AGX3D (no local-read encoder) correctly stay out.- The only consumer,
agx3_order_g17p_local_read_tile_ops, admits local_read/subpassLoad shapes under the uniform pixel-class transaction; comment updated to match. - On G13G/G13X the predicate is false both before and after (AGX2 encoding, not AGX3B/3C): zero behavior change on our chips. The new test-chip row
"0000 00000 1111 11111 0 0"pins that. test-inline-mrtgains G16S/G16CEXPECT_TRUEcoverage plus chip-gate rows alongside the existing G15G/G18G false cases.
Evidence: builds, unit tests, 13,781-case dEQP-VK.compute diffs on M1 / M1 Max
Exact head 60974faf built aarch64 on mesa-xbuild (pr703-60974faf).
| Host | Suite | dEQP-VK.compute vs aur-base-617c7fe6 |
|---|---|---|
| jwm1 (T8103/M1) | meson test --suite asahi --suite poly: 182/182 (177 asahi + 5 poly) OK | 0 diffs / 13,781 cases |
| jw16 (T6001/M1 Max) | — | 0 diffs / 13,781 cases |
|
Merged into |
PR aurora-silicon#703 copied meta->g17p_colour_unit_range into the old field name s->info.fs.g17p_colour_unit_range, which was renamed to s->info.fs.colour_unit_range on aurora-wip. Update the assignment in hk_g17p_layout_shader_create_local_read() to match hk_shader_info::fs. Signed-off-by: Diljit Singh <hey@djdev.me>
Summary
Implements general, spec-compliant TBDR on-chip tile-memory lowering for Vulkan color input attachments in Borealis on AGX3 (
agx_chip_local_read_tilebuffer():G16G,G17P, andM5/G17G/G17S/G17C), keeping eligibleBY_REGIONcolor input-attachment barriers within a single on-chip render pass instead of splitting through DRAM.Scope of on-chip vs memory-backed paths:
VK_KHR_dynamic_rendering_local_readcolor reads after an in-passBY_REGIONcolor input-attachment barrier, as well as traditional render-pass in-subpass self-dependencies (BY_REGION).vk_render_passlowers subpass transitions outsideCmdBeginRendering/CmdEndRendering, and M5 pass merge treatsINPUT_ATTACHMENT_READas an ordered dependency. Depth/stencil input attachments, spilled tilebuffers, non-BY_REGIONbarriers, and view/format/swizzle mismatches also fall back cleanly to DRAM.Architecture (5 commits)
agx: support multi-block local_read tile protocol on AGX3(6d0f68466e8)key.agx3_local_readenabling multi-blockLD_TILE/ST_TILEordering (agx3_g17p_local_read_protocol()) across arbitrary control flow and read-only partitions, grouping single-sample entry-blockLD_TILEs and phase-splitting colour class lifetimes (early release of load-only pairs retiring all in-flight load-only scoreboard slots, including sharedAGX3Bslot 6 reissues; deferred wait for store-only pairs).LD_TILE/ST_TILEordering for MSAA (msaa > 1) and retires any incoming scoreboard wait before register-sample tile loads.borealis: keep BY_REGION color input-attachment barriers on-chip when eligible(d0ddf30770a)hk_barrier_classify()withcolor_input_local_read,color_attachment_count, anddepth_stencil_writessoBY_REGIONin-pass barriers targetingVK_ACCESS_2_INPUT_ATTACHMENT_READ_BITstay on-chip when the active pass is eligible.BY_REGION, depth/stencil input-attachment barriers, aliasing attachments, spilled tilebuffers, and mixed non-tile accesses still split safely to DRAM.borealis: lower color subpass input attachments to on-chip tile memory(b29dfcfd694)subpassLoad(single-sample and per-sample MSAA), with shader binary cache version bumps.load_local_pixel_agx) with an inlined color epilog.kept_local_read_barrierper render pass so any subsequent draw that cannot safely use on-chip tile reads splits the pass cleanly to DRAM before issuing texture-backed reads.nir/agx: forbid reordering and sinking local_pixel_agx tile accesses(dfc6bd0ab3f)CAN_REORDERfromload_local_pixel_agxandstore_local_pixel_agxinnir_intrinsics.pyand removesnir_intrinsic_load_local_pixel_agxfromnir_opt_sink.c.VK_KHR_dynamic_rendering_local_readinput attachment mappings (e.g.pColorAttachmentInputIndices = {1, 0, 2, 3}, caught by M5 Pro CTS 1.4.7.1attachment_mapping_input_attachments*), where NIR could sinkload_local_pixel_agx(RT0)paststore_local_pixel_agx(RT0).asahi,borealis: gate on-chip local_read with capability predicate and tighten barrier tracking(9f53266b749)agx_chip_local_read_tilebuffer()inagx_chip.h(G16G,G17P, andM5/G17G/G17S/G17C, excluding unverifiedG15*andG18G) and routes all Vulkan and compiler local-read gates through it, removing rawAGX_CHIP_G17Pchecks inhk_prepare_local_read_nir(), bumpingHK_CLASSIC_SHADER_BINARY_VERSION(34 -> 35), and failing closed inagx3_pack_binary()ifkey.agx3_local_readis passed on an unsupported chip.hk_barrier_classify_ex(..., bool *used_local_read)sokept_local_read_barrieris set only when the local-read rule actually kept the barrier, and extractshk_barrier_local_read_draw_needs_split()with focused unit coverage intest-hk-barrier.c.test-inline-mrt.cppacrossG16G,G17P, andG17Splus negativeG15*/G18Ggating and{1, 0, 2, 3}cross-RT swap WAR regression tests.Verification
Host CI (
fedora-mesaci.sh)9f53266b74914bbb8d559e4eeb0da99fc74901b6(ICD git-9f53266b74): 155/155 PASS (0fail,0timeout,0skipped), includingagx_tests,hk_barrier, andhk_execution_allowance.DEFAULT_BRANCH=aurora-wip .github/aurora/agent-policy.sh pr HEAD: PR head is clean.Physical Hardware — MacBook Neo (
Apple A18 Pro / G17P B1)aurora-wip9b918e130f5vs R1b29dfcfd694) and R2 verification at exact HEAD9f53266b749(ICD git-9f53266b74):gpubench-vkrender.deferred(100% bit-exact CRC-32:16/16EXACT at R29f53266b749)aurora-wip(us/submit)9f53266b749(us/submit)aurora-wipgpu_ustiledram)5e4130ceEXACTtiledram)5e4130ceEXACTtiledram)665b6e78EXACTtiledram)665b6e78EXACTtile2cfe9a54EXACTtile2cfe9a54EXACTtiledb6d5feaEXACTtiledb6d5feaEXACTdram7c09507fEXACTdram7c09507fEXACTdram22db814dEXACTdram22db814dEXACTdram2cfe9a54EXACTdram2cfe9a54EXACTdramdb6d5feaEXACTdramdb6d5feaEXACTVulkan CTS on MacBook Neo at exact R2 HEAD
9f53266b749(8,877passed,0failed,0warnings)dEQP-VK.renderpasses.dynamic_rendering.primary_cmd_buff.local_read.*dEQP-VK.renderpasses.dynamic_rendering.partial_secondary_cmd_buff.local_read.*dEQP-VK.renderpasses.renderpass1.suballocation.formats.*.input.*dEQP-VK.renderpasses.renderpass2.suballocation.formats.*.input.*dEQP-VK.renderpasses.renderpass1.suballocation.attachment_allocation.input_output.*dEQP-VK.renderpasses.renderpass2.suballocation.attachment_allocation.input_output.*dEQP-VK.renderpasses.renderpass1.dedicated_allocation.attachment_allocation.input_output.*dEQP-VK.renderpasses.renderpass2.dedicated_allocation.attachment_allocation.input_output.*dEQP-VK.renderpasses.renderpass1.suballocation.subpass_dependencies.*dEQP-VK.renderpasses.renderpass2.suballocation.subpass_dependencies.*dEQP-VK.renderpasses.renderpass1.suballocation.multisample.*dEQP-VK.renderpasses.renderpass2.suballocation.multisample.*dEQP-VK.renderpasses.renderpass1.suballocation.*input_attachment*dEQP-VK.renderpasses.renderpass2.suballocation.*input_attachment*dEQP-VK.image.general_layout.input_attachment.*dEQP-VK.multiview.*input_attachments*9f53266b749)The 6
NotSupportedcases in bothprimary_cmd_buff.local_read.*andpartial_secondary_cmd_buff.local_read.*are allNotSupported (dynamicRenderingLocalReadDepthStencilAttachments not supported at vktDynamicRenderingLocalReadTests.cpp:2503):depth_stencil_mapping_to_no_indexdepth_stencil_mapping_to_no_index_depth_cleardepth_stencil_mapping_to_no_index_stencil_cleardepth_stencil_mapping_to_same_indexdepth_stencil_mapping_to_large_indexdepth_mapping_stencil_not(Note: Neo's installed CTS build does not contain
graphics_pipeline_library.local_read.*orattachment_mapping_input_attachments*; those are covered by unit regression testLocalRead.CrossRtSwapPreservesLoadBeforeStoreand M5 Pro CTS 1.4.7.1.)Hardware Health
FAULTS_DELTA=0,AVC_DELTA=0,PMU 30 00,neo-no-idle-sleep.service active.