Skip to content

hk: compress large G17P RGBA8/BGRA8 mip chains that are only sampled and transferred - #63

Merged
RyanTheTide merged 1 commit into
aurora-wipfrom
perf/g17p-transfer-compression-20261024
Oct 24, 2026
Merged

RyanTheTide merged 1 commit into
aurora-wipfrom
perf/g17p-transfer-compression-20261024

Conversation

@RyanTheTide

Copy link
Copy Markdown

DJ asked us to check that transfer compression works on the Neo. Mostly it does. On G17P, TRANSFER_SRC and TRANSFER_DST never stop an image being compressed, and no transfer path decompresses anything. Copies, uploads, blits, resolves and clears read compressed sources through the texture unit, and they write compressed destinations through the PBE or the metadata fast clear. Layout transitions to and from the transfer layouts don't touch the data either.

The one gap we can close without new hardware facts is in the allocation policy. G17P kept every RGBA8/BGRA8 UNORM mip chain that isn't a colour attachment uncompressed. That's the usual sampled texture, uploaded with vkCmdCopyBufferToImage and mipmapped with vkCmdBlitImage. The rule is from before #33, when mip blits into a compressed image cost a render job per level. #33's compressed mip path removed that reason, so now the rule only makes these textures slower. The same texture as R8G8B8A8_SRGB was already compressed.

Uploads into a compressed image are still a render pass per region, while a plain image takes one compute copy. So small textures stay plain. This compresses from 2^17 texels at level 0 (HK_G17P_MIP_PBE_MIN_TEXELS), the size where DJ measured a render pass beating compute for a mip level. M1/M2 never use this policy (it returns early for anything but G17P).

Benchmarks (Neo, A18 Pro, 7.3.0-aurora-73t)

Method: a scratch Vulkan microbench (not in the tree). Each run creates a sampled RGBA8 UNORM texture with a full mip chain and SAMPLED, TRANSFER_SRC and TRANSFER_DST usage only. It then times four steps in separate submissions with GPU timestamps:

  • upload, a vkCmdCopyBufferToImage of level 0;
  • mip gen, a linear vkCmdBlitImage chain;
  • sample, 16 fullscreen draws into a 2048x2048 target sampling the texture trilinearly;
  • read back, a vkCmdCopyImageToBuffer of level 0, checked bit for bit against the upload. Every run matched.

Content is either "ui" (32x32 flat blocks with borders) or "noise" (random, incompressible). There's also a batch case, 200 128x128 or 100 256x256 textures uploaded and mipmapped in one command buffer, which is what toolkits do at startup.

The policy was picked by an environment variable in a measurement-only build, so all three policies ran on the same binary in the same boot: off (current), gate (this PR), all (no exclusion). 8 outer reps rotated the order of the three policies, with 5 inner reps each (inner rep 0 dropped). All units ran on E-cores 1 to 4 with the seat idle, and P-core peak stayed under 60 C. Numbers are median GPU microseconds, with the range of per-rep medians in brackets.

Size Content Step off (plain) gate (this PR) gate/off all
512x512 ui upload 282 (263-284) 269 (236-286) 0.95 233
512x512 ui mip gen 266 (210-283) 213 (193-268) 0.80 211
512x512 ui sample 552 (549-555) 472 (469-493) 0.86 469
512x512 ui read back 223 (192-243) 223 (188-263) 1.00 195
512x512 noise upload 302 (274-354) 315 (250-322) 1.04 239
512x512 noise mip gen 238 (235-296) 228 (219-287) 0.96 220
512x512 noise sample 598 (570-666) 556 (529-598) 0.93 520
512x512 noise read back 256 (202-263) 228 (203-264) 0.89 194
1024x1024 ui upload 462 (431-495) 310 (283-348) 0.67 305
1024x1024 ui mip gen 375 (366-426) 251 (249-287) 0.67 254
1024x1024 ui sample 578 (562-640) 468 (464-505) 0.81 468
1024x1024 ui read back 320 (264-338) 289 (272-321) 0.91 290
1024x1024 noise upload 460 (451-524) 354 (318-379) 0.77 333
1024x1024 noise mip gen 431 (405-437) 341 (323-344) 0.79 329
1024x1024 noise sample 614 (594-637) 589 (569-619) 0.96 588
1024x1024 noise read back 313 (291-391) 305 (279-331) 0.97 293
2048x2048 ui upload 1146 (1097-1173) 626 (609-644) 0.55 615
2048x2048 ui mip gen 933 (928-986) 374 (367-383) 0.40 357
2048x2048 ui sample 708 (633-723) 488 (477-504) 0.69 485
2048x2048 ui read back 851 (844-912) 784 (748-791) 0.92 776
2048x2048 noise upload 1160 (1111-1197) 741 (725-772) 0.64 738
2048x2048 noise mip gen 986 (938-992) 565 (549-604) 0.57 575
2048x2048 noise sample 858 (824-869) 724 (646-744) 0.84 702
2048x2048 noise read back 946 (917-956) 901 (889-935) 0.95 906
4096x4096 ui upload 3875 (3868-3970) 1813 (1802-1839) 0.47 1826
4096x4096 ui mip gen 3147 (3116-3189) 739 (693-766) 0.23 750
4096x4096 ui sample 855 (834-891) 523 (509-573) 0.61 553
4096x4096 ui read back 3586 (3545-3605) 3266 (3223-3289) 0.91 3223
4096x4096 noise upload 3872 (3861-3896) 2469 (2445-2491) 0.64 2485
4096x4096 noise mip gen 3163 (3125-3179) 1849 (1800-1856) 0.58 1846
4096x4096 noise sample 1047 (998-1080) 890 (881-929) 0.85 884
4096x4096 noise read back 3579 (3541-3603) 3666 (3606-3673) 1.02 3660
200 x 128x128 batch ui upload + mip gen 4797 (4766-4826) 4749 (4727-4759) 0.99 12636 (2.63x)
100 x 256x256 batch ui upload + mip gen 5151 (5111-5175) 5140 (5094-5181) 1.00 6349 (1.23x)

Below 2^17 texels "gate" runs exactly the same code as "off", so the small sizes are unchanged by construction. The "all" column is why the gate exists. Compressing small textures makes the batches 2.6 and 1.2 times slower, because every upload becomes a render pass.

The one step that gets slower is reading back an incompressible 4096x4096 level, by 2% (3666 vs 3579 us). For the same texture, upload, mip gen and sampling together drop from 8082 to 5208 us.

Conformance

Vulkan CTS 1.4.6.2, same kit and kernel for base and candidate (73t on all three machines). The candidate was 7615582 + #55..#60 + the #57 fixups + this commit, and the base was 7615582. Today's aurora-wip has all of that except #56, which touches index draws only.

Machine Names Groups vs 7615582
Neo (A18 Pro) 401,764 stride50, all of copy_and_blit, the RGBA8/BGRA8/mip subsets of image, texture, pipeline sampler/image/image_view and renderpass clears, image_clearing 0 changes
M2 605,583 stride50, the same G1 groups, the jgoyvaerts groups 0 changes
M1 Pro 605,583 as M2 0 changes except the memory_model guard_local.image.frag flake, which fails 12/20 on base too

GL CTS samples through zink on the Neo (every 20th name of gl46, gles2-aosp and gles3-aosp): identical with and without this commit. Zink gives its textures colour-attachment usage, so it was never affected.

Unit test: hk_g17p_compression passes (3359 checks) with the new boundary cases at 362x362 (just under 2^17) and 512x256 (exactly 2^17).

Not covered here

These G17P images stay uncompressed until we have the hardware facts to compress them:

  • arrays, cube maps and 3D (layered compressed PBE);
  • MSAA;
  • mipmapped depth;
  • compute stores into compressed images, which would make uploads into compressed images a single dispatch as on M1/M2.

🤖 Generated with Claude Code

…red to

G17P kept every RGBA8/BGRA8 UNORM image with mip levels and without
colour attachment usage uncompressed, so that its mip blits stayed on
the raw compute kernels. Those kernels could not write compression
metadata, and a compressed destination took one render job per level.
hk_g17p_compressed_blit has since made mip generation into compressed
images fast, so the rule only costs time now. It covers the common
sampled texture, created for sampling and transfers only, uploaded with
vkCmdCopyBufferToImage and mipmapped with vkCmdBlitImage. The same
texture in R8G8B8A8_SRGB was already compressed.

Uploads into a compressed image are still a render pass per region,
where a plain image takes one compute copy, so small textures stay
plain. Compress from HK_G17P_MIP_PBE_MIN_TEXELS texels at level 0, the
size where a render pass already beats compute for a mip level.

Measured on the A18 Pro with sampled, transfer-only textures and full
mip chains (median GPU time, compressed over plain):

  size       content  upload  mip gen  sample  read back
  1024x1024  UI       0.67    0.67     0.81    0.91
  2048x2048  UI       0.55    0.40     0.69    0.92
  4096x4096  UI       0.47    0.23     0.61    0.91
  2048x2048  noise    0.64    0.57     0.84    0.95
  4096x4096  noise    0.64    0.58     0.85    1.02

Batches of 200 128x128 and 100 256x256 textures are unchanged (0.99,
1.00). Compressing those too would have made them 2.6 and 1.2 times
slower. G13 and G14 never take this policy.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide merged commit 80dd9f9 into aurora-wip Oct 24, 2026
2 of 4 checks passed
@RyanTheTide
RyanTheTide deleted the perf/g17p-transfer-compression-20261024 branch October 24, 2026 07:48
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.

1 participant