panfrost: Make pan_layout.c panfrost_device agnostic
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Constantine Shablya <constantine.shablya@collabora.com> Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26698>
This commit is contained in:

committed by
Marge Bot

parent
f4f2b7492b
commit
387882d811
@@ -136,7 +136,7 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
|
||||
};
|
||||
|
||||
bool valid =
|
||||
pan_image_layout_init(dev, &rsc->image.layout, &explicit_layout);
|
||||
pan_image_layout_init(dev->arch, &rsc->image.layout, &explicit_layout);
|
||||
|
||||
if (!valid) {
|
||||
FREE(rsc);
|
||||
@@ -504,7 +504,8 @@ panfrost_resource_setup(struct panfrost_device *dev,
|
||||
.crc = panfrost_should_checksum(dev, pres),
|
||||
};
|
||||
|
||||
ASSERTED bool valid = pan_image_layout_init(dev, &pres->image.layout, NULL);
|
||||
ASSERTED bool valid =
|
||||
pan_image_layout_init(dev->arch, &pres->image.layout, NULL);
|
||||
assert(valid);
|
||||
}
|
||||
|
||||
|
@@ -205,13 +205,12 @@ pan_afbc_body_align(uint64_t modifier)
|
||||
}
|
||||
|
||||
static inline unsigned
|
||||
format_minimum_alignment(const struct panfrost_device *dev,
|
||||
enum pipe_format format, bool afbc)
|
||||
format_minimum_alignment(unsigned arch, enum pipe_format format, bool afbc)
|
||||
{
|
||||
if (afbc)
|
||||
return 16;
|
||||
|
||||
if (dev->arch < 7)
|
||||
if (arch < 7)
|
||||
return 64;
|
||||
|
||||
switch (format) {
|
||||
@@ -304,8 +303,7 @@ panfrost_texture_offset(const struct pan_image_layout *layout, unsigned level,
|
||||
}
|
||||
|
||||
bool
|
||||
pan_image_layout_init(const struct panfrost_device *dev,
|
||||
struct pan_image_layout *layout,
|
||||
pan_image_layout_init(unsigned arch, struct pan_image_layout *layout,
|
||||
const struct pan_image_explicit_layout *explicit_layout)
|
||||
{
|
||||
/* Explicit stride only work with non-mipmap, non-array, single-sample
|
||||
@@ -318,7 +316,7 @@ pan_image_layout_init(const struct panfrost_device *dev,
|
||||
return false;
|
||||
|
||||
bool afbc = drm_is_afbc(layout->modifier);
|
||||
int align_req = format_minimum_alignment(dev, layout->format, afbc);
|
||||
int align_req = format_minimum_alignment(arch, layout->format, afbc);
|
||||
|
||||
/* Mandate alignment */
|
||||
if (explicit_layout) {
|
||||
@@ -326,7 +324,7 @@ pan_image_layout_init(const struct panfrost_device *dev,
|
||||
|
||||
int align_mask = align_req - 1;
|
||||
|
||||
if (dev->arch >= 7) {
|
||||
if (arch >= 7) {
|
||||
rejected = ((explicit_layout->offset & align_mask) ||
|
||||
(explicit_layout->row_stride & align_mask));
|
||||
} else {
|
||||
@@ -386,7 +384,7 @@ pan_image_layout_init(const struct panfrost_device *dev,
|
||||
unsigned row_stride = fmt_blocksize * effective_width * block_size.height;
|
||||
|
||||
/* On v7+ row_stride and offset alignment requirement are equal */
|
||||
if (dev->arch >= 7) {
|
||||
if (arch >= 7) {
|
||||
row_stride = ALIGN_POT(row_stride, align_req);
|
||||
}
|
||||
|
||||
|
@@ -36,7 +36,6 @@
|
||||
#include "genxml/gen_macros.h"
|
||||
#include "util/format/u_format.h"
|
||||
#include "pan_bo.h"
|
||||
#include "pan_device.h"
|
||||
#include "pan_format.h"
|
||||
#include "pan_util.h"
|
||||
|
||||
@@ -309,8 +308,7 @@ struct pan_image_explicit_layout {
|
||||
};
|
||||
|
||||
bool
|
||||
pan_image_layout_init(const struct panfrost_device *dev,
|
||||
struct pan_image_layout *layout,
|
||||
pan_image_layout_init(unsigned arch, struct pan_image_layout *layout,
|
||||
const struct pan_image_explicit_layout *explicit_layout);
|
||||
|
||||
unsigned panfrost_get_legacy_stride(const struct pan_image_layout *layout,
|
||||
|
@@ -267,8 +267,6 @@ TEST(LegacyStride, FromLegacyAFBC)
|
||||
/* dEQP-GLES3.functional.texture.format.compressed.etc1_2d_pot */
|
||||
TEST(Layout, ImplicitLayoutInterleavedETC2)
|
||||
{
|
||||
struct panfrost_device dev = {0};
|
||||
|
||||
struct pan_image_layout l = {
|
||||
.modifier = DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED,
|
||||
.format = PIPE_FORMAT_ETC2_RGB8,
|
||||
@@ -282,7 +280,7 @@ TEST(Layout, ImplicitLayoutInterleavedETC2)
|
||||
unsigned offsets[9] = {0, 8192, 10240, 10752, 10880,
|
||||
11008, 11136, 11264, 11392};
|
||||
|
||||
ASSERT_TRUE(pan_image_layout_init(&dev, &l, NULL));
|
||||
ASSERT_TRUE(pan_image_layout_init(0, &l, NULL));
|
||||
|
||||
for (unsigned i = 0; i < 8; ++i) {
|
||||
unsigned size = (offsets[i + 1] - offsets[i]);
|
||||
@@ -297,8 +295,6 @@ TEST(Layout, ImplicitLayoutInterleavedETC2)
|
||||
|
||||
TEST(Layout, ImplicitLayoutInterleavedASTC5x5)
|
||||
{
|
||||
struct panfrost_device dev = {0};
|
||||
|
||||
struct pan_image_layout l = {
|
||||
.modifier = DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED,
|
||||
.format = PIPE_FORMAT_ASTC_5x5,
|
||||
@@ -309,7 +305,7 @@ TEST(Layout, ImplicitLayoutInterleavedASTC5x5)
|
||||
.dim = MALI_TEXTURE_DIMENSION_2D,
|
||||
.nr_slices = 1};
|
||||
|
||||
ASSERT_TRUE(pan_image_layout_init(&dev, &l, NULL));
|
||||
ASSERT_TRUE(pan_image_layout_init(0, &l, NULL));
|
||||
|
||||
/* The image is 50x50 pixels, with 5x5 blocks. So it is a 10x10 grid of ASTC
|
||||
* blocks. 4x4 tiles of ASTC blocks are u-interleaved, so we have to round up
|
||||
@@ -325,8 +321,6 @@ TEST(Layout, ImplicitLayoutInterleavedASTC5x5)
|
||||
|
||||
TEST(Layout, ImplicitLayoutLinearASTC5x5)
|
||||
{
|
||||
struct panfrost_device dev = {0};
|
||||
|
||||
struct pan_image_layout l = {.modifier = DRM_FORMAT_MOD_LINEAR,
|
||||
.format = PIPE_FORMAT_ASTC_5x5,
|
||||
.width = 50,
|
||||
@@ -336,7 +330,7 @@ TEST(Layout, ImplicitLayoutLinearASTC5x5)
|
||||
.dim = MALI_TEXTURE_DIMENSION_2D,
|
||||
.nr_slices = 1};
|
||||
|
||||
ASSERT_TRUE(pan_image_layout_init(&dev, &l, NULL));
|
||||
ASSERT_TRUE(pan_image_layout_init(0, &l, NULL));
|
||||
|
||||
/* The image is 50x50 pixels, with 5x5 blocks. So it is a 10x10 grid of ASTC
|
||||
* blocks. Each ASTC block is 16 bytes, so the row stride is 160 bytes,
|
||||
@@ -352,8 +346,6 @@ TEST(Layout, ImplicitLayoutLinearASTC5x5)
|
||||
/* dEQP-GLES3.functional.texture.format.unsized.rgba_unsigned_byte_3d_pot */
|
||||
TEST(AFBCLayout, Linear3D)
|
||||
{
|
||||
struct panfrost_device dev = {0};
|
||||
|
||||
uint64_t modifier = DRM_FORMAT_MOD_ARM_AFBC(
|
||||
AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 | AFBC_FORMAT_MOD_SPARSE);
|
||||
|
||||
@@ -366,7 +358,7 @@ TEST(AFBCLayout, Linear3D)
|
||||
.dim = MALI_TEXTURE_DIMENSION_3D,
|
||||
.nr_slices = 1};
|
||||
|
||||
ASSERT_TRUE(pan_image_layout_init(&dev, &l, NULL));
|
||||
ASSERT_TRUE(pan_image_layout_init(0, &l, NULL));
|
||||
|
||||
/* AFBC Surface stride is bytes between consecutive surface headers, which is
|
||||
* the header size since this is a 3D texture. At superblock size 16x16, the
|
||||
@@ -392,8 +384,6 @@ TEST(AFBCLayout, Linear3D)
|
||||
|
||||
TEST(AFBCLayout, Tiled16x16)
|
||||
{
|
||||
struct panfrost_device dev = {0};
|
||||
|
||||
uint64_t modifier =
|
||||
DRM_FORMAT_MOD_ARM_AFBC(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 |
|
||||
AFBC_FORMAT_MOD_TILED | AFBC_FORMAT_MOD_SPARSE);
|
||||
@@ -407,7 +397,7 @@ TEST(AFBCLayout, Tiled16x16)
|
||||
.dim = MALI_TEXTURE_DIMENSION_2D,
|
||||
.nr_slices = 1};
|
||||
|
||||
ASSERT_TRUE(pan_image_layout_init(&dev, &l, NULL));
|
||||
ASSERT_TRUE(pan_image_layout_init(0, &l, NULL));
|
||||
|
||||
/* The image is 917x417. Superblocks are 16x16, so there are 58x27
|
||||
* superblocks. Superblocks are grouped into 8x8 tiles, so there are 8x4
|
||||
@@ -431,8 +421,6 @@ TEST(AFBCLayout, Tiled16x16)
|
||||
|
||||
TEST(AFBCLayout, Linear16x16Minimal)
|
||||
{
|
||||
struct panfrost_device dev = {0};
|
||||
|
||||
uint64_t modifier = DRM_FORMAT_MOD_ARM_AFBC(
|
||||
AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 | AFBC_FORMAT_MOD_SPARSE);
|
||||
|
||||
@@ -445,7 +433,7 @@ TEST(AFBCLayout, Linear16x16Minimal)
|
||||
.dim = MALI_TEXTURE_DIMENSION_2D,
|
||||
.nr_slices = 1};
|
||||
|
||||
ASSERT_TRUE(pan_image_layout_init(&dev, &l, NULL));
|
||||
ASSERT_TRUE(pan_image_layout_init(0, &l, NULL));
|
||||
|
||||
/* Image is 1x1 to test for correct alignment everywhere. */
|
||||
EXPECT_EQ(l.slices[0].offset, 0);
|
||||
@@ -458,8 +446,6 @@ TEST(AFBCLayout, Linear16x16Minimal)
|
||||
|
||||
TEST(AFBCLayout, Tiled16x16Minimal)
|
||||
{
|
||||
struct panfrost_device dev = {0};
|
||||
|
||||
uint64_t modifier =
|
||||
DRM_FORMAT_MOD_ARM_AFBC(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 |
|
||||
AFBC_FORMAT_MOD_TILED | AFBC_FORMAT_MOD_SPARSE);
|
||||
@@ -473,7 +459,7 @@ TEST(AFBCLayout, Tiled16x16Minimal)
|
||||
.dim = MALI_TEXTURE_DIMENSION_2D,
|
||||
.nr_slices = 1};
|
||||
|
||||
ASSERT_TRUE(pan_image_layout_init(&dev, &l, NULL));
|
||||
ASSERT_TRUE(pan_image_layout_init(0, &l, NULL));
|
||||
|
||||
/* Image is 1x1 to test for correct alignment everywhere. */
|
||||
EXPECT_EQ(l.slices[0].offset, 0);
|
||||
|
@@ -89,7 +89,7 @@ panvk_image_create(VkDevice _device, const VkImageCreateInfo *pCreateInfo,
|
||||
.nr_slices = image->vk.mip_levels,
|
||||
};
|
||||
|
||||
pan_image_layout_init(pdev, &image->pimage.layout, NULL);
|
||||
pan_image_layout_init(pdev->arch, &image->pimage.layout, NULL);
|
||||
|
||||
*pImage = panvk_image_to_handle(image);
|
||||
return VK_SUCCESS;
|
||||
|
Reference in New Issue
Block a user