mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-02 01:28:07 +02:00
asahi: Add group tests
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18813>
This commit is contained in:
parent
8b464f4c59
commit
9061e960b2
1 changed files with 48 additions and 0 deletions
|
|
@ -45,6 +45,27 @@ const struct {
|
|||
{ INFINITY, 0x380, true },
|
||||
};
|
||||
|
||||
const struct {
|
||||
uint32_t group_size;
|
||||
uint32_t length;
|
||||
uint32_t value;
|
||||
uint32_t encoded;
|
||||
} group_cases[] = {
|
||||
/* Groups of 16 in a 4-bit word */
|
||||
{ 16, 4, 0, 0x1 },
|
||||
{ 16, 4, 1, 0x1 },
|
||||
{ 16, 4, 16, 0x1 },
|
||||
{ 16, 4, 17, 0x2 },
|
||||
{ 16, 4, 31, 0x2 },
|
||||
{ 16, 4, 32, 0x2 },
|
||||
{ 16, 4, 33, 0x3 },
|
||||
{ 16, 4, 239, 0xF },
|
||||
{ 16, 4, 240, 0xF },
|
||||
{ 16, 4, 241, 0x0 },
|
||||
{ 16, 4, 255, 0x0 },
|
||||
{ 16, 4, 256, 0x0 },
|
||||
};
|
||||
|
||||
TEST(LODClamp, Encode)
|
||||
{
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(lod_cases); ++i)
|
||||
|
|
@ -63,3 +84,30 @@ TEST(LODClamp, Decode)
|
|||
ASSERT_EQ(__gen_unpack_lod(cl, 0, 10), lod_cases[i].f);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Groups, Encode)
|
||||
{
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(group_cases); ++i) {
|
||||
ASSERT_EQ(__gen_to_groups(group_cases[i].value,
|
||||
group_cases[i].group_size,
|
||||
group_cases[i].length),
|
||||
group_cases[i].encoded);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Groups, Decode)
|
||||
{
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(group_cases); ++i) {
|
||||
unsigned expected = ALIGN_POT(group_cases[i].value,
|
||||
group_cases[i].group_size);
|
||||
|
||||
/* Clamp to minimum encodable */
|
||||
if (group_cases[i].value == 0)
|
||||
expected = group_cases[i].group_size;
|
||||
|
||||
ASSERT_EQ(__gen_from_groups(group_cases[i].encoded,
|
||||
group_cases[i].group_size,
|
||||
group_cases[i].length),
|
||||
expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue