From 0b359878956056fde2a0e30431adc9a67319a237 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Mon, 15 Mar 2021 18:54:23 +0000 Subject: [PATCH] tu: Skip tu_tiling_config_update_tile_layout() if not using gmem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise pass->tile_align_w will be 0, leading to a divide by zero and undefined behavior. In practice, I saw this lead to an infinite loop in tests like dEQP-VK.draw.instanced.draw_indexed_indirect_vk_primitive_topology_line_list_attrib_divisor_0_multiview Reviewed-by: Samuel Iglesias Gonsálvez Part-of: --- src/freedreno/vulkan/tu_util.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/freedreno/vulkan/tu_util.c b/src/freedreno/vulkan/tu_util.c index a53b9a7e731..1133c0e0cf9 100644 --- a/src/freedreno/vulkan/tu_util.c +++ b/src/freedreno/vulkan/tu_util.c @@ -98,6 +98,12 @@ tu_tiling_config_update_tile_layout(struct tu_framebuffer *fb, .height = align(fb->height, tile_align_h), }; + /* will force to sysmem, don't bother trying to have a valid tile config + * TODO: just skip all GMEM stuff when sysmem is forced? + */ + if (!pass->gmem_pixels) + return; + if (unlikely(dev->physical_device->instance->debug_flags & TU_DEBUG_FORCEBIN)) { /* start with 2x2 tiles */ fb->tile_count.width = 2; @@ -120,12 +126,6 @@ tu_tiling_config_update_tile_layout(struct tu_framebuffer *fb, util_align_npot(DIV_ROUND_UP(fb->height, fb->tile_count.height), tile_align_h); } - /* will force to sysmem, don't bother trying to have a valid tile config - * TODO: just skip all GMEM stuff when sysmem is forced? - */ - if (!pass->gmem_pixels) - return; - /* do not exceed gmem size */ while (fb->tile0.width * fb->tile0.height > pass->gmem_pixels) { if (fb->tile0.width > MAX2(tile_align_w, fb->tile0.height)) {