From 187a95e617d8358579eeb06b98f3b45bb050b9b5 Mon Sep 17 00:00:00 2001 From: Matt Coster Date: Thu, 1 Dec 2022 16:33:45 +0000 Subject: [PATCH] pvr: Add pvr_csb_bake() This is a simple helper for minimizing the storage requirements of control streams. It discards all information required only while building the control stream and returns just the status and the list of BOs backing the control stream. The first BO in the list is the start of the control stream. Especially for small, deterministically sized control streams, there's no sense in lugging around an entire builder structure once it's built. Signed-off-by: Matt Coster Reviewed-by: Karmjit Mahil Part-of: --- src/imagination/vulkan/pvr_csb.c | 33 ++++++++++++++++++++++++++++++++ src/imagination/vulkan/pvr_csb.h | 1 + 2 files changed, 34 insertions(+) diff --git a/src/imagination/vulkan/pvr_csb.c b/src/imagination/vulkan/pvr_csb.c index bb5593616cc..e664fdb19dd 100644 --- a/src/imagination/vulkan/pvr_csb.c +++ b/src/imagination/vulkan/pvr_csb.c @@ -110,6 +110,39 @@ void pvr_csb_finish(struct pvr_csb *csb) pvr_csb_init(NULL, PVR_CMD_STREAM_TYPE_INVALID, csb); } +/** + * \brief Discard information only required while building and return the BOs. + * + * \param[in] csb Control Stream Builder object to bake. + * \param[out] bo_list_out A list of \c pvr_bo containing the control stream. + * + * \return The last status value of \c csb. + * + * The value of \c bo_list_out is only defined iff this function returns + * \c VK_SUCCESS. It is not allowed to call this function on a \c pvr_csb for + * a deferred control stream type. + * + * The state of \c csb after calling this function (iff it returns + * \c VK_SUCCESS) is identical to that after calling #pvr_csb_finish(). + * Unlike #pvr_csb_finish(), however, the caller must free every entry in + * \c bo_list_out itself. + */ +VkResult pvr_csb_bake(struct pvr_csb *const csb, + struct list_head *const bo_list_out) +{ + assert(csb->stream_type != PVR_CMD_STREAM_TYPE_GRAPHICS_DEFERRED); + + if (csb->status != VK_SUCCESS) + return csb->status; + + *bo_list_out = csb->pvr_bo_list; + + /* Same as pvr_csb_finish(). */ + pvr_csb_init(NULL, PVR_CMD_STREAM_TYPE_INVALID, csb); + + return VK_SUCCESS; +} + /** * \brief Helper function to extend csb memory. * diff --git a/src/imagination/vulkan/pvr_csb.h b/src/imagination/vulkan/pvr_csb.h index 91f30887dff..571c4a59ab8 100644 --- a/src/imagination/vulkan/pvr_csb.h +++ b/src/imagination/vulkan/pvr_csb.h @@ -131,6 +131,7 @@ void pvr_csb_init(struct pvr_device *device, enum pvr_cmd_stream_type stream_type, struct pvr_csb *csb); void pvr_csb_finish(struct pvr_csb *csb); +VkResult pvr_csb_bake(struct pvr_csb *csb, struct list_head *bo_list_out); void *pvr_csb_alloc_dwords(struct pvr_csb *csb, uint32_t num_dwords); VkResult pvr_csb_copy(struct pvr_csb *csb_dst, struct pvr_csb *csb_src); void pvr_csb_emit_link(struct pvr_csb *csb, pvr_dev_addr_t addr, bool ret);