Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/asahi/lib/agx_chip_caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,28 @@ enum agx_chip_cap {
* fragment epilog encoding (skipping empty-mask targets and encoding
* per-format partial channel masks natively). Verified on G18G. */
AGX_CAP_NATIVE_MIXED_EPILOG = 1u << 17,

/* HAL200/Gen9 lossless colour and depth/stencil compression in Borealis:
* single-sample 1-8B colour (2D, arrays, cubemaps, single-mip 3D), 16B
* colour (single-sample 2D, arrays, cubemaps), single-level 1x/2x/4x depth
* and 1x stencil, shared DRM_FORMAT_MOD_APPLE_GPU_TILED_COMPRESSED colour
* images, in-place spill decompression via libagx_agx3_decompress, and Gen9
* compressed compute mip blits. Enabled across native HAL200 AGX3B parts
* (G16G and G17P), which share the Gen9 PBE/texture/ZLS/AIL metadata
* contract; off on G15* (M3, G15/RTKit 2419 CS generation), M5 HAL300
* (Gen10, gated separately), G18G, and AGX2. 2x/4x MSAA colour compression
* on these parts is gated separately by AGX_CAP_HAL200_MSAA_COLOR_COMPRESSION
* so a measurement on one AGX3B part does not imply the other. */
AGX_CAP_HAL200_LOSSLESS_COMPRESSION = 1u << 18,

/* HAL200/Gen9 lossless 2x/4x MSAA colour compression in Borealis: 1-8B
* colour attachments (including arrays, input attachments, multiview, and
* MRT spills decompressed in place by libagx_agx3_decompress). Qualified on
* G17P (A18 Pro, M4 Pro, M4 Max) by the --jobs 4 full-case resolve_image
* run; off on G16G until its remaining diff_layout_copy_before_resolving
* variants are triaged and qualified. Off on every chip without
* AGX_CAP_HAL200_LOSSLESS_COMPRESSION. */
AGX_CAP_HAL200_MSAA_COLOR_COMPRESSION = 1u << 19,
};

/* What the admitted AGX2 chips (G13G, G13X, G14G, G14X) share. */
Expand All @@ -139,7 +161,8 @@ enum agx_chip_cap {
AGX_CAP_TRI_MERGE_ACROSS_SIDE_EFFECTS | AGX_CAP_SPARSE_BINDING | \
AGX_CAP_SPARSE_RESIDENCY_3D | AGX_CAP_COALESCE_PURE_GLOBAL_WORKGROUPS | \
AGX_CAP_CDM_WAR_WEAK_BARRIER | AGX_CAP_GEN9_2D_COMPRESSION | \
AGX_CAP_MOD3_REG_BANK_RA)
AGX_CAP_MOD3_REG_BANK_RA | AGX_CAP_HAL200_LOSSLESS_COMPRESSION | \
AGX_CAP_HAL200_MSAA_COLOR_COMPRESSION)

/* What the M5 parts (G17G, G17S, G17C) share. */
#define AGX_CAPS_M5 \
Expand All @@ -166,7 +189,10 @@ enum agx_chip_cap {
X(G15C, AGX_CAPS_NATIVE, __VA_ARGS__) \
X(G15D, AGX_CAP_COOPERATIVE_MATRIX, __VA_ARGS__) \
X(G16P, AGX_CAP_COOPERATIVE_MATRIX, __VA_ARGS__) \
X(G16G, AGX_CAPS_NATIVE | AGX_CAP_NATIVE_PREAMBLE, __VA_ARGS__) \
X(G16G, \
AGX_CAPS_NATIVE | AGX_CAP_NATIVE_PREAMBLE | \
AGX_CAP_HAL200_LOSSLESS_COMPRESSION, \
__VA_ARGS__) \
X(G16S, AGX_CAP_COOPERATIVE_MATRIX, __VA_ARGS__) \
X(G16C, AGX_CAP_COOPERATIVE_MATRIX, __VA_ARGS__) \
X(G17P, AGX_CAPS_G17P, __VA_ARGS__) \
Expand Down
40 changes: 39 additions & 1 deletion src/asahi/lib/tests/test-chip-caps.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ static const unsigned all_caps =
AGX_CAP_COALESCE_PURE_GLOBAL_WORKGROUPS | AGX_CAP_CDM_WAR_WEAK_BARRIER |
AGX_CAP_GEN9_2D_COMPRESSION | AGX_CAP_MOD3_REG_BANK_RA |
AGX_CAP_GEN10_2D_COMPRESSION | AGX_CAP_SPARSE_BINDING |
AGX_CAP_ZLS_FULL_RENDER_BOUNDS | AGX_CAP_NATIVE_MIXED_EPILOG;
AGX_CAP_ZLS_FULL_RENDER_BOUNDS | AGX_CAP_NATIVE_MIXED_EPILOG |
AGX_CAP_HAL200_LOSSLESS_COMPRESSION | AGX_CAP_HAL200_MSAA_COLOR_COMPRESSION;
#undef CAP_BIT

/* Each chip of AGX_CHIPS has exactly one row, and the rows are in its
Expand Down Expand Up @@ -202,6 +203,41 @@ test_native_mixed_epilog(void)
}
}

/* AGX_CAP_HAL200_LOSSLESS_COMPRESSION is enabled across native HAL200 AGX3B
* parts (G16G and G17P) and off on G15* (M3), M5 HAL300 (Gen10), G18G, AGX2,
* and unadmitted parts. */
static void
test_hal200_lossless_compression(void)
{
for (unsigned i = 0; i <= AGX_CHIP_UNKNOWN; ++i) {
const enum agx_chip c = (enum agx_chip)i;
const bool expected = c == AGX_CHIP_G16G || c == AGX_CHIP_G17P;
CHECK_CHIP(agx_chip_has_cap(c, AGX_CAP_HAL200_LOSSLESS_COMPRESSION) ==
expected,
c);
CHECK_CHIP(agx_chip_has_cap(c, AGX_CAP_HAL200_LOSSLESS_COMPRESSION) ==
agx_chip_native_hal200(c),
c);
}
}

/* AGX_CAP_HAL200_MSAA_COLOR_COMPRESSION is enabled only on G17P: G16G shares
* the HAL200 PBE/texture/ZLS contract but its 1-8B 2x/4x MSAA colour variants
* are not qualified yet. */
static void
test_hal200_msaa_color_compression(void)
{
for (unsigned i = 0; i <= AGX_CHIP_UNKNOWN; ++i) {
const enum agx_chip c = (enum agx_chip)i;
CHECK_CHIP(agx_chip_has_cap(c, AGX_CAP_HAL200_MSAA_COLOR_COMPRESSION) ==
(c == AGX_CHIP_G17P),
c);
/* MSAA colour never enables without the base HAL200 cap. */
if (agx_chip_has_cap(c, AGX_CAP_HAL200_MSAA_COLOR_COMPRESSION))
CHECK_CHIP(agx_chip_has_cap(c, AGX_CAP_HAL200_LOSSLESS_COMPRESSION), c);
}
}

int
main(void)
{
Expand All @@ -215,6 +251,8 @@ main(void)
test_sparse_binding();
test_zls_full_render_bounds();
test_native_mixed_epilog();
test_hal200_lossless_compression();
test_hal200_msaa_color_compression();

if (failures) {
fprintf(stderr, "agx_chip_caps: %u of %u checks failed\n", failures,
Expand Down
3 changes: 2 additions & 1 deletion src/asahi/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ if with_tools.contains('drm-shim') and with_asahi_vk and with_tests
files('../gallium/drivers/asahi/tests/run-shim.py'),
libasahi_noop_drm_shim,
hal200_vulkan_msaa_depth_compression,
] + (chip == 'g17p' ? ['--expect-1x-compressed'] : []),
'--expect-1x-compressed',
],
env : [
'ASAHI_SHIM_CHIP=' + chip,
'VK_DRIVER_FILES=' + _dev_icd.full_path(),
Expand Down
53 changes: 50 additions & 3 deletions src/asahi/vulkan/hk_cmd_meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -2238,7 +2238,8 @@ hk_g17p_compressed_blit_supported(const struct hk_device *dev,
const struct hk_image *dst,
const VkBlitImageInfo2 *info)
{
if (dev->dev.chip != AGX_CHIP_G17P || info->regionCount == 0 ||
if (!agx_chip_has_cap(dev->dev.chip, AGX_CAP_HAL200_LOSSLESS_COMPRESSION) ||
info->regionCount == 0 ||
!(src->planes[0].layout.compressed || dst->planes[0].layout.compressed))
return false;

Expand All @@ -2263,7 +2264,7 @@ hk_g17p_compressed_blit_supported(const struct hk_device *dev,
if (ail_is_level_logically_compressed(&dst->planes[0].layout, level) &&
((uint32_t)region->dstOffsets[1].x != width ||
(uint32_t)region->dstOffsets[1].y != height ||
hk_g17p_mip_level_through_pbe(width, height)))
hk_mip_level_through_pbe(dev->dev.chip, width, height)))
return false;
}
return true;
Expand Down Expand Up @@ -3486,7 +3487,53 @@ hk_xfer_resolveimage2(VkCommandBuffer commandBuffer,

struct hk_meta_save save;
hk_meta_begin(cmd, &save, VK_PIPELINE_BIND_POINT_GRAPHICS);
vk_meta_resolve_image2(&cmd->vk, &dev->meta, pResolveImageInfo);
/* HAL200 writes a compressed colour array one layer at a time: the
* qualified BG/EOT contract is single-layer, so a layered render through
* the generic resolve path reaches a compressed source array's
* per-layer metadata through hardware stride derivation that is not
* reliable at --jobs 4 concurrency. hk_CmdCopyImage and
* hk_CmdBlitImage split 2D-array regions into per-slice passes on the
* same contract; apply the same split here so the generic resolve runs
* one layer at a time whenever either image is a compressed 2D
* array. */
if (agx_chip_native_agx3(dev->dev.chip) &&
src_image->vk.image_type == VK_IMAGE_TYPE_2D &&
dst_image->vk.image_type == VK_IMAGE_TYPE_2D &&
(src_layout->compressed || dst_layout->compressed)) {
for (uint32_t r = 0; r < pResolveImageInfo->regionCount; ++r) {
const VkImageResolve2 *region = &pResolveImageInfo->pRegions[r];
const uint32_t src_slices =
vk_image_subresource_layer_count(&src_image->vk,
&region->srcSubresource);
const uint32_t dst_slices =
vk_image_subresource_layer_count(&dst_image->vk,
&region->dstSubresource);

for (uint32_t slice = 0; slice < src_slices; ++slice) {
VkImageResolve2 one;
if (!hk_g17p_image_resolve_slice(
dev->dev.chip, src_image->vk.image_type,
dst_image->vk.image_type, src_slices, dst_slices,
region, slice, &one)) {
vk_command_buffer_set_error(&cmd->vk,
VK_ERROR_FEATURE_NOT_PRESENT);
break;
}

VkResolveImageInfo2 info = *pResolveImageInfo;
info.regionCount = 1;
info.pRegions = &one;
vk_meta_resolve_image2(&cmd->vk, &dev->meta, &info);
if (vk_command_buffer_has_error(&cmd->vk))
break;
}

if (vk_command_buffer_has_error(&cmd->vk))
break;
}
} else {
vk_meta_resolve_image2(&cmd->vk, &dev->meta, pResolveImageInfo);
}
hk_meta_end(cmd, &save, VK_PIPELINE_BIND_POINT_GRAPHICS);
}

Expand Down
5 changes: 3 additions & 2 deletions src/asahi/vulkan/hk_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "hk_buffer_view.h"
#include "hk_entrypoints.h"
#include "hk_g17p_compression.h"
#include "hk_image.h"
#include "hk_physical_device.h"

Expand Down Expand Up @@ -46,9 +47,9 @@ hk_modifier_features(const struct agx_device *dev, uint64_t mod,
if (!hk_can_compress_format(dev, vk_format))
return 0;

/* G17P and M5 share compressed images without storage or host-copy
/* HAL200 and M5 share compressed images without storage or host-copy
* access (hk_g17p_shared_compression_shape()). */
if (agx_chip_g17p_or_m5(dev->chip))
if (hk_chip_shared_compression_supported(dev->chip))
return props->optimalTilingFeatures &
~(VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT |
VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT |
Expand Down
Loading