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 a824018174ab4a0e5566e92fdbed765ec17d7f11..e47ae9b8afd7a934f29ae021ba7a2caac2050fad 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 5193b896ffce18d5c6f5b0ee8f08a41dc9191011..fe2750ba10b30d44c51cfad62b67c302c04e0c5a 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 afa2c3c7ef74525be9ac08dfb9b2f4fbe496613e..c36e507166039afb572ce6df639e1400368ae00c 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 377085e7159eac1a12ff152c4fe6b789eba5ad41..9e9d2d9bc4db122b3ee869c5d1ce13018763f396 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 c0ada87f83ee30a0a249df4577182cf5b5b47ce5..869c69b25b34f5b948bf10890a1ea9f526c3e6cc 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 adda4a0460bb4335a6a930323fbd09d05d398892..997d04a83cfb69b379f0c6f3957adfa7cbfffa62 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 b7417ec92a9d44c764f5e0419b0e3f14cd3af54e..147f7070039433b19814145b88b50b303dee2604 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 b3307422ea330a60e6fd2ee4c7e131fe1e1ef108..db85573592b54ebfdc7643725f499041f0ab0939 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 9db34ef8a03bbb979c8a0937ea214b3c2cb1bfa0..7f47eaf2a710ddbda6f0d22c684487d43373af67 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)
 {