ail: Add MSAA tests

This tests the following matrix:
- Format: RGBA8Unorm, RGBA16Unorm, RGBA32Float
- Samples: 2 or 4
- Layers: 1 or 2
- Width: Interesting values 1..4097
- Height: Interesting values 1..4097

Compression is based on the dimensions (that is, everything that can be
compressed is). This test compares both the total texture size and the
compression metadata offset.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22971>
This commit is contained in:
Asahi Lina 2023-05-10 17:31:43 +09:00 committed by Marge Bot
parent e918509284
commit 0a398b0ef9
2 changed files with 14751 additions and 0 deletions

File diff suppressed because it is too large Load diff

View file

@ -29,6 +29,16 @@ struct miptest {
uint32_t offsets[16];
};
struct msaatest {
enum pipe_format format;
uint32_t width, height, depth;
uint8_t levels;
uint8_t samples;
bool is_compressed;
uint32_t meta_offset;
uint32_t size;
};
static struct sizetest comptests[] = {
#include "comp-twiddled.txt"
};
@ -41,6 +51,10 @@ static struct miptest miptests[] = {
#include "miptree.txt"
};
static struct msaatest msaatests[] = {
#include "msaa.txt"
};
TEST(Generated, CompTwiddled)
{
for (unsigned i = 0; i < ARRAY_SIZE(comptests); ++i) {
@ -117,3 +131,40 @@ TEST(Generated, Miptree2D)
}
}
}
TEST(Generated, MSAA)
{
for (unsigned i = 0; i < ARRAY_SIZE(msaatests); ++i) {
struct msaatest test = msaatests[i];
struct ail_layout layout = {
.width_px = test.width,
.height_px = test.height,
.depth_px = test.depth,
.sample_count_sa = test.samples,
.levels = test.levels,
.tiling = test.is_compressed ? AIL_TILING_TWIDDLED_COMPRESSED
: AIL_TILING_TWIDDLED,
.format = test.format,
};
ail_make_miptree(&layout);
EXPECT_EQ(layout.size_B, test.size)
<< test.width << "x" << test.height << "x" << test.depth << " "
<< (int)test.levels << "L " << (int)test.samples << "S "
<< util_format_short_name(test.format)
<< (test.is_compressed ? " " : " un")
<< "compressed texture has wrong allocation size, off by "
<< ((int)layout.size_B - (int)test.size);
if (test.is_compressed) {
EXPECT_EQ(layout.metadata_offset_B, test.meta_offset)
<< test.width << "x" << test.height << "x" << test.depth << " "
<< (int)test.levels << "L " << (int)test.samples << "S "
<< util_format_short_name(test.format)
<< "compressed texture has wrong metadata offset size, off by "
<< ((int)layout.metadata_offset_B - (int)test.meta_offset);
}
}
}