Skip to content
Closed
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
9 changes: 5 additions & 4 deletions src/asahi/vulkan/hk_cmd_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -3769,10 +3769,11 @@ hk_begin_rendering(VkCommandBuffer commandBuffer,

perf_debug(cmd, "Decompressing in-place");

/* libagx_decompress has no G17P binary. G17P only compresses
* 1-8 byte single-sample targets, which cannot spill (8 x 8 B
* fit the 120 B/sample tilebuffer), so this is unreachable;
* fail closed with a diagnostic rather than a NULL program. */
/* libagx_decompress has no G17P binary. G17P admits only
* single-sample colour attachments of at most 8 bytes, so a
* pass containing one fits even with seven 16-byte targets.
* Compressed MSAA images are for transfer/sampling use only.
* Keep the guard if allocation policy ever admits more. */
if (dev->dev.chip == AGX_CHIP_G17P) {
mesa_loge_once("G17P: spilled render pass with a compressed "
"attachment (%s) is unsupported",
Expand Down
8 changes: 6 additions & 2 deletions src/asahi/vulkan/hk_g17p_compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@

/* G17P lossless compression policy. Admitted images use texture reads and
* PBE/ZLS writes or metadata fast clears. Storage and host access stay
* excluded. Colour formats are bounded to 8 bytes per sample, so compressed
* single-sample attachments cannot spill the 120-byte tilebuffer.
* excluded. Colour formats are bounded to 8 bytes per sample, so a
* single-sample pass containing one fits the 120-byte tilebuffer even with
* seven other 16-byte attachments.
*
* Layered colour allocations currently use one level: the compressed PBE's
* secondary-view stride aliases its mip fields. Keep the existing ordinary
* 2D mip path separate until layered mip stores can be represented.
* Multisample colour images are admitted for transfer/sampling use only.
* Application colour attachments may spill at 2x/4x, which requires an
* in-place decompression path before raw eMRT stores. G17P has no such kernel.
* A format's own footprint cannot prove safety: other attachments, a stored
* LOAD attachment or multiview can force the pass to spill. Keep this an
* allocation decision, including images first used in a non-spilling pass.
* Depth/stencil has independent ZLS data and metadata layer strides and does
* not spill; it remains limited to one level.
*
Expand Down
14 changes: 14 additions & 0 deletions src/asahi/vulkan/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,20 @@ if with_tests
suite : ['asahi'],
)

test(
'hk_g17p_msaa_spill',
executable(
'hk_g17p_msaa_spill_test',
files('tests/test-hk-g17p-msaa-spill.c'),
include_directories : [inc_include, inc_src, inc_asahi],
dependencies : [idep_mesautil, idep_vulkan_util],
link_with : [libasahi_lib, libasahi_layout],
gnu_symbol_visibility : 'hidden',
),
timeout : 180,
suite : ['asahi'],
)

test(
'hk_g17p_metadata_grid',
executable(
Expand Down
43 changes: 43 additions & 0 deletions src/asahi/vulkan/tests/g17p-msaa-spill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# G17P colour MSAA spill coverage

Colour MSAA render attachments remain plain. An image can be attached beside
other formats in any later render pass, so an allocation rule based on that
image's footprint alone cannot establish that its passes never spill.

The current eMRT preparation path converts every colour attachment of a spilling
pass to raw storage. G17P has no in-place decompression kernel. Enabling compressed
PBE writes does not supply that conversion. Compression admission must remain
closed until either that conversion or compression-preserving eMRT access is
implemented, including all samples, layers, metadata and ordering.

Run `meson test -C build hk_g17p_msaa_spill hk_g17p_compression` with tests enabled.
The spill test calls the production allocator. It discovers every colour-renderable
AIL format's tilebuffer size and alignment, including a superset of Vulkan's
padded/scaled formats. It enumerates all stable-sorted sequences of those
footprints for zero through eight attachments at 1x, 2x and 4x, both layered and
non-layered. Orders within equal alignments are kept. Permutations across different
alignments and holes only rename slots after the allocator's stable sort, so they
have the same spill outcome. Explicit witnesses also move a small target through
every slot.

Both allocator limits used by the driver are covered: the normal imageblock and,
for MSAA, the eight-byte limit for stored LOAD attachments or multiview. A footprint
is marked compressed if any admitted Vulkan colour format uses it. Every spilling
layout must contain no compressed colour attachment, including resident targets,
because render-pass preparation considers all its attachments. These are CPU
policy/allocator checks. They do not prove GPU execution of eMRT.

The same executable can inspect individual layouts without a GPU. For example:

```sh
build/src/asahi/vulkan/hk_g17p_msaa_spill_test --probe 2 normal plain \
PIPE_FORMAT_R32G32B32A32_FLOAT PIPE_FORMAT_R32G32B32A32_FLOAT \
PIPE_FORMAT_R32G32B32A32_FLOAT PIPE_FORMAT_R32G32B32A32_FLOAT \
PIPE_FORMAT_R32G32B32A32_FLOAT PIPE_FORMAT_R32G32B32A32_FLOAT \
PIPE_FORMAT_R32G32B32A32_FLOAT PIPE_FORMAT_R8G8B8A8_UNORM
```

Use `normal`, `reload` or `multiview` for the pass mode and `plain` or `layered`
for its layer shape. `reload` means a LOAD attachment that is also stored.
`PIPE_FORMAT_NONE` represents an unused attachment slot. The output lists tile
geometry and a spill bit for each logical slot. Invalid arguments return status 2.
38 changes: 38 additions & 0 deletions src/asahi/vulkan/tests/test-hk-g17p-compression.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,43 @@ check_shape(VkFormat format, bool is_depth)
CHECK(!ELIGIBLE(i));
}

/* Compression is chosen for the image's whole lifetime. Its first render
* pass, attachment slot and neighbouring formats are unknown at allocation.
* Cover every admitted colour format, including the smallest ones that can
* spill next to wide targets, and input/transient attachment combinations.
*/
static void
check_colour_msaa_spill_policy(void)
{
for (unsigned f = 1; f <= VK_FORMAT_ASTC_12x12_SRGB_BLOCK; ++f) {
if (!hk_g17p_compression_color_format((VkFormat)f))
continue;

for (unsigned samples = 1; samples <= 4; samples *= 2) {
for (unsigned layers = 1; layers <= 4; layers *= 4) {
VkImageCreateInfo i = image((VkFormat)f, 64, 64, 1,
VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
i.samples = (VkSampleCountFlagBits)samples;
i.arrayLayers = layers;
CHECK(ELIGIBLE(i));
for (unsigned mask = 0; mask < 4; ++mask) {
VkImageCreateInfo attachment = i;
attachment.usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
if (mask & 1)
attachment.usage |= VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
if (mask & 2)
attachment.usage |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
CHECK(ELIGIBLE(attachment) == (samples == 1));
attachment.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT |
VK_IMAGE_CREATE_EXTENDED_USAGE_BIT;
CHECK(ELIGIBLE(attachment) == (samples == 1));
}
}
}
}
}

static void
check_layered_and_msaa(void)
{
Expand Down Expand Up @@ -535,6 +572,7 @@ main(void)
check_shape(VK_FORMAT_D16_UNORM, true);
check_shape(VK_FORMAT_D32_SFLOAT_S8_UINT, true);
check_layered_and_msaa();
check_colour_msaa_spill_policy();
check_minecraft();
check_zink();
check_shared();
Expand Down
Loading
Loading