xref: /aosp_15_r20/external/mesa3d/src/nouveau/vulkan/nvk_cmd_pool.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2022 Collabora Ltd. and Red Hat Inc.
3  * SPDX-License-Identifier: MIT
4  */
5 #ifndef NVK_CMD_POOL_H
6 #define NVK_CMD_POOL_H
7 
8 #include "nvk_private.h"
9 
10 #include "vk_command_pool.h"
11 
12 #define NVK_CMD_MEM_SIZE 64*1024
13 
14 struct nvkmd_mem;
15 
16 /* Recyclable command buffer BO, used for both push buffers and upload */
17 struct nvk_cmd_mem {
18    struct nvkmd_mem *mem;
19 
20    /** Link in nvk_cmd_pool::free_bos or nvk_cmd_buffer::bos */
21    struct list_head link;
22 };
23 
24 struct nvk_cmd_pool {
25    struct vk_command_pool vk;
26 
27    /** List of nvk_cmd_mem */
28    struct list_head free_mem;
29    struct list_head free_gart_mem;
30 };
31 
32 VK_DEFINE_NONDISP_HANDLE_CASTS(nvk_cmd_pool, vk.base, VkCommandPool,
33                                VK_OBJECT_TYPE_COMMAND_POOL)
34 
35 static inline struct nvk_device *
nvk_cmd_pool_device(struct nvk_cmd_pool * pool)36 nvk_cmd_pool_device(struct nvk_cmd_pool *pool)
37 {
38    return (struct nvk_device *)pool->vk.base.device;
39 }
40 
41 VkResult nvk_cmd_pool_alloc_mem(struct nvk_cmd_pool *pool,
42                                 bool force_gart,
43                                 struct nvk_cmd_mem **mem_out);
44 
45 void nvk_cmd_pool_free_mem_list(struct nvk_cmd_pool *pool,
46                                 struct list_head *mem_list);
47 void nvk_cmd_pool_free_gart_mem_list(struct nvk_cmd_pool *pool,
48                                      struct list_head *mem_list);
49 #endif /* NVK_CMD_POOL_H */
50