Repository navigation
G17P: compressed colour render targets (hk shared/WSI, Gallium, zink) and fast compressed mipmaps - #33
Merged
DjDeveloperr merged 9 commits intoOct 23, 2026
Conversation
Three host tests relied on assert() but did not undefine NDEBUG. The package build sets b_ndebug, so test-hk-host-as dropped its staging-layout call and crashed, and the lifetime and execution-allowance tests checked nothing. Undefine NDEBUG before <assert.h>, as the other hk tests do.
test-gen1-wait and test-hk-rt-inlining undefined NDEBUG before the NIR headers. In a b_ndebug build that declares the out-of-line nir_validate_shader(), which libnir does not provide then, so the tests fail to link and the build stops. Undefine it just before <assert.h>, as the other hk tests do.
G17P never advertised DRM_FORMAT_MOD_APPLE_GPU_TILED_COMPRESSED. The private compression policy refuses external memory and WSI images, so every swapchain image, a headless one included, was plain GPU tiling and its end-of-tile stores moved uncompressed data. With one level, one layer and one sample, the G17P compressed allocation is a function of the format and the extent alone (legacy AIL policy: the image, then its metadata, in one memory plane), so exporter and importer derive the same layout, and import already follows the modifier through hk_map_compression(). The packets that write and read such an image are the compressed single-level 2D PBE and the compressed texture descriptor the private policy already uses for colour images. - Advertise the modifier for the private colour formats whose end-of-tile store class matches, without storage and host-transfer features. - Let choose_drm_format_mod() take it for 2D images with one level, one layer and one sample, at least 16x16, without storage, host-transfer or feedback-loop usage, including WSI images (which carry ALIAS). - Limit format queries and explicit creation with the modifier to that shape. Feedback-loop usage stays accepted on import, as for the interchange modifier, because zink adds it to imported render targets. The display planes list only LINEAR, so a scanout tranche never offers the modifier. AGX2 and the other AGX3 parts are unchanged.
Gallium refused compression on every AGX3 part because the compressed PBE was thought to be unknown. The Gen9 GPU-tiled compressed 2D packet is encoded by the shared codec Honeykrisp compresses G17P colour images with, and agx_gallium_pack_native_pbe() already accepts it. What Gallium lacks on AGX3 is in-place decompression, which it uses for spilled render targets and for feedback loops on shared images. Compress only the G17P images that never need it: private (sampler-view and render-target binds only), single-level, single-layer, single-sample 2D images of the colour formats in agx_g17p_compression_color_format(). Each takes at most 8 bytes of a tilebuffer sample, so beside seven 16-byte targets it still fits the 120 bytes G17P has and never spills. Feedback loops and shader-image bindings reallocate such an image uncompressed, as on AGX2. Imported compressed images stay sample-only, and depth and stencil stay plain. The new tests pin Gallium's end-of-tile packet to the native bytes the Honeykrisp tests carry and check the no-spill bound for every admitted format in every render-target slot. The G17P blit shim test now expects its compression-eligible target to be compressed. AGX2 and the other AGX3 parts are unchanged.
Honeykrisp decides lossless compression once, at image creation, and refuses it for colour images with ATTACHMENT_FEEDBACK_LOOP usage: a draw that samples other texels of a compressed tile while that tile is being stored can read it mid-update. zink adds the usage to every colour render target, so on G17P no GL colour target was ever compressed. On G17P Honeykrisp exposes VK_KHR_unified_image_layouts, so zink runs with general_layout: it never selects the feedback-loop layout, never enables a feedback loop on an attachment and never reaches add_implicit_feedback_loop(). The usage is only that hint to the driver. For Honeykrisp with general_layout: - create colour images without the usage, except imported, exported, scanout, linear, sparse and protected ones, which keep it from creation; - before a draw samples a level and layer of one of its colour attachments that overlap the attachment (the test add_implicit_feedback_loop() applies), or while an attachment is resident as a bindless texture, recreate that image with the usage and copy its contents, as zink already does to add storage or mutable usage; - do the same before a blit or copy within one level of one image. Draws check only after the framebuffer, the graphics sampler views, the bound graphics shaders or bindless texture residency changed, the state that decides whether a draw samples one of its colour attachments; a draw without such a change costs a byte load and a branch. An image is recreated at most once, and other contexts rebind it. Depth images and swapchain images keep the usage. Drivers without unified image layouts, Honeykrisp on M1 and M2 included, are unchanged. Under the G17P noop DRM shim, GL render targets on zink are now compressed. A GLES test sees one recreation for a sampled feedback loop, for sampling the attached level and for a copy within a level, and none for a bound but unsampled texture, another level, ping-pong rendering or depth feedback.
On G17P a copy into a losslessly compressed image takes the vk_meta
graphics path. Its source view covered every array layer from layer 0,
and the copy shader selected the copied layer by index. hk describes an
uncompressed view of a block-compressed image as a standalone image of
one level, so the hardware derives that image's layer stride, not the
allocation's: only layer 0 is addressed correctly. For a 132x132 R11 EAC
cube the strides happen to agree at level 0 (0xc000) but not at level 1
(0x4000 against 0xc000), so faces 1 to 5 of smaller levels were read from
the wrong memory.
Add vk_meta_copy_image_properties::copied_layers_src_view: the source
view then covers only the copied layers (3D slices as a 2D array), which
the copy addresses from zero. hk sets it for block-compressed images on
its native AGX3 graphics copy path (G15S, G15C and G17P), which splits
every region into single layers or slices; AGX2 is unchanged. On that
path pack_texture logs once if an uncompressed view of a block-compressed
image ever spans several layers; applications cannot create one, as
blockTexelViewCompatibleMultipleLayers is false.
This fixes dEQP-GLES31.functional.copy_image.mixed.
viewclass_64_bits_mixed.{r11_eac,signed_r11_eac}_*.cubemap_to_* on zink,
which reach the path now that zink colour images are compressed.
g17p-vulkan-compressed-layer-copy copies R11 EAC cube faces and 3D slices
into a compressed RG32F mip chain and checks every block by readback.
With --shim it runs under the no-op DRM shim as the
hk-g17p-compressed-layer-copy test, which fails without this change.
Each vkCmdBlitImage into a compressed G17P image records a meta render pass. With glmark2 terrain on zink, 46 such blits per frame (its mipmap generation) took the frame from 1.14M to 3.42M user-mode instructions under the G17P no-op DRM shim. Three costs that every meta operation or draw pays: - A driver-internal image view made only to be sampled, as meta operations make for their sources, packs only its sampled descriptors, not the storage, attachment and end-of-tile ones it never uses. - Push descriptor sets are uploaded, and saved and restored around meta operations, for the bytes their layout uses rather than all 3 KiB. - The two G17P mesh diagnostics are looked up only for G17P mesh draws, not on every vertex-state publication, and the zero-colour release diagnostic once, not for every background or end-of-tile program. Terrain with its blits as render passes goes from 3.42M to 2.74M instructions per frame. The descriptors that are packed, and the data the GPU reads, are unchanged.
A linear vkCmdBlitImage into a compressed G17P image is a render pass, so a mip chain is one render pass per level, each waiting for the level before it. On G17P a glGenerateMipmap of a 1920x1080 RGBA8 render target with compressed levels took 1.0-1.4 ms against 0.41-0.44 ms uncompressed, and glmark2 terrain recorded 55 render passes per frame instead of 9. Blits of the shape the uncompressed compute path takes (RGBA8 or BGRA8 UNORM, 2D, one layer, a 1x, 2x or 2x+1 downsample) into or out of a compressed image now take one dispatch per region. The source level is read through the texture unit, which decodes any tile state. The destination texels are written raw in the GPU-tiled layout, by invocations laid out in Morton order so that each group of 32 writes 128 contiguous bytes. When the destination level is compressed, which needs a blit covering the whole level, each of its 16x16 metadata tiles is set to the uncompressed mode, the state libagx_decompress leaves a tile in on AGX2; libagx_fast_clear writes G17P metadata words the same way with the solid mode. The arithmetic is libagx_mipmap_unorm8x4_odd's, which reproduces the linear blit. g17p-vulkan-compressed-mip-blit generates compressed mip chains (even, odd, wide, tall, BGRA, 4K), reads every level back and compares it bit for bit with the filter computed on the CPU, loads and stores a generated level in a render pass, and blits a compressed level into a plain image. It passes on G17P hardware, where the copy-and-blit CTS blit cases for these formats also match base (340 pass, 136 not supported). Under the no-op DRM shim it runs as hk-g17p-compressed-mip-blit, which fails if a blit chain records a render pass. Its --bench mode times whole chains holding a gradient, the gradient with noise, or noise, on compressed and plain images, and --grid single levels each way hk can generate them. hk_g17p_metadata_grid checks the metadata indexing against libagx_fast_clear's and against the metadata AIL allocates per level.
…er pass The compute downsample avoids a render pass's fixed cost but writes the level raw, and on G17P raw compute stores are slower than PBE stores even where compression saves nothing. Each level blitted repeatedly, each blit waiting for the one before as in a chain, holding a gradient / the gradient with noise / noise (g17p-vulkan-compressed-mip-blit --grid on G17P hardware), in ms per level: level compute render pass 2048x2048 1.316 / 1.514 / 1.934 0.236 / 0.761 / 1.561 960x540 0.144 / 0.148 / 0.179 0.046 / 0.071 / 0.124 640x360 0.066 / 0.069 / 0.084 0.045 / 0.044 / 0.061 480x270 0.040 / 0.043 / 0.051 0.049 / 0.043 / 0.047 256x256 0.022 / 0.023 / 0.029 0.045 / 0.043 / 0.047 A render pass costs about 0.04 ms whatever the level up to 640x360; compute costs 0.26-0.33 ns per texel. They cross between 480x270 (129,600 texels, compute faster for smooth content, even for the noisy gradient, slower by 7% for noise) and 640x360 (230,400, the render pass faster for every content): at about 148K, 132K and 115K texels for the three contents. So compressed levels of 2^17 (131,072) texels or more take the render pass, and the rest of the chain stays in compute. The render pass also leaves those levels compressed for what samples them. Scenes on G17P (zink, glmark2), base / compute for every level / render pass from 2^20 texels / from 2^18: refract 1080p 264-273 / 375-378 / 489 / 520-523, refract 4K 76-78 / 121-123 / 213-214 / 218-219, terrain 1080p 174-182 / 204-208 / 204-206 / 222, terrain 4K 49-51 / 61-63 / 66-67 / 68. glGenerateMipmap of a 3840x2160 target took 1.54-1.77 ms on base, 0.38-0.48 ms from 2^18; of 1920x1080, 0.46-0.49 and 0.17-0.22 ms. Between 2^18 and 2^17 only levels such as 640x360 change, which the per-level data puts in the render pass. The shim test expects a render pass for exactly the levels at or above the threshold, and hk_g17p_metadata_grid checks the split for common chains.
DjDeveloperr
force-pushed
the
aurora/g17p-compressed-render-targets-20261022
branch
from
October 22, 2026 23:07
66f4cbf to
9d73df9
Compare
Author
|
Rebased onto aurora-wip c363804; no conflicts. The one zink copy_image case that passed only on retry during the CTS run ( |
This was referenced Oct 23, 2026
RyanTheTide
deleted the
aurora/g17p-compressed-render-targets-20261022
branch
October 25, 2026 05:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This series compresses G17P colour render targets in the places that were still uncompressed, and fixes what that exposed. It is stacked on the two test-fix commits from the RT-gating PR.
M1/M2 (AGX2) code paths are unchanged.
Hardware results (Neo A18 Pro, against aurora-wip dde4825, both run orders):
No scene regressed.
Correctness: