From b7a492630ea3459fa60ba4eb902bab0495dc6777 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Thu, 13 Feb 2025 11:57:35 -0500 Subject: [PATCH] tu: Implement bin skipping for zero-density regions Follow the semi-documented behavior of the blob driver and skip rendering bins whose fragment density is 0 (i.e. fragment area is infinite). Some Oculus VR apps using an earlier version of the Unity SDK rely on this instead of VK_QCOM_multiview_per_view_render_areas. Part-of: --- src/freedreno/vulkan/tu_cmd_buffer.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/freedreno/vulkan/tu_cmd_buffer.cc b/src/freedreno/vulkan/tu_cmd_buffer.cc index c76cbedf9ac..23cdda8241e 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.cc +++ b/src/freedreno/vulkan/tu_cmd_buffer.cc @@ -3745,6 +3745,18 @@ tu_calc_frag_area(struct tu_cmd_buffer *cmd, float area = raw_areas[i].width * raw_areas[i].height; float frac_x = modff(raw_areas[i].width, &floor_x); float frac_y = modff(raw_areas[i].height, &floor_y); + + /* The Vulkan spec says that a density of 0 results in an undefined + * fragment area. However the blob driver skips rendering tiles with 0 + * density, and apps rely on that behavior. Replicate that here. + */ + if (!isfinite(area)) { + tile->frag_areas[i].width = UINT32_MAX; + tile->frag_areas[i].height = UINT32_MAX; + tile->visible_views &= ~(1u << i); + continue; + } + /* The spec allows rounding up one of the axes as long as the total * area is less than or equal to the original area. Take advantage of * this to try rounding up the number with the largest fraction.