Mesa (master): panfrost: Fix viewports

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Mar 26 23:37:32 UTC 2019


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

Author: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Date:   Sun Mar 24 20:01:15 2019 +0000

panfrost: Fix viewports

Our viewport code hardcoded a number of wrong assumptions, which sort of
sometimes worked but was definitely wrong (and broke most of dEQP). This
corrects the logic, accounting for flipped-Y framebuffers, which
fixes... most of dEQP.

Signed-off-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>

---

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

diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index 19cdb6c0444..8c4502b1cd8 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -1059,12 +1059,19 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
         /* Generate the viewport vector of the form: <width/2, height/2, centerx, centery> */
         const struct pipe_viewport_state *vp = &ctx->pipe_viewport;
 
+        /* For flipped-Y buffers (signaled by negative scale), the translate is
+         * flipped as well */
+
+        float translate_y =
+                vp->scale[1] >= 0.0 ? vp->translate[1] :
+                (ctx->pipe_framebuffer.height - vp->translate[1]);
+
         float viewport_vec4[] = {
                 vp->scale[0],
                 fabsf(vp->scale[1]),
 
                 vp->translate[0],
-                /* -1.0 * vp->translate[1] */ fabs(1.0 * vp->scale[1]) /* XXX */
+                translate_y
         };
 
         for (int i = 0; i < PIPE_SHADER_TYPES; ++i) {
@@ -1147,17 +1154,19 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
                 .clip_maxz = 1.0,
         };
 
+        /* Always scissor to the viewport by default. */
+        view.viewport0[0] = (int) (vp->translate[0] - vp->scale[0]);
+        view.viewport1[0] = MALI_POSITIVE((int) (vp->translate[0] + vp->scale[0]));
+
+        view.viewport0[1] = (int) (translate_y - fabs(vp->scale[1]));
+        view.viewport1[1] = MALI_POSITIVE((int) (translate_y + fabs(vp->scale[1])));
+
         if (ss && ctx->rasterizer && ctx->rasterizer->base.scissor && 0) {
                 view.viewport0[0] = ss->minx;
                 view.viewport0[1] = ss->miny;
                 view.viewport1[0] = MALI_POSITIVE(ss->maxx);
                 view.viewport1[1] = MALI_POSITIVE(ss->maxy);
-        } else {
-                view.viewport0[0] = 0;
-                view.viewport0[1] = 0;
-                view.viewport1[0] = MALI_POSITIVE(ctx->pipe_framebuffer.width);
-                view.viewport1[1] = MALI_POSITIVE(ctx->pipe_framebuffer.height);
-        }
+        } 
 
         ctx->payload_tiler.postfix.viewport =
                 panfrost_upload_transient(ctx,




More information about the mesa-commit mailing list