freedreno/a6xx: add fd_emit_take_group()
authorRob Clark <robdclark@chromium.org>
Fri, 2 Aug 2019 16:57:08 +0000 (09:57 -0700)
committerRob Clark <robdclark@chromium.org>
Tue, 13 Aug 2019 15:11:26 +0000 (08:11 -0700)
Which takes ownership of the stateobj.  Useful for streaming state-
objs, to avoid an extra ref/unref

Worth ~5% at gl_driver2

Signed-off-by: Rob Clark <robdclark@chromium.org>
src/gallium/drivers/freedreno/a6xx/fd6_emit.c
src/gallium/drivers/freedreno/a6xx/fd6_emit.h

index 7b858106910cc0654276d09fb1f064ef5be67f46..ef584177d160d58ebae8650e16ef900b6b56b09c 100644 (file)
@@ -602,10 +602,8 @@ fd6_emit_combined_textures(struct fd_ringbuffer *ring, struct fd6_emit *emit,
                        needs_border |= fd6_emit_textures(ctx->pipe, stateobj, type, tex,
                                        bcolor_offset, v, ctx);
 
-                       fd6_emit_add_group(emit, stateobj, s[type].state_id,
+                       fd6_emit_take_group(emit, stateobj, s[type].state_id,
                                        s[type].enable_mask);
-
-                       fd_ringbuffer_del(stateobj);
                }
        }
 
@@ -793,12 +791,10 @@ fd6_emit_state(struct fd_ringbuffer *ring, struct fd6_emit *emit)
                struct fd_ringbuffer *state;
 
                state = build_vbo_state(emit, emit->vs);
-               fd6_emit_add_group(emit, state, FD6_GROUP_VBO, 0x6);
-               fd_ringbuffer_del(state);
+               fd6_emit_take_group(emit, state, FD6_GROUP_VBO, 0x6);
 
                state = build_vbo_state(emit, emit->bs);
-               fd6_emit_add_group(emit, state, FD6_GROUP_VBO_BINNING, 0x1);
-               fd_ringbuffer_del(state);
+               fd6_emit_take_group(emit, state, FD6_GROUP_VBO_BINNING, 0x1);
        }
 
        if (dirty & FD_DIRTY_ZSA) {
@@ -814,12 +810,10 @@ fd6_emit_state(struct fd_ringbuffer *ring, struct fd6_emit *emit)
                struct fd_ringbuffer *state;
 
                state = build_lrz(emit, false);
-               fd6_emit_add_group(emit, state, FD6_GROUP_LRZ, 0x6);
-               fd_ringbuffer_del(state);
+               fd6_emit_take_group(emit, state, FD6_GROUP_LRZ, 0x6);
 
                state = build_lrz(emit, true);
-               fd6_emit_add_group(emit, state, FD6_GROUP_LRZ_BINNING, 0x1);
-               fd_ringbuffer_del(state);
+               fd6_emit_take_group(emit, state, FD6_GROUP_LRZ_BINNING, 0x1);
        }
 
        if (dirty & FD_DIRTY_STENCIL_REF) {
@@ -946,8 +940,7 @@ fd6_emit_state(struct fd_ringbuffer *ring, struct fd6_emit *emit)
                if (ir3_needs_vs_driver_params(vp))
                        ir3_emit_vs_driver_params(vp, vsconstobj, ctx, emit->info);
 
-               fd6_emit_add_group(emit, vsconstobj, FD6_GROUP_VS_CONST, 0x7);
-               fd_ringbuffer_del(vsconstobj);
+               fd6_emit_take_group(emit, vsconstobj, FD6_GROUP_VS_CONST, 0x7);
        }
 
        if (ctx->dirty_shader[PIPE_SHADER_FRAGMENT] & DIRTY_CONST) {
@@ -963,8 +956,7 @@ fd6_emit_state(struct fd_ringbuffer *ring, struct fd6_emit *emit)
                ir3_emit_image_dims(ctx->screen, fp, fsconstobj,
                                &ctx->shaderimg[PIPE_SHADER_FRAGMENT]);
 
-               fd6_emit_add_group(emit, fsconstobj, FD6_GROUP_FS_CONST, 0x6);
-               fd_ringbuffer_del(fsconstobj);
+               fd6_emit_take_group(emit, fsconstobj, FD6_GROUP_FS_CONST, 0x6);
        }
 
        struct ir3_stream_output_info *info = &vp->shader->stream_output;
@@ -1057,8 +1049,7 @@ fd6_emit_state(struct fd_ringbuffer *ring, struct fd6_emit *emit)
                OUT_PKT4(obj, REG_A6XX_SP_IBO_COUNT, 1);
                OUT_RING(obj, mapping->num_ibo);
 
-               fd6_emit_add_group(emit, obj, FD6_GROUP_IBO, 0x6);
-               fd_ringbuffer_del(obj);
+               fd6_emit_take_group(emit, obj, FD6_GROUP_IBO, 0x6);
                fd_ringbuffer_del(state);
        }
 
index e46091a49bc9b6b26fc8b9a76af5c9ff75e2c9c3..2ffb76c39006cb8ddfd06c5406360f02aa592aa3 100644 (file)
@@ -113,16 +113,23 @@ fd6_emit_get_prog(struct fd6_emit *emit)
 }
 
 static inline void
-fd6_emit_add_group(struct fd6_emit *emit, struct fd_ringbuffer *stateobj,
+fd6_emit_take_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));
        struct fd6_state_group *g = &emit->groups[emit->num_groups++];
-       g->stateobj = fd_ringbuffer_ref(stateobj);
+       g->stateobj = stateobj;
        g->group_id = group_id;
        g->enable_mask = enable_mask;
 }
 
+static inline void
+fd6_emit_add_group(struct fd6_emit *emit, struct fd_ringbuffer *stateobj,
+               enum fd6_state_id group_id, unsigned enable_mask)
+{
+       fd6_emit_take_group(emit, fd_ringbuffer_ref(stateobj), group_id, enable_mask);
+}
+
 static inline unsigned
 fd6_event_write(struct fd_batch *batch, struct fd_ringbuffer *ring,
                enum vgt_event_type evt, bool timestamp)