From 344ec4258731ecc52f9803c338be1ded08fedcd3 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 7 Jan 2024 12:08:43 -0400 Subject: [PATCH] asahi: add missing tib alignment check + unit test replicating issue. Fixes arb_sample_shading-builtin-gl-sample-mask-mrt-alpha-to-coverage Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/lib/agx_tilebuffer.c | 6 +++--- src/asahi/lib/tests/test-tilebuffer.cpp | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/asahi/lib/agx_tilebuffer.c b/src/asahi/lib/agx_tilebuffer.c index 11dca587ae7..34a55e659b8 100644 --- a/src/asahi/lib/agx_tilebuffer.c +++ b/src/asahi/lib/agx_tilebuffer.c @@ -91,9 +91,9 @@ agx_build_tilebuffer_layout(enum pipe_format *formats, uint8_t nr_cbufs, * TODO: Suboptimal, we might be able to reorder render targets to * avoid fragmentation causing spilling. */ - bool fits = - (new_offset_B <= MAX_BYTES_PER_SAMPLE) && - (new_offset_B * MIN_TILE_SIZE_PX * nr_samples) <= MAX_BYTES_PER_TILE; + bool fits = (new_offset_B <= MAX_BYTES_PER_SAMPLE) && + (ALIGN_POT(new_offset_B, 8) * MIN_TILE_SIZE_PX * + nr_samples) <= MAX_BYTES_PER_TILE; if (fits) { tib._offset_B[rt] = offset_B; diff --git a/src/asahi/lib/tests/test-tilebuffer.cpp b/src/asahi/lib/tests/test-tilebuffer.cpp index 81b8db162c4..905db02215b 100644 --- a/src/asahi/lib/tests/test-tilebuffer.cpp +++ b/src/asahi/lib/tests/test-tilebuffer.cpp @@ -128,7 +128,30 @@ struct test tests[] = { .tile_size = { 32, 32 }, }, 8192 - } + }, + { + "MRT test that requires spilling to consider alignment requirements", + 4, + { + PIPE_FORMAT_R32_FLOAT, + PIPE_FORMAT_R32_FLOAT, + PIPE_FORMAT_R32_FLOAT, + PIPE_FORMAT_R32_FLOAT, + PIPE_FORMAT_R32_FLOAT, + PIPE_FORMAT_R32_FLOAT, + PIPE_FORMAT_R32_FLOAT, + PIPE_FORMAT_R32_FLOAT, + }, + { + .spilled = { false, false, false, false, false, false, true, true }, + ._offset_B = { 0, 4, 8, 12, 16, 20, 0, 0}, + .sample_size_B = 24, + .nr_samples = 4, + .tile_size = { 16, 16 }, + }, + 24576 + }, + }; /* clang-format on */