v3dv: add a cl_advance_and_end helper
authorIago Toral Quiroga <itoral@igalia.com>
Mon, 23 Jan 2023 09:57:40 +0000 (10:57 +0100)
committerMarge Bot <emma+marge@anholt.net>
Thu, 26 Jan 2023 06:21:33 +0000 (06:21 +0000)
For the common case where we're emitting packet we don't need to
update the cl_out pointer and then store the result in cl->next,
we can directly update cl->next.

This shows a small improvement in vkoverhead's scores for basic
draw tests.

Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20897>

src/broadcom/vulkan/v3dv_cl.h

index 52b0666..db1dfb0 100644 (file)
@@ -118,6 +118,13 @@ cl_advance(struct v3dv_cl_out **cl, uint32_t n)
 }
 
 static inline void
+cl_advance_and_end(struct v3dv_cl *cl, uint32_t n)
+{
+   cl->next = (struct v3dv_cl_out *)((char *)(cl->next) + n);
+   assert(v3dv_cl_offset(cl) <= cl->size);
+}
+
+static inline void
 cl_aligned_u32(struct v3dv_cl_out **cl, uint32_t n)
 {
    *(uint32_t *)(*cl) = n;
@@ -178,8 +185,7 @@ void v3dv_cl_ensure_space_with_branch(struct v3dv_cl *cl, uint32_t space);
         ({                                                       \
                 struct v3dv_cl_out *cl_out = cl_start(cl);        \
                 cl_packet_pack(packet)(cl, (uint8_t *)cl_out, &name); \
-                cl_advance(&cl_out, cl_packet_length(packet));   \
-                cl_end(cl, cl_out);                              \
+                cl_advance_and_end(cl, cl_packet_length(packet)); \
                 _loop_terminate = NULL;                          \
         }))                                                      \
 
@@ -195,8 +201,7 @@ void v3dv_cl_ensure_space_with_branch(struct v3dv_cl *cl, uint32_t space);
                 cl_packet_pack(packet)(cl, packed, &name);       \
                 for (int _i = 0; _i < cl_packet_length(packet); _i++) \
                         ((uint8_t *)cl_out)[_i] = packed[_i] | (prepacked)[_i]; \
-                cl_advance(&cl_out, cl_packet_length(packet));   \
-                cl_end(cl, cl_out);                              \
+                cl_advance_and_end(cl, cl_packet_length(packet)); \
                 _loop_terminate = NULL;                          \
         }))                                                      \