freedreno: a2xx: enable early-Z testing
authorJonathan Marek <jonathan@marek.ca>
Fri, 23 Nov 2018 15:58:11 +0000 (10:58 -0500)
committerRob Clark <robdclark@gmail.com>
Mon, 28 Jan 2019 18:04:41 +0000 (13:04 -0500)
Enable earlyZ when alpha test is disabled.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/a2xx/fd2_emit.c
src/gallium/drivers/freedreno/a2xx/fd2_program.h
src/gallium/drivers/freedreno/a2xx/fd2_zsa.c
src/gallium/drivers/freedreno/a2xx/ir2_nir.c

index 9628f267365ce839d25b63fae292dde9aed0bd9c..e98f86a82574933361b9f61847dcf9a8b3011159 100644 (file)
@@ -190,6 +190,7 @@ fd2_emit_state(struct fd_context *ctx, const enum fd_dirty_3d_state dirty)
 {
        struct fd2_blend_stateobj *blend = fd2_blend_stateobj(ctx->blend);
        struct fd2_zsa_stateobj *zsa = fd2_zsa_stateobj(ctx->zsa);
+       struct fd2_shader_stateobj *fp = ctx->prog.fp;
        struct fd_ringbuffer *ring = ctx->batch->draw;
 
        /* NOTE: we probably want to eventually refactor this so each state
@@ -205,12 +206,16 @@ fd2_emit_state(struct fd_context *ctx, const enum fd_dirty_3d_state dirty)
                OUT_RING(ring, ctx->sample_mask);
        }
 
-       if (dirty & (FD_DIRTY_ZSA | FD_DIRTY_STENCIL_REF)) {
+       if (dirty & (FD_DIRTY_ZSA | FD_DIRTY_STENCIL_REF | FD_DIRTY_PROG)) {
                struct pipe_stencil_ref *sr = &ctx->stencil_ref;
+               uint32_t val = zsa->rb_depthcontrol;
+
+               if (fp->has_kill)
+                       val &= ~A2XX_RB_DEPTHCONTROL_EARLY_Z_ENABLE;
 
                OUT_PKT3(ring, CP_SET_CONSTANT, 2);
                OUT_RING(ring, CP_REG(REG_A2XX_RB_DEPTHCONTROL));
-               OUT_RING(ring, zsa->rb_depthcontrol);
+               OUT_RING(ring, val);
 
                OUT_PKT3(ring, CP_SET_CONSTANT, 4);
                OUT_RING(ring, CP_REG(REG_A2XX_RB_STENCILREFMASK_BF));
index d4ac93bfed3378c1a9181a520abc641ee0069118..00e89d4e0a654f223c912d5d900d51192f3317c9 100644 (file)
@@ -51,6 +51,7 @@ struct fd2_shader_stateobj {
 
        bool writes_psize;
        bool need_param;
+       bool has_kill;
 
        /* note:
         * fragment shader only has one variant
index 64b31b677badebc7f8c733bbdc609c8359d6d086..d3c19b4450c858f6c6137d86bb077577de2e5fbf 100644 (file)
@@ -49,7 +49,8 @@ fd2_zsa_state_create(struct pipe_context *pctx,
                A2XX_RB_DEPTHCONTROL_ZFUNC(cso->depth.func); /* maps 1:1 */
 
        if (cso->depth.enabled)
-               so->rb_depthcontrol |= A2XX_RB_DEPTHCONTROL_Z_ENABLE;
+               so->rb_depthcontrol |= A2XX_RB_DEPTHCONTROL_Z_ENABLE |
+                       COND(!cso->alpha.enabled, A2XX_RB_DEPTHCONTROL_EARLY_Z_ENABLE);
        if (cso->depth.writemask)
                so->rb_depthcontrol |= A2XX_RB_DEPTHCONTROL_Z_WRITE_ENABLE;
 
index 9b81fc4f55870f816af975edeabc20f141d9dbb7..5d92f86befcffd4eb94ec30de0f68f572331e635 100644 (file)
@@ -633,6 +633,7 @@ emit_intrinsic(struct ir2_context *ctx, nir_intrinsic_instr *intr)
                }
                instr->alu.export = -1;
                instr->src_count = 1;
+               ctx->so->has_kill = true;
                break;
        case nir_intrinsic_load_front_face:
                /* gl_FrontFacing is in the sign of param.x