From 928a857496e188d464e8cfe6eeae64229c49aa9f Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Thu, 13 Feb 2025 15:59:04 -0500 Subject: [PATCH] tu: Make sure tiles being merged are adjacent Even though we always try to merge a horizontally or vertically adjacent tile, when we try to merge a vertically adjacent tile it may not actually be adjacent because it was merged horizontally and the current tile wasn't or vice versa. We have to detect this and reject merging it. Fixes: 3fdaad0948c ("tu: Implement bin merging for fragment density map") Part-of: --- src/freedreno/vulkan/tu_cmd_buffer.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/freedreno/vulkan/tu_cmd_buffer.cc b/src/freedreno/vulkan/tu_cmd_buffer.cc index ef120c9d44f..9d8b7aa06db 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.cc +++ b/src/freedreno/vulkan/tu_cmd_buffer.cc @@ -2401,6 +2401,19 @@ try_merge_tiles(struct tu_tile_config *dst, const struct tu_tile_config *src, return false; } + /* The tiles must be vertically or horizontally adjacent and have the + * compatible width/height. + */ + if (dst->pos.x == src->pos.x) { + if (dst->extent.height != src->extent.height) + return false; + } else if (dst->pos.y == src->pos.y) { + if (dst->extent.width != src->extent.width) + return false; + } else { + return false; + } + if (!has_abs_bin_mask) { /* The mask of the combined tile has to fit in 16 bits */ uint32_t hw_mask = slot_mask >> (ffs(slot_mask) - 1);