From fad76470d54a1c87677e4659fcd65f19ba81d58d Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 17 Jul 2019 16:30:09 -0700 Subject: panfrost: Make scissor test more robust See v3d implementation. Signed-off-by: Alyssa Rosenzweig --- src/gallium/drivers/panfrost/pan_context.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src') 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 -- cgit v1.2.3