asahi: Fix nonmipmapped array textures

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: 6ff75da8aa ("ail: Introduce image layout module")
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18380>
This commit is contained in:
Alyssa Rosenzweig 2022-09-02 22:39:07 -04:00 committed by Marge Bot
parent a41d732784
commit 4442be1155
2 changed files with 18 additions and 1 deletions

View file

@ -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));

View file

@ -24,6 +24,23 @@
#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 = {