xref: /aosp_15_r20/external/mesa3d/src/asahi/vulkan/hk_cmd_pool.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright 2024 Valve Corporation
3  * Copyright 2024 Alyssa Rosenzweig
4  * Copyright 2022-2023 Collabora Ltd. and Red Hat Inc.
5  * SPDX-License-Identifier: MIT
6  */
7 
8 #pragma once
9 
10 #include "hk_private.h"
11 
12 #include "vk_command_pool.h"
13 
14 #define HK_CMD_BO_SIZE 1024 * 128
15 
16 /* Recyclable command buffer BO, used for both push buffers and upload */
17 struct hk_cmd_bo {
18    struct agx_bo *bo;
19 
20    void *map;
21 
22    /** Link in hk_cmd_pool::free_bos or hk_cmd_buffer::bos */
23    struct list_head link;
24 };
25 
26 struct hk_cmd_pool {
27    struct vk_command_pool vk;
28 
29    /** List of hk_cmd_bo */
30    struct list_head free_bos;
31    struct list_head free_usc_bos;
32 };
33 
34 VK_DEFINE_NONDISP_HANDLE_CASTS(hk_cmd_pool, vk.base, VkCommandPool,
35                                VK_OBJECT_TYPE_COMMAND_POOL)
36 
37 static inline struct hk_device *
hk_cmd_pool_device(struct hk_cmd_pool * pool)38 hk_cmd_pool_device(struct hk_cmd_pool *pool)
39 {
40    return (struct hk_device *)pool->vk.base.device;
41 }
42 
43 VkResult hk_cmd_pool_alloc_bo(struct hk_cmd_pool *pool, bool force_usc,
44                               struct hk_cmd_bo **bo_out);
45 
46 void hk_cmd_pool_free_bo_list(struct hk_cmd_pool *pool, struct list_head *bos);
47 void hk_cmd_pool_free_usc_bo_list(struct hk_cmd_pool *pool,
48                                   struct list_head *bos);
49