Mesa (main): turnip: clamp to 1 for negative bottom-right of viewport.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 3 03:03:17 UTC 2022


Module: Mesa
Branch: main
Commit: 8eb5178a6db9cad5798bbb7fb4476893e2f58334
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8eb5178a6db9cad5798bbb7fb4476893e2f58334

Author: Hyunjun Ko <zzoon at igalia.com>
Date:   Wed Jun  1 01:37:16 2022 +0000

turnip: clamp to 1 for negative bottom-right of viewport.

This fixes a crash of spec@!opengl 3.0 at viewport-clamp in
piglit(with zink).
Also fixes a crash of negativeviewportheight in Sascha's examples.

Closes: #6583

Signed-off-by: Hyunjun Ko <zzoon at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16831>

---

 src/freedreno/vulkan/tu_pipeline.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c
index 0a55e2c13ee..4fca334e401 100644
--- a/src/freedreno/vulkan/tu_pipeline.c
+++ b/src/freedreno/vulkan/tu_pipeline.c
@@ -1950,13 +1950,16 @@ tu6_emit_viewport(struct tu_cs *cs, const VkViewport *viewports, uint32_t num_vi
 
       min.x = MAX2(min.x, 0);
       min.y = MAX2(min.y, 0);
+      max.x = MAX2(max.x, 1);
+      max.y = MAX2(max.y, 1);
 
       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) |
-                     A6XX_GRAS_SC_VIEWPORT_SCISSOR_TL_Y(max.y - 1));
+      tu_cs_emit(cs, A6XX_GRAS_SC_VIEWPORT_SCISSOR_BR_X(max.x - 1) |
+                     A6XX_GRAS_SC_VIEWPORT_SCISSOR_BR_Y(max.y - 1));
    }
 
    tu_cs_emit_pkt4(cs, REG_A6XX_GRAS_CL_Z_CLAMP(0), num_viewport * 2);



More information about the mesa-commit mailing list