Module: Mesa
Branch: master
Commit: fad76470d54a1c87677e4659fcd65f19ba81d58d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fad76470d54a1c87677e4659fcd65f19ba81d58d

Author: Alyssa Rosenzweig <[email protected]>
Date:   Wed Jul 17 16:30:09 2019 -0700

panfrost: Make scissor test more robust

See v3d implementation.

Signed-off-by: Alyssa Rosenzweig <[email protected]>

---

 src/gallium/drivers/panfrost/pan_context.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

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

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to