Skip to content

agx: bound AGX3 ILP schedule by tile-store payload bank - #1255

Merged
RyanTheTide merged 3 commits into
aurora-wipfrom
djdev/agx-ilp-tile-store-bank
Nov 27, 2026
Merged

RyanTheTide merged 3 commits into
aurora-wipfrom
djdev/agx-ilp-tile-store-bank

Conversation

@DjDeveloperr

Copy link
Copy Markdown

Summary

On AGX3, ST_TILE reads its payload from a bounded low-register bank (agx3_tile_store_bank(), 16/32/64 halves) with natural power-of-two alignment above agx_reserved_registers(). Previously, only AGX3B skipped fragment sample hoisting when a block had multi-sample tile stores to the same pixel offset (ilp_block_has_multi_sample_tile_stores()). On AGX3C (M5), ILP sample hoisting/interleaving on layered 8x MSAA R32G32B32A32_{SINT,UINT,SFLOAT} reload background shaders moved four 8-half ST_TILE payloads (32 halves) ahead of wait_pix + st_tile, overflowing the 16-half bank and failing compilation with tile-store payload bank overflow.

This replaces the AGX3B-only special case with a direct tile-store payload bank check inside ilp_schedule_block() for all AGX3 non-preamble fragment shaders:

  • Before committing a candidate schedule order[], compute live ST_TILE payload packing feasibility in [agx_reserved_registers(ctx), agx3_tile_store_bank(ctx)) using natural power-of-two alignment for both the original order and the candidate order.
  • Reject any candidate whose simultaneously live ST_TILE payloads overflow the bank when the original order fits (or with higher peak demand than the original order).
  • Add AGX3C (G17S and G17G) layered 8x MSAA RGBA32 reload regression tests (Layered8xRgba32ReloadKeepsTileStoreBankOnG17S and Layered8xRgba32ReloadKeepsTileStoreBankOnG17G) to test-bg-shader-schedule.cpp.

Fixes #1253

Tested

Verified on J714s (Apple M5 Pro / G17S B1, AGX3C, kernel 7.3.0-m5-cdirect16) vs aurora-wip (99658583598f):

  • Exact #1253 CTS repro (dEQP-VK.api.image_clearing.core.clear_color_attachment.multiple_layers.r32g32b32a32_{sfloat,sint,uint}_64x11_sample_count_8):
    • aurora-wip: 3/3 Fail
    • This branch: 3/3 Pass
  • Targeted layered MSAA image-clearing + RGBA32 resolve VK CTS (2,499 cases): 1,243 Pass / 1,256 Skip / 0 Fail
  • GCC release --suite asahi (including all 7 BgShaderSchedule.* tests): 336/336 Pass
  • gpubench-vk MSAA=4 ABBA non-regression:
    • render.deferred mode=tile msaa=4 res=1080p: gpu_us 156.8 -> 156.9 us (+0.05%), CRC 6dc74b48 identical
    • render.postfx msaa=4 res=1080p: gpu_us 150.2 -> 150.2 us (+0.00%), CRC 668d6f0a identical
  • Device health: online=1, crashed=0, 0 new GPU faults.

Risk

Low. Only rejects candidate AGX3 fragment ILP schedules that would exceed [agx_reserved_registers(), agx3_tile_store_bank()), preserving full ILP hoisting for single-target and small-payload fragments (NormalSingleStoreFragmentStillHoistsSamples still hoists all 4 loads; render.postfx and render.deferred MSAA=4 are unchanged).

Not yet

  • Exact-head (90b270bd5443, dropping const on 3 u_sparse_bitset * helper parameters for Clang -Werror) Clang assert --suite asahi + multi-gen (G17P/G16G/G17G/G17D) verification.

On AGX3, ST_TILE reads its payload from a bounded low-register bank
(agx3_tile_store_bank(), 16/32/64 halves) with natural power-of-two
alignment above agx_reserved_registers(). Previously, only AGX3B skipped
fragment sample hoisting when a block had multi-sample tile stores to the
same pixel offset; on AGX3C (M5), ILP sample hoisting/interleaving on
layered 8x MSAA RGBA32 reload shaders kept four 8-half ST_TILE payloads
(32 halves) live simultaneously ahead of wait_pix + st_tile, overflowing
the 16-half bank and failing shader compilation with 'tile-store payload
bank overflow'.

Check live ST_TILE payload bank feasibility directly inside
ilp_schedule_block() for all AGX3 non-preamble fragment shaders before
committing a candidate order, replacing the AGX3B-only special case.
Reject any candidate whose simultaneously live ST_TILE payloads cannot
pack into [agx_reserved_registers(), agx3_tile_store_bank()) when the
original order fits (or with higher peak demand than the original order).

Add AGX3C (G17S/G17G) layered 8x MSAA RGBA32 reload regression tests to
test-bg-shader-schedule.cpp.

Fixes #1253

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 27, 2026 19:58
agx_ra() asserts that all sources of a COLLECT have matching size.
agx_immediate() and agx_zero() produce 16-bit operands, while coords and
layer are 32-bit; materialize 32-bit immediates with agx_mov_imm() so the
layered 8x RGBA32 reload test passes assert-enabled builds too.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@RyanTheTide

Copy link
Copy Markdown

90b270bd5443 J316s (aarch64, Clang 23.1.4 Fedora 23.1.4-1.fc45, -Dbuildtype=release -Db_ndebug=false) FAIL in BgShaderSchedule.Layered8xRgba32ReloadKeepsTileStoreBankOnG17S:

  • Clang 23.1.4 compile of agx_pressure_schedule.c + all 1,799 asahi targets succeeded cleanly (0 errors).
  • agx_tests --gtest_filter="BgShaderSchedule.*": first 5 tests PASS, then test 6 (Layered8xRgba32ReloadKeepsTileStoreBankOnG17S) aborts under asserts:
    agx_tests: ../src/src/asahi/compiler/agx_register_allocate.c:5038: void agx_ra(agx_context *): Assertion `ins->src[i].size == ins->src[0].size' failed.
    
  • Root cause in test_layered_8x_rgba32_reload() (src/asahi/compiler/test/test-bg-shader-schedule.cpp): cc = agx_collect_to(b, sample_coord, 4) mixes AGX_SIZE_32 sources (coords, layer) with AGX_SIZE_16 sources (agx_immediate(i) and agx_zero()), tripping AGX_OPCODE_COLLECT lowering's ins->src[i].size == ins->src[0].size assert (missed under -Db_ndebug=true). Using 32-bit sources (agx_mov_imm(b, 32, i) / agx_mov_imm(b, 32, 0)) should fix the test.

…d test

Emit agx_mov_imm() before agx_collect_to() so the collect reads an
already-defined SSA temporary, and pack 3x32-bit coordinates matching
AGX_DIM_2D_MS_ARRAY width validation.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@RyanTheTide

Copy link
Copy Markdown

7856a05713ba Borealis Clang 23.1.4 assert + 3-gen PASS (-Dbuildtype=release -Db_ndebug=false, isolated VK_DRIVER_FILES, stock Mesa untouched):

  • J316s (M1 Pro, G13S, 7.3.0-aurora-fleet89): Clang 23.1.4 BgShaderSchedule.* 7/7 PASS (assert abort fixed), full meson test --suite asahi 215/215 PASS (0 FAIL); deqp-vk 368 PASS / 0 FAIL (api.smoke.* 8/8, api.image_clearing.core.clear_color_attachment.multiple_layers.*sample_count_* 360/1,764); 0 GPU faults, Enforcing, 0 failed units, 0 new AVC.
  • J700 (MacBook Neo, G17P, 7.3.0-aurora-fleet89): deqp-vk 514 PASS / 0 FAIL (api.smoke.* 8/8, clear_color_attachment.multiple_layers.*sample_count_* 452/1,764, renderpasses.renderpass2.*r32g32b32a32*resolve* 54/72); 0 GPU faults, Enforcing, 0 failed units, 0 new AVC.
  • J615 (M3 Air, G15G, 7.3.0-aurora-fleet90-airs2): deqp-vk 514 PASS / 0 FAIL (same suites); 0 GPU faults, Enforcing, 0 failed units, 0 new AVC.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH, then merge at 7856a05713ba.
Blockers: Please identify the commit used for the J714s 3/3 reproducer pass, and post the exact-head J714s run if that result came from an earlier build.
Checked: The scheduler compares original and candidate liveness against the allocator’s existing bank and reserved prefix. The corrected fixture supplies three 32-bit collect operands and passes all seven Clang assert scheduler cases at this commit. Exact-head CTS passes on J316s, J700 and J615. The configured predicate follows AGX3 fragment shader execution and tile-store bank eligibility.

#1255 (comment)

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH, then merge at 7856a05713ba994f861852e3e4958668cf4b438a (code is ready; the merge waits only on an exact-head J714s row)
Blockers: none
Checked: Read the whole diff, body and comments. The Clang assert failure reported at 90b270bd5443 is fixed at this head: the 8x RGBA32 fixture now builds a three-operand 32-bit collect, and the full drm-shim suite passes with -Db_ndebug=false under Clang. The new bank check simulates the live ST_TILE payloads with natural power-of-two packing above agx_reserved_registers() for both the source order and the candidate order, and it only rejects a candidate that overflows when the source order fits, or that overflows with a higher peak. That subsumes the removed AGX3B-only multi-sample skip, and the existing G17P/G16G background-reload and multi-sample tests still pass under the general check. It is keyed on ISA encoding plus fragment stage and adds no chip or board gate. The new tests fail without the scheduler change and pass with it. The exact-head rows from J316s, J700 and J615 are in #1255 (comment). The J714s 3/3 repro result in the body predates this head, so a J714s rerun of dEQP-VK.api.image_clearing.core.clear_color_attachment.multiple_layers.r32g32b32a32_*_sample_count_8 at 7856a05713ba is the one item left before merge.
Non-blocking: ilp_tile_store_bank_overflows() walks every instruction in the shader each time a block is scheduled. That is fine at today's shader sizes, but the width table could be built once per agx_ilp_schedule() call.

Evidence
  • Gate: 7856a057 merged into aurora-wip a58f52b53bb1 (clean merge-tree), x86 drm-shim build, Clang, -Dbuildtype=release -Db_ndebug=false, meson test --suite asahi --suite poly: 338/338 OK.
  • Mutation: the same tree with agx_pressure_schedule.c reverted to the aurora-wip version: BgShaderSchedule.* gives 5 passed and 2 failed (Layered8xRgba32ReloadKeepsTileStoreBankOnG17S/G17G: 8 loads hoisted before the first tile store; payloads at halves 16, 24, ... 56 against the 16-half bank). With the PR's file it is 7/7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agx: #1190 ILP interleave overflows tile-store payload bank on M5 layered 8x RGBA32 reload shaders

2 participants