freedreno: move shader-stage dirty bits to global dirty flag
authorRob Clark <robclark@freedesktop.org>
Tue, 3 May 2016 20:54:21 +0000 (16:54 -0400)
committerRob Clark <robclark@freedesktop.org>
Wed, 4 May 2016 15:25:55 +0000 (11:25 -0400)
This was always a bit overly complicated, and had some issues (like
ctx->prog.dirty not getting reset at the end of the batch).  It also
required some special hacks to avoid resetting dirty state on binning
pass.  So just move it all into ctx->dirty (leaving some free bits
for future shader stages), and make FD_DIRTY_PROG just be the union
of all FD_SHADER_DIRTY_*.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/a2xx/fd2_program.c
src/gallium/drivers/freedreno/a3xx/fd3_draw.c
src/gallium/drivers/freedreno/a3xx/fd3_emit.c
src/gallium/drivers/freedreno/a4xx/fd4_draw.c
src/gallium/drivers/freedreno/a4xx/fd4_emit.c
src/gallium/drivers/freedreno/freedreno_context.h
src/gallium/drivers/freedreno/freedreno_program.c
src/gallium/drivers/freedreno/ir3/ir3_shader.c

index 5ccfd58bfe1d3138a5f63e65781dd4511a48e482..4f317721db0a764dad5fe9cbce3bf23cb3a568c4 100644 (file)
@@ -247,15 +247,12 @@ fd2_program_validate(struct fd_context *ctx)
         * from the vertex shader.  And therefore if frag shader has changed we
         * need to recompile both vert and frag shader.
         */
-       if (prog->dirty & FD_SHADER_DIRTY_FP)
+       if (ctx->dirty & FD_SHADER_DIRTY_FP)
                compile(prog, prog->fp);
 
-       if (prog->dirty & (FD_SHADER_DIRTY_FP | FD_SHADER_DIRTY_VP))
+       if (ctx->dirty & (FD_SHADER_DIRTY_FP | FD_SHADER_DIRTY_VP))
                compile(prog, prog->vp);
 
-       if (prog->dirty)
-               ctx->dirty |= FD_DIRTY_PROG;
-
        /* if necessary, fix up vertex fetch instructions: */
        if (ctx->dirty & (FD_DIRTY_VTXSTATE | FD_DIRTY_PROG))
                patch_vtx_fetches(ctx, prog->vp, ctx->vtx.vtx);
@@ -292,8 +289,6 @@ fd2_program_emit(struct fd_ringbuffer *ring,
                        A2XX_SQ_PROGRAM_CNTL_VS_EXPORT_COUNT(vs_export) |
                        A2XX_SQ_PROGRAM_CNTL_PS_REGS(fs_gprs) |
                        A2XX_SQ_PROGRAM_CNTL_VS_REGS(vs_gprs));
-
-       prog->dirty = 0;
 }
 
 /* Creates shader:
index b6c3ea674e6e068ba47ef0d137a3ce19d86f283f..dc4558e964407287c2f7e4a5daa591dd7512a153 100644 (file)
@@ -104,31 +104,29 @@ fixup_shader_state(struct fd_context *ctx, struct ir3_shader_key *key)
        struct ir3_shader_key *last_key = &fd3_ctx->last_key;
 
        if (!ir3_shader_key_equal(last_key, key)) {
-               ctx->dirty |= FD_DIRTY_PROG;
-
                if (last_key->has_per_samp || key->has_per_samp) {
                        if ((last_key->vsaturate_s != key->vsaturate_s) ||
                                        (last_key->vsaturate_t != key->vsaturate_t) ||
                                        (last_key->vsaturate_r != key->vsaturate_r))
-                               ctx->prog.dirty |= FD_SHADER_DIRTY_VP;
+                               ctx->dirty |= FD_SHADER_DIRTY_VP;
 
                        if ((last_key->fsaturate_s != key->fsaturate_s) ||
                                        (last_key->fsaturate_t != key->fsaturate_t) ||
                                        (last_key->fsaturate_r != key->fsaturate_r))
-                               ctx->prog.dirty |= FD_SHADER_DIRTY_FP;
+                               ctx->dirty |= FD_SHADER_DIRTY_FP;
                }
 
                if (last_key->vclamp_color != key->vclamp_color)
-                       ctx->prog.dirty |= FD_SHADER_DIRTY_VP;
+                       ctx->dirty |= FD_SHADER_DIRTY_VP;
 
                if (last_key->fclamp_color != key->fclamp_color)
-                       ctx->prog.dirty |= FD_SHADER_DIRTY_FP;
+                       ctx->dirty |= FD_SHADER_DIRTY_FP;
 
                if (last_key->color_two_side != key->color_two_side)
-                       ctx->prog.dirty |= FD_SHADER_DIRTY_FP;
+                       ctx->dirty |= FD_SHADER_DIRTY_FP;
 
                if (last_key->half_precision != key->half_precision)
-                       ctx->prog.dirty |= FD_SHADER_DIRTY_FP;
+                       ctx->dirty |= FD_SHADER_DIRTY_FP;
 
                fd3_ctx->last_key = *key;
        }
index e1d0a4fee84fe496aa9a2c68b9f664536e667644..4a5242aedb03f429735169c637f98607b386f4b5 100644 (file)
@@ -659,11 +659,6 @@ fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
                ir3_emit_consts(vp, ring, ctx, emit->info, dirty);
                if (!emit->key.binning_pass)
                        ir3_emit_consts(fp, ring, ctx, emit->info, dirty);
-               /* mark clean after emitting consts.. a bit ugly, but since binning
-                * pass is emitted first, we want to do this only for main draw:
-                */
-               if (!emit->key.binning_pass)
-                       ctx->prog.dirty = 0;
        }
 
        if (dirty & (FD_DIRTY_BLEND | FD_DIRTY_FRAMEBUFFER)) {
index d49c529aab4d11a54b7f63bf2782ac4d827c679b..af02d31fb913cbbb61b9d2eaf4bd49d42fe22dd7 100644 (file)
@@ -88,36 +88,34 @@ fixup_shader_state(struct fd_context *ctx, struct ir3_shader_key *key)
        struct ir3_shader_key *last_key = &fd4_ctx->last_key;
 
        if (!ir3_shader_key_equal(last_key, key)) {
-               ctx->dirty |= FD_DIRTY_PROG;
-
                if (last_key->has_per_samp || key->has_per_samp) {
                        if ((last_key->vsaturate_s != key->vsaturate_s) ||
                                        (last_key->vsaturate_t != key->vsaturate_t) ||
                                        (last_key->vsaturate_r != key->vsaturate_r) ||
                                        (last_key->vastc_srgb != key->vastc_srgb))
-                               ctx->prog.dirty |= FD_SHADER_DIRTY_VP;
+                               ctx->dirty |= FD_SHADER_DIRTY_VP;
 
                        if ((last_key->fsaturate_s != key->fsaturate_s) ||
                                        (last_key->fsaturate_t != key->fsaturate_t) ||
                                        (last_key->fsaturate_r != key->fsaturate_r) ||
                                        (last_key->fastc_srgb != key->fastc_srgb))
-                               ctx->prog.dirty |= FD_SHADER_DIRTY_FP;
+                               ctx->dirty |= FD_SHADER_DIRTY_FP;
                }
 
                if (last_key->vclamp_color != key->vclamp_color)
-                       ctx->prog.dirty |= FD_SHADER_DIRTY_VP;
+                       ctx->dirty |= FD_SHADER_DIRTY_VP;
 
                if (last_key->fclamp_color != key->fclamp_color)
-                       ctx->prog.dirty |= FD_SHADER_DIRTY_FP;
+                       ctx->dirty |= FD_SHADER_DIRTY_FP;
 
                if (last_key->color_two_side != key->color_two_side)
-                       ctx->prog.dirty |= FD_SHADER_DIRTY_FP;
+                       ctx->dirty |= FD_SHADER_DIRTY_FP;
 
                if (last_key->half_precision != key->half_precision)
-                       ctx->prog.dirty |= FD_SHADER_DIRTY_FP;
+                       ctx->dirty |= FD_SHADER_DIRTY_FP;
 
                if (last_key->rasterflat != key->rasterflat)
-                       ctx->prog.dirty |= FD_SHADER_DIRTY_FP;
+                       ctx->dirty |= FD_SHADER_DIRTY_FP;
 
                fd4_ctx->last_key = *key;
        }
index 459494c09034d71a28c0dd9ad7211ef896473729..00e985d27e5407aaf8c8784e09cd484406a1586b 100644 (file)
@@ -649,11 +649,6 @@ fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
                ir3_emit_consts(vp, ring, ctx, emit->info, dirty);
                if (!emit->key.binning_pass)
                        ir3_emit_consts(fp, ring, ctx, emit->info, dirty);
-               /* mark clean after emitting consts.. a bit ugly, but since binning
-                * pass is emitted first, we want to do this only for main draw:
-                */
-               if (!emit->key.binning_pass)
-                       ctx->prog.dirty = 0;
        }
 
        if ((dirty & FD_DIRTY_BLEND)) {
index e65688e6c589dbf1bfa1c073ce527c3d75217e1f..80c638a7e38e6258650a777f1ca1e7995ce0997c 100644 (file)
@@ -54,10 +54,8 @@ struct fd_texture_stateobj {
 
 struct fd_program_stateobj {
        void *vp, *fp;
-       enum {
-               FD_SHADER_DIRTY_VP = (1 << 0),
-               FD_SHADER_DIRTY_FP = (1 << 1),
-       } dirty;
+
+       /* rest only used by fd2.. split out: */
        uint8_t num_exports;
        /* Indexed by semantic name or TGSI_SEMANTIC_COUNT + semantic index
         * for TGSI_SEMANTIC_GENERIC.  Special vs exports (position and point-
@@ -327,21 +325,26 @@ struct fd_context {
                FD_DIRTY_FRAGTEX     = (1 <<  3),
                FD_DIRTY_VERTTEX     = (1 <<  4),
                FD_DIRTY_TEXSTATE    = (1 <<  5),
-               FD_DIRTY_PROG        = (1 <<  6),
-               FD_DIRTY_BLEND_COLOR = (1 <<  7),
-               FD_DIRTY_STENCIL_REF = (1 <<  8),
-               FD_DIRTY_SAMPLE_MASK = (1 <<  9),
-               FD_DIRTY_FRAMEBUFFER = (1 << 10),
-               FD_DIRTY_STIPPLE     = (1 << 11),
-               FD_DIRTY_VIEWPORT    = (1 << 12),
-               FD_DIRTY_CONSTBUF    = (1 << 13),
-               FD_DIRTY_VTXSTATE    = (1 << 14),
-               FD_DIRTY_VTXBUF      = (1 << 15),
-               FD_DIRTY_INDEXBUF    = (1 << 16),
-               FD_DIRTY_SCISSOR     = (1 << 17),
-               FD_DIRTY_STREAMOUT   = (1 << 18),
-               FD_DIRTY_UCP         = (1 << 19),
-               FD_DIRTY_BLEND_DUAL  = (1 << 20),
+
+               FD_SHADER_DIRTY_VP   = (1 <<  6),
+               FD_SHADER_DIRTY_FP   = (1 <<  7),
+               /* skip geom/tcs/tes/compute */
+               FD_DIRTY_PROG        = FD_SHADER_DIRTY_FP | FD_SHADER_DIRTY_VP,
+
+               FD_DIRTY_BLEND_COLOR = (1 << 12),
+               FD_DIRTY_STENCIL_REF = (1 << 13),
+               FD_DIRTY_SAMPLE_MASK = (1 << 14),
+               FD_DIRTY_FRAMEBUFFER = (1 << 15),
+               FD_DIRTY_STIPPLE     = (1 << 16),
+               FD_DIRTY_VIEWPORT    = (1 << 17),
+               FD_DIRTY_CONSTBUF    = (1 << 18),
+               FD_DIRTY_VTXSTATE    = (1 << 19),
+               FD_DIRTY_VTXBUF      = (1 << 20),
+               FD_DIRTY_INDEXBUF    = (1 << 21),
+               FD_DIRTY_SCISSOR     = (1 << 22),
+               FD_DIRTY_STREAMOUT   = (1 << 23),
+               FD_DIRTY_UCP         = (1 << 24),
+               FD_DIRTY_BLEND_DUAL  = (1 << 25),
        } dirty;
 
        struct pipe_blend_state *blend;
index 9c51119d371663990c0b164a05570f0e68cec454..ae6c65831bb262f434e6907fca196947f9abec81 100644 (file)
@@ -37,8 +37,7 @@ fd_fp_state_bind(struct pipe_context *pctx, void *hwcso)
 {
        struct fd_context *ctx = fd_context(pctx);
        ctx->prog.fp = hwcso;
-       ctx->prog.dirty |= FD_SHADER_DIRTY_FP;
-       ctx->dirty |= FD_DIRTY_PROG;
+       ctx->dirty |= FD_SHADER_DIRTY_FP;
 }
 
 static void
@@ -46,8 +45,7 @@ fd_vp_state_bind(struct pipe_context *pctx, void *hwcso)
 {
        struct fd_context *ctx = fd_context(pctx);
        ctx->prog.vp = hwcso;
-       ctx->prog.dirty |= FD_SHADER_DIRTY_VP;
-       ctx->dirty |= FD_DIRTY_PROG;
+       ctx->dirty |= FD_SHADER_DIRTY_VP;
 }
 
 static const char *solid_fp =
index 8019a1286c062def61833576d9566fa78f5cedff..4062ca989f00f31795c4c9ccbd33ecb3bdfca79b 100644 (file)
@@ -647,10 +647,10 @@ ir3_emit_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer *ring,
 
                if (v->type == SHADER_VERTEX) {
                        constbuf = &ctx->constbuf[PIPE_SHADER_VERTEX];
-                       shader_dirty = !!(ctx->prog.dirty & FD_SHADER_DIRTY_VP);
+                       shader_dirty = !!(dirty & FD_SHADER_DIRTY_VP);
                } else if (v->type == SHADER_FRAGMENT) {
                        constbuf = &ctx->constbuf[PIPE_SHADER_FRAGMENT];
-                       shader_dirty = !!(ctx->prog.dirty & FD_SHADER_DIRTY_FP);
+                       shader_dirty = !!(dirty & FD_SHADER_DIRTY_FP);
                } else {
                        unreachable("bad shader type");
                        return;