| 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 |
#define HK_CMD_POOL_BO_MAX 32 |
| 16 |
|
| 17 |
/* Recyclable command buffer BO, used for both push buffers and upload */ |
| 18 |
struct hk_cmd_bo { |
| 19 |
struct agx_bo *bo; |
| 20 |
|
| 21 |
void *map; |
| 22 |
|
| 23 |
/** Link in hk_cmd_pool::free_bos or hk_cmd_buffer::bos */ |
| 24 |
struct list_head link; |
| 25 |
}; |
| 26 |
|
| 27 |
struct hk_cmd_pool { |
| 28 |
struct vk_command_pool vk; |
| 29 |
|
| 30 |
/** List of hk_cmd_bo */ |
| 31 |
struct list_head free_bos; |
| 32 |
struct list_head free_usc_bos; |
| 33 |
uint32_t num_free_bos; |
| 34 |
uint32_t num_free_usc_bos; |
| 35 |
}; |
| 36 |
|
| 37 |
VK_DEFINE_NONDISP_HANDLE_CASTS(hk_cmd_pool, vk.base, VkCommandPool, |
| 38 |
VK_OBJECT_TYPE_COMMAND_POOL) |
| 39 |
|
| 40 |
static inline struct hk_device * |
| 41 |
hk_cmd_pool_device(struct hk_cmd_pool *pool) |
| 42 |
{ |
| 43 |
return (struct hk_device *)pool->vk.base.device; |
| 44 |
} |
| 45 |
|
| 46 |
VkResult hk_cmd_pool_alloc_bo(struct hk_cmd_pool *pool, bool force_usc, |
| 47 |
struct hk_cmd_bo **bo_out); |
| 48 |
|
| 49 |
void hk_cmd_pool_free_bo_list(struct hk_cmd_pool *pool, struct list_head *bos); |
| 50 |
void hk_cmd_pool_free_usc_bo_list(struct hk_cmd_pool *pool, |
| 51 |
struct list_head *bos); |