Skip to content

borealis: leave M5 R16 storage images uncompressed by default - #1425

Merged
RyanTheTide merged 1 commit into
aurora-wipfrom
fix/borealis-m5-r16-storage-plain
Nov 30, 2026
Merged

RyanTheTide merged 1 commit into
aurora-wipfrom
fix/borealis-m5-r16-storage-plain

Conversation

@erikwb

@erikwb erikwb commented Nov 30, 2026

Copy link
Copy Markdown

What: The M5 storage-compression default no longer compresses R16 UNORM/SNORM/UINT/SINT images that shaders write: bit 10 of ASAHI_M5_STORAGE_COMPRESSION is now clear in the default (32767 → 31743). This gives up compression of a class that saves little bandwidth, in exchange for speed where such an image is sampled heavily. In Cyberpunk 2077 a 640x400 R16 image is point-sampled up to 96 times per pixel, and the T2 benchmark on the M5 Max goes from 49.27 to 51.37 FPS (+2.07, +4.2 %). R16F and every other class keep compressing, and the environment variable still selects any mask (32767 restores the old default).
Tested: J716c (M5 Max) at 3582830: Cyberpunk 2077 T2 49.27 → 51.37 FPS (4 head samples interleaved with 5 base samples, se 0.11). 110,791 CTS case runs per arm over two lists (101,632 distinct cases) identical to the base build (0 new fail/crash/timeout). vulkan-storage-compression (35 formats) and vulkan-storage-alias (41 groups) are exact with the new default and with 32767. 0 GPU kernel error lines.
Risk: two-way door · every M5 the storage rule applies to (M5, M5 Pro, M5 Max: G17G, G17S, G17C). M4 and older never compress storage images and are unaffected.
Not yet: M5 Pro and base M5 rows: we have neither Mac. The workload the R16 class was added for (SCP: Secret Laboratory, M5 Pro) was not re-measured. Its one number was taken together with mipmapped storage images, so the R16 share of it is unknown.

Details

The rule. hk_m5_storage_compression_eligible() (hk_image.c) admits a storage image to lossless compression on chips whose PBE merges shader stores into compressed tiles (hk_chip_supports_compressed_storage_pbe(): the M5 family). It decides by format class, one bit of ASAHI_M5_STORAGE_COMPRESSION per class, and the default selected all 15 classes. On M5 a compressed storage image has no decompress pass or driver detour. Each shader store merges into a compressed tile in the PBE, and each read decodes one in the texture unit, so the cost or saving comes with every access.

This class. Bit 10 covers R16_UNORM, R16_SNORM, R16_UINT and R16_SINT (one 16-bit channel). A two-byte texel saves little bandwidth compressed, but every store and every read still goes through the compressed path. The rule already keeps storage-only R8/RG8 images plain for the same reason (BeamNG ran about 1.6 % slower with them compressed). Usage cannot tell the costly case apart here. vkd3d-proton creates these images with storage, sampled, transfer and colour-attachment usage (0x1f), the same usage as the RGBA16F targets where compression wins. A texel-size rule would also change R16F and the R8/RG8 render targets, which were not measured. So the class bit is the narrowest selector.

History. The class was admitted before the public history begins, in one commit together with mipmapped storage images (bit 12). That commit's one measurement covers both changes together: SCP: Secret Laboratory at 3024x1964 on the M5 Pro (the rule then ran on G17S only), 51.3/55.6 FPS against 50.0/53.3. Its text names Unity HDRP's 12-level RGBA16 colour pyramid (bits 7 and 12) as the workload. Nothing measured the R16 class on its own, on any chip. The M5 Max has used the rule since #693 extended it to every M5.

What changes. On every M5, R16 UNORM/SNORM/UINT/SINT storage images are created plain, whether single-level or mipmapped. Nothing else changes: R16F (bit 2), RG16 (bit 8), the R8/RG8 colour-attachment class (bit 13) and the rest behave as before. In Cyberpunk 2077's T2 frame the class holds three images. Two are 640x400 R16_UNORM: one is written by a compute shader and then point-sampled by the screen-space reflection march: up to 96 reads per pixel (3 rays, 8 steps of 4 samples, before early exits). The third is an 80x50 R16_UINT image.

Code. The bit and the default are named in hk_g17p_compression.h (HK_M5_STORAGE_R16, HK_M5_STORAGE_COMPRESSION_DEFAULT). test-hk-g17p-compression checks that the default leaves exactly that bit clear. The header of vulkan-storage-compression now notes that its R16 cases need ASAHI_M5_STORAGE_COMPRESSION=32767 to run compressed.

Evidence

Machine: J716c (M5 Max, G17C), kernel 7.3.0-ewb417+ #1 SMP PREEMPT_DYNAMIC Mon Nov 30 14:50:30 UTC 2026, default command line, on AC.

Driver identities (both built with the same builder and options, release, -mcpu=apple-m5):

Arm Commit Version string libvulkan_asahi.so sha256
base 717a7d62e004489553aee578926cf418022e2eb9 (aurora-wip) Mesa 26.3.0-devel (git-717a7d62e0) c4a35ee5b34fdd58c87d9ce742f907fe8584ba448ddcdf60c10e228c760956f3
head 3582830cf1cb86bc132381ad7584fc354aadea44 Mesa 26.3.0-devel (git-3582830cf1) d388b7d432e7c78ea2a939953b1de6e11ffe85ad86ac2348f050e7cce4023b29

Game A/B at the head. Cyberpunk 2077 built-in benchmark, 2560x1600 High (T2 tier of issue #457), Proton build cur-fex-main-vkmain, the same harness and tuning for both arms, and a per-build shader cache warmed by one discarded run per arm. Runs alternate A B A B … A. Each head sample is compared with the mean of the base runs on either side of it. There was no early stop.

Samples (FPS) Mean sd
base 49.03 50.01 48.85 49.17 49.31 49.27 0.44
head 51.45 51.38 51.40 51.25 51.37 0.08
delta per head sample +1.93 +1.95 +2.39 +2.01 +2.07 (+4.2 %) se 0.11

GPU compute time per frame (fdinfo, base → head) was about 19.3 → 18.4 ms; vertex and fragment time were unchanged (2.15 / 7.0 ms). The battery charged from 59 % to 66 % during the session (AC, no power clamp).

The same switch on earlier builds (the environment variable on unchanged builds, not the head; listed only to show the effect is stable):

Build, configuration control (FPS) mask 31743 (FPS) delta
aurora-wip 89ddabbf72c + a default-off diagnostic switch 50.04 50.11 49.36 49.98 52.07 51.56 51.54 +1.90 (se 0.05)
same build, with a loader that enables the system-level cache (aura #549) 51.51 51.81 51.68 52.33 54.09 53.92 54.24 +2.28 (se 0.08)

With the system-level cache on, clearing the whole mask (0) gained less, +1.46 (se 0.30): 53.69 53.13 52.99. Turning off all compression on 5e89c89ce5d lost 0.97 FPS (se 0.15). So the rest of the rule is a net gain in this game, and only the R16 class costs.

Conformance (dEQP-VK 7ba03cdac7ae, 6 workers, base first, then head, same process boundaries):

Caselist Arm Cases Pass Fail Crash Timeout NotSupported
R16 + image load/store (every single-channel R16 case in image, api.copy_and_blit, api.image_clearing, texture, compute, the first 3,000 of renderpasses; all of image.load_store, image.store, image.load_store_lod, image.qualifiers; no image.host_image_copy) base 22,584 13,885 0 0 0 8,699
head 22,584 13,885 0 0 0 8,699
all of image (no host_image_copy), compute.pipeline, texture.shadow base 88,207 40,489 8 0 0 47,710
head 88,207 40,489 8 0 0 47,710

0 cases differ. The 8 failures are the same on both arms: compute.pipeline.cooperative_matrix.khr_r.subgroupscope.reduce_sum_rowcol{,_changedim}.float16_float16.*, not related to images. NotSupported sets are identical.

Storage tests (vulkan-storage-compression 300x200, vulkan-storage-alias):

Arm Mask storage-compression storage-alias
base default 35 formats, 0 failed 41/41 groups pass
base 32767 35 formats, 0 failed 41/41 groups pass
head default 35 formats, 0 failed 41/41 groups pass
head 32767 35 formats, 0 failed 41/41 groups pass

Compression state of the test's R16_UNORM image (usage 0x1f), from the driver's image-creation log: base default compressed=1, base 32767 compressed=1, head default compressed=0, head 32767 compressed=1. The R16 cases therefore cover both the plain path (new default) and the compressed path (32767).

Unit test: hk_g17p_compression passes (8,366 checks).

System health over the window: 0 GPU kernel error lines (faults, recoveries, timeouts, lost devices) in the streamed kernel log; 0 lost device lines this boot. Failed units: aurora-peripherals.service, a standing failure on this Mac with both builds. Also systemd-networkd-wait-online.service, which timed out at boot, 2 minutes after power-on and before any of these runs.

The M5 storage-compression rule admits shader-written images by format
class, one ASAHI_M5_STORAGE_COMPRESSION bit per class, and its default
selected every class. Clear the bit of the R16 UNORM, SNORM, UINT and SINT
class (bit 10) in the default, so these images stay plain. R16F and the
other classes are unchanged, and the environment variable still selects
any mask (32767 restores the old default).

A single-channel 16-bit texel saves little bandwidth compressed, while
each shader store merges into a compressed tile and each read decodes
one. In Cyberpunk 2077 the screen-space reflection march point-samples a
640x400 R16_UNORM image, written by a compute shader, about a hundred
times per pixel. The class was admitted together with mipmapped storage
images, and the one measurement behind the two (SCP: Secret Laboratory
on an M5 Pro) was taken with both at once.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb
erikwb requested review from a team and DjDeveloperr as code owners November 30, 2026 18:20

@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: MERGE at 3582830c

Blockers: none.

Checked:

  • src/asahi/vulkan/hk_g17p_compression.h & hk_image.c (+33/-3 across 4 files): HK_M5_STORAGE_R16 (1u << 10, matching 1024) is cleared from HK_M5_STORAGE_COMPRESSION_DEFAULT (0x7fffu & ~HK_M5_STORAGE_R16 = 31743), leaving R16_{UNORM,SNORM,UINT,SINT} storage images uncompressed by default while keeping R16F and all other storage classes compressed and preserving ASAHI_M5_STORAGE_COMPRESSION=32767 override support.
  • Scoped strictly to M5 (hk_chip_supports_compressed_storage_pbe()); M4 and earlier generations are unaffected.
  • src/asahi/vulkan/tests/test-hk-g17p-compression.c (check_m5_storage_default()) and vulkan_storage_compression.c comments align with the new default.
  • Exact-head 3582830cf1cb hardware verification on J716c (M5 Max, G17C): Cyberpunk 2077 T2 49.27 -> 51.37 FPS (+2.07 FPS, +4.2%, se 0.11, 4 head / 5 base interleaved), 110,791 dEQP-VK runs (101,632 distinct cases) identical to base with 0 new failures/crashes/timeouts, vulkan-storage-compression (35 formats) and vulkan-storage-alias (41/41 groups) passing under both default (compressed=0) and 32767 (compressed=1), hk_g17p_compression (8,366 checks) passing, 0 GPU kernel errors.
Evidence
  • Single-generation M5-only conservative policy change (disabling compression on one 16-bit single-channel storage class) with thorough exact-head J716c A/B and conformance coverage; M5 Pro / base M5 follow-up rows can be requested without holding merge.

@RyanTheTide

Copy link
Copy Markdown

@DjDeveloperr, code-owner heads-up: App approval at 3582830cf1cb from a different lane. This PR goes into the merge train's next combined A/B (aurora-wip 6e153e59 + #1417 #1418 #1425) on M1 Pro G13S + M4 G16G. If that row is clean, I plan to land it via --admin under the 6-point rule no earlier than one hour from now, unless you post a hold.

@RyanTheTide

Copy link
Copy Markdown

Merge-train landing at 3582830cf1cb.

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

@RyanTheTide
RyanTheTide merged commit 84ba0be into aurora-wip Nov 30, 2026
@RyanTheTide
RyanTheTide deleted the fix/borealis-m5-r16-storage-plain branch November 30, 2026 23:29
@m0d16l14n1

Copy link
Copy Markdown

Base M5 row (MacBook Air 15" M5, J815, G17G), kernel 7.3.0-aurora-j815-dev, PR head on aurora-wip 6e153e5 vs that base, release builds, dEQP-VK 1.4.7.1 (+ KhronosGroup/VK-GL-CTS@c2c05e95f97f):

  • every mustpass R16 case (76,408): 51,627 = 51,627 Pass, 0 diffs; dEQP gate (15,958): 11,297 = 11,297 Pass, 0 diffs; 0 GPU faults.
  • Small Vulkan microbenchmark (R16 storage image written once, then sampled 100 times per pixel, 640x400, GPU timestamps, 3 reps): march 1.106 ms compressed (old default) vs 0.652 ms with this PR (1.7x); R16_SNORM 1.067 vs 0.652 ms; R16F and RGBA16F unchanged (controls). Short marches on a 2560x1600 image are 1-9 % faster compressed (1-32 taps), so the default here fits sampling-heavy use.

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.

3 participants