freedreno: add helper to mark all state clean
authorRob Clark <robdclark@gmail.com>
Sun, 16 Apr 2017 18:52:16 +0000 (14:52 -0400)
committerRob Clark <robdclark@gmail.com>
Tue, 18 Apr 2017 20:32:00 +0000 (16:32 -0400)
Note that this involves juggling around a bit when we emit and clear
texture state.  So split out from the patch that adds the helper to set
all state dirty.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/a2xx/fd2_draw.c
src/gallium/drivers/freedreno/a2xx/fd2_emit.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/a5xx/fd5_draw.c
src/gallium/drivers/freedreno/a5xx/fd5_emit.c
src/gallium/drivers/freedreno/freedreno_context.h

index a824018..e47ae9b 100644 (file)
@@ -116,6 +116,8 @@ fd2_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info)
 
        emit_cacheflush(ring);
 
+       fd_context_all_clean(ctx);
+
        return true;
 }
 
index 5193b89..fe2750b 100644 (file)
@@ -182,7 +182,7 @@ fd2_emit_vertex_bufs(struct fd_ringbuffer *ring, uint32_t val,
 }
 
 void
-fd2_emit_state(struct fd_context *ctx, uint32_t dirty)
+fd2_emit_state(struct fd_context *ctx, const uint32_t dirty)
 {
        struct fd2_blend_stateobj *blend = fd2_blend_stateobj(ctx->blend);
        struct fd2_zsa_stateobj *zsa = fd2_zsa_stateobj(ctx->zsa);
@@ -311,8 +311,6 @@ fd2_emit_state(struct fd_context *ctx, uint32_t dirty)
 
        if (dirty & (FD_DIRTY_VERTTEX | FD_DIRTY_FRAGTEX | FD_DIRTY_PROG))
                emit_textures(ring, ctx);
-
-       ctx->dirty &= ~dirty;
 }
 
 /* emit per-context initialization:
index afa2c3c..c36e507 100644 (file)
@@ -163,6 +163,8 @@ fd3_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info)
        emit.fp = NULL;
        draw_impl(ctx, ctx->batch->binning, &emit);
 
+       fd_context_all_clean(ctx);
+
        return true;
 }
 
index 377085e..9e9d2d9 100644 (file)
@@ -490,7 +490,7 @@ fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
 {
        const struct ir3_shader_variant *vp = fd3_emit_get_vp(emit);
        const struct ir3_shader_variant *fp = fd3_emit_get_fp(emit);
-       uint32_t dirty = emit->dirty;
+       const uint32_t dirty = emit->dirty;
 
        emit_marker(ring, 5);
 
@@ -786,21 +786,11 @@ fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
        if (dirty & (FD_DIRTY_VERTTEX | FD_DIRTY_FRAGTEX))
                fd_wfi(ctx->batch, ring);
 
-       if (dirty & FD_DIRTY_VERTTEX) {
-               if (vp->has_samp)
-                       emit_textures(ctx, ring, SB_VERT_TEX, &ctx->tex[PIPE_SHADER_VERTEX]);
-               else
-                       dirty &= ~FD_DIRTY_VERTTEX;
-       }
-
-       if (dirty & FD_DIRTY_FRAGTEX) {
-               if (fp->has_samp)
-                       emit_textures(ctx, ring, SB_FRAG_TEX, &ctx->tex[PIPE_SHADER_FRAGMENT]);
-               else
-                       dirty &= ~FD_DIRTY_FRAGTEX;
-       }
+       if (dirty & FD_DIRTY_VERTTEX)
+               emit_textures(ctx, ring, SB_VERT_TEX, &ctx->tex[PIPE_SHADER_VERTEX]);
 
-       ctx->dirty &= ~dirty;
+       if (dirty & FD_DIRTY_FRAGTEX)
+               emit_textures(ctx, ring, SB_FRAG_TEX, &ctx->tex[PIPE_SHADER_FRAGMENT]);
 }
 
 /* emit setup at begin of new cmdstream buffer (don't rely on previous
index c0ada87..869c69b 100644 (file)
@@ -168,6 +168,8 @@ fd4_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info)
        emit.fp = NULL;
        draw_impl(ctx, ctx->batch->binning, &emit);
 
+       fd_context_all_clean(ctx);
+
        return true;
 }
 
index adda4a0..997d04a 100644 (file)
@@ -499,7 +499,7 @@ fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
 {
        const struct ir3_shader_variant *vp = fd4_emit_get_vp(emit);
        const struct ir3_shader_variant *fp = fd4_emit_get_fp(emit);
-       uint32_t dirty = emit->dirty;
+       const uint32_t dirty = emit->dirty;
 
        emit_marker(ring, 5);
 
@@ -740,21 +740,11 @@ fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
                OUT_RING(ring, A4XX_RB_BLEND_ALPHA_F32(bcolor->color[3]));
        }
 
-       if (dirty & FD_DIRTY_VERTTEX) {
-               if (vp->has_samp)
-                       emit_textures(ctx, ring, SB4_VS_TEX, &ctx->tex[PIPE_SHADER_VERTEX], vp);
-               else
-                       dirty &= ~FD_DIRTY_VERTTEX;
-       }
-
-       if (dirty & FD_DIRTY_FRAGTEX) {
-               if (fp->has_samp)
-                       emit_textures(ctx, ring, SB4_FS_TEX, &ctx->tex[PIPE_SHADER_FRAGMENT], fp);
-               else
-                       dirty &= ~FD_DIRTY_FRAGTEX;
-       }
+       if (dirty & FD_DIRTY_VERTTEX)
+               emit_textures(ctx, ring, SB4_VS_TEX, &ctx->tex[PIPE_SHADER_VERTEX], vp);
 
-       ctx->dirty &= ~dirty;
+       if (dirty & FD_DIRTY_FRAGTEX)
+               emit_textures(ctx, ring, SB4_FS_TEX, &ctx->tex[PIPE_SHADER_FRAGMENT], fp);
 }
 
 /* emit setup at begin of new cmdstream buffer (don't rely on previous
index b7417ec..147f707 100644 (file)
@@ -154,6 +154,8 @@ fd5_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info)
                }
        }
 
+       fd_context_all_clean(ctx);
+
        return true;
 }
 
index b330742..db85573 100644 (file)
@@ -398,7 +398,7 @@ fd5_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
 {
        const struct ir3_shader_variant *vp = fd5_emit_get_vp(emit);
        const struct ir3_shader_variant *fp = fd5_emit_get_fp(emit);
-       uint32_t dirty = emit->dirty;
+       const uint32_t dirty = emit->dirty;
        bool needs_border = false;
 
        emit_marker5(ring, 5);
@@ -648,31 +648,21 @@ fd5_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
        }
 
        if (dirty & FD_DIRTY_VERTTEX) {
-               if (vp->has_samp) {
-                       needs_border |= emit_textures(ctx, ring, SB4_VS_TEX,
-                                       &ctx->tex[PIPE_SHADER_VERTEX]);
-                       OUT_PKT4(ring, REG_A5XX_TPL1_VS_TEX_COUNT, 1);
-                       OUT_RING(ring, ctx->tex[PIPE_SHADER_VERTEX].num_textures);
-               } else {
-                       dirty &= ~FD_DIRTY_VERTTEX;
-               }
+               needs_border |= emit_textures(ctx, ring, SB4_VS_TEX,
+                               &ctx->tex[PIPE_SHADER_VERTEX]);
+               OUT_PKT4(ring, REG_A5XX_TPL1_VS_TEX_COUNT, 1);
+               OUT_RING(ring, ctx->tex[PIPE_SHADER_VERTEX].num_textures);
        }
 
        if (dirty & FD_DIRTY_FRAGTEX) {
-               if (fp->has_samp) {
-                       needs_border |= emit_textures(ctx, ring, SB4_FS_TEX,
-                                       &ctx->tex[PIPE_SHADER_FRAGMENT]);
-                       OUT_PKT4(ring, REG_A5XX_TPL1_FS_TEX_COUNT, 1);
-                       OUT_RING(ring, ctx->tex[PIPE_SHADER_FRAGMENT].num_textures);
-               } else {
-                       dirty &= ~FD_DIRTY_FRAGTEX;
-               }
+               needs_border |= emit_textures(ctx, ring, SB4_FS_TEX,
+                               &ctx->tex[PIPE_SHADER_FRAGMENT]);
+               OUT_PKT4(ring, REG_A5XX_TPL1_FS_TEX_COUNT, 1);
+               OUT_RING(ring, ctx->tex[PIPE_SHADER_FRAGMENT].num_textures);
        }
 
        if (needs_border)
                emit_border_color(ctx, ring);
-
-       ctx->dirty &= ~dirty;
 }
 
 /* emit setup at begin of new cmdstream buffer (don't rely on previous
index 9db34ef..7f47eaf 100644 (file)
@@ -332,6 +332,12 @@ fd_context_all_dirty(struct fd_context *ctx)
        ctx->dirty = ~0;
 }
 
+static inline void
+fd_context_all_clean(struct fd_context *ctx)
+{
+       ctx->dirty = 0;
+}
+
 static inline struct pipe_scissor_state *
 fd_context_get_scissor(struct fd_context *ctx)
 {