From: Vasily Khoruzhick Date: Sun, 26 Jan 2020 18:30:17 +0000 (-0800) Subject: lima: disable early-z if fragment shader uses discard X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fe5267d32233192b57969a19d5733e874e63bb15;p=mesa.git lima: disable early-z if fragment shader uses discard We have to disable early-z if fragment shader uses discard, otherwise we'll get misrendering. Reported-by: Icenowy Zheng Reviewed-by: Andreas Baierl Signed-off-by: Vasily Khoruzhick Tested-by: Marge Bot Part-of: --- diff --git a/src/gallium/drivers/lima/lima_context.h b/src/gallium/drivers/lima/lima_context.h index 304576b7b6d..140d7f9cd95 100644 --- a/src/gallium/drivers/lima/lima_context.h +++ b/src/gallium/drivers/lima/lima_context.h @@ -55,6 +55,7 @@ struct lima_fs_shader_state { void *shader; int shader_size; int stack_size; + bool uses_discard; struct lima_bo *bo; }; diff --git a/src/gallium/drivers/lima/lima_draw.c b/src/gallium/drivers/lima/lima_draw.c index 446ba3b5697..af637f4375c 100644 --- a/src/gallium/drivers/lima/lima_draw.c +++ b/src/gallium/drivers/lima/lima_draw.c @@ -1132,6 +1132,7 @@ lima_calculate_depth_test(struct pipe_depth_state *depth, struct pipe_rasterizer static void lima_pack_render_state(struct lima_context *ctx, const struct pipe_draw_info *info) { + struct lima_fs_shader_state *fs = ctx->fs; struct lima_render_state *render = lima_ctx_buff_alloc(ctx, lima_ctx_buff_pp_plb_rsw, sizeof(*render)); @@ -1239,11 +1240,15 @@ lima_pack_render_state(struct lima_context *ctx, const struct pipe_draw_info *in render->textures_address = 0x00000000; /* more investigation */ - render->aux0 = 0x00000300 | (ctx->vs->varying_stride >> 3); + render->aux0 = 0x00000100 | (ctx->vs->varying_stride >> 3); render->aux1 = 0x00001000; if (ctx->blend->base.dither) render->aux1 |= 0x00002000; + /* Enable Early-Z if shader doesn't have discard */ + if (!fs->uses_discard) + render->aux0 |= 0x200; + if (ctx->tex_stateobj.num_samplers) { render->textures_address = lima_ctx_buff_va(ctx, lima_ctx_buff_pp_tex_desc, LIMA_CTX_BUFF_SUBMIT_PP); diff --git a/src/gallium/drivers/lima/lima_program.c b/src/gallium/drivers/lima/lima_program.c index 071a736624d..9b9796d588b 100644 --- a/src/gallium/drivers/lima/lima_program.c +++ b/src/gallium/drivers/lima/lima_program.c @@ -287,6 +287,8 @@ lima_create_fs_state(struct pipe_context *pctx, return NULL; } + so->uses_discard = nir->info.fs.uses_discard; + return so; }