radeonsi: emit primitive restart only if it changes
authorMarek Olšák <marek.olsak@amd.com>
Sun, 7 Dec 2014 19:14:41 +0000 (20:14 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 10 Dec 2014 20:59:37 +0000 (21:59 +0100)
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeonsi/si_hw_context.c
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_state_draw.c

index 6c2734eac29548ba2f08ca5567f0a0c2e7e00b0c..0bbc381bc9c9babbe8ca94953bb14855a62a8668 100644 (file)
@@ -156,4 +156,6 @@ void si_begin_new_cs(struct si_context *ctx)
 
        ctx->b.initial_gfx_cs_size = ctx->b.rings.gfx.cs->cdw;
        si_invalidate_draw_sh_constants(ctx);
+       ctx->last_primitive_restart_en = -1;
+       ctx->last_restart_index = SI_RESTART_INDEX_UNKNOWN;
 }
index e3cc09a0b85bd820f658d6b932ae1d3af95c7a65..471a55440d686a1994bddb809299614af5886b60 100644 (file)
 #define SI_BIG_ENDIAN 0
 #endif
 
-/* The base vertex can be any number, but we must pick one which
- * will mean "unknown" for the purpose of state tracking and the number
- * shouldn't be a commonly-used one. */
+/* The base vertex and primitive restart can be any number, but we must pick
+ * one which will mean "unknown" for the purpose of state tracking and
+ * the number shouldn't be a commonly-used one. */
 #define SI_BASE_VERTEX_UNKNOWN INT_MIN
+#define SI_RESTART_INDEX_UNKNOWN INT_MIN
 
 #define SI_TRACE_CS 0
 #define SI_TRACE_CS_DWORDS             6
@@ -179,6 +180,8 @@ struct si_context {
        int                     last_base_vertex;
        int                     last_start_instance;
        int                     last_sh_base_reg;
+       int                     last_primitive_restart_en;
+       int                     last_restart_index;
 };
 
 /* si_blit.c */
index f9ff0e34c1744dc828fc17b8fd8f3e64feed5b9c..40a55c50fe99d0f6a65d403c5a31d37d181ba988 100644 (file)
@@ -193,8 +193,20 @@ static void si_emit_draw_registers(struct si_context *sctx,
        }
 
        r600_write_context_reg(cs, R_028A6C_VGT_GS_OUT_PRIM_TYPE, gs_out_prim);
-       r600_write_context_reg(cs, R_02840C_VGT_MULTI_PRIM_IB_RESET_INDX, info->restart_index);
-       r600_write_context_reg(cs, R_028A94_VGT_MULTI_PRIM_IB_RESET_EN, info->primitive_restart);
+
+       /* Primitive restart. */
+       if (info->primitive_restart != sctx->last_primitive_restart_en) {
+               r600_write_context_reg(cs, R_028A94_VGT_MULTI_PRIM_IB_RESET_EN, info->primitive_restart);
+               sctx->last_primitive_restart_en = info->primitive_restart;
+
+               if (info->primitive_restart &&
+                   (info->restart_index != sctx->last_restart_index ||
+                    sctx->last_restart_index == SI_RESTART_INDEX_UNKNOWN)) {
+                       r600_write_context_reg(cs, R_02840C_VGT_MULTI_PRIM_IB_RESET_INDX,
+                                              info->restart_index);
+                       sctx->last_restart_index = info->restart_index;
+               }
+       }
 }
 
 static void si_emit_draw_packets(struct si_context *sctx,