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 <icenowy@aosc.io> Reviewed-by: Andreas Baierl <ichgeh@imkreisrum.de> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3570> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3570>
This commit is contained in:
@@ -55,6 +55,7 @@ struct lima_fs_shader_state {
|
||||
void *shader;
|
||||
int shader_size;
|
||||
int stack_size;
|
||||
bool uses_discard;
|
||||
struct lima_bo *bo;
|
||||
};
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -287,6 +287,8 @@ lima_create_fs_state(struct pipe_context *pctx,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
so->uses_discard = nir->info.fs.uses_discard;
|
||||
|
||||
return so;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user