From 243724031b25d98c776de1076ff982022402f313 Mon Sep 17 00:00:00 2001 From: Danylo Piliaiev Date: Tue, 16 Mar 2021 19:48:30 +0200 Subject: [PATCH] turnip: clamp to zero negative upper left corner of viewport We cannot send negative viewport coordinates to the hardware, so clamp them since negative min.x/y is valid per spec. The negative origin still counts in calculations of guardband. Fixes crash in 3DMark's "Sling Shot Extreme" test. Signed-off-by: Danylo Piliaiev Part-of: --- src/freedreno/vulkan/tu_pipeline.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c index f3eab34cc3d..f81f034ab96 100644 --- a/src/freedreno/vulkan/tu_pipeline.c +++ b/src/freedreno/vulkan/tu_pipeline.c @@ -1731,8 +1731,12 @@ tu6_emit_viewport(struct tu_cs *cs, const VkViewport *viewports, uint32_t num_vi /* allow viewport->width = 0.0f for un-initialized viewports: */ if (min.x == max.x) max.x++; - assert(min.x >= 0 && min.x < max.x); - assert(min.y >= 0 && min.y < max.y); + + min.x = MAX2(min.x, 0); + min.y = MAX2(min.y, 0); + + assert(min.x < max.x); + assert(min.y < max.y); tu_cs_emit(cs, A6XX_GRAS_SC_VIEWPORT_SCISSOR_TL_X(min.x) | A6XX_GRAS_SC_VIEWPORT_SCISSOR_TL_Y(min.y)); tu_cs_emit(cs, A6XX_GRAS_SC_VIEWPORT_SCISSOR_TL_X(max.x - 1) |