summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/freedreno/fdl/fd5_layout.c121
-rw-r--r--src/freedreno/fdl/fd5_layout_test.c129
-rw-r--r--src/freedreno/fdl/fd6_layout.c438
-rw-r--r--src/freedreno/fdl/fd6_layout_test.c1171
-rw-r--r--src/freedreno/fdl/fd_layout_test.c159
-rw-r--r--src/freedreno/fdl/fd_layout_test.h36
-rw-r--r--src/freedreno/fdl/freedreno_layout.c50
-rw-r--r--src/freedreno/fdl/freedreno_layout.h183
8 files changed, 1180 insertions, 1107 deletions
diff --git a/src/freedreno/fdl/fd5_layout.c b/src/freedreno/fdl/fd5_layout.c
index 159773fff61..b2d26a40c72 100644
--- a/src/freedreno/fdl/fd5_layout.c
+++ b/src/freedreno/fdl/fd5_layout.c
@@ -30,76 +30,75 @@
#include "freedreno_layout.h"
void
-fdl5_layout(struct fdl_layout *layout,
- enum pipe_format format, uint32_t nr_samples,
- uint32_t width0, uint32_t height0, uint32_t depth0,
- uint32_t mip_levels, uint32_t array_size, bool is_3d)
+fdl5_layout(struct fdl_layout *layout, enum pipe_format format,
+ uint32_t nr_samples, uint32_t width0, uint32_t height0,
+ uint32_t depth0, uint32_t mip_levels, uint32_t array_size,
+ bool is_3d)
{
- assert(nr_samples > 0);
- layout->width0 = width0;
- layout->height0 = height0;
- layout->depth0 = depth0;
+ assert(nr_samples > 0);
+ layout->width0 = width0;
+ layout->height0 = height0;
+ layout->depth0 = depth0;
- layout->cpp = util_format_get_blocksize(format);
- layout->cpp *= nr_samples;
- layout->cpp_shift = ffs(layout->cpp) - 1;
+ layout->cpp = util_format_get_blocksize(format);
+ layout->cpp *= nr_samples;
+ layout->cpp_shift = ffs(layout->cpp) - 1;
- layout->format = format;
- layout->nr_samples = nr_samples;
- layout->layer_first = !is_3d;
+ layout->format = format;
+ layout->nr_samples = nr_samples;
+ layout->layer_first = !is_3d;
- uint32_t heightalign = layout->cpp == 1 ? 32 : 16;
- /* in layer_first layout, the level (slice) contains just one
- * layer (since in fact the layer contains the slices)
- */
- uint32_t layers_in_level = layout->layer_first ? 1 : array_size;
+ uint32_t heightalign = layout->cpp == 1 ? 32 : 16;
+ /* in layer_first layout, the level (slice) contains just one
+ * layer (since in fact the layer contains the slices)
+ */
+ uint32_t layers_in_level = layout->layer_first ? 1 : array_size;
- /* use 128 pixel alignment for cpp=1 and cpp=2 */
- if (layout->cpp < 4 && layout->tile_mode)
- fdl_set_pitchalign(layout, fdl_cpp_shift(layout) + 7);
- else
- fdl_set_pitchalign(layout, fdl_cpp_shift(layout) + 6);
+ /* use 128 pixel alignment for cpp=1 and cpp=2 */
+ if (layout->cpp < 4 && layout->tile_mode)
+ fdl_set_pitchalign(layout, fdl_cpp_shift(layout) + 7);
+ else
+ fdl_set_pitchalign(layout, fdl_cpp_shift(layout) + 6);
- for (uint32_t level = 0; level < mip_levels; level++) {
- struct fdl_slice *slice = &layout->slices[level];
- uint32_t tile_mode = fdl_tile_mode(layout, level);
- uint32_t pitch = fdl_pitch(layout, level);
- uint32_t nblocksy = util_format_get_nblocksy(format, u_minify(height0, level));
+ for (uint32_t level = 0; level < mip_levels; level++) {
+ struct fdl_slice *slice = &layout->slices[level];
+ uint32_t tile_mode = fdl_tile_mode(layout, level);
+ uint32_t pitch = fdl_pitch(layout, level);
+ uint32_t nblocksy =
+ util_format_get_nblocksy(format, u_minify(height0, level));
- if (tile_mode) {
- nblocksy = align(nblocksy, heightalign);
- } else {
- /* The blits used for mem<->gmem work at a granularity of
- * 32x32, which can cause faults due to over-fetch on the
- * last level. The simple solution is to over-allocate a
- * bit the last level to ensure any over-fetch is harmless.
- * The pitch is already sufficiently aligned, but height
- * may not be:
- */
- if (level == mip_levels - 1)
- nblocksy = align(nblocksy, 32);
- }
+ if (tile_mode) {
+ nblocksy = align(nblocksy, heightalign);
+ } else {
+ /* The blits used for mem<->gmem work at a granularity of
+ * 32x32, which can cause faults due to over-fetch on the
+ * last level. The simple solution is to over-allocate a
+ * bit the last level to ensure any over-fetch is harmless.
+ * The pitch is already sufficiently aligned, but height
+ * may not be:
+ */
+ if (level == mip_levels - 1)
+ nblocksy = align(nblocksy, 32);
+ }
- slice->offset = layout->size;
+ slice->offset = layout->size;
- const int alignment = is_3d ? 4096 : 1;
+ const int alignment = is_3d ? 4096 : 1;
- /* 1d array and 2d array textures must all have the same layer size
- * for each miplevel on a3xx. 3d textures can have different layer
- * sizes for high levels, but the hw auto-sizer is buggy (or at least
- * different than what this code does), so as soon as the layer size
- * range gets into range, we stop reducing it.
- */
- if (is_3d && (
- level == 1 ||
- (level > 1 && layout->slices[level - 1].size0 > 0xf000)))
- slice->size0 = align(nblocksy * pitch, alignment);
- else if (level == 0 || layout->layer_first || alignment == 1)
- slice->size0 = align(nblocksy * pitch, alignment);
- else
- slice->size0 = layout->slices[level - 1].size0;
+ /* 1d array and 2d array textures must all have the same layer size
+ * for each miplevel on a3xx. 3d textures can have different layer
+ * sizes for high levels, but the hw auto-sizer is buggy (or at least
+ * different than what this code does), so as soon as the layer size
+ * range gets into range, we stop reducing it.
+ */
+ if (is_3d && (level == 1 ||
+ (level > 1 && layout->slices[level - 1].size0 > 0xf000)))
+ slice->size0 = align(nblocksy * pitch, alignment);
+ else if (level == 0 || layout->layer_first || alignment == 1)
+ slice->size0 = align(nblocksy * pitch, alignment);
+ else
+ slice->size0 = layout->slices[level - 1].size0;
- layout->size += slice->size0 * u_minify(depth0, level) * layers_in_level;
- }
+ layout->size += slice->size0 * u_minify(depth0, level) * layers_in_level;
+ }
}
-
diff --git a/src/freedreno/fdl/fd5_layout_test.c b/src/freedreno/fdl/fd5_layout_test.c
index e8496996d3b..adfd951b3b2 100644
--- a/src/freedreno/fdl/fd5_layout_test.c
+++ b/src/freedreno/fdl/fd5_layout_test.c
@@ -34,71 +34,82 @@
* on a Pixel 2
*/
static const struct testcase testcases[] = {
- /* Basic POT, non-UBWC layout test */
- {
- .format = PIPE_FORMAT_R9G9B9E5_FLOAT,
- .layout = {
- .tile_mode = TILE5_3,
- .width0 = 32, .height0 = 32,
- .slices = {
- { .offset = 0, .pitch = 256 },
- { .offset = 8192, .pitch = 256 },
- { .offset = 12288, .pitch = 256 },
- { .offset = 14336, .pitch = 256 },
- { .offset = 15360, .pitch = 256 },
- { .offset = 15872, .pitch = 256 },
- },
- },
- },
+ /* Basic POT, non-UBWC layout test */
+ {
+ .format = PIPE_FORMAT_R9G9B9E5_FLOAT,
+ .layout =
+ {
+ .tile_mode = TILE5_3,
+ .width0 = 32,
+ .height0 = 32,
+ .slices =
+ {
+ {.offset = 0, .pitch = 256},
+ {.offset = 8192, .pitch = 256},
+ {.offset = 12288, .pitch = 256},
+ {.offset = 14336, .pitch = 256},
+ {.offset = 15360, .pitch = 256},
+ {.offset = 15872, .pitch = 256},
+ },
+ },
+ },
- /* Some 3D cases of sizes from the CTS, when I was suspicious of our 3D
- * layout.
- */
- {
- .format = PIPE_FORMAT_R9G9B9E5_FLOAT,
- .is_3d = true,
- .layout = {
- .tile_mode = TILE5_3,
- .ubwc = false,
- .width0 = 59, .height0 = 37, .depth0 = 11,
- .slices = {
- { .offset = 0, .pitch = 256 },
- { .offset = 135168, .pitch = 256 },
- { .offset = 176128, .pitch = 256 },
- { .offset = 192512, .pitch = 256 },
- { .offset = 200704, .pitch = 256 },
- { .offset = 208896, .pitch = 256 },
- },
- },
- },
- {
- .format = PIPE_FORMAT_R32G32_FLOAT,
- .is_3d = true,
- .layout = {
- .tile_mode = TILE5_3,
- .ubwc = false,
- .width0 = 63, .height0 = 29, .depth0 = 11,
- .slices = {
- { .offset = 0, .pitch = 512 },
- { .offset = 180224, .pitch = 512 },
- { .offset = 221184, .pitch = 512 },
- { .offset = 237568, .pitch = 512 },
- { .offset = 245760, .pitch = 512 },
- { .offset = 253952, .pitch = 512 },
- },
- },
- },
+ /* Some 3D cases of sizes from the CTS, when I was suspicious of our 3D
+ * layout.
+ */
+ {
+ .format = PIPE_FORMAT_R9G9B9E5_FLOAT,
+ .is_3d = true,
+ .layout =
+ {
+ .tile_mode = TILE5_3,
+ .ubwc = false,
+ .width0 = 59,
+ .height0 = 37,
+ .depth0 = 11,
+ .slices =
+ {
+ {.offset = 0, .pitch = 256},
+ {.offset = 135168, .pitch = 256},
+ {.offset = 176128, .pitch = 256},
+ {.offset = 192512, .pitch = 256},
+ {.offset = 200704, .pitch = 256},
+ {.offset = 208896, .pitch = 256},
+ },
+ },
+ },
+ {
+ .format = PIPE_FORMAT_R32G32_FLOAT,
+ .is_3d = true,
+ .layout =
+ {
+ .tile_mode = TILE5_3,
+ .ubwc = false,
+ .width0 = 63,
+ .height0 = 29,
+ .depth0 = 11,
+ .slices =
+ {
+ {.offset = 0, .pitch = 512},
+ {.offset = 180224, .pitch = 512},
+ {.offset = 221184, .pitch = 512},
+ {.offset = 237568, .pitch = 512},
+ {.offset = 245760, .pitch = 512},
+ {.offset = 253952, .pitch = 512},
+ },
+ },
+ },
};
int
main(int argc, char **argv)
{
- int ret = 0;
+ int ret = 0;
- for (int i = 0; i < ARRAY_SIZE(testcases); i++) {
- if (!fdl_test_layout(&testcases[i], 540))
- ret = 1;
- }
+ for (int i = 0; i < ARRAY_SIZE(testcases); i++) {
+ if (!fdl_test_layout(&testcases[i], 540))
+ ret = 1;
+ }
- return ret;
+ return ret;
}
diff --git a/src/freedreno/fdl/fd6_layout.c b/src/freedreno/fdl/fd6_layout.c
index f6a0a984bce..0067adb52ff 100644
--- a/src/freedreno/fdl/fd6_layout.c
+++ b/src/freedreno/fdl/fd6_layout.c
@@ -32,239 +32,239 @@
static bool
is_r8g8(struct fdl_layout *layout)
{
- return layout->cpp == 2 &&
- util_format_get_nr_components(layout->format) == 2;
+ return layout->cpp == 2 &&
+ util_format_get_nr_components(layout->format) == 2;
}
void
-fdl6_get_ubwc_blockwidth(struct fdl_layout *layout,
- uint32_t *blockwidth, uint32_t *blockheight)
+fdl6_get_ubwc_blockwidth(struct fdl_layout *layout, uint32_t *blockwidth,
+ uint32_t *blockheight)
{
- static const struct {
- uint8_t width;
- uint8_t height;
- } blocksize[] = {
- { 16, 4 }, /* cpp = 1 */
- { 16, 4 }, /* cpp = 2 */
- { 16, 4 }, /* cpp = 4 */
- { 8, 4, }, /* cpp = 8 */
- { 4, 4, }, /* cpp = 16 */
- { 4, 2 }, /* cpp = 32 */
- { 0, 0 }, /* cpp = 64 (TODO) */
- };
-
- /* special case for r8g8: */
- if (is_r8g8(layout)) {
- *blockwidth = 16;
- *blockheight = 8;
- return;
- }
-
- uint32_t cpp = fdl_cpp_shift(layout);
- assert(cpp < ARRAY_SIZE(blocksize));
- *blockwidth = blocksize[cpp].width;
- *blockheight = blocksize[cpp].height;
+ static const struct {
+ uint8_t width;
+ uint8_t height;
+ } blocksize[] = {
+ { 16, 4 }, /* cpp = 1 */
+ { 16, 4 }, /* cpp = 2 */
+ { 16, 4 }, /* cpp = 4 */
+ { 8, 4 }, /* cpp = 8 */
+ { 4, 4 }, /* cpp = 16 */
+ { 4, 2 }, /* cpp = 32 */
+ { 0, 0 }, /* cpp = 64 (TODO) */
+ };
+
+ /* special case for r8g8: */
+ if (is_r8g8(layout)) {
+ *blockwidth = 16;
+ *blockheight = 8;
+ return;
+ }
+
+ uint32_t cpp = fdl_cpp_shift(layout);
+ assert(cpp < ARRAY_SIZE(blocksize));
+ *blockwidth = blocksize[cpp].width;
+ *blockheight = blocksize[cpp].height;
}
static void
fdl6_tile_alignment(struct fdl_layout *layout, uint32_t *heightalign)
{
- layout->pitchalign = fdl_cpp_shift(layout);
- *heightalign = 16;
-
- if (is_r8g8(layout) || layout->cpp == 1) {
- layout->pitchalign = 1;
- *heightalign = 32;
- } else if (layout->cpp == 2) {
- layout->pitchalign = 2;
- }
-
- /* note: this base_align is *probably* not always right,
- * it doesn't really get tested. for example with UBWC we might
- * want 4k alignment, since we align UBWC levels to 4k
- */
- if (layout->cpp == 1)
- layout->base_align = 64;
- else if (layout->cpp == 2)
- layout->base_align = 128;
- else
- layout->base_align = 256;
+ layout->pitchalign = fdl_cpp_shift(layout);
+ *heightalign = 16;
+
+ if (is_r8g8(layout) || layout->cpp == 1) {
+ layout->pitchalign = 1;
+ *heightalign = 32;
+ } else if (layout->cpp == 2) {
+ layout->pitchalign = 2;
+ }
+
+ /* note: this base_align is *probably* not always right,
+ * it doesn't really get tested. for example with UBWC we might
+ * want 4k alignment, since we align UBWC levels to 4k
+ */
+ if (layout->cpp == 1)
+ layout->base_align = 64;
+ else if (layout->cpp == 2)
+ layout->base_align = 128;
+ else
+ layout->base_align = 256;
}
/* NOTE: good way to test this is: (for example)
* piglit/bin/texelFetch fs sampler3D 100x100x8
*/
bool
-fdl6_layout(struct fdl_layout *layout,
- enum pipe_format format, uint32_t nr_samples,
- uint32_t width0, uint32_t height0, uint32_t depth0,
- uint32_t mip_levels, uint32_t array_size, bool is_3d,
- struct fdl_explicit_layout *explicit_layout)
+fdl6_layout(struct fdl_layout *layout, enum pipe_format format,
+ uint32_t nr_samples, uint32_t width0, uint32_t height0,
+ uint32_t depth0, uint32_t mip_levels, uint32_t array_size,
+ bool is_3d, struct fdl_explicit_layout *explicit_layout)
{
- uint32_t offset = 0, heightalign;
- uint32_t ubwc_blockwidth, ubwc_blockheight;
-
- assert(nr_samples > 0);
- layout->width0 = width0;
- layout->height0 = height0;
- layout->depth0 = depth0;
-
- layout->cpp = util_format_get_blocksize(format);
- layout->cpp *= nr_samples;
- layout->cpp_shift = ffs(layout->cpp) - 1;
-
- layout->format = format;
- layout->nr_samples = nr_samples;
- layout->layer_first = !is_3d;
-
- fdl6_get_ubwc_blockwidth(layout, &ubwc_blockwidth, &ubwc_blockheight);
-
- if (depth0 > 1 || ubwc_blockwidth == 0)
- layout->ubwc = false;
-
- if (layout->ubwc || util_format_is_depth_or_stencil(format))
- layout->tile_all = true;
-
- /* in layer_first layout, the level (slice) contains just one
- * layer (since in fact the layer contains the slices)
- */
- uint32_t layers_in_level = layout->layer_first ? 1 : array_size;
-
- /* note: for tiled+noubwc layouts, we can use a lower pitchalign
- * which will affect the linear levels only, (the hardware will still
- * expect the tiled alignment on the tiled levels)
- */
- if (layout->tile_mode) {
- fdl6_tile_alignment(layout, &heightalign);
- } else {
- layout->base_align = 64;
- layout->pitchalign = 0;
- /* align pitch to at least 16 pixels:
- * both turnip and galium assume there is enough alignment for 16x4
- * aligned gmem store. turnip can use CP_BLIT to work without this
- * extra alignment, but gallium driver doesn't implement it yet
- */
- if (layout->cpp > 4)
- layout->pitchalign = fdl_cpp_shift(layout) - 2;
-
- /* when possible, use a bit more alignment than necessary
- * presumably this is better for performance?
- */
- if (!explicit_layout)
- layout->pitchalign = fdl_cpp_shift(layout);
-
- /* not used, avoid "may be used uninitialized" warning */
- heightalign = 1;
- }
-
- fdl_set_pitchalign(layout, layout->pitchalign + 6);
-
- if (explicit_layout) {
- offset = explicit_layout->offset;
- layout->pitch0 = explicit_layout->pitch;
- if (align(layout->pitch0, 1 << layout->pitchalign) != layout->pitch0)
- return false;
- }
-
- uint32_t ubwc_width0 = width0;
- uint32_t ubwc_height0 = height0;
- uint32_t ubwc_tile_height_alignment = RGB_TILE_HEIGHT_ALIGNMENT;
- if (mip_levels > 1) {
- /* With mipmapping enabled, UBWC layout is power-of-two sized,
- * specified in log2 width/height in the descriptors. The height
- * alignment is 64 for mipmapping, but for buffer sharing (always
- * single level) other participants expect 16.
- */
- ubwc_width0 = util_next_power_of_two(width0);
- ubwc_height0 = util_next_power_of_two(height0);
- ubwc_tile_height_alignment = 64;
- }
- layout->ubwc_width0 = align(DIV_ROUND_UP(ubwc_width0, ubwc_blockwidth),
- RGB_TILE_WIDTH_ALIGNMENT);
- ubwc_height0 = align(DIV_ROUND_UP(ubwc_height0, ubwc_blockheight),
- ubwc_tile_height_alignment);
-
- for (uint32_t level = 0; level < mip_levels; level++) {
- uint32_t depth = u_minify(depth0, level);
- struct fdl_slice *slice = &layout->slices[level];
- struct fdl_slice *ubwc_slice = &layout->ubwc_slices[level];
- uint32_t tile_mode = fdl_tile_mode(layout, level);
- uint32_t pitch = fdl_pitch(layout, level);
- uint32_t height;
-
- /* tiled levels of 3D textures are rounded up to PoT dimensions: */
- if (is_3d && tile_mode) {
- height = u_minify(util_next_power_of_two(height0), level);
- } else {
- height = u_minify(height0, level);
- }
-
- uint32_t nblocksy = util_format_get_nblocksy(format, height);
- if (tile_mode)
- nblocksy = align(nblocksy, heightalign);
-
- /* The blits used for mem<->gmem work at a granularity of
- * 16x4, which can cause faults due to over-fetch on the
- * last level. The simple solution is to over-allocate a
- * bit the last level to ensure any over-fetch is harmless.
- * The pitch is already sufficiently aligned, but height
- * may not be. note this only matters if last level is linear
- */
- if (level == mip_levels - 1)
- nblocksy = align(nblocksy, 4);
-
- slice->offset = offset + layout->size;
-
- /* 1d array and 2d array textures must all have the same layer size
- * for each miplevel on a6xx. 3d textures can have different layer
- * sizes for high levels, but the hw auto-sizer is buggy (or at least
- * different than what this code does), so as soon as the layer size
- * range gets into range, we stop reducing it.
- */
- if (is_3d) {
- if (level < 1 || layout->slices[level - 1].size0 > 0xf000) {
- slice->size0 = align(nblocksy * pitch, 4096);
- } else {
- slice->size0 = layout->slices[level - 1].size0;
- }
- } else {
- slice->size0 = nblocksy * pitch;
- }
-
- layout->size += slice->size0 * depth * layers_in_level;
-
- if (layout->ubwc) {
- /* with UBWC every level is aligned to 4K */
- layout->size = align(layout->size, 4096);
-
- uint32_t meta_pitch = fdl_ubwc_pitch(layout, level);
- uint32_t meta_height = align(u_minify(ubwc_height0, level),
- ubwc_tile_height_alignment);
-
- ubwc_slice->size0 = align(meta_pitch * meta_height, UBWC_PLANE_SIZE_ALIGNMENT);
- ubwc_slice->offset = offset + layout->ubwc_layer_size;
- layout->ubwc_layer_size += ubwc_slice->size0;
- }
- }
-
- if (layout->layer_first) {
- layout->layer_size = align(layout->size, 4096);
- layout->size = layout->layer_size * array_size;
- }
-
- /* Place the UBWC slices before the uncompressed slices, because the
- * kernel expects UBWC to be at the start of the buffer. In the HW, we
- * get to program the UBWC and non-UBWC offset/strides
- * independently.
- */
- if (layout->ubwc) {
- for (uint32_t level = 0; level < mip_levels; level++)
- layout->slices[level].offset += layout->ubwc_layer_size * array_size;
- layout->size += layout->ubwc_layer_size * array_size;
- }
-
- /* include explicit offset in size */
- layout->size += offset;
-
- return true;
+ uint32_t offset = 0, heightalign;
+ uint32_t ubwc_blockwidth, ubwc_blockheight;
+
+ assert(nr_samples > 0);
+ layout->width0 = width0;
+ layout->height0 = height0;
+ layout->depth0 = depth0;
+
+ layout->cpp = util_format_get_blocksize(format);
+ layout->cpp *= nr_samples;
+ layout->cpp_shift = ffs(layout->cpp) - 1;
+
+ layout->format = format;
+ layout->nr_samples = nr_samples;
+ layout->layer_first = !is_3d;
+
+ fdl6_get_ubwc_blockwidth(layout, &ubwc_blockwidth, &ubwc_blockheight);
+
+ if (depth0 > 1 || ubwc_blockwidth == 0)
+ layout->ubwc = false;
+
+ if (layout->ubwc || util_format_is_depth_or_stencil(format))
+ layout->tile_all = true;
+
+ /* in layer_first layout, the level (slice) contains just one
+ * layer (since in fact the layer contains the slices)
+ */
+ uint32_t layers_in_level = layout->layer_first ? 1 : array_size;
+
+ /* note: for tiled+noubwc layouts, we can use a lower pitchalign
+ * which will affect the linear levels only, (the hardware will still
+ * expect the tiled alignment on the tiled levels)
+ */
+ if (layout->tile_mode) {
+ fdl6_tile_alignment(layout, &heightalign);
+ } else {
+ layout->base_align = 64;
+ layout->pitchalign = 0;
+ /* align pitch to at least 16 pixels:
+ * both turnip and galium assume there is enough alignment for 16x4
+ * aligned gmem store. turnip can use CP_BLIT to work without this
+ * extra alignment, but gallium driver doesn't implement it yet
+ */
+ if (layout->cpp > 4)
+ layout->pitchalign = fdl_cpp_shift(layout) - 2;
+
+ /* when possible, use a bit more alignment than necessary
+ * presumably this is better for performance?
+ */
+ if (!explicit_layout)
+ layout->pitchalign = fdl_cpp_shift(layout);
+
+ /* not used, avoid "may be used uninitialized" warning */
+ heightalign = 1;
+ }
+
+ fdl_set_pitchalign(layout, layout->pitchalign + 6);
+
+ if (explicit_layout) {
+ offset = explicit_layout->offset;
+ layout->pitch0 = explicit_layout->pitch;
+ if (align(layout->pitch0, 1 << layout->pitchalign) != layout->pitch0)
+ return false;
+ }
+
+ uint32_t ubwc_width0 = width0;
+ uint32_t ubwc_height0 = height0;
+ uint32_t ubwc_tile_height_alignment = RGB_TILE_HEIGHT_ALIGNMENT;
+ if (mip_levels > 1) {
+ /* With mipmapping enabled, UBWC layout is power-of-two sized,
+ * specified in log2 width/height in the descriptors. The height
+ * alignment is 64 for mipmapping, but for buffer sharing (always
+ * single level) other participants expect 16.
+ */
+ ubwc_width0 = util_next_power_of_two(width0);
+ ubwc_height0 = util_next_power_of_two(height0);
+ ubwc_tile_height_alignment = 64;
+ }
+ layout->ubwc_width0 = align(DIV_ROUND_UP(ubwc_width0, ubwc_blockwidth),
+ RGB_TILE_WIDTH_ALIGNMENT);
+ ubwc_height0 = align(DIV_ROUND_UP(ubwc_height0, ubwc_blockheight),
+ ubwc_tile_height_alignment);
+
+ for (uint32_t level = 0; level < mip_levels; level++) {
+ uint32_t depth = u_minify(depth0, level);
+ struct fdl_slice *slice = &layout->slices[level];
+ struct fdl_slice *ubwc_slice = &layout->ubwc_slices[level];
+ uint32_t tile_mode = fdl_tile_mode(layout, level);
+ uint32_t pitch = fdl_pitch(layout, level);
+ uint32_t height;
+
+ /* tiled levels of 3D textures are rounded up to PoT dimensions: */
+ if (is_3d && tile_mode) {
+ height = u_minify(util_next_power_of_two(height0), level);
+ } else {
+ height = u_minify(height0, level);
+ }
+
+ uint32_t nblocksy = util_format_get_nblocksy(format, height);
+ if (tile_mode)
+ nblocksy = align(nblocksy, heightalign);
+
+ /* The blits used for mem<->gmem work at a granularity of
+ * 16x4, which can cause faults due to over-fetch on the
+ * last level. The simple solution is to over-allocate a
+ * bit the last level to ensure any over-fetch is harmless.
+ * The pitch is already sufficiently aligned, but height
+ * may not be. note this only matters if last level is linear
+ */
+ if (level == mip_levels - 1)
+ nblocksy = align(nblocksy, 4);
+
+ slice->offset = offset + layout->size;
+
+ /* 1d array and 2d array textures must all have the same layer size
+ * for each miplevel on a6xx. 3d textures can have different layer
+ * sizes for high levels, but the hw auto-sizer is buggy (or at least
+ * different than what this code does), so as soon as the layer size
+ * range gets into range, we stop reducing it.
+ */
+ if (is_3d) {
+ if (level < 1 || layout->slices[level - 1].size0 > 0xf000) {
+ slice->size0 = align(nblocksy * pitch, 4096);
+ } else {
+ slice->size0 = layout->slices[level - 1].size0;
+ }
+ } else {
+ slice->size0 = nblocksy * pitch;
+ }
+
+ layout->size += slice->size0 * depth * layers_in_level;
+
+ if (layout->ubwc) {
+ /* with UBWC every level is aligned to 4K */
+ layout->size = align(layout->size, 4096);
+
+ uint32_t meta_pitch = fdl_ubwc_pitch(layout, level);
+ uint32_t meta_height =
+ align(u_minify(ubwc_height0, level), ubwc_tile_height_alignment);
+
+ ubwc_slice->size0 =
+ align(meta_pitch * meta_height, UBWC_PLANE_SIZE_ALIGNMENT);
+ ubwc_slice->offset = offset + layout->ubwc_layer_size;
+ layout->ubwc_layer_size += ubwc_slice->size0;
+ }
+ }
+
+ if (layout->layer_first) {
+ layout->layer_size = align(layout->size, 4096);
+ layout->size = layout->layer_size * array_size;
+ }
+
+ /* Place the UBWC slices before the uncompressed slices, because the
+ * kernel expects UBWC to be at the start of the buffer. In the HW, we
+ * get to program the UBWC and non-UBWC offset/strides
+ * independently.
+ */
+ if (layout->ubwc) {
+ for (uint32_t level = 0; level < mip_levels; level++)
+ layout->slices[level].offset += layout->ubwc_layer_size * array_size;
+ layout->size += layout->ubwc_layer_size * array_size;
+ }
+
+ /* include explicit offset in size */
+ layout->size += offset;
+
+ return true;
}
diff --git a/src/freedreno/fdl/fd6_layout_test.c b/src/freedreno/fdl/fd6_layout_test.c
index d8b4a032903..91639843df7 100644
--- a/src/freedreno/fdl/fd6_layout_test.c
+++ b/src/freedreno/fdl/fd6_layout_test.c
@@ -29,66 +29,75 @@
#include <stdio.h>
-static const struct testcase testcases[] = {
- /* A straightforward first testcase, linear, with an obvious format. */
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .width0 = 32, .height0 = 32,
- .slices = {
- { .offset = 0, .pitch = 256 },
- { .offset = 8192, .pitch = 256 },
- { .offset = 12288, .pitch = 256 },
- { .offset = 14336, .pitch = 256 },
- { .offset = 15360, .pitch = 256 },
- { .offset = 15872, .pitch = 256 },
- },
- },
- },
+static const struct testcase
+ testcases[] =
+ {
+ /* A straightforward first testcase, linear, with an obvious format. */
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .width0 = 32,
+ .height0 = 32,
+ .slices =
+ {
+ {.offset = 0, .pitch = 256},
+ {.offset = 8192, .pitch = 256},
+ {.offset = 12288, .pitch = 256},
+ {.offset = 14336, .pitch = 256},
+ {.offset = 15360, .pitch = 256},
+ {.offset = 15872, .pitch = 256},
+ },
+ },
+ },
- /* A tiled/ubwc layout from the blob driver, at a size where the a630 blob
- * driver does something interesting for linear.
- */
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .tile_mode = TILE6_3,
- .ubwc = true,
- .width0 = 1024, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 4096 },
- { .offset = 65536, .pitch = 2048 },
- { .offset = 98304, .pitch = 1024 },
- { .offset = 114688, .pitch = 512 },
- { .offset = 122880, .pitch = 256 },
- { .offset = 126976, .pitch = 256 },
- { .offset = 131072, .pitch = 256 },
- { .offset = 135168, .pitch = 256 },
- { .offset = 139264, .pitch = 256 },
- { .offset = 143360, .pitch = 256 },
- { .offset = 147456, .pitch = 256 },
- },
- .ubwc_slices = {
- { .offset = 0, .pitch = 64 },
- { .offset = 4096, .pitch = 64 },
- { .offset = 8192, .pitch = 64 },
- { .offset = 12288, .pitch = 64 },
- { .offset = 16384, .pitch = 64 },
- { .offset = 20480, .pitch = 64 },
- { .offset = 24576, .pitch = 64 },
- { .offset = 28672, .pitch = 64 },
- { .offset = 32768, .pitch = 64 },
- { .offset = 36864, .pitch = 64 },
- { .offset = 40960, .pitch = 64 },
- },
- },
- },
+ /* A tiled/ubwc layout from the blob driver, at a size where the a630
+ * blob driver does something interesting for linear.
+ */
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .tile_mode = TILE6_3,
+ .ubwc = true,
+ .width0 = 1024,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 4096},
+ {.offset = 65536, .pitch = 2048},
+ {.offset = 98304, .pitch = 1024},
+ {.offset = 114688, .pitch = 512},
+ {.offset = 122880, .pitch = 256},
+ {.offset = 126976, .pitch = 256},
+ {.offset = 131072, .pitch = 256},
+ {.offset = 135168, .pitch = 256},
+ {.offset = 139264, .pitch = 256},
+ {.offset = 143360, .pitch = 256},
+ {.offset = 147456, .pitch = 256},
+ },
+ .ubwc_slices =
+ {
+ {.offset = 0, .pitch = 64},
+ {.offset = 4096, .pitch = 64},
+ {.offset = 8192, .pitch = 64},
+ {.offset = 12288, .pitch = 64},
+ {.offset = 16384, .pitch = 64},
+ {.offset = 20480, .pitch = 64},
+ {.offset = 24576, .pitch = 64},
+ {.offset = 28672, .pitch = 64},
+ {.offset = 32768, .pitch = 64},
+ {.offset = 36864, .pitch = 64},
+ {.offset = 40960, .pitch = 64},
+ },
+ },
+ },
- /* An interesting layout from the blob driver on a630, showing that
- * per-level pitch must be derived from level 0's pitch, not width0. We
- * don't do this level 0 pitch disalignment (we pick 4096), so disabled
- * this test for now.
- */
+/* An interesting layout from the blob driver on a630, showing that
+ * per-level pitch must be derived from level 0's pitch, not width0. We
+ * don't do this level 0 pitch disalignment (we pick 4096), so disabled
+ * this test for now.
+ */
#if 0
{
.format = PIPE_FORMAT_R8G8B8A8_UNORM,
@@ -111,508 +120,580 @@ static const struct testcase testcases[] = {
},
#endif
- /* A layout that we failed on (129 wide has a surprise level 1 pitch
- * increase), and the sizes bracketing it.
- */
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .width0 = 128, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 512 },
- { .offset = 512, .pitch = 256 },
- { .offset = 768, .pitch = 256 },
- { .offset = 1024, .pitch = 256 },
- { .offset = 1280, .pitch = 256 },
- { .offset = 1536, .pitch = 256 },
- { .offset = 1792, .pitch = 256 },
- { .offset = 2048, .pitch = 256 },
- },
- },
- },
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .width0 = 129, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 768 },
- { .offset = 768, .pitch = 512 },
- { .offset = 1280, .pitch = 256 },
- { .offset = 1536, .pitch = 256 },
- { .offset = 1792, .pitch = 256 },
- { .offset = 2048, .pitch = 256 },
- { .offset = 2304, .pitch = 256 },
- { .offset = 2560, .pitch = 256 },
- },
- },
- },
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .width0 = 130, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 768 },
- { .offset = 768, .pitch = 512 },
- { .offset = 1280, .pitch = 256 },
- { .offset = 1536, .pitch = 256 },
- { .offset = 1792, .pitch = 256 },
- { .offset = 2048, .pitch = 256 },
- { .offset = 2304, .pitch = 256 },
- { .offset = 2560, .pitch = 256 },
- },
- },
- },
+ /* A layout that we failed on (129 wide has a surprise level 1 pitch
+ * increase), and the sizes bracketing it.
+ */
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .width0 = 128,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 512},
+ {.offset = 512, .pitch = 256},
+ {.offset = 768, .pitch = 256},
+ {.offset = 1024, .pitch = 256},
+ {.offset = 1280, .pitch = 256},
+ {.offset = 1536, .pitch = 256},
+ {.offset = 1792, .pitch = 256},
+ {.offset = 2048, .pitch = 256},
+ },
+ },
+ },
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .width0 = 129,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 768},
+ {.offset = 768, .pitch = 512},
+ {.offset = 1280, .pitch = 256},
+ {.offset = 1536, .pitch = 256},
+ {.offset = 1792, .pitch = 256},
+ {.offset = 2048, .pitch = 256},
+ {.offset = 2304, .pitch = 256},
+ {.offset = 2560, .pitch = 256},
+ },
+ },
+ },
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .width0 = 130,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 768},
+ {.offset = 768, .pitch = 512},
+ {.offset = 1280, .pitch = 256},
+ {.offset = 1536, .pitch = 256},
+ {.offset = 1792, .pitch = 256},
+ {.offset = 2048, .pitch = 256},
+ {.offset = 2304, .pitch = 256},
+ {.offset = 2560, .pitch = 256},
+ },
+ },
+ },
- /* The 129 failure seems to be across formats, let's test some cpps */
- {
- .format = PIPE_FORMAT_R8_UNORM,
- .layout = {
- .width0 = 129, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 192 },
- { .offset = 192, .pitch = 128 },
- { .offset = 320, .pitch = 64 },
- { .offset = 384, .pitch = 64 },
- { .offset = 448, .pitch = 64 },
- { .offset = 512, .pitch = 64 },
- { .offset = 576, .pitch = 64 },
- { .offset = 640, .pitch = 64 },
- },
- },
- },
- {
- .format = PIPE_FORMAT_R16_UINT,
- .layout = {
- .width0 = 129, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 384 },
- { .offset = 384, .pitch = 256 },
- { .offset = 640, .pitch = 128 },
- { .offset = 768, .pitch = 128 },
- { .offset = 896, .pitch = 128 },
- { .offset = 1024, .pitch = 128 },
- { .offset = 1152, .pitch = 128 },
- { .offset = 1280, .pitch = 128 },
- },
- },
- },
- {
- .format = PIPE_FORMAT_R32G32B32A32_FLOAT,
- .layout = {
- .width0 = 129, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 3072 },
- { .offset = 3072, .pitch = 2048 },
- { .offset = 5120, .pitch = 1024 },
- { .offset = 6144, .pitch = 1024 },
- { .offset = 7168, .pitch = 1024 },
- { .offset = 8192, .pitch = 1024 },
- { .offset = 9216, .pitch = 1024 },
- { .offset = 10240, .pitch = 1024 },
- },
- },
- },
+ /* The 129 failure seems to be across formats, let's test some cpps */
+ {
+ .format = PIPE_FORMAT_R8_UNORM,
+ .layout =
+ {
+ .width0 = 129,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 192},
+ {.offset = 192, .pitch = 128},
+ {.offset = 320, .pitch = 64},
+ {.offset = 384, .pitch = 64},
+ {.offset = 448, .pitch = 64},
+ {.offset = 512, .pitch = 64},
+ {.offset = 576, .pitch = 64},
+ {.offset = 640, .pitch = 64},
+ },
+ },
+ },
+ {
+ .format = PIPE_FORMAT_R16_UINT,
+ .layout =
+ {
+ .width0 = 129,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 384},
+ {.offset = 384, .pitch = 256},
+ {.offset = 640, .pitch = 128},
+ {.offset = 768, .pitch = 128},
+ {.offset = 896, .pitch = 128},
+ {.offset = 1024, .pitch = 128},
+ {.offset = 1152, .pitch = 128},
+ {.offset = 1280, .pitch = 128},
+ },
+ },
+ },
+ {
+ .format = PIPE_FORMAT_R32G32B32A32_FLOAT,
+ .layout =
+ {
+ .width0 = 129,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 3072},
+ {.offset = 3072, .pitch = 2048},
+ {.offset = 5120, .pitch = 1024},
+ {.offset = 6144, .pitch = 1024},
+ {.offset = 7168, .pitch = 1024},
+ {.offset = 8192, .pitch = 1024},
+ {.offset = 9216, .pitch = 1024},
+ {.offset = 10240, .pitch = 1024},
+ },
+ },
+ },
- /* The 129 failure replicated at every +256 pixels wide. Pick one of
- * them, and this time increase the height as a new variable as well.
- */
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .width0 = 385, .height0 = 128,
- .slices = {
- { .offset = 0, .pitch = 1792 },
- { .offset = 229376, .pitch = 1024 },
- { .offset = 294912, .pitch = 512 },
- { .offset = 311296, .pitch = 256 },
- { .offset = 315392, .pitch = 256 },
- { .offset = 317440, .pitch = 256 },
- { .offset = 318464, .pitch = 256 },
- { .offset = 318976, .pitch = 256 },
- { .offset = 319232, .pitch = 256 },
- },
- },
- },
+ /* The 129 failure replicated at every +256 pixels wide. Pick one of
+ * them, and this time increase the height as a new variable as well.
+ */
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .width0 = 385,
+ .height0 = 128,
+ .slices =
+ {
+ {.offset = 0, .pitch = 1792},
+ {.offset = 229376, .pitch = 1024},
+ {.offset = 294912, .pitch = 512},
+ {.offset = 311296, .pitch = 256},
+ {.offset = 315392, .pitch = 256},
+ {.offset = 317440, .pitch = 256},
+ {.offset = 318464, .pitch = 256},
+ {.offset = 318976, .pitch = 256},
+ {.offset = 319232, .pitch = 256},
+ },
+ },
+ },
- /* At 257-259 (and replicated every +256 pixels) we had another failure. */
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .width0 = 257, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 1280 },
- { .offset = 1280, .pitch = 768 },
- { .offset = 2048, .pitch = 512 },
- { .offset = 2560, .pitch = 256 },
- { .offset = 2816, .pitch = 256 },
- { .offset = 3072, .pitch = 256 },
- { .offset = 3328, .pitch = 256 },
- { .offset = 3584, .pitch = 256 },
- { .offset = 3840, .pitch = 256 },
- },
- },
- },
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .width0 = 258, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 1280 },
- { .offset = 1280, .pitch = 768 },
- { .offset = 2048, .pitch = 512 },
- { .offset = 2560, .pitch = 256 },
- { .offset = 2816, .pitch = 256 },
- { .offset = 3072, .pitch = 256 },
- { .offset = 3328, .pitch = 256 },
- { .offset = 3584, .pitch = 256 },
- { .offset = 3840, .pitch = 256 },
- },
- },
- },
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .width0 = 259, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 1280 },
- { .offset = 1280, .pitch = 768 },
- { .offset = 2048, .pitch = 512 },
- { .offset = 2560, .pitch = 256 },
- { .offset = 2816, .pitch = 256 },
- { .offset = 3072, .pitch = 256 },
- { .offset = 3328, .pitch = 256 },
- { .offset = 3584, .pitch = 256 },
- { .offset = 3840, .pitch = 256 },
- },
- },
- },
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .width0 = 260, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 1280 },
- { .offset = 1280, .pitch = 768 },
- { .offset = 2048, .pitch = 512 },
- { .offset = 2560, .pitch = 256 },
- { .offset = 2816, .pitch = 256 },
- { .offset = 3072, .pitch = 256 },
- { .offset = 3328, .pitch = 256 },
- { .offset = 3584, .pitch = 256 },
- { .offset = 3840, .pitch = 256 },
- },
- },
- },
+ /* At 257-259 (and replicated every +256 pixels) we had another
+ failure. */
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .width0 = 257,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 1280},
+ {.offset = 1280, .pitch = 768},
+ {.offset = 2048, .pitch = 512},
+ {.offset = 2560, .pitch = 256},
+ {.offset = 2816, .pitch = 256},
+ {.offset = 3072, .pitch = 256},
+ {.offset = 3328, .pitch = 256},
+ {.offset = 3584, .pitch = 256},
+ {.offset = 3840, .pitch = 256},
+ },
+ },
+ },
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .width0 = 258,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 1280},
+ {.offset = 1280, .pitch = 768},
+ {.offset = 2048, .pitch = 512},
+ {.offset = 2560, .pitch = 256},
+ {.offset = 2816, .pitch = 256},
+ {.offset = 3072, .pitch = 256},
+ {.offset = 3328, .pitch = 256},
+ {.offset = 3584, .pitch = 256},
+ {.offset = 3840, .pitch = 256},
+ },
+ },
+ },
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .width0 = 259,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 1280},
+ {.offset = 1280, .pitch = 768},
+ {.offset = 2048, .pitch = 512},
+ {.offset = 2560, .pitch = 256},
+ {.offset = 2816, .pitch = 256},
+ {.offset = 3072, .pitch = 256},
+ {.offset = 3328, .pitch = 256},
+ {.offset = 3584, .pitch = 256},
+ {.offset = 3840, .pitch = 256},
+ },
+ },
+ },
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .width0 = 260,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 1280},
+ {.offset = 1280, .pitch = 768},
+ {.offset = 2048, .pitch = 512},
+ {.offset = 2560, .pitch = 256},
+ {.offset = 2816, .pitch = 256},
+ {.offset = 3072, .pitch = 256},
+ {.offset = 3328, .pitch = 256},
+ {.offset = 3584, .pitch = 256},
+ {.offset = 3840, .pitch = 256},
+ },
+ },
+ },
- /* And, again for the 257-9 failure, test a replica with a larger size*/
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .width0 = 513, .height0 = 32,
- .slices = {
- { .offset = 0, .pitch = 2304 },
- { .offset = 73728, .pitch = 1280 },
- { .offset = 94208, .pitch = 768 },
- { .offset = 100352, .pitch = 512 },
- { .offset = 102400, .pitch = 256 },
- { .offset = 102912, .pitch = 256 },
- { .offset = 103168, .pitch = 256 },
- { .offset = 103424, .pitch = 256 },
- { .offset = 103680, .pitch = 256 },
- { .offset = 103936, .pitch = 256 },
- },
- },
- },
+ /* And, again for the 257-9 failure, test a replica with a larger size*/
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .width0 = 513,
+ .height0 = 32,
+ .slices =
+ {
+ {.offset = 0, .pitch = 2304},
+ {.offset = 73728, .pitch = 1280},
+ {.offset = 94208, .pitch = 768},
+ {.offset = 100352, .pitch = 512},
+ {.offset = 102400, .pitch = 256},
+ {.offset = 102912, .pitch = 256},
+ {.offset = 103168, .pitch = 256},
+ {.offset = 103424, .pitch = 256},
+ {.offset = 103680, .pitch = 256},
+ {.offset = 103936, .pitch = 256},
+ },
+ },
+ },
- /* Oh, look. The 513-517 failure extends up to 518 at the next texture
- * level!
- */
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .width0 = 518, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 2304 },
- { .offset = 2304, .pitch = 1280 },
- { .offset = 3584, .pitch = 768 },
- { .offset = 4352, .pitch = 512 },
- { .offset = 4864, .pitch = 256 },
- { .offset = 5120, .pitch = 256 },
- { .offset = 5376, .pitch = 256 },
- { .offset = 5632, .pitch = 256 },
- { .offset = 5888, .pitch = 256 },
- { .offset = 6144, .pitch = 256 },
- },
- },
- },
+ /* Oh, look. The 513-517 failure extends up to 518 at the next texture
+ * level!
+ */
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .width0 = 518,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 2304},
+ {.offset = 2304, .pitch = 1280},
+ {.offset = 3584, .pitch = 768},
+ {.offset = 4352, .pitch = 512},
+ {.offset = 4864, .pitch = 256},
+ {.offset = 5120, .pitch = 256},
+ {.offset = 5376, .pitch = 256},
+ {.offset = 5632, .pitch = 256},
+ {.offset = 5888, .pitch = 256},
+ {.offset = 6144, .pitch = 256},
+ },
+ },
+ },
- /* Tiled mode testing of the unusual 1/2-bytes-per-pixel pitch alignment */
- {
- .format = PIPE_FORMAT_R8_UNORM,
- .layout = {
- .tile_mode = TILE6_3,
- .width0 = 129, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 256 },
- { .offset = 8192, .pitch = 128 },
- { .offset = 12288, .pitch = 128 },
- { .offset = 16384, .pitch = 128 },
- { .offset = 20480, .pitch = 128 },
- { .offset = 20608, .pitch = 128 },
- { .offset = 20736, .pitch = 128 },
- { .offset = 20864, .pitch = 128 },
- },
- },
- },
+ /* Tiled mode testing of the unusual 1/2-bytes-per-pixel pitch
+ alignment */
+ {
+ .format = PIPE_FORMAT_R8_UNORM,
+ .layout =
+ {
+ .tile_mode = TILE6_3,
+ .width0 = 129,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 256},
+ {.offset = 8192, .pitch = 128},
+ {.offset = 12288, .pitch = 128},
+ {.offset = 16384, .pitch = 128},
+ {.offset = 20480, .pitch = 128},
+ {.offset = 20608, .pitch = 128},
+ {.offset = 20736, .pitch = 128},
+ {.offset = 20864, .pitch = 128},
+ },
+ },
+ },
- /* Single-level RGBA8888 UBWC following UBWC alignment rules laid out in
- * msm_media_info.h to verify that we don't break buffer sharing.
- */
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .tile_mode = TILE6_3,
- .ubwc = true,
- .width0 = 16384, .height0 = 129,
- .slices = {
- { .offset = 1024 * 48, .pitch = 16384 * 4 },
- },
- .ubwc_slices = {
- { .offset = 0, .pitch = 1024 },
- },
- },
- },
+ /* Single-level RGBA8888 UBWC following UBWC alignment rules laid out
+ * in msm_media_info.h to verify that we don't break buffer sharing.
+ */
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .tile_mode = TILE6_3,
+ .ubwc = true,
+ .width0 = 16384,
+ .height0 = 129,
+ .slices =
+ {
+ {.offset = 1024 * 48, .pitch = 16384 * 4},
+ },
+ .ubwc_slices =
+ {
+ {.offset = 0, .pitch = 1024},
+ },
+ },
+ },
- /* UBWC: Pitch comes from POT-aligned level 0. */
- /* Pitch fixed in this commit, but offsets broken. Will be fixed in
- * following commits.
- */
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .tile_mode = TILE6_3,
- .ubwc = true,
- .width0 = 2049, .height0 = 128,
- .slices = {
- { .offset = 0, .pitch = 8448 },
- { .offset = 1081344, .pitch = 4352 },
- { .offset = 1359872, .pitch = 2304 },
- { .offset = 1433600, .pitch = 1280 },
- { .offset = 1454080, .pitch = 768 },
- { .offset = 1466368, .pitch = 512 },
- { .offset = 1474560, .pitch = 256 },
- { .offset = 1478656, .pitch = 256 },
- { .offset = 1482752, .pitch = 256 },
- { .offset = 1486848, .pitch = 256 },
- { .offset = 1490944, .pitch = 256 },
- { .offset = 1495040, .pitch = 256 },
- },
- .ubwc_slices = {
- { .offset = 0, .pitch = 256 },
- { .offset = 16384, .pitch = 128 },
- { .offset = 24576, .pitch = 64 },
- { .offset = 28672, .pitch = 64 },
- { .offset = 32768, .pitch = 64 },
- { .offset = 36864, .pitch = 64 },
- { .offset = 40960, .pitch = 64 },
- { .offset = 45056, .pitch = 64 },
- { .offset = 49152, .pitch = 64 },
- { .offset = 53248, .pitch = 64 },
- { .offset = 57344, .pitch = 64 },
- { .offset = 61440, .pitch = 64 },
- },
- },
- },
- /* UBWC: Height comes from POT-aligned level 0. */
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .tile_mode = TILE6_3,
- .ubwc = true,
- .width0 = 1024, .height0 = 1025,
- .slices = {
- { .offset = 0, .pitch = 4096 },
- { .offset = 4259840, .pitch = 2048 },
- { .offset = 5308416, .pitch = 1024 },
- { .offset = 5570560, .pitch = 512 },
- { .offset = 5636096, .pitch = 256 },
- { .offset = 5652480, .pitch = 256 },
- { .offset = 5660672, .pitch = 256 },
- { .offset = 5664768, .pitch = 256 },
- { .offset = 5668864, .pitch = 256 },
- { .offset = 5672960, .pitch = 256 },
- { .offset = 5677056, .pitch = 256 },
- },
- .ubwc_slices = {
- { .offset = 0, .pitch = 64 },
- { .offset = 32768, .pitch = 64 },
- { .offset = 49152, .pitch = 64 },
- { .offset = 57344, .pitch = 64 },
- { .offset = 61440, .pitch = 64 },
- { .offset = 65536, .pitch = 64 },
- { .offset = 69632, .pitch = 64 },
- { .offset = 73728, .pitch = 64 },
- { .offset = 77824, .pitch = 64 },
- { .offset = 81920, .pitch = 64 },
- { .offset = 86016, .pitch = 64 },
- },
- },
- },
+ /* UBWC: Pitch comes from POT-aligned level 0. */
+ /* Pitch fixed in this commit, but offsets broken. Will be fixed in
+ * following commits.
+ */
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .tile_mode = TILE6_3,
+ .ubwc = true,
+ .width0 = 2049,
+ .height0 = 128,
+ .slices =
+ {
+ {.offset = 0, .pitch = 8448},
+ {.offset = 1081344, .pitch = 4352},
+ {.offset = 1359872, .pitch = 2304},
+ {.offset = 1433600, .pitch = 1280},
+ {.offset = 1454080, .pitch = 768},
+ {.offset = 1466368, .pitch = 512},
+ {.offset = 1474560, .pitch = 256},
+ {.offset = 1478656, .pitch = 256},
+ {.offset = 1482752, .pitch = 256},
+ {.offset = 1486848, .pitch = 256},
+ {.offset = 1490944, .pitch = 256},
+ {.offset = 1495040, .pitch = 256},
+ },
+ .ubwc_slices =
+ {
+ {.offset = 0, .pitch = 256},
+ {.offset = 16384, .pitch = 128},
+ {.offset = 24576, .pitch = 64},
+ {.offset = 28672, .pitch = 64},
+ {.offset = 32768, .pitch = 64},
+ {.offset = 36864, .pitch = 64},
+ {.offset = 40960, .pitch = 64},
+ {.offset = 45056, .pitch = 64},
+ {.offset = 49152, .pitch = 64},
+ {.offset = 53248, .pitch = 64},
+ {.offset = 57344, .pitch = 64},
+ {.offset = 61440, .pitch = 64},
+ },
+ },
+ },
+ /* UBWC: Height comes from POT-aligned level 0. */
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .tile_mode = TILE6_3,
+ .ubwc = true,
+ .width0 = 1024,
+ .height0 = 1025,
+ .slices =
+ {
+ {.offset = 0, .pitch = 4096},
+ {.offset = 4259840, .pitch = 2048},
+ {.offset = 5308416, .pitch = 1024},
+ {.offset = 5570560, .pitch = 512},
+ {.offset = 5636096, .pitch = 256},
+ {.offset = 5652480, .pitch = 256},
+ {.offset = 5660672, .pitch = 256},
+ {.offset = 5664768, .pitch = 256},
+ {.offset = 5668864, .pitch = 256},
+ {.offset = 5672960, .pitch = 256},
+ {.offset = 5677056, .pitch = 256},
+ },
+ .ubwc_slices =
+ {
+ {.offset = 0, .pitch = 64},
+ {.offset = 32768, .pitch = 64},
+ {.offset = 49152, .pitch = 64},
+ {.offset = 57344, .pitch = 64},
+ {.offset = 61440, .pitch = 64},
+ {.offset = 65536, .pitch = 64},
+ {.offset = 69632, .pitch = 64},
+ {.offset = 73728, .pitch = 64},
+ {.offset = 77824, .pitch = 64},
+ {.offset = 81920, .pitch = 64},
+ {.offset = 86016, .pitch = 64},
+ },
+ },
+ },
- /* UBWC: Get at minimum height of a level across cpps */
- {
- .format = PIPE_FORMAT_R16_UINT,
- .layout = {
- .tile_mode = TILE6_3,
- .ubwc = true,
- .width0 = 16384, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 32768 },
- { .offset = 524288, .pitch = 16384 },
- { .offset = 786432, .pitch = 8192 },
- { .offset = 917504, .pitch = 4096 },
- { .offset = 983040, .pitch = 2048 },
- { .offset = 1015808, .pitch = 1024 },
- { .offset = 1032192, .pitch = 512 },
- { .offset = 1040384, .pitch = 256 },
- { .offset = 1044480, .pitch = 256 },
- { .offset = 1048576, .pitch = 256 },
- { .offset = 1052672, .pitch = 256 },
- { .offset = 1056768, .pitch = 256 },
- { .offset = 1060864, .pitch = 256 },
- { .offset = 1064960, .pitch = 256 },
- { .offset = 1069056, .pitch = 256 },
- },
- .ubwc_slices = {
- { .offset = 0, .pitch = 1024 },
- { .offset = 65536, .pitch = 512 },
- { .offset = 98304, .pitch = 256 },
- { .offset = 114688, .pitch = 128 },
- { .offset = 122880, .pitch = 64 },
- { .offset = 126976, .pitch = 64 },
- { .offset = 131072, .pitch = 64 },
- { .offset = 135168, .pitch = 64 },
- { .offset = 139264, .pitch = 64 },
- { .offset = 143360, .pitch = 64 },
- { .offset = 147456, .pitch = 64 },
- { .offset = 151552, .pitch = 64 },
- { .offset = 155648, .pitch = 64 },
- { .offset = 159744, .pitch = 64 },
- { .offset = 163840, .pitch = 64 },
- },
- },
- },
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .tile_mode = TILE6_3,
- .ubwc = true,
- .width0 = 16384, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 65536 },
- { .offset = 1048576, .pitch = 32768 },
- { .offset = 1572864, .pitch = 16384 },
- { .offset = 1835008, .pitch = 8192 },
- { .offset = 1966080, .pitch = 4096 },
- { .offset = 2031616, .pitch = 2048 },
- { .offset = 2064384, .pitch = 1024 },
- { .offset = 2080768, .pitch = 512 },
- { .offset = 2088960, .pitch = 256 },
- { .offset = 2093056, .pitch = 256 },
- { .offset = 2097152, .pitch = 256 },
- { .offset = 2101248, .pitch = 256 },
- { .offset = 2105344, .pitch = 256 },
- { .offset = 2109440, .pitch = 256 },
- { .offset = 2113536, .pitch = 256 },
- },
- .ubwc_slices = {
- { .offset = 0, .pitch = 1024 },
- { .offset = 65536, .pitch = 512 },
- { .offset = 98304, .pitch = 256 },
- { .offset = 114688, .pitch = 128 },
- { .offset = 122880, .pitch = 64 },
- { .offset = 126976, .pitch = 64 },
- { .offset = 131072, .pitch = 64 },
- { .offset = 135168, .pitch = 64 },
- { .offset = 139264, .pitch = 64 },
- { .offset = 143360, .pitch = 64 },
- { .offset = 147456, .pitch = 64 },
- { .offset = 151552, .pitch = 64 },
- { .offset = 155648, .pitch = 64 },
- { .offset = 159744, .pitch = 64 },
- { .offset = 163840, .pitch = 64 },
- },
- },
- },
- {
- .format = PIPE_FORMAT_R32G32B32A32_FLOAT,
- .layout = {
- .tile_mode = TILE6_3,
- .ubwc = true,
- .width0 = 16384, .height0 = 1,
- .slices = {
- { .offset = 0, .pitch = 262144 },
- { .offset = 4194304, .pitch = 131072 },
- { .offset = 6291456, .pitch = 65536 },
- { .offset = 7340032, .pitch = 32768 },
- { .offset = 7864320, .pitch = 16384 },
- { .offset = 8126464, .pitch = 8192 },
- { .offset = 8257536, .pitch = 4096 },
- { .offset = 8323072, .pitch = 2048 },
- { .offset = 8355840, .pitch = 1024 },
- { .offset = 8372224, .pitch = 1024 },
- { .offset = 8388608, .pitch = 1024 },
- { .offset = 8404992, .pitch = 1024 },
- { .offset = 8421376, .pitch = 1024 },
- { .offset = 8437760, .pitch = 1024 },
- { .offset = 8454144, .pitch = 1024 },
- },
- .ubwc_slices = {
- { .offset = 0, .pitch = 4096 },
- { .offset = 262144, .pitch = 2048 },
- { .offset = 393216, .pitch = 1024 },
- { .offset = 458752, .pitch = 512 },
- { .offset = 491520, .pitch = 256 },
- { .offset = 507904, .pitch = 128 },
- { .offset = 516096, .pitch = 64 },
- { .offset = 520192, .pitch = 64 },
- { .offset = 524288, .pitch = 64 },
- { .offset = 528384, .pitch = 64 },
- { .offset = 532480, .pitch = 64 },
- { .offset = 536576, .pitch = 64 },
- { .offset = 540672, .pitch = 64 },
- { .offset = 544768, .pitch = 64 },
- { .offset = 548864, .pitch = 64 },
- },
- },
- },
+ /* UBWC: Get at minimum height of a level across cpps */
+ {
+ .format = PIPE_FORMAT_R16_UINT,
+ .layout =
+ {
+ .tile_mode = TILE6_3,
+ .ubwc = true,
+ .width0 = 16384,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 32768},
+ {.offset = 524288, .pitch = 16384},
+ {.offset = 786432, .pitch = 8192},
+ {.offset = 917504, .pitch = 4096},
+ {.offset = 983040, .pitch = 2048},
+ {.offset = 1015808, .pitch = 1024},
+ {.offset = 1032192, .pitch = 512},
+ {.offset = 1040384, .pitch = 256},
+ {.offset = 1044480, .pitch = 256},
+ {.offset = 1048576, .pitch = 256},
+ {.offset = 1052672, .pitch = 256},
+ {.offset = 1056768, .pitch = 256},
+ {.offset = 1060864, .pitch = 256},
+ {.offset = 1064960, .pitch = 256},
+ {.offset = 1069056, .pitch = 256},
+ },
+ .ubwc_slices =
+ {
+ {.offset = 0, .pitch = 1024},
+ {.offset = 65536, .pitch = 512},
+ {.offset = 98304, .pitch = 256},
+ {.offset = 114688, .pitch = 128},
+ {.offset = 122880, .pitch = 64},
+ {.offset = 126976, .pitch = 64},
+ {.offset = 131072, .pitch = 64},
+ {.offset = 135168, .pitch = 64},
+ {.offset = 139264, .pitch = 64},
+ {.offset = 143360, .pitch = 64},
+ {.offset = 147456, .pitch = 64},
+ {.offset = 151552, .pitch = 64},
+ {.offset = 155648, .pitch = 64},
+ {.offset = 159744, .pitch = 64},
+ {.offset = 163840, .pitch = 64},
+ },
+ },
+ },
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .tile_mode = TILE6_3,
+ .ubwc = true,
+ .width0 = 16384,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 65536},
+ {.offset = 1048576, .pitch = 32768},
+ {.offset = 1572864, .pitch = 16384},
+ {.offset = 1835008, .pitch = 8192},
+ {.offset = 1966080, .pitch = 4096},
+ {.offset = 2031616, .pitch = 2048},
+ {.offset = 2064384, .pitch = 1024},
+ {.offset = 2080768, .pitch = 512},
+ {.offset = 2088960, .pitch = 256},
+ {.offset = 2093056, .pitch = 256},
+ {.offset = 2097152, .pitch = 256},
+ {.offset = 2101248, .pitch = 256},
+ {.offset = 2105344, .pitch = 256},
+ {.offset = 2109440, .pitch = 256},
+ {.offset = 2113536, .pitch = 256},
+ },
+ .ubwc_slices =
+ {
+ {.offset = 0, .pitch = 1024},
+ {.offset = 65536, .pitch = 512},
+ {.offset = 98304, .pitch = 256},
+ {.offset = 114688, .pitch = 128},
+ {.offset = 122880, .pitch = 64},
+ {.offset = 126976, .pitch = 64},
+ {.offset = 131072, .pitch = 64},
+ {.offset = 135168, .pitch = 64},
+ {.offset = 139264, .pitch = 64},
+ {.offset = 143360, .pitch = 64},
+ {.offset = 147456, .pitch = 64},
+ {.offset = 151552, .pitch = 64},
+ {.offset = 155648, .pitch = 64},
+ {.offset = 159744, .pitch = 64},
+ {.offset = 163840, .pitch = 64},
+ },
+ },
+ },
+ {
+ .format = PIPE_FORMAT_R32G32B32A32_FLOAT,
+ .layout =
+ {
+ .tile_mode = TILE6_3,
+ .ubwc = true,
+ .width0 = 16384,
+ .height0 = 1,
+ .slices =
+ {
+ {.offset = 0, .pitch = 262144},
+ {.offset = 4194304, .pitch = 131072},
+ {.offset = 6291456, .pitch = 65536},
+ {.offset = 7340032, .pitch = 32768},
+ {.offset = 7864320, .pitch = 16384},
+ {.offset = 8126464, .pitch = 8192},
+ {.offset = 8257536, .pitch = 4096},
+ {.offset = 8323072, .pitch = 2048},
+ {.offset = 8355840, .pitch = 1024},
+ {.offset = 8372224, .pitch = 1024},
+ {.offset = 8388608, .pitch = 1024},
+ {.offset = 8404992, .pitch = 1024},
+ {.offset = 8421376, .pitch = 1024},
+ {.offset = 8437760, .pitch = 1024},
+ {.offset = 8454144, .pitch = 1024},
+ },
+ .ubwc_slices =
+ {
+ {.offset = 0, .pitch = 4096},
+ {.offset = 262144, .pitch = 2048},
+ {.offset = 393216, .pitch = 1024},
+ {.offset = 458752, .pitch = 512},
+ {.offset = 491520, .pitch = 256},
+ {.offset = 507904, .pitch = 128},
+ {.offset = 516096, .pitch = 64},
+ {.offset = 520192, .pitch = 64},
+ {.offset = 524288, .pitch = 64},
+ {.offset = 528384, .pitch = 64},
+ {.offset = 532480, .pitch = 64},
+ {.offset = 536576, .pitch = 64},
+ {.offset = 540672, .pitch = 64},
+ {.offset = 544768, .pitch = 64},
+ {.offset = 548864, .pitch = 64},
+ },
+ },
+ },
- {
- .format = PIPE_FORMAT_R8G8B8A8_UNORM,
- .layout = {
- .tile_mode = TILE6_3,
- .ubwc = true,
- .nr_samples = 4,
- .width0 = 412, .height0 = 732,
- .slices = {
- { .offset = 0, .pitch = 7168 },
- },
- .ubwc_slices = {
- { .offset = 0, .pitch = 128 },
- },
- },
- },
+ {
+ .format = PIPE_FORMAT_R8G8B8A8_UNORM,
+ .layout =
+ {
+ .tile_mode = TILE6_3,
+ .ubwc = true,
+ .nr_samples = 4,
+ .width0 = 412,
+ .height0 = 732,
+ .slices =
+ {
+ {.offset = 0, .pitch = 7168},
+ },
+ .ubwc_slices =
+ {
+ {.offset = 0, .pitch = 128},
+ },
+ },
+ },
};
int
main(int argc, char **argv)
{
- int ret = 0;
+ int ret = 0;
- for (int i = 0; i < ARRAY_SIZE(testcases); i++) {
- if (!fdl_test_layout(&testcases[i], 630))
- ret = 1;
- }
+ for (int i = 0; i < ARRAY_SIZE(testcases); i++) {
+ if (!fdl_test_layout(&testcases[i], 630))
+ ret = 1;
+ }
- return ret;
+ return ret;
}
diff --git a/src/freedreno/fdl/fd_layout_test.c b/src/freedreno/fdl/fd_layout_test.c
index 08e8c1b2509..457cd426036 100644
--- a/src/freedreno/fdl/fd_layout_test.c
+++ b/src/freedreno/fdl/fd_layout_test.c
@@ -29,98 +29,85 @@
#include <stdio.h>
-bool fdl_test_layout(const struct testcase *testcase, int gpu_id)
+bool
+fdl_test_layout(const struct testcase *testcase, int gpu_id)
{
- struct fdl_layout layout = {
- .ubwc = testcase->layout.ubwc,
- .tile_mode = testcase->layout.tile_mode,
- };
- bool ok = true;
+ struct fdl_layout layout = {
+ .ubwc = testcase->layout.ubwc,
+ .tile_mode = testcase->layout.tile_mode,
+ };
+ bool ok = true;
- int max_size = MAX2(testcase->layout.width0, testcase->layout.height0);
- int mip_levels = 1;
- while (max_size > 1 && testcase->layout.slices[mip_levels].pitch) {
- mip_levels++;
- max_size = u_minify(max_size, 1);
- }
+ int max_size = MAX2(testcase->layout.width0, testcase->layout.height0);
+ int mip_levels = 1;
+ while (max_size > 1 && testcase->layout.slices[mip_levels].pitch) {
+ mip_levels++;
+ max_size = u_minify(max_size, 1);
+ }
- if (gpu_id >= 600) {
- fdl6_layout(&layout,
- testcase->format,
- MAX2(testcase->layout.nr_samples, 1),
- testcase->layout.width0,
- MAX2(testcase->layout.height0, 1),
- MAX2(testcase->layout.depth0, 1),
- mip_levels,
- MAX2(testcase->array_size, 1),
- testcase->is_3d,
- NULL);
- } else {
- assert(gpu_id >= 500);
- fdl5_layout(&layout,
- testcase->format,
- MAX2(testcase->layout.nr_samples, 1),
- testcase->layout.width0,
- MAX2(testcase->layout.height0, 1),
- MAX2(testcase->layout.depth0, 1),
- mip_levels,
- MAX2(testcase->array_size, 1),
- testcase->is_3d);
- }
+ if (gpu_id >= 600) {
+ fdl6_layout(&layout, testcase->format,
+ MAX2(testcase->layout.nr_samples, 1), testcase->layout.width0,
+ MAX2(testcase->layout.height0, 1),
+ MAX2(testcase->layout.depth0, 1), mip_levels,
+ MAX2(testcase->array_size, 1), testcase->is_3d, NULL);
+ } else {
+ assert(gpu_id >= 500);
+ fdl5_layout(&layout, testcase->format,
+ MAX2(testcase->layout.nr_samples, 1), testcase->layout.width0,
+ MAX2(testcase->layout.height0, 1),
+ MAX2(testcase->layout.depth0, 1), mip_levels,
+ MAX2(testcase->array_size, 1), testcase->is_3d);
+ }
- /* fdl lays out UBWC data before the color data, while all we have
- * recorded in this testcase are the color offsets (other than the UBWC
- * buffer sharing test). Shift the fdl layout down so we can compare
- * color offsets.
- */
- if (layout.ubwc && !testcase->layout.slices[0].offset) {
- for (int l = 1; l < mip_levels; l++)
- layout.slices[l].offset -= layout.slices[0].offset;
- layout.slices[0].offset = 0;
- }
+ /* fdl lays out UBWC data before the color data, while all we have
+ * recorded in this testcase are the color offsets (other than the UBWC
+ * buffer sharing test). Shift the fdl layout down so we can compare
+ * color offsets.
+ */
+ if (layout.ubwc && !testcase->layout.slices[0].offset) {
+ for (int l = 1; l < mip_levels; l++)
+ layout.slices[l].offset -= layout.slices[0].offset;
+ layout.slices[0].offset = 0;
+ }
- for (int l = 0; l < mip_levels; l++) {
- if (layout.slices[l].offset != testcase->layout.slices[l].offset) {
- fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: offset 0x%x != 0x%x\n",
- util_format_short_name(testcase->format),
- layout.width0, layout.height0, layout.depth0,
- layout.nr_samples, l,
- layout.slices[l].offset,
- testcase->layout.slices[l].offset);
- ok = false;
- }
- if (fdl_pitch(&layout, l) != testcase->layout.slices[l].pitch) {
- fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: pitch %d != %d\n",
- util_format_short_name(testcase->format),
- layout.width0, layout.height0, layout.depth0,
- layout.nr_samples, l,
- fdl_pitch(&layout, l),
- testcase->layout.slices[l].pitch);
- ok = false;
- }
+ for (int l = 0; l < mip_levels; l++) {
+ if (layout.slices[l].offset != testcase->layout.slices[l].offset) {
+ fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: offset 0x%x != 0x%x\n",
+ util_format_short_name(testcase->format), layout.width0,
+ layout.height0, layout.depth0, layout.nr_samples, l,
+ layout.slices[l].offset, testcase->layout.slices[l].offset);
+ ok = false;
+ }
+ if (fdl_pitch(&layout, l) != testcase->layout.slices[l].pitch) {
+ fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: pitch %d != %d\n",
+ util_format_short_name(testcase->format), layout.width0,
+ layout.height0, layout.depth0, layout.nr_samples, l,
+ fdl_pitch(&layout, l), testcase->layout.slices[l].pitch);
+ ok = false;
+ }
- if (layout.ubwc_slices[l].offset != testcase->layout.ubwc_slices[l].offset) {
- fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: UBWC offset 0x%x != 0x%x\n",
- util_format_short_name(testcase->format),
- layout.width0, layout.height0, layout.depth0,
- layout.nr_samples, l,
- layout.ubwc_slices[l].offset,
- testcase->layout.ubwc_slices[l].offset);
- ok = false;
- }
- if (fdl_ubwc_pitch(&layout, l) != testcase->layout.ubwc_slices[l].pitch) {
- fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: UBWC pitch %d != %d\n",
- util_format_short_name(testcase->format),
- layout.width0, layout.height0, layout.depth0,
- layout.nr_samples, l,
- fdl_ubwc_pitch(&layout, l),
- testcase->layout.ubwc_slices[l].pitch);
- ok = false;
- }
- }
+ if (layout.ubwc_slices[l].offset !=
+ testcase->layout.ubwc_slices[l].offset) {
+ fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: UBWC offset 0x%x != 0x%x\n",
+ util_format_short_name(testcase->format), layout.width0,
+ layout.height0, layout.depth0, layout.nr_samples, l,
+ layout.ubwc_slices[l].offset,
+ testcase->layout.ubwc_slices[l].offset);
+ ok = false;
+ }
+ if (fdl_ubwc_pitch(&layout, l) != testcase->layout.ubwc_slices[l].pitch) {
+ fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: UBWC pitch %d != %d\n",
+ util_format_short_name(testcase->format), layout.width0,
+ layout.height0, layout.depth0, layout.nr_samples, l,
+ fdl_ubwc_pitch(&layout, l),
+ testcase->layout.ubwc_slices[l].pitch);
+ ok = false;
+ }
+ }
- if (!ok)
- fprintf(stderr, "\n");
+ if (!ok)
+ fprintf(stderr, "\n");
- return ok;
+ return ok;
}
diff --git a/src/freedreno/fdl/fd_layout_test.h b/src/freedreno/fdl/fd_layout_test.h
index edf56cec511..75280bf5dfe 100644
--- a/src/freedreno/fdl/fd_layout_test.h
+++ b/src/freedreno/fdl/fd_layout_test.h
@@ -22,26 +22,26 @@
*/
struct testcase {
- enum pipe_format format;
+ enum pipe_format format;
- int array_size; /* Size for array textures, or 0 otherwise. */
- bool is_3d;
+ int array_size; /* Size for array textures, or 0 otherwise. */
+ bool is_3d;
- /* Partially filled layout of input parameters and expected results. */
- struct {
- uint32_t tile_mode : 2;
- bool ubwc : 1;
- uint32_t width0, height0, depth0;
- uint32_t nr_samples;
- struct {
- uint32_t offset;
- uint32_t pitch;
- } slices[FDL_MAX_MIP_LEVELS];
- struct {
- uint32_t offset;
- uint32_t pitch;
- } ubwc_slices[FDL_MAX_MIP_LEVELS];
- } layout;
+ /* Partially filled layout of input parameters and expected results. */
+ struct {
+ uint32_t tile_mode : 2;
+ bool ubwc : 1;
+ uint32_t width0, height0, depth0;
+ uint32_t nr_samples;
+ struct {
+ uint32_t offset;
+ uint32_t pitch;
+ } slices[FDL_MAX_MIP_LEVELS];
+ struct {
+ uint32_t offset;
+ uint32_t pitch;
+ } ubwc_slices[FDL_MAX_MIP_LEVELS];
+ } layout;
};
bool fdl_test_layout(const struct testcase *testcase, int gpu_id);
diff --git a/src/freedreno/fdl/freedreno_layout.c b/src/freedreno/fdl/freedreno_layout.c
index c6dc5ecf769..a334288010c 100644
--- a/src/freedreno/fdl/freedreno_layout.c
+++ b/src/freedreno/fdl/freedreno_layout.c
@@ -32,35 +32,35 @@
void
fdl_layout_buffer(struct fdl_layout *layout, uint32_t size)
{
- layout->width0 = size;
- layout->height0 = 1;
- layout->depth0 = 1;
- layout->cpp = 1;
- layout->cpp_shift = 0;
- layout->size = size;
- layout->format = PIPE_FORMAT_R8_UINT;
- layout->nr_samples = 1;
+ layout->width0 = size;
+ layout->height0 = 1;
+ layout->depth0 = 1;
+ layout->cpp = 1;
+ layout->cpp_shift = 0;
+ layout->size = size;
+ layout->format = PIPE_FORMAT_R8_UINT;
+ layout->nr_samples = 1;
}
void
fdl_dump_layout(struct fdl_layout *layout)
{
- for (uint32_t level = 0; level < ARRAY_SIZE(layout->slices) && layout->slices[level].size0; level++) {
- struct fdl_slice *slice = &layout->slices[level];
- struct fdl_slice *ubwc_slice = &layout->ubwc_slices[level];
+ for (uint32_t level = 0;
+ level < ARRAY_SIZE(layout->slices) && layout->slices[level].size0;
+ level++) {
+ struct fdl_slice *slice = &layout->slices[level];
+ struct fdl_slice *ubwc_slice = &layout->ubwc_slices[level];
- fprintf(stderr, "%s: %ux%ux%u@%ux%u:\t%2u: stride=%4u, size=%6u,%6u, aligned_height=%3u, offset=0x%x,0x%x, layersz %5u,%5u tiling=%d\n",
- util_format_name(layout->format),
- u_minify(layout->width0, level),
- u_minify(layout->height0, level),
- u_minify(layout->depth0, level),
- layout->cpp, layout->nr_samples,
- level,
- fdl_pitch(layout, level),
- slice->size0, ubwc_slice->size0,
- slice->size0 / fdl_pitch(layout, level),
- slice->offset, ubwc_slice->offset,
- layout->layer_size, layout->ubwc_layer_size,
- fdl_tile_mode(layout, level));
- }
+ fprintf(
+ stderr,
+ "%s: %ux%ux%u@%ux%u:\t%2u: stride=%4u, size=%6u,%6u, "
+ "aligned_height=%3u, offset=0x%x,0x%x, layersz %5u,%5u tiling=%d\n",
+ util_format_name(layout->format), u_minify(layout->width0, level),
+ u_minify(layout->height0, level), u_minify(layout->depth0, level),
+ layout->cpp, layout->nr_samples, level, fdl_pitch(layout, level),
+ slice->size0, ubwc_slice->size0,
+ slice->size0 / fdl_pitch(layout, level), slice->offset,
+ ubwc_slice->offset, layout->layer_size, layout->ubwc_layer_size,
+ fdl_tile_mode(layout, level));
+ }
}
diff --git a/src/freedreno/fdl/freedreno_layout.h b/src/freedreno/fdl/freedreno_layout.h
index 494c88f4554..e25b7800de9 100644
--- a/src/freedreno/fdl/freedreno_layout.h
+++ b/src/freedreno/fdl/freedreno_layout.h
@@ -27,9 +27,9 @@
#include <stdbool.h>
#include <stdint.h>
+#include "util/format/u_format.h"
#include "util/u_debug.h"
#include "util/u_math.h"
-#include "util/format/u_format.h"
/* Shared freedreno mipmap layout helper
*
@@ -78,14 +78,14 @@
#define FDL_MAX_MIP_LEVELS 15
struct fdl_slice {
- uint32_t offset; /* offset of first layer in slice */
- uint32_t size0; /* size of first layer in slice */
+ uint32_t offset; /* offset of first layer in slice */
+ uint32_t size0; /* size of first layer in slice */
};
/* parameters for explicit (imported) layout */
struct fdl_explicit_layout {
- uint32_t offset;
- uint32_t pitch;
+ uint32_t offset;
+ uint32_t pitch;
};
/**
@@ -94,106 +94,107 @@ struct fdl_explicit_layout {
* to derive this.
*/
struct fdl_layout {
- struct fdl_slice slices[FDL_MAX_MIP_LEVELS];
- struct fdl_slice ubwc_slices[FDL_MAX_MIP_LEVELS];
- uint32_t pitch0;
- uint32_t ubwc_width0;
- uint32_t layer_size;
- uint32_t ubwc_layer_size; /* in bytes */
- bool ubwc : 1;
- bool layer_first : 1; /* see above description */
- bool tile_all : 1;
-
- /* Note that for tiled textures, beyond a certain mipmap level (ie.
- * when width is less than block size) things switch to linear. In
- * general you should not directly look at fdl_layout::tile_mode,
- * but instead use fdl_surface::tile_mode which will correctly take
- * this into account.
- */
- uint32_t tile_mode : 2;
- /* Bytes per pixel (where a "pixel" is a single row of a block in the case
- * of compression), including each sample in the case of multisample
- * layouts.
- */
- uint8_t cpp;
-
- /**
- * Left shift necessary to multiply by cpp. Invalid for NPOT cpp, please
- * use fdl_cpp_shift() to sanity check you aren't hitting that case.
- */
- uint8_t cpp_shift;
-
- uint32_t width0, height0, depth0;
- uint32_t nr_samples;
- enum pipe_format format;
-
- uint32_t size; /* Size of the whole image, in bytes. */
- uint32_t base_align; /* Alignment of the base address, in bytes. */
- uint8_t pitchalign; /* log2(pitchalign) */
+ struct fdl_slice slices[FDL_MAX_MIP_LEVELS];
+ struct fdl_slice ubwc_slices[FDL_MAX_MIP_LEVELS];
+ uint32_t pitch0;
+ uint32_t ubwc_width0;
+ uint32_t layer_size;
+ uint32_t ubwc_layer_size; /* in bytes */
+ bool ubwc : 1;
+ bool layer_first : 1; /* see above description */
+ bool tile_all : 1;
+
+ /* Note that for tiled textures, beyond a certain mipmap level (ie.
+ * when width is less than block size) things switch to linear. In
+ * general you should not directly look at fdl_layout::tile_mode,
+ * but instead use fdl_surface::tile_mode which will correctly take
+ * this into account.
+ */
+ uint32_t tile_mode : 2;
+ /* Bytes per pixel (where a "pixel" is a single row of a block in the case
+ * of compression), including each sample in the case of multisample
+ * layouts.
+ */
+ uint8_t cpp;
+
+ /**
+ * Left shift necessary to multiply by cpp. Invalid for NPOT cpp, please
+ * use fdl_cpp_shift() to sanity check you aren't hitting that case.
+ */
+ uint8_t cpp_shift;
+
+ uint32_t width0, height0, depth0;
+ uint32_t nr_samples;
+ enum pipe_format format;
+
+ uint32_t size; /* Size of the whole image, in bytes. */
+ uint32_t base_align; /* Alignment of the base address, in bytes. */
+ uint8_t pitchalign; /* log2(pitchalign) */
};
static inline uint32_t
fdl_cpp_shift(const struct fdl_layout *layout)
{
- assert(util_is_power_of_two_or_zero(layout->cpp));
- return layout->cpp_shift;
+ assert(util_is_power_of_two_or_zero(layout->cpp));
+ return layout->cpp_shift;
}
static inline uint32_t
fdl_pitch(const struct fdl_layout *layout, unsigned level)
{
- return align(u_minify(layout->pitch0, level), 1 << layout->pitchalign);
+ return align(u_minify(layout->pitch0, level), 1 << layout->pitchalign);
}
-#define RGB_TILE_WIDTH_ALIGNMENT 64
+#define RGB_TILE_WIDTH_ALIGNMENT 64
#define RGB_TILE_HEIGHT_ALIGNMENT 16
#define UBWC_PLANE_SIZE_ALIGNMENT 4096
static inline uint32_t
fdl_ubwc_pitch(const struct fdl_layout *layout, unsigned level)
{
- if (!layout->ubwc)
- return 0;
- return align(u_minify(layout->ubwc_width0, level), RGB_TILE_WIDTH_ALIGNMENT);
+ if (!layout->ubwc)
+ return 0;
+ return align(u_minify(layout->ubwc_width0, level), RGB_TILE_WIDTH_ALIGNMENT);
}
static inline uint32_t
fdl_layer_stride(const struct fdl_layout *layout, unsigned level)
{
- if (layout->layer_first)
- return layout->layer_size;
- else
- return layout->slices[level].size0;
+ if (layout->layer_first)
+ return layout->layer_size;
+ else
+ return layout->slices[level].size0;
}
/* a2xx is special and needs PoT alignment for mipmaps: */
static inline uint32_t
fdl2_pitch(const struct fdl_layout *layout, unsigned level)
{
- uint32_t pitch = fdl_pitch(layout, level);
- if (level)
- pitch = util_next_power_of_two(pitch);
- return pitch;
+ uint32_t pitch = fdl_pitch(layout, level);
+ if (level)
+ pitch = util_next_power_of_two(pitch);
+ return pitch;
}
static inline uint32_t
fdl2_pitch_pixels(const struct fdl_layout *layout, unsigned level)
{
- return fdl2_pitch(layout, level) >> fdl_cpp_shift(layout);
+ return fdl2_pitch(layout, level) >> fdl_cpp_shift(layout);
}
static inline uint32_t
-fdl_surface_offset(const struct fdl_layout *layout, unsigned level, unsigned layer)
+fdl_surface_offset(const struct fdl_layout *layout, unsigned level,
+ unsigned layer)
{
- const struct fdl_slice *slice = &layout->slices[level];
- return slice->offset + fdl_layer_stride(layout, level) * layer;
+ const struct fdl_slice *slice = &layout->slices[level];
+ return slice->offset + fdl_layer_stride(layout, level) * layer;
}
static inline uint32_t
fdl_ubwc_offset(const struct fdl_layout *layout, unsigned level, unsigned layer)
{
- const struct fdl_slice *slice = &layout->ubwc_slices[level];
- return slice->offset + layer * layout->ubwc_layer_size;
+ const struct fdl_slice *slice = &layout->ubwc_slices[level];
+ return slice->offset + layer * layout->ubwc_layer_size;
}
/* Minimum layout width to enable UBWC. */
@@ -202,60 +203,54 @@ fdl_ubwc_offset(const struct fdl_layout *layout, unsigned level, unsigned layer)
static inline bool
fdl_level_linear(const struct fdl_layout *layout, int level)
{
- if (layout->tile_all)
- return false;
+ if (layout->tile_all)
+ return false;
- unsigned w = u_minify(layout->width0, level);
- if (w < FDL_MIN_UBWC_WIDTH)
- return true;
+ unsigned w = u_minify(layout->width0, level);
+ if (w < FDL_MIN_UBWC_WIDTH)
+ return true;
- return false;
+ return false;
}
static inline uint32_t
fdl_tile_mode(const struct fdl_layout *layout, int level)
{
- if (layout->tile_mode && fdl_level_linear(layout, level))
- return 0; /* linear */
- else
- return layout->tile_mode;
+ if (layout->tile_mode && fdl_level_linear(layout, level))
+ return 0; /* linear */
+ else
+ return layout->tile_mode;
}
static inline bool
fdl_ubwc_enabled(const struct fdl_layout *layout, int level)
{
- return layout->ubwc;
+ return layout->ubwc;
}
-void
-fdl_layout_buffer(struct fdl_layout *layout, uint32_t size);
+void fdl_layout_buffer(struct fdl_layout *layout, uint32_t size);
-void
-fdl5_layout(struct fdl_layout *layout,
- enum pipe_format format, uint32_t nr_samples,
- uint32_t width0, uint32_t height0, uint32_t depth0,
- uint32_t mip_levels, uint32_t array_size, bool is_3d);
+void fdl5_layout(struct fdl_layout *layout, enum pipe_format format,
+ uint32_t nr_samples, uint32_t width0, uint32_t height0,
+ uint32_t depth0, uint32_t mip_levels, uint32_t array_size,
+ bool is_3d);
-bool
-fdl6_layout(struct fdl_layout *layout,
- enum pipe_format format, uint32_t nr_samples,
- uint32_t width0, uint32_t height0, uint32_t depth0,
- uint32_t mip_levels, uint32_t array_size, bool is_3d,
- struct fdl_explicit_layout *plane_layout);
+bool fdl6_layout(struct fdl_layout *layout, enum pipe_format format,
+ uint32_t nr_samples, uint32_t width0, uint32_t height0,
+ uint32_t depth0, uint32_t mip_levels, uint32_t array_size,
+ bool is_3d, struct fdl_explicit_layout *plane_layout);
static inline void
fdl_set_pitchalign(struct fdl_layout *layout, unsigned pitchalign)
{
- uint32_t nblocksx = util_format_get_nblocksx(layout->format, layout->width0);
- layout->pitchalign = pitchalign;
- layout->pitch0 = align(nblocksx * layout->cpp, 1 << pitchalign);
+ uint32_t nblocksx = util_format_get_nblocksx(layout->format, layout->width0);
+ layout->pitchalign = pitchalign;
+ layout->pitch0 = align(nblocksx * layout->cpp, 1 << pitchalign);
}
-void
-fdl_dump_layout(struct fdl_layout *layout);
+void fdl_dump_layout(struct fdl_layout *layout);
-void
-fdl6_get_ubwc_blockwidth(struct fdl_layout *layout,
- uint32_t *blockwidth, uint32_t *blockheight);
+void fdl6_get_ubwc_blockwidth(struct fdl_layout *layout, uint32_t *blockwidth,
+ uint32_t *blockheight);
#endif /* FREEDRENO_LAYOUT_H_ */