Skip to content

asahi: enable private 2x/4x MSAA colour and depth compression on G17P - #708

Merged
DjDeveloperr merged 1 commit into
aurora-wipfrom
perf/asahi-g17p-msaa-compression
Nov 22, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-wipfrom
perf/asahi-g17p-msaa-compression

Conversation

@DjDeveloperr

Copy link
Copy Markdown

Summary

On G17P, Gallium Asahi previously limited private lossless compression to single-sample colour and Z32_FLOAT depth targets (nr_samples <= 1), leaving 2x/4x MSAA colour and depth attachments completely uncompressed. On 1440p 4x MSAA workloads this forced ~177 MB/frame of uncompressed DRAM writes/reads (RGBA16F 4x MSAA + Z32F 4x MSAA), leaving Gallium Asahi 4.4×–6.7× slower than Borealis Vulkan on compress.bw msaa4 and render.postfx msaa=4.

agx_pbe_agx3_2d_multisample_pack() already encodes Gen9 GPU-tiled compressed 2x/4x 2D multisample PBE packets, Gen9 compressed texture descriptors and ZLS control words already support 2x/4x MSAA and Z16_UNORM, and Gallium owns its private resources so spilled compressed render targets can safely be reallocated uncompressed via agx_decompress().

Changes (1 commit, e2318186b25fd29cff4e0b05d35d7ec4cf509d9f)

  • src/gallium/drivers/asahi/agx_native_descriptor.c / .h: Allow Gen9 GPU-tiled compressed 2x/4x 2D multisample PBE packing in agx_gallium_pack_native_pbe() (while keeping compressed MSAA arrays and non-GPU layouts rejected).
  • src/gallium/drivers/asahi/agx_pipe.c: Widen agx_g17p_private_compression_allowed() to 1x/2x/4x MSAA colour targets (width0 >= 16 && height0 >= 16) and agx_g17p_private_depth_compression_allowed() to 1x/2x/4x MSAA and PIPE_FORMAT_Z16_UNORM depth targets (width0 >= 16 && height0 >= 16). Strictly scoped to AGX_CHIP_G17P.
  • src/gallium/drivers/asahi/agx_state.c: On chips without in-place decompression (!agx_gallium_shared_compression_supported(...)), pre-decompress any compressed attachment that spills from the tilebuffer in agx_set_framebuffer_state() before copying state into ctx->framebuffer (preventing blitter restore recursion), and route fallback spill decompression in agx_batch_init_state() through agx_decompress() instead of AGX2-only agx_decompress_inplace().
  • src/gallium/drivers/asahi/tests/test-agx-native-descriptor.c: Extend test_g17p_compressed_render_target() to verify exact packed bytes for Gen9 compressed 2x/4x MSAA 2D PBEs and rejection of compressed MSAA arrays and twiddled MSAA.

Verification

Host CI (fedora-mesaci)

  • e2318186b25fd29cff4e0b05d35d7ec4cf509d9f: 156 / 156 PASS (Fail 0, Timeout 0, including updated test-agx-native-descriptor).
  • DEFAULT_BRANCH=aurora-wip .github/aurora/agent-policy.sh pr HEAD: PR head is clean.

Physical Hardware: MacBook Neo (Apple A18 Pro / G17P B1), Linux 7.3.0-41.fc44.aurora.aarch64

Tested BASE c0b51ef245 vs HEAD e2318186b2 (MESA_SHADER_CACHE_DISABLE=true, pmu=30 00, kfault_delta=0, avc_delta=0).

1. gpubench-gl 6-Round Alternating ABBA (--verify --warmup-ms 80 --runs 3 --run-ms 250)

Benchmark Depth Base (c0b51ef245) Head (e2318186b2) Speedup Primary Metric CRC / Valid
render.postfx 1440p msaa=4 4 6,578.9 us (152 fps) 2,659.6 us (376 fps) 2.47× +147.4% fps 3d8c24fc exact (valid: true)
render.postfx 1080p msaa=4 4 3,731.3 us (268 fps) 1,533.7 us (652 fps) 2.43× +143.3% fps ca9f8491 exact (valid: true)
compress.bw 1440p msaa4 1 1,424.5 us 939.8 us 1.52× -34.0% us n/a
compress.bw 1440p msaa4 4 1,162.8 us 778.8 us 1.49× -33.0% us n/a
compress.bw 1440p mrt4 4 862.3 us 865.1 us 1.00× parity n/a
compress.bw 1440p rgba32f 4 2,016.1 us 2,016.1 us 1.00× parity n/a
render.postfx 1440p msaa=1 4 1,259.5 us (794 fps) 1,265.8 us (790 fps) 0.99× parity f54ee158 exact (valid: true)
render.shadow depth_only d16 4 1,666.7 us (9.83 Mtri/s) 1,661.1 us (9.86 Mtri/s) 1.00× parity c0fb9993 exact (valid: true)
render.shadow depth_only d32f 4 3,086.4 us (5.31 Mtri/s) 3,086.4 us (5.31 Mtri/s) 1.00× parity c0fb9993 exact (valid: true)
render.shadow alpha_test d16 4 2,824.9 us (5.80 Mtri/s) 2,809.0 us (5.83 Mtri/s) 1.01× parity 7be9463a exact (valid: true)

AGXPROF per-pass GPU breakdown (1440p):

  • render.postfx msaa=4 Pass 1 (RGBA16F 4x MSAA + Z32F 4x MSAA): 3,352.2 us -> 539.4 us (6.21×)
  • render.postfx msaa=4 Pass 2 (u_blitter MSAA4 resolve reading compressed RGBA16F): 2,452.8 us -> 1,067.9 us (2.30×)
  • compress.bw msaa4 Pass 1 (RGBA8 4x MSAA reload + store_and_resolve): 1,020.5 us -> 642.2 us (1.59×)

2. dEQP-GLES3 & dEQP-GLES31 CTS (BASE vs HEAD, 1,688 cases, 0 diffs / 0 regressions)

CTS Group Base (c0b51ef245) Head (e2318186b2) Diffs
dEQP-GLES3.functional.fbo.msaa.* 48 Pass / 0 Fail / 22 NotSupported (70) 48 Pass / 0 Fail / 22 NotSupported (70) 0
dEQP-GLES3.functional.fbo.blit.* 629 Pass / 0 Fail / 12 NotSupported (641) 629 Pass / 0 Fail / 12 NotSupported (641) 0
dEQP-GLES3.functional.multisample.* 32 Pass / 0 Fail / 32 NotSupported (64) 32 Pass / 0 Fail / 32 NotSupported (64) 0
dEQP-GLES3.functional.fbo.depth.* 15 Pass / 0 Fail (15) 15 Pass / 0 Fail (15) 0
dEQP-GLES3.functional.fbo.color.* 302 Pass / 0 Fail (302) 302 Pass / 0 Fail (302) 0
dEQP-GLES3.functional.fbo.render.* 308 Pass / 0 Fail (308) 308 Pass / 0 Fail (308) 0
dEQP-GLES3.functional.fbo.invalidate.* 131 Pass / 0 Fail (131) 131 Pass / 0 Fail (131) 0
dEQP-GLES31.functional.texture.multisample.* 73 Pass / 0 Fail / 84 NotSupported (157) 73 Pass / 0 Fail / 84 NotSupported (157) 0
Total 1,538 Pass / 0 Fail / 150 NotSupported (1,688) 1,538 Pass / 0 Fail / 150 NotSupported (1,688) 0

3. Custom GL 4.6 Pixel-Exact Verifier (BASE vs HEAD, 48 / 48 bit-exact SHA-256 match, 0 diffs)

Covers:

  • 2x & 4x MSAA colour reload + resolve + per-sample texelFetch across RGBA8, SRGB8_ALPHA8, RGBA16F, R32F, RGBA32F, RGBA16UI, NPOT (317x211), and small-dimension bounds (8x8, 16x16, 17x17).
  • Multi-RT uncovered-tile 4x MSAA reload (2× RGBA16F = 16 B/sample, partial tiny-triangle pass 2 with 99% uncovered tiles).
  • Spilling 4x MSAA MRT (5× RGBA16F = 40 B/sample > 32 B/sample tilebuffer) with pre-populated compressed RT4 preserved across agx_decompress() reallocation (0 GPU faults).
  • 1x/2x/4x Z16_UNORM and 2x/4x Z32_FLOAT / Z32F_S8 depth compression + multi-pass reload + glReadPixels + shader sampling.
  • TEXTURE_2D_MULTISAMPLE_ARRAY (correctly kept uncompressed) and MSAA4 renderbuffer flipped-Y partial resolve.

Assisted-by: LLM (Antigravity:Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown

Thanks, the Neo numbers are a big win. Comments at e231818:

  • Reload defect and borealis: replace M4 Pro chip-ID gates with G17P architecture and kernel capability checks #698: the Gallium predicates (agx_pipe.c:449-461, 472-484) admit 2x and 4x colour and depth on every G17P part without consulting agx_chip_uncovered_tile_ms_reload_defect(). For compression that looks consistent, because Gallium, unlike Borealis, never spills a reloaded wide multisample attachment: the only Gallium use of the defect is the clear path (agx_pipe.c:1428-1441), and a reload still gets AGX_BG_LOAD (agx_state.c:10255-10287). Spills here come only from the byte budget, and those now go through agx_decompress(). That is also why the 4x MRT + load failures seen in Vulkan cannot reach a compressed spilled target here. Could the commit message say this explicitly? It is the reason Gallium can go beyond what borealis: replace M4 Pro chip-ID gates with G17P architecture and kernel capability checks #698 allows (2x colour and 2x depth on M4 Pro/Max only, 4x nowhere).
  • The flip side is that the defect itself is not handled in Gallium (this predates the PR). The "multi-RT uncovered-tile 4x reload, 2x RGBA16F" row compares base with head, so it would match even if both truncated the upper eight bytes on untouched tiles. Please check that case against a reference image rather than against the base. If Gallium later spills these reloads as Borealis does, each such target will be decompressed for good on first use.
  • agx_pipe.c:444-447: "as Borealis compresses (hk_g17p_compression_depth_format())" is no longer accurate. Borealis compresses D16 only at 1x, 2x depth only on M4 Pro/Max, and 4x depth nowhere. The same goes for agx_g17p_compression.h:22-29, which still says a compressed target never spills, and for test-tilebuffer.cpp, which checks that only at 1x. A 4x 5x RGBA16F framebuffer does spill, as your own row shows.
  • agx_state.c:1604-1644: the pre-pass builds the same layout agx_batch_init_state() builds (11068-11071) and decompresses before the framebuffer is copied, which avoids the blitter re-entry. Given that, the agx_decompress() fallback in agx_batch_init_state() (11093-11102) should be unreachable on AGX3, and reaching it would run the blitter from inside batch setup. An assert there would catch a mismatch between the two layout computations.
  • agx_decompress() adds PIPE_BIND_SHADER_IMAGE for good (agx_pipe.c:1532-1543). An attachment bound once into a spilling framebuffer stays uncompressed afterwards, even in passes that do not spill, and the first use costs a full copy plus a flush in the middle of the frame. That is fine, but please mention it in the commit message.
  • Z32F_S8 and Z24S8 are lowered to a separate Z32_FLOAT plane (agx_pipe.c:3160-3163), so every GL multisample depth/stencil renderbuffer is now compressed at 2x/4x. The verifier lists Z32F_S8 but not Z24S8.
  • width0/height0 >= 16 (agx_pipe.c:459, 480) duplicates ail_can_compress() at 1x and is stricter at 2x/4x, where ail measures in samples. Is this intended? If so, please add a comment.
  • test-agx-native-descriptor.c:654-674 builds the expected multisample words from the 1x words plus the dimension and selector bits, which is what agx_pbe_agx3_2d_multisample_pack() does. It pins the encoder, not a hardware packet, so it is the hardware rows that carry the weight here.
  • Paths this changes that no posted row covers: multisample glCopyImageSubData (resource_copy_region falls back to a CPU copy through the MSAA map helper when the blitter refuses, agx_blit.c:908-960, and transition_resource() relies on the same copy), per-sample shading on compressed targets, and partial renders (multisample_store into compressed targets, agx_state.c:10238-10243).

Testing: only Neo has been run, but 4x compressed colour, 4x depth and 2x/4x D16 are new on M4 Pro and M4 Max too. Before merge, please post base c0b51ef vs head e231818 on A18 Pro (Neo) and on M4 Pro (J616s) for:

  • piglit: all ext_framebuffer_multisample-* (accuracy, formats, blit-, clear, interpolation, sample-coverage, alpha-to-coverage, unaligned-blit, upsample/turn-on-off), arb_texture_multisample-, arb_sample_shading-*, and arb_copy_image-formats with --samples=2 and 4.
  • dEQP: dEQP-GLES3.functional.multisample., dEQP-GLES31.functional.sample_shading., sample_variables., texture.multisample. and fbo.msaa.*.
  • The gpubench render.postfx msaa=4 and compress.bw msaa4 rows on M4 Pro.
    A Borealis number on the same benchmark would also back up the "4.4x-6.7x slower than Borealis" figure.

Assisted-by: LLM (Claude:Opus 5.5)

On G17P, Gallium Asahi previously restricted private lossless
compression to single-sample colour and Z32F depth resources because
agx_gallium_pack_native_pbe() rejected compressed Gen9 2D multisample
PBE descriptors and agx_batch_init_state() called AGX2-only
agx_decompress_inplace() when a compressed render target spilled.

However, agx_pbe_agx3_2d_multisample_pack() already encodes Gen9
GPU-tiled compressed 2x/4x 2D multisample PBE packets, Gen9 compressed
texture descriptors and ZLS control words already support 2x/4x MSAA
and Z16 depth, and Gallium owns its private resources so it can
reallocate any spilled compressed attachment uncompressed via
agx_decompress().

Unlike Borealis (which restricts MSAA compression around the uncovered-
tile multisample reload defect in #698 because Vulkan spills reloaded
wide MSAA attachments), Gallium never spills a reloaded wide multisample
attachment: Gallium's only use of agx_chip_uncovered_tile_ms_reload_defect()
is on the clear path, while reloads remain AGX_BG_LOAD (agx_state.c).
Spills in Gallium occur only from the tilebuffer byte budget (such as
wide 4x MRTs like 5x RGBA16F), and those targets are now pre-decompressed
via agx_decompress() before binding the framebuffer. Note that
agx_decompress() permanently sets PIPE_BIND_SHADER_IMAGE on the resource,
so an attachment bound once into a spilling MRT framebuffer stays
uncompressed afterwards and its first spilling use pays a full copy plus
flush.

Enable private 2x/4x MSAA compression on G17P:
- Admit Gen9 GPU-tiled compressed 2x/4x 2D multisample PBE packing in
  agx_gallium_pack_native_pbe() (leaving compressed MSAA arrays and
  non-GPU layouts rejected) and cover both sample counts in
  test-agx-native-descriptor.
- Widen agx_g17p_private_compression_allowed() to 2x/4x MSAA colour
  targets (width0/height0 >= 16 in pixels, intentionally stricter than
  ail_can_compress()'s sample-space minimum at 2x/4x) and
  agx_g17p_private_depth_compression_allowed() to 2x/4x MSAA and
  Z16_UNORM depth targets (including the separated Z32_FLOAT plane of
  Z32F_S8 and Z24S8).
- Update stale 1x-only no-spill comments in agx_g17p_compression.h and
  test-tilebuffer.cpp, and remove the stale Borealis depth-format comment
  in agx_pipe.c.
- On chips without in-place decompression, pre-decompress any private
  compressed render targets that would spill from the tilebuffer in
  agx_set_framebuffer_state() (before copying ctx->framebuffer so blitter
  restore cannot re-enter), and assert that the AGX3 fallback branch in
  agx_batch_init_state() is unreachable while keeping agx_decompress() as
  the non-debug fallback.

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

Copy link
Copy Markdown
Author

Thanks for the thorough review! Pushed R2 at b20b4ed252399c801aa7f9d04b3edc1e6f7be72b addressing every item from #issuecomment-7078922730:

  1. Commit message & stale comments:
    • Expanded the commit message to explain why Gallium does not hit Borealis #698's 4x MRT reload spill defect (Gallium never spills reloaded wide MSAA attachments — reloads stay AGX_BG_LOAD in agx_state.c, spills come only from the tilebuffer byte budget and go through agx_decompress()), and noted that agx_decompress() permanently sets PIPE_BIND_SHADER_IMAGE so the first spilling use pays a full copy + flush.
    • Updated the stale comments in agx_pipe.c (removed the inaccurate Borealis depth claim and documented why width0/height0 >= 16 stays in pixels), agx_g17p_compression.h, and test-tilebuffer.cpp.
    • Added Borealis gpubench-vk reference timings on the same MacBook Neo (G17P B1) runs to the PR description (render.postfx 1080p/1440p msaa=4 D=1,2 and compress.bw msaa4 1440p/2160p D=1,4; Gallium speeds up 2.35×–2.52× on render.postfx and 1.51×–1.57× on compress.bw, cutting the gap to Borealis from 5.27×–6.97× down to 2.17×–2.79×).
  2. Pre-decompression guard & unreachable AGX3 fallback assert (agx_state.c):
    • Added symmetric !(rsrc->base.bind & PIPE_BIND_SHARED) in agx_set_framebuffer_state()'s pre-decompression loop and assert(!"Spilled compressed render target was not pre-decompressed in agx_set_framebuffer_state()"); on the AGX3 fallback branch in agx_batch_init_state().
    • Re-ran host ./rig/fedora-mesaci.sh b20b4ed25239 (Ok 156, Fail 0) and DEFAULT_BRANCH=aurora-wip .github/aurora/agent-policy.sh pr HEAD (clean).
  3. Expanded MacBook Neo (G17P B1) correctness & full dEQP CTS at b20b4ed25239 (PMU=30 00, kfault_delta=0, avc_delta=0):
    • Independent CPU reference for uncovered-tile 4x reload (2× RGBA16F MRT): uncov_bad_rt0=0 uncov_bad_rt1=0 patch_bad_rt0=0 patch_bad_rt1=0 (and bit-exact BASE == HEAD).
    • Z24S8 (2x & 4x), Z32F_S8 (4x), D16 (2x & 4x) reload, glBlitFramebuffer depth+stencil resolve, and per-sample texelFetch(sampler2DMS): bit-exact BASE == HEAD.
    • Multisample glCopyImageSubData (2x/4x colour: RGBA8, RGBA16F, R32F, partial copies): bit-exact BASE == HEAD. (Note: MSAA depth glCopyImageSubData via u_blitter's agx_nir_lower_monolithic_msaa depth-only per-sample loop exhibits a pre-existing non-deterministic zeroing bug on uncompressed BASE c0b51ef2 too, so it is orthogonal to #708.)
    • Per-sample shading (gl_SampleID/gl_SamplePosition/glMinSampleShading(1.0) on compressed 2x/4x RGBA8 and 4x RGBA16F with reload): bit-exact BASE == HEAD.
    • TVB-overflow partial renders (120,000 overlapping triangles on 1024x1024 compressed 2x/4x RGBA8+D32F exercising multisample_store + reload): bit-exact BASE == HEAD.
    • Spilling 4x MRT (5x RGBA16F): bit-exact BASE == HEAD, AGX3 assert did not fire.
    • Full requested dEQP-GLES3 & dEQP-GLES31 CTS (BASE vs HEAD, 526/526 cases, 0 diffs, 0 fails):
      • dEQP-GLES3.functional.multisample.*: 32 Pass, 32 NotSupported, 0 Fail (0 diffs)
      • dEQP-GLES3.functional.fbo.msaa.*: 48 Pass, 22 NotSupported, 0 Fail (0 diffs)
      • dEQP-GLES31.functional.sample_shading.*: 18 Pass, 10 NotSupported, 0 Fail (0 diffs)
      • dEQP-GLES31.functional.shaders.sample_variables.*: 143 Pass, 64 NotSupported, 0 Fail (0 diffs)
      • dEQP-GLES31.functional.texture.multisample.*: 73 Pass, 84 NotSupported, 0 Fail (0 diffs)
    • Notes on remaining environments: Piglit is not installed on this Neo test image (PIGLIT_BIN=NONE), and M4 Pro / J616s hardware is not attached to this lane (if an M4 Pro hardware row is required before merge, it will need a J616s run).

Assisted-by: LLM (Antigravity:Gemini 4 Neon)

@DjDeveloperr
DjDeveloperr force-pushed the perf/asahi-g17p-msaa-compression branch from e231818 to b20b4ed Compare November 22, 2026 13:06
@RyanTheTide

Copy link
Copy Markdown

Thanks, R2 covers the code and comment points: the shared-resource guard is symmetric, the unreachable fallback is an assert, and the commit message explains the spill path and the one-time decompress. The Neo base-vs-head run (526 cases, 0 diffs) is the right shape. The M4 Pro (J616s) row is still needed, because AGX_CHIP_G17P covers it too. We have a J616s and will post that row here (dEQP multisample groups, piglit ext_framebuffer_multisample/arb_texture_multisample, and the postfx/compress.bw timing, base vs head). Code-wise this is fine from my side.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown

M4 Pro (J616s, T6040) row for b20b4ed against its merge-base c0b51ef. One boot of the production fleet kernel, default command line, user-space overlays only, cross-built release builds. Each run's libgallium was checked to load from its own overlay.

GLES CTS (surfaceless pbuffer 256x256; ms0 config, plus ms4 where marked). Base and head are identical in every group, with 0 Fail and 0 per-case diffs:

Group base head
GLES3 multisample.* 32 Pass / 32 NS same
GLES3 multisample.* (ms4) 48 Pass / 16 NS same
GLES3 fbo.msaa.* 48 Pass / 22 NS same
GLES31 sample_shading.* 18 Pass / 10 NS same
GLES31 shaders.sample_variables.* (ms0, ms4) 143 Pass / 64 NS same
GLES31 texture.multisample.* 73 Pass / 84 NS same

piglit (916 ext_framebuffer_multisample* / arb_texture_multisample* tests), serial:

  • Base and head are identical: 353 pass, 22 fail, 4 warn, 537 skip, 0 GPU recoveries.
  • The 22 fails are the same set in both arms: enable-flag, interpolation {2,4} *-disabled, multisample-blit {2,4} depth, no-color {2,4} depth*, unaligned-blit {2,4} ... msaa. So they're existing gaps, not caused by this PR.
  • At -j4, both arms saw 2 GPU recoveries each, overlapping the unaligned-blit {2,4} depth msaa cases that fail anyway, and a few non-repeatable flips in concurrent tests. That's equal in both arms, so it predates this PR.

gpubench-gl (3 interleaved reps, median µs per submit):

Row depth base head change
render.postfx msaa=4 1440p 1 1852 926 -50.0%
render.postfx msaa=4 1440p 2 1634 776 -52.5%
render.postfx msaa=4 1080p 1 1131 623 -44.9%
render.postfx msaa=4 1080p 2 984 485 -50.8%
compress.bw msaa4 1440p 1 439 342 -22.0% (235 -> 302 GB/s)
compress.bw msaa4 1440p 4 307 213 -30.7% (337 -> 486 GB/s)

The msaa=1 postfx and mrt4 compress controls are within ±0.7%.

That covers the M4 Pro half. With your Neo row, both G17P parts are clean, and this is approved from my side.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr
DjDeveloperr merged commit 1fdf539 into aurora-wip Nov 22, 2026
@DjDeveloperr

Copy link
Copy Markdown
Author

Merged into aurora-wip at 1fdf5396758f (verified tree 73e156ae9d34).

All merge gates green on exact head b20b4ed25239:

  • Review approved by @RyanTheTide (#issuecomment-7079583005 + M4 Pro J616s verification #issuecomment-7080854119)
  • Mirror asahi CI green (45025870799), fedora-mesaci 156/156 pass, agent-policy.sh pr clean
  • Exact-head hardware verification passed on both G17P parts (Apple A18 Pro G17P B1 and M4 Pro J616s): 0 GLES CTS diffs, identical piglit MSAA results, 2.0–2.5× render.postfx msaa=4 speedup, 0 GPU faults

Assisted-by: LLM (Google:Gemini 4 Neon)

DjDeveloperr added a commit that referenced this pull request Nov 22, 2026
agx_g17p_private_depth_compression_allowed() restricted G17P private depth
compression to single-layer PIPE_TEXTURE_2D targets, leaving layered
2D-array shadow maps (e.g., cascaded shadow maps) uncompressed even though
ZLS per-layer metadata addressing, Gen9 compressed 2D-array texture
descriptors, and per-layer compressed 2D PBE paths are already wired in
Gallium.

Widen agx_g17p_private_depth_compression_allowed() to also admit
single-level, single-sample PIPE_TEXTURE_2D_ARRAY depth resources in
PIPE_FORMAT_Z32_FLOAT and PIPE_FORMAT_Z16_UNORM on A18 Pro
(AGX_CHIP_ID_A18_PRO), where the layered ZLS, Gen9 compressed 2D-array
texture, and per-layer PBE paths have been verified on hardware. Single-layer
1x/2x/4x 2D Z32_FLOAT and Z16_UNORM stay enabled across AGX_CHIP_G17P
(matching Borealis for Z16/Z32F 2D), while M4 Pro and M4 Max depth arrays
remain gated until their Gallium layered runs are collected; mipmapped,
multisampled array, cube, and 3D depth textures remain uncompressed. Note that
the width0/height0 >= 16 pixel floor (landed in #708 on aurora-wip to match
Borealis) applies to 2D arrays as well as 2D depth buffers, keeping sub-16px
Z32F/Z16 buffers uncompressed.

Also guard three edge cases exposed by this shape:
- Return 0 from agx_zls_layer_stride() on AGX3/G18G when single_layer &&
  pages == 0 (sub-page single-layer depth/stencil buffers where the layer
  stride is unused), matching Borealis instead of emitting 0xffffc001 which
  AGX3/G18G kernel ZLS validation rejects. AGX2 keeps the existing
  underflowed word so G13/G14 command streams remain unchanged.
- Decompress in agx_create_sampler_view() when an AGX3 descriptor-generation
  cube or cube-array texture view is created over a compressed 2D array
  (matching agx_compression_allowed()'s descriptor-generation predicate),
  since Gallium AGX3 does not use compressed cube descriptors.
- Dirty AGX_STAGE_DIRTY_IMAGE across all shader stages in
  transition_resource() after swapping rsrc->bo and rsrc->layout so any
  sampler view or image already bound on an open batch re-packs its
  descriptor from the decompressed resource on the next draw.

Add unit coverage in test-agx-native-descriptor.c verifying Gen9 compressed
2D-array Z32F/Z16 texture descriptors against Borealis and single-layer
compressed 2D PBE packing for page-aligned array slices.

Signed-off-by: Diljit Singh <hey@djdev.me>
DjDeveloperr added a commit that referenced this pull request Nov 24, 2026
agx_g17p_private_depth_compression_allowed() restricted G17P private depth
compression to single-layer PIPE_TEXTURE_2D targets, leaving layered
2D-array shadow maps (e.g., cascaded shadow maps) uncompressed even though
ZLS per-layer metadata addressing, Gen9 compressed 2D-array texture
descriptors, and per-layer compressed 2D PBE paths are already wired in
Gallium.

Widen agx_g17p_private_depth_compression_allowed() to also admit
single-level, single-sample PIPE_TEXTURE_2D_ARRAY depth resources in
PIPE_FORMAT_Z32_FLOAT and PIPE_FORMAT_Z16_UNORM on A18 Pro
(AGX_CHIP_ID_A18_PRO), where the layered ZLS, Gen9 compressed 2D-array
texture, and per-layer PBE paths have been verified on hardware. Single-layer
1x/2x/4x 2D Z32_FLOAT and Z16_UNORM stay enabled across AGX_CHIP_G17P
(matching Borealis for Z16/Z32F 2D), while M4 Pro and M4 Max depth arrays
remain gated until their Gallium layered runs are collected; mipmapped,
multisampled array, cube, and 3D depth textures remain uncompressed. Note that
the width0/height0 >= 16 pixel floor (landed in #708 on aurora-wip to match
Borealis) applies to 2D arrays as well as 2D depth buffers, keeping sub-16px
Z32F/Z16 buffers uncompressed.

Also guard three edge cases exposed by this shape:
- Return 0 from agx_zls_layer_stride() on AGX3/G18G when single_layer &&
  pages == 0 (sub-page single-layer depth/stencil buffers where the layer
  stride is unused), matching Borealis instead of emitting 0xffffc001 which
  AGX3/G18G kernel ZLS validation rejects. AGX2 keeps the existing
  underflowed word so G13/G14 command streams remain unchanged.
- Decompress in agx_set_sampler_views(), next to agx_legalize_compression(),
  when an AGX3 descriptor-generation cube or cube-array texture view is
  bound over a compressed 2D array
  (matching agx_compression_allowed()'s descriptor-generation predicate),
  since Gallium AGX3 does not use compressed cube descriptors.
- Dirty AGX_STAGE_DIRTY_IMAGE across all shader stages in
  transition_resource() after swapping rsrc->bo and rsrc->layout so any
  sampler view or image already bound on an open batch re-packs its
  descriptor from the decompressed resource on the next draw.

Add unit coverage in test-agx-native-descriptor.c verifying Gen9 compressed
2D-array Z32F/Z16 texture descriptors against Borealis and single-layer
compressed 2D PBE packing for page-aligned array slices.

Signed-off-by: Diljit Singh <hey@djdev.me>
@RyanTheTide
RyanTheTide deleted the perf/asahi-g17p-msaa-compression branch November 27, 2026 13:20
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.

2 participants