From 84af2cb44ab56772d79bc60771162327f75f943d Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Mon, 5 Jun 2023 11:39:19 +0200 Subject: [PATCH] v3dv: simplify scissor setup for negative viewport height MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit KHR_maintenance1 allows clients to specify a negative height, but not a negative width, so assert on that and simplify the computations for the horizontal dimension. Reviewed-by: Alejandro Piñeiro Part-of: --- src/broadcom/vulkan/v3dv_cmd_buffer.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/broadcom/vulkan/v3dv_cmd_buffer.c b/src/broadcom/vulkan/v3dv_cmd_buffer.c index ee19717..a14db07 100644 --- a/src/broadcom/vulkan/v3dv_cmd_buffer.c +++ b/src/broadcom/vulkan/v3dv_cmd_buffer.c @@ -2264,11 +2264,14 @@ emit_scissor(struct v3dv_cmd_buffer *cmd_buffer) */ float *vptranslate = dynamic->viewport.translate[0]; float *vpscale = dynamic->viewport.scale[0]; + assert(vpscale[0] >= 0); - float vp_minx = -fabsf(vpscale[0]) + vptranslate[0]; - float vp_maxx = fabsf(vpscale[0]) + vptranslate[0]; - float vp_miny = -fabsf(vpscale[1]) + vptranslate[1]; - float vp_maxy = fabsf(vpscale[1]) + vptranslate[1]; + float vp_minx = vptranslate[0] - vpscale[0]; + float vp_maxx = vptranslate[0] + vpscale[0]; + + /* With KHR_maintenance1 viewport may have negative Y */ + float vp_miny = vptranslate[1] - fabsf(vpscale[1]); + float vp_maxy = vptranslate[1] + fabsf(vpscale[1]); /* Quoting from v3dx_emit: * "Clip to the scissor if it's enabled, but still clip to the -- 2.7.4