freedreno/a6xx: add infrastructure for CP_DRAW_STATE
authorRob Clark <robdclark@gmail.com>
Sun, 7 Oct 2018 17:58:30 +0000 (13:58 -0400)
committerRob Clark <robdclark@gmail.com>
Wed, 17 Oct 2018 16:44:48 +0000 (12:44 -0400)
Add helper to add state-groups to emit, and code to emit CP_DRAW_STATE
packet if we have any state-groups.

Signed-off-by: Rob Clark <robdclark@gmail.com>
configure.ac
meson.build
src/gallium/drivers/freedreno/a6xx/fd6_emit.c
src/gallium/drivers/freedreno/a6xx/fd6_emit.h

index 520948b0518f071d439a680e4470fcd752cb04c5..ab9bdce885f5e5133d50e41b3909039869fbd12e 100644 (file)
@@ -78,7 +78,7 @@ LIBDRM_AMDGPU_REQUIRED=2.4.93
 LIBDRM_INTEL_REQUIRED=2.4.75
 LIBDRM_NVVIEUX_REQUIRED=2.4.66
 LIBDRM_NOUVEAU_REQUIRED=2.4.66
-LIBDRM_FREEDRENO_REQUIRED=2.4.93
+LIBDRM_FREEDRENO_REQUIRED=2.4.96
 LIBDRM_ETNAVIV_REQUIRED=2.4.89
 LIBDRM_VC4_REQUIRED=2.4.89
 
index 002ce35a6086df0bbeb72713b28ad555f935a543..505cc6c79bd6df13e5c20942ecf19b91b247133c 100644 (file)
@@ -1112,7 +1112,7 @@ _drm_amdgpu_ver = '2.4.93'
 _drm_radeon_ver = '2.4.71'
 _drm_nouveau_ver = '2.4.66'
 _drm_etnaviv_ver = '2.4.89'
-_drm_freedreno_ver = '2.4.93'
+_drm_freedreno_ver = '2.4.96'
 _drm_intel_ver = '2.4.75'
 _drm_ver = '2.4.75'
 
index 45bb5250ec8e050aaf83809421b8820091895ab6..fc4a53f865186da9c72d89481b6b977e75a332de 100644 (file)
@@ -940,6 +940,22 @@ fd6_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
 
        if (ctx->dirty_shader[PIPE_SHADER_FRAGMENT] & FD_DIRTY_SHADER_IMAGE)
                fd6_emit_images(ctx, ring, PIPE_SHADER_FRAGMENT);
+
+       if (emit->num_groups > 0) {
+               OUT_PKT7(ring, CP_SET_DRAW_STATE, 3 * emit->num_groups);
+               for (unsigned i = 0; i < emit->num_groups; i++) {
+                       struct fd6_state_group *g = &emit->groups[i];
+                       unsigned n = fd_ringbuffer_size(g->stateobj) / 4;
+
+                       OUT_RING(ring, CP_SET_DRAW_STATE__0_COUNT(n) |
+                                       CP_SET_DRAW_STATE__0_ENABLE_MASK(g->enable_mask) |
+                                       CP_SET_DRAW_STATE__0_GROUP_ID(g->group_id));
+                       OUT_RB(ring, g->stateobj);
+
+                       fd_ringbuffer_del(g->stateobj);
+               }
+               emit->num_groups = 0;
+       }
 }
 
 void
index 4ebb5987423a045e602889f3e36217a6a56443c9..a2117a1b2442aca97c0d30d0e159c8d1b98a9327 100644 (file)
 
 struct fd_ringbuffer;
 
+/* To collect all the state objects to emit in a single CP_SET_DRAW_STATE
+ * packet, the emit tracks a collection of however many state_group's that
+ * need to be emit'd.
+ */
+enum fd6_state_id {
+       FD6_GROUP_CONST,
+};
+
+struct fd6_state_group {
+       struct fd_ringbuffer *stateobj;
+       enum fd6_state_id group_id;
+       uint8_t enable_mask;
+};
+
 /* grouped together emit-state for prog/vertex/state emit: */
 struct fd6_emit {
        struct pipe_debug_callback *debug;
@@ -63,6 +77,9 @@ struct fd6_emit {
        /* TODO: other shader stages.. */
 
        unsigned streamout_mask;
+
+       struct fd6_state_group groups[32];
+       unsigned num_groups;
 };
 
 static inline const struct ir3_shader_variant *
@@ -91,6 +108,19 @@ fd6_emit_get_fp(struct fd6_emit *emit)
        return emit->fp;
 }
 
+static inline void
+fd6_emit_add_group(struct fd6_emit *emit, struct fd_ringbuffer *stateobj,
+               enum fd6_state_id group_id, unsigned enable_mask)
+{
+       debug_assert(emit->num_groups < ARRAY_SIZE(emit->groups));
+       if (fd_ringbuffer_size(stateobj) == 0)
+               return;
+       struct fd6_state_group *g = &emit->groups[emit->num_groups++];
+       g->stateobj = stateobj;
+       g->group_id = group_id;
+       g->enable_mask = enable_mask;
+}
+
 static inline void
 fd6_event_write(struct fd_batch *batch, struct fd_ringbuffer *ring,
                enum vgt_event_type evt, bool timestamp)