Skip to content

asahi,borealis: raise AGX3 Ioto program buffer capacity for large CProg input sets - #1301

Merged
RyanTheTide merged 1 commit into
aurora-wipfrom
fix/ioto-cprog-program-max-size
Nov 28, 2026
Merged

RyanTheTide merged 1 commit into
aurora-wipfrom
fix/ioto-cprog-program-max-size

Conversation

@RyanTheTide

Copy link
Copy Markdown

What

Raises the AGX3 Ioto program software buffer capacity from 6,144 to 12,288 bytes (AGX3_G17P_COMPUTE_PROGRAM_MAX_SIZE, AGX3_G17P_GRAPHICS_PROGRAM_MAX_SIZE, their Borealis mirrors guarded by static_assert, and MAX_IOTO_PROGRAM_SIZE in the stream validator), and passes cprog_inputs to agx3_ioto_uniform_program_desc_body_bound() in hk_fused_compute_ioto_bound() so fused compute Ioto reservations also cover large constant-program input sets.

Fixes #1169.

When an AGX3 native constant program imports a few hundred uniform halves that include 8-bit or 16-bit fields, odd compact TPS alignment forces pack_cprog_copy() to split paired halves into two extended 16-bit COPY instructions (10 bytes each on GPU0 / G16G and G17P). Both failing dEQP-VK.ubo.random compute cases compose to valid bodies of 6,488 bytes (429 CProg input halves, 57 load chunks) and 6,410 bytes (383 CProg input halves, 53 load chunks), exceeding the 6,144-byte buffer sized before TPS CProg input publication was added. There is no 6 KiB hardware limit (Ioto programs are linear streams bump-allocated out of 128 KiB USC arena chunks with a uint16_t length), and 12,288 bytes covers even a worst-case 511-half odd-aligned 16-range layout (8,470 B emitted / 10,102 B bound on G16G/G17P; 6,696 B emitted on M5).

Tested

  • Host unit tests (a528cf444623): meson test --suite asahi: 219/219 OK, 0 Fail (includes new test_g17p_compute_large_cprog_inputs verifying both exact Borealis: two dEQP-VK.ubo.random cases fail with VK_ERROR_FEATURE_NOT_PRESENT at vkEndCommandBuffer (G16G, G17P) #1169 layouts on G16G and G17P plus the 511-half 16-range worst case, and a hk_fused_compute_ioto_bound() check in hk_fused_cprog).
  • J700 (MacBook Neo, G17P B1, 7.3.0-aurora-fleet89, default cmdline, libvulkan_asahi.so c38f9512c5a4737f at a528cf444623, cts-vk4 3fd4ea31):
    • dEQP-VK.ubo.random.16bit.nested_structs_arrays_instance_arrays_compute.14: base b605996a Fail (VK_ERROR_FEATURE_NOT_PRESENT at hk_cmd_dispatch.c:1347) -> head a528cf444623 Pass (Full white image ok).
    • dEQP-VK.ubo.random.8bit.all_out_of_order_offsets.10: base b605996a Fail (VK_ERROR_FEATURE_NOT_PRESENT at hk_cmd_dispatch.c:1347) -> head a528cf444623 Pass (Full white image ok).
    • Passing neighbor control dEQP-VK.ubo.random.16bit.nested_structs_arrays_instance_arrays_compute.13: Pass; fwcrash=0.
  • J615 (MacBook Air M3, G15G B0, 7.3.0-aurora-fleet90-airs2, default cmdline, same binary c38f9512c5a4737f at a528cf444623, cts-vk4 3fd4ea31):
    • Full dEQP-VK.ubo.* suite (2-shard): 13,240/13,240 Pass, 0 Fail, fwcrash=0, Enforcing, 0 failed units.

Risk

Low. Raises only software staging/validator buffer capacities from 6 KiB to 12 KiB (hk_cmd_publish_ioto_program() still advances the USC arena by the actual aligned program length, so typical small shaders consume zero extra GPU memory). Temporary stack frames in the Ioto composer grow by 6–12 KiB (up to ~24 KiB in agx3_g17p_compute_program_generate), well within Linux thread stacks. Revert by reverting this single commit.

Not yet

  • Full 13,240-case dEQP-VK.ubo.* sweep on J700 (G17P) and live G16G (J713/J773g) exclusive-compute-queue run (lab J713 currently runs fleet85 without DRM_ASAHI_FEATURE_INDEPENDENT_QUEUES; G16G uses the identical GPU0 10-byte COPY path verified in unit tests and on G17P).
  • CI green and non-author review.
Root-cause measurements and worst-case sizing
Layout Chip Ranges Chunks cprog_inputs halves desc_body_bound Actual body bytes
16bit.nested_structs_arrays_instance_arrays_compute.14 G16G / G17P 6 57 429 8,096 6,488
8bit.all_out_of_order_offsets.10 G16G / G17P 7 53 383 7,924 6,410
16-range 511-half odd-aligned worst case G16G / G17P 16 64 511 10,102 8,470
16-range 511-half odd-aligned worst case G17G (M5) 16 64 511 9,206 6,696

…og input sets

When an AGX3 native constant program imports a few hundred uniform halves
containing 8-bit or 16-bit fields, odd compact TPS alignment forces
pack_cprog_copy() to split paired halves into two extended 16-bit COPY
instructions (10 bytes each on GPU0 / G16G and G17P). On both
dEQP-VK.ubo.random.16bit.nested_structs_arrays_instance_arrays_compute.14
(429 CProg input halves, 57 load chunks) and
dEQP-VK.ubo.random.8bit.all_out_of_order_offsets.10 (383 CProg input
halves, 53 load chunks), the valid Ioto body composes to 6,488 and 6,410
bytes respectively, exceeding the 6,144-byte software buffer sized before
TPS CProg input publication was added. The loader then returns NULL and
command-buffer recording fails with VK_ERROR_FEATURE_NOT_PRESENT at
vkEndCommandBuffer.

Even a worst-case 511-half odd-aligned layout across 16 disjoint ranges
composes to 8,470 bytes on GPU0 (G16G/G17P) and 6,696 bytes on GPU1 (M5),
with a conservative bound of ~10.1 KiB plus fixed tail/suffix. There is no
6 KiB hardware limit: Ioto programs are linear streams bump-allocated out
of 128 KiB USC arena chunks with a uint16_t length.

Raise AGX3_G17P_COMPUTE_PROGRAM_MAX_SIZE,
AGX3_G17P_GRAPHICS_PROGRAM_MAX_SIZE, their Borealis mirrors (guarded by
static_assert), and the stream validator's MAX_IOTO_PROGRAM_SIZE from
6,144 to 12,288 bytes. Also pass cprog_inputs to
agx3_ioto_uniform_program_desc_body_bound() in
hk_fused_compute_ioto_bound() so fused compute reservations cover large
CProg input sets.

Add unit tests covering both failing UBO compute layouts on G16G and G17P,
the 511-half odd-aligned 16-range worst case, and the fused compute Ioto
bound check.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>

@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 a528cf44

Blockers:

  1. Independent maintainer approval at a528cf44 is required before merge.

Checked: no Apple material, no AI attribution, human DCO Signed-off-by, Borealis naming clean in prose, no chip/board/firmware gates, no parameters or hardcoded hardware-safety limits, full diff (+139/-9 across 8 files) verified against all AGX3_G17P_*_PROGRAM_MAX_SIZE / HK_AGX3_G17P_*_PROGRAM_MAX_SIZE / MAX_IOTO_PROGRAM_SIZE sites in src/asahi/, static_assert enforces compiler/Borealis size parity, uint16_t length fields in hk_agx3_multi_draw_ioto_tpl and agx3_reencode_entry comfortably fit 12288, hk_fused_compute_ioto_bound() now passes cprog_inputs to agx3_ioto_uniform_program_desc_body_bound(), host unit tests (219/219) and exact-head hardware rows on J700 (G17P, both #1169 failing UBO cases flipped Fail -> Pass) and J615 (G15G, full 13,240/13,240 dEQP-VK.ubo.* PASS) are recorded, branch is MERGEABLE against aurora-wip.

Evidence
  • Checked all occurrences of 6144 and PROGRAM_MAX_SIZE across src/asahi/ and src/gallium/drivers/asahi/:
    • src/asahi/compiler/agx3_compute_program.h & agx3_graphics_program.h: raised 6144u -> 12288u with comments explaining the software composer capacity bound.
    • src/asahi/vulkan/hk_agx3_ioto_program_core.h & .c: raised Borealis mirrors to 12288u and added static_assert guards against the compiler header constants.
    • src/asahi/drm-shim/asahi_g17p_stream_validator.c: raised MAX_IOTO_PROGRAM_SIZE to 12288.
    • src/asahi/vulkan/hk_cmd_dispatch.c:3639-3651: hk_fused_compute_ioto_bound() switches from agx3_ioto_uniform_program_body_bound() to agx3_ioto_uniform_program_desc_body_bound() passing cprog_inputs when s->b.info.has_preamble && s->b.info.agx3_preamble_tps_inputs, keeping the reservation >= emitted size (test-hk-fused-cprog.c:247).
    • Verified downstream struct length fields (hk_agx3_multi_draw_ioto_tpl.length, agx3_reencode_entry.{in,out}_length) are uint16_t (max 65,535 >= 12,288) and no other hardcoded 6144 Ioto program caps remain.
  • Regression test test_g17p_compute_large_cprog_inputs() covers both exact #1169 layouts plus a 511-half 16-range odd-aligned worst case on both AGX_CHIP_G16G and AGX_CHIP_G17P, confirming 6144 < length <= 12288.
  • Non-blocking nit: ## Risk describes revertability cleanly; adding the explicit two-way keyword keeps it aligned with the org PR template.

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed and verified at exact head a528cf44462351e359758bbbcb19e925889abe05 on Apple M5 Max (J775c, G17C B1):

  • Code audit: Consistent raise of AGX3_G17P_{COMPUTE,GRAPHICS}_PROGRAM_MAX_SIZE, their Borealis mirrors (guarded by static_assert in hk_agx3_ioto_program_core.c), and MAX_IOTO_PROGRAM_SIZE in the stream validator from 6144 to 12288 bytes. hk_fused_compute_ioto_bound() properly switches to agx3_ioto_uniform_program_desc_body_bound() with cprog_inputs when has_preamble && agx3_preamble_tps_inputs, and unit coverage exercises both real odd-aligned UBO cases and the 511-half worst case on G16G/G17P plus the fused-bound check.
  • Unit suite: meson test -C build --suite asahi — 337/337 PASS (0 fail).
  • Live J775c Borealis overlay (MESA_SHADER_CACHE_DISABLE=1):
    • dEQP-VK.api.smoke.*: 8/8 PASS
    • dEQP-VK.ubo.random.16bit.* (ASAHI_MESA_DEBUG=verify): 750/750 PASS
    • dEQP-VK.ubo.random.8bit.* (ASAHI_MESA_DEBUG=verify): 750/750 PASS
    • dmesg: 0 GPU/kernel faults or warnings.

Verdict: MERGE at a528cf444623.

@RyanTheTide

Copy link
Copy Markdown
Author

Merge-train landing at a528cf444623.

Revert: git revert -m 1 <merge commit> on aurora-wip. A regression gets reverted first and fixed after.

@RyanTheTide
RyanTheTide merged commit da42173 into aurora-wip Nov 28, 2026
@RyanTheTide
RyanTheTide deleted the fix/ioto-cprog-program-max-size branch November 28, 2026 20:11
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.

Borealis: two dEQP-VK.ubo.random cases fail with VK_ERROR_FEATURE_NOT_PRESENT at vkEndCommandBuffer (G16G, G17P)

2 participants