v3dv: add a cl_advance_and_end helper

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>
This commit is contained in:
Iago Toral Quiroga 2023-01-23 10:57:40 +01:00 committed by Marge Bot
parent a08d6d8b59
commit a3ed7f3ff2

View file

@ -117,6 +117,13 @@ cl_advance(struct v3dv_cl_out **cl, uint32_t n)
(*cl) = (struct v3dv_cl_out *)((char *)(*cl) + 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)
{
@ -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; \
})) \