freedreno/a3xx: fix viewport state during clear
authorRob Clark <robclark@freedesktop.org>
Tue, 21 Oct 2014 16:25:28 +0000 (12:25 -0400)
committerRob Clark <robclark@freedesktop.org>
Wed, 22 Oct 2014 00:08:49 +0000 (20:08 -0400)
Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/a3xx/fd3_draw.c

index e168d97ab52c269d2bab37ebf3c97583de1f4b1d..0fb0625bfa5389e6d914c9c28b883c3ff98cf731 100644 (file)
@@ -158,6 +158,22 @@ fd3_draw(struct fd_context *ctx, const struct pipe_draw_info *info)
        draw_impl(ctx, ctx->ring, &emit);
 }
 
+/* clear operations ignore viewport state, so we need to reset it
+ * based on framebuffer state:
+ */
+static void
+reset_viewport(struct fd_ringbuffer *ring, struct pipe_framebuffer_state *pfb)
+{
+       float half_width = pfb->width * 0.5f;
+       float half_height = pfb->height * 0.5f;
+
+       OUT_PKT0(ring, REG_A3XX_GRAS_CL_VPORT_XOFFSET, 4);
+       OUT_RING(ring, A3XX_GRAS_CL_VPORT_XOFFSET(half_width - 0.5));
+       OUT_RING(ring, A3XX_GRAS_CL_VPORT_XSCALE(half_width));
+       OUT_RING(ring, A3XX_GRAS_CL_VPORT_YOFFSET(half_height - 0.5));
+       OUT_RING(ring, A3XX_GRAS_CL_VPORT_YSCALE(-half_height));
+}
+
 /* binning pass cmds for a clear:
  * NOTE: newer blob drivers don't use binning for clear, which is probably
  * preferable since it is low vtx count.  However that doesn't seem to
@@ -183,6 +199,7 @@ fd3_clear_binning(struct fd_context *ctx, unsigned dirty)
 
        fd3_emit_state(ctx, ring, &emit);
        fd3_emit_vertex_bufs(ring, &emit);
+       reset_viewport(ring, &ctx->framebuffer);
 
        OUT_PKT0(ring, REG_A3XX_PC_PRIM_VTX_CNTL, 1);
        OUT_RING(ring, A3XX_PC_PRIM_VTX_CNTL_STRIDE_IN_VPC(0) |
@@ -219,7 +236,7 @@ fd3_clear(struct fd_context *ctx, unsigned buffers,
                },
        };
 
-       dirty &= FD_DIRTY_VIEWPORT | FD_DIRTY_FRAMEBUFFER | FD_DIRTY_SCISSOR;
+       dirty &= FD_DIRTY_FRAMEBUFFER | FD_DIRTY_SCISSOR;
        dirty |= FD_DIRTY_PROG;
        emit.dirty = dirty;
 
@@ -227,6 +244,7 @@ fd3_clear(struct fd_context *ctx, unsigned buffers,
 
        /* emit generic state now: */
        fd3_emit_state(ctx, ring, &emit);
+       reset_viewport(ring, &ctx->framebuffer);
 
        OUT_PKT0(ring, REG_A3XX_RB_BLEND_ALPHA, 1);
        OUT_RING(ring, A3XX_RB_BLEND_ALPHA_UINT(0xff) |