From b936b1f9b49b0eb5c5ca3048790f032aa9b02ecb Mon Sep 17 00:00:00 2001 From: Vasily Khoruzhick Date: Fri, 10 Jan 2020 19:35:11 -0800 Subject: [PATCH] lima: fix viewport clipping Apparently Mali4x0 doesn't do viewport clipping, so anything rendered beyond viewport is still rendered. Looks like we need to use scissors to do clipping. Fixes most of dEQP-GLES2.functional.clipping.*, 6 out of 7 remaining failures fail on blob as well. Remaining [1] fails on many other gallium drivers. [1] dEQP-GLES2.functional.clipping.triangle_vertex.clip_three.clip_neg_x_neg_z_and_pos_x_pos_z_and_neg_x_neg_y_pos_z Suggested-by: Ilia Mirkin Reviewed-by: Qiang Yu Tested-by: Andreas Baierl Signed-off-by: Vasily Khoruzhick --- src/gallium/drivers/lima/lima_draw.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/lima/lima_draw.c b/src/gallium/drivers/lima/lima_draw.c index 0a0c60dbb94..d8ca64c9253 100644 --- a/src/gallium/drivers/lima/lima_draw.c +++ b/src/gallium/drivers/lima/lima_draw.c @@ -827,6 +827,7 @@ lima_pack_plbu_cmd(struct lima_context *ctx, const struct pipe_draw_info *info) { struct lima_context_framebuffer *fb = &ctx->framebuffer; struct lima_vs_shader_state *vs = ctx->vs; + unsigned minx, maxx, miny, maxy; lima_pack_head_plbu_cmd(ctx); @@ -876,14 +877,25 @@ lima_pack_plbu_cmd(struct lima_context *ctx, const struct pipe_draw_info *info) */ if (ctx->rasterizer->base.scissor) { struct pipe_scissor_state *scissor = &ctx->scissor; - PLBU_CMD_SCISSORS(scissor->minx, scissor->maxx, scissor->miny, scissor->maxy); - lima_damage_rect_union(ctx, scissor->minx, scissor->maxx, - scissor->miny, scissor->maxy); + minx = scissor->minx; + maxx = scissor->maxx; + miny = scissor->miny; + maxy = scissor->maxy; } else { - PLBU_CMD_SCISSORS(0, fb->base.width, 0, fb->base.height); - lima_damage_rect_union(ctx, 0, fb->base.width, 0, fb->base.height); + minx = 0; + maxx = fb->base.width; + miny = 0; + maxy = fb->base.height; } + minx = MAX2(minx, ctx->viewport.left); + maxx = MIN2(maxx, ctx->viewport.right); + miny = MAX2(miny, ctx->viewport.bottom); + maxy = MIN2(maxy, ctx->viewport.top); + + PLBU_CMD_SCISSORS(minx, maxx, miny, maxy); + lima_damage_rect_union(ctx, minx, maxx, miny, maxy); + PLBU_CMD_UNKNOWN1(); PLBU_CMD_DEPTH_RANGE_NEAR(fui(ctx->viewport.near)); -- 2.30.2