From a3ed7f3ff233aabaef2db532af1f795230002f0d Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Mon, 23 Jan 2023 10:57:40 +0100 Subject: [PATCH] v3dv: add a cl_advance_and_end helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Part-of: --- src/broadcom/vulkan/v3dv_cl.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/broadcom/vulkan/v3dv_cl.h b/src/broadcom/vulkan/v3dv_cl.h index 52b06663f27..db1dfb08ccc 100644 --- a/src/broadcom/vulkan/v3dv_cl.h +++ b/src/broadcom/vulkan/v3dv_cl.h @@ -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; \ })) \