isl/tests: add TileX memcpy testing

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31469>
This commit is contained in:
Lionel Landwerlin 2024-03-29 00:24:36 +02:00 committed by Marge Bot
parent 2994eca831
commit 05b641becc

View file

@ -108,9 +108,30 @@ uint8_t *linear_to_tile4_swizzle(const uint8_t * base_addr, uint32_t pitch, uint
return (uint8_t *) (base_addr + tiled_off);
}
uint8_t *linear_to_tileX_swizzle(const uint8_t * base_addr, uint32_t pitch, uint32_t x_B, uint32_t y_px)
{
const uint32_t cu = 9, cv = 3;
const uint32_t tile_id = (y_px >> cv) * (pitch >> cu) + (x_B >> cu);
/* The table below represents the mapping from coordinate (x_B, y_px) to
* byte offset in a 512x8px 1Bpp image:
*
* Bit ind : 11 10 9 8 7 6 5 4 3 2 1 0
* Tile-X : v2 v1 v0 u8 u7 u6 u5 u4 u3 u2 u1 u0
*/
uint32_t tiled_off;
tiled_off = tile_id * 4096 |
swizzle_bitops(x_B, 9, 0, 0) |
swizzle_bitops(y_px, 3, 0, 9);
return (uint8_t *) (base_addr + tiled_off);
}
struct tile_swizzle_ops swizzle_opers[] = {
{ISL_TILING_Y0, linear_to_tileY_swizzle},
{ISL_TILING_4, linear_to_tile4_swizzle},
{ISL_TILING_X, linear_to_tileX_swizzle},
};
class tileTFixture: public ::testing::Test {
@ -149,6 +170,11 @@ class tile4Fixture : public tileTFixture,
int, int>>
{};
class tileXFixture : public tileTFixture,
public ::testing::WithParamInterface<std::tuple<int, int,
int, int>>
{};
void tileTFixture::test_setup(TILE_CONV convert,
enum isl_tiling tiling_fmt,
enum isl_format format,
@ -326,6 +352,25 @@ TEST_P(tile4Fixture, tiletolin)
run_test(x1, x2, y1, y2);
}
TEST_P(tileXFixture, lintotile)
{
auto [x1, x2, y1, y2] = GetParam();
test_setup(LIN_TO_TILE, ISL_TILING_X, IMAGE_FORMAT, x2, y2);
if (print_results)
printf("Coordinates: x1=%d x2=%d y1=%d y2=%d \n", x1, x2, y1, y2);
run_test(x1, x2, y1, y2);
}
TEST_P(tileXFixture, tiletolin)
{
auto [x1, x2, y1, y2] = GetParam();
test_setup(TILE_TO_LIN, ISL_TILING_X, IMAGE_FORMAT, x2, y2);
if (print_results)
printf("Coordinates: x1=%d x2=%d y1=%d y2=%d \n", x1, x2, y1, y2);
run_test(x1, x2, y1, y2);
}
INSTANTIATE_TEST_SUITE_P(tileY, tileYFixture, testing::Values(TILE_COORDINATES));
INSTANTIATE_TEST_SUITE_P(tile4, tile4Fixture, testing::Values(TILE_COORDINATES));
INSTANTIATE_TEST_SUITE_P(tileX, tileXFixture, testing::Values(TILE_COORDINATES));