From: Alyssa Rosenzweig Date: Wed, 17 Jul 2019 23:30:09 +0000 (-0700) Subject: panfrost: Make scissor test more robust X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fad76470d54a1c87677e4659fcd65f19ba81d58d;p=mesa.git panfrost: Make scissor test more robust See v3d implementation. Signed-off-by: Alyssa Rosenzweig --- diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index c022e950c00..c3e191403fb 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -1371,19 +1371,26 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data) }; /* Always scissor to the viewport by default. */ - int minx = (int) (vp->translate[0] - vp->scale[0]); - int maxx = (int) (vp->translate[0] + vp->scale[0]); + float vp_minx = (int) (vp->translate[0] - fabsf(vp->scale[0])); + float vp_maxx = (int) (vp->translate[0] + fabsf(vp->scale[0])); - int miny = (int) (vp->translate[1] - vp->scale[1]); - int maxy = (int) (vp->translate[1] + vp->scale[1]); + float vp_miny = (int) (vp->translate[1] - fabsf(vp->scale[1])); + float vp_maxy = (int) (vp->translate[1] + fabsf(vp->scale[1])); /* Apply the scissor test */ + unsigned minx, miny, maxx, maxy; + if (ss && ctx->rasterizer && ctx->rasterizer->base.scissor) { - minx = ss->minx; - maxx = ss->maxx; - miny = ss->miny; - maxy = ss->maxy; + minx = MAX2(ss->minx, vp_minx); + miny = MAX2(ss->miny, vp_miny); + maxx = MIN2(ss->maxx, vp_maxx); + maxy = MIN2(ss->maxy, vp_maxy); + } else { + minx = vp_minx; + miny = vp_miny; + maxx = vp_maxx; + maxy = vp_maxy; } /* Hardware needs the min/max to be strictly ordered, so flip if we