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 <matt.coster@imgtec.com>
Reviewed-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20932>
This commit is contained in:
Matt Coster
2022-12-01 16:33:45 +00:00
committed by Marge Bot
parent 695cf75266
commit 187a95e617
2 changed files with 34 additions and 0 deletions

View File

@@ -110,6 +110,39 @@ void pvr_csb_finish(struct pvr_csb *csb)
pvr_csb_init(NULL, PVR_CMD_STREAM_TYPE_INVALID, 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. * \brief Helper function to extend csb memory.
* *

View File

@@ -131,6 +131,7 @@ void pvr_csb_init(struct pvr_device *device,
enum pvr_cmd_stream_type stream_type, enum pvr_cmd_stream_type stream_type,
struct pvr_csb *csb); struct pvr_csb *csb);
void pvr_csb_finish(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); 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); 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); void pvr_csb_emit_link(struct pvr_csb *csb, pvr_dev_addr_t addr, bool ret);