pot_level can be greater than the number of levels actually included --
don't overallocate. Fix the issue and add a representative unit test.
Fixes:
dEQP-GLES2.functional.texture.size.cube.512x512_rgb888
Fixes:
6ff75da8aa4 ("ail: Introduce image layout module")
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18380>
/* 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));
#include <gtest/gtest.h>
#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 = {