diff --git a/src/asahi/layout/layout.c b/src/asahi/layout/layout.c index 500b0b75f4d..227b2d17910 100644 --- a/src/asahi/layout/layout.c +++ b/src/asahi/layout/layout.c @@ -101,7 +101,7 @@ ail_initialize_twiddled(struct ail_layout *layout) /* First allocate the large miptree. All tiles in the large miptree are of * size tilesize_el and have their dimensions given by stx/sty/sarea. */ - for (unsigned l = 0; l < pot_level; ++l) { + for (unsigned l = 0; l < MIN2(pot_level, layout->levels); ++l) { unsigned tiles = (sarea_tiles >> (2 * l)); bool pad_left = (stx_tiles & BITFIELD_MASK(l)); diff --git a/src/asahi/layout/tests/test-layout.cpp b/src/asahi/layout/tests/test-layout.cpp index 2d2d2740bb9..9c9e4e45e58 100644 --- a/src/asahi/layout/tests/test-layout.cpp +++ b/src/asahi/layout/tests/test-layout.cpp @@ -24,6 +24,23 @@ #include #include "layout.h" +TEST(Cubemap, Nonmipmapped) +{ + struct ail_layout layout = { + .width_px = 512, + .height_px = 512, + .depth_px = 6, + .levels = 1, + .tiling = AIL_TILING_TWIDDLED, + .format = PIPE_FORMAT_R8G8B8A8_UNORM, + }; + + ail_make_miptree(&layout); + + EXPECT_EQ(layout.layer_stride_B, ALIGN_POT(512 * 512 * 4, 0x4000)); + EXPECT_EQ(layout.size_B, ALIGN_POT(512 * 512 * 4 * 6, 0x4000)); +} + TEST(Miptree, SmokeTestBuffer) { struct ail_layout layout = {