Repository navigation
asahi: enable private 2x/4x MSAA colour and depth compression on G17P - #708
Conversation
|
Thanks, the Neo numbers are a big win. Comments at e231818:
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:
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>
|
Thanks for the thorough review! Pushed R2 at
Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
e231818 to
b20b4ed
Compare
|
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 Assisted-by: LLM (Claude:Opus 5.5) |
|
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:
piglit (916
gpubench-gl (3 interleaved reps, median µs per submit):
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) |
|
Merged into All merge gates green on exact head
Assisted-by: LLM (Google:Gemini 4 Neon) |
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>
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>
Summary
On
G17P, Gallium Asahi previously limited private lossless compression to single-sample colour andZ32_FLOATdepth 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 (RGBA16F4x MSAA +Z32F4x MSAA), leaving Gallium Asahi 4.4×–6.7× slower than Borealis Vulkan oncompress.bw msaa4andrender.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 andZ16_UNORM, and Gallium owns its private resources so spilled compressed render targets can safely be reallocated uncompressed viaagx_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 inagx_gallium_pack_native_pbe()(while keeping compressed MSAA arrays and non-GPU layouts rejected).src/gallium/drivers/asahi/agx_pipe.c: Widenagx_g17p_private_compression_allowed()to 1x/2x/4x MSAA colour targets (width0 >= 16 && height0 >= 16) andagx_g17p_private_depth_compression_allowed()to 1x/2x/4x MSAA andPIPE_FORMAT_Z16_UNORMdepth targets (width0 >= 16 && height0 >= 16). Strictly scoped toAGX_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 inagx_set_framebuffer_state()before copyingstateintoctx->framebuffer(preventing blitter restore recursion), and route fallback spill decompression inagx_batch_init_state()throughagx_decompress()instead of AGX2-onlyagx_decompress_inplace().src/gallium/drivers/asahi/tests/test-agx-native-descriptor.c: Extendtest_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 updatedtest-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), Linux7.3.0-41.fc44.aurora.aarch64Tested BASE
c0b51ef245vs HEADe2318186b2(MESA_SHADER_CACHE_DISABLE=true,pmu=30 00,kfault_delta=0,avc_delta=0).1.
gpubench-gl6-Round Alternating ABBA (--verify --warmup-ms 80 --runs 3 --run-ms 250)c0b51ef245)e2318186b2)render.postfx1440pmsaa=46,578.9 us(152 fps)2,659.6 us(376 fps)2.47×+147.4%fps3d8c24fcexact (valid: true)render.postfx1080pmsaa=43,731.3 us(268 fps)1,533.7 us(652 fps)2.43×+143.3%fpsca9f8491exact (valid: true)compress.bw1440pmsaa41,424.5 us939.8 us1.52×-34.0%uscompress.bw1440pmsaa41,162.8 us778.8 us1.49×-33.0%uscompress.bw1440pmrt4862.3 us865.1 us1.00×compress.bw1440prgba32f2,016.1 us2,016.1 us1.00×render.postfx1440pmsaa=11,259.5 us(794 fps)1,265.8 us(790 fps)0.99×f54ee158exact (valid: true)render.shadowdepth_onlyd161,666.7 us(9.83 Mtri/s)1,661.1 us(9.86 Mtri/s)1.00×c0fb9993exact (valid: true)render.shadowdepth_onlyd32f3,086.4 us(5.31 Mtri/s)3,086.4 us(5.31 Mtri/s)1.00×c0fb9993exact (valid: true)render.shadowalpha_testd162,824.9 us(5.80 Mtri/s)2,809.0 us(5.83 Mtri/s)1.01×7be9463aexact (valid: true)AGXPROFper-pass GPU breakdown (1440p):render.postfx msaa=4Pass 1 (RGBA16F4x MSAA +Z32F4x MSAA):3,352.2 us -> 539.4 us(6.21×)render.postfx msaa=4Pass 2 (u_blitterMSAA4 resolve reading compressedRGBA16F):2,452.8 us -> 1,067.9 us(2.30×)compress.bw msaa4Pass 1 (RGBA84x MSAA reload +store_and_resolve):1,020.5 us -> 642.2 us(1.59×)2.
dEQP-GLES3&dEQP-GLES31CTS (BASE vs HEAD, 1,688 cases, 0 diffs / 0 regressions)c0b51ef245)e2318186b2)dEQP-GLES3.functional.fbo.msaa.*dEQP-GLES3.functional.fbo.blit.*dEQP-GLES3.functional.multisample.*dEQP-GLES3.functional.fbo.depth.*dEQP-GLES3.functional.fbo.color.*dEQP-GLES3.functional.fbo.render.*dEQP-GLES3.functional.fbo.invalidate.*dEQP-GLES31.functional.texture.multisample.*3. Custom GL 4.6 Pixel-Exact Verifier (BASE vs HEAD, 48 / 48 bit-exact SHA-256 match, 0 diffs)
Covers:
texelFetchacrossRGBA8,SRGB8_ALPHA8,RGBA16F,R32F,RGBA32F,RGBA16UI, NPOT (317x211), and small-dimension bounds (8x8,16x16,17x17).2× RGBA16F= 16 B/sample, partial tiny-triangle pass 2 with 99% uncovered tiles).5× RGBA16F= 40 B/sample > 32 B/sample tilebuffer) with pre-populated compressed RT4 preserved acrossagx_decompress()reallocation (0GPU faults).Z16_UNORMand 2x/4xZ32_FLOAT/Z32F_S8depth 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)