| 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 "asahi/lib/agx_bo.h" |
| 13 |
#include "util/simple_mtx.h" |
| 14 |
|
| 15 |
struct hk_device; |
| 16 |
|
| 17 |
struct hk_descriptor_table { |
| 18 |
simple_mtx_t mutex; |
| 19 |
|
| 20 |
uint32_t desc_size; /**< Size of a descriptor */ |
| 21 |
uint32_t alloc; /**< Number of descriptors allocated */ |
| 22 |
uint32_t max_alloc; /**< Maximum possible number of descriptors */ |
| 23 |
uint32_t next_desc; /**< Next unallocated descriptor */ |
| 24 |
uint32_t free_count; /**< Size of free_table */ |
| 25 |
|
| 26 |
struct agx_bo *bo; |
| 27 |
void *map; |
| 28 |
|
| 29 |
/* Stack for free descriptor elements */ |
| 30 |
uint32_t *free_table; |
| 31 |
}; |
| 32 |
|
| 33 |
VkResult hk_descriptor_table_init(struct hk_device *dev, |
| 34 |
struct hk_descriptor_table *table, |
| 35 |
uint32_t descriptor_size, |
| 36 |
uint32_t min_descriptor_count, |
| 37 |
uint32_t max_descriptor_count); |
| 38 |
|
| 39 |
void hk_descriptor_table_finish(struct hk_device *dev, |
| 40 |
struct hk_descriptor_table *table); |
| 41 |
|
| 42 |
VkResult hk_descriptor_table_add(struct hk_device *dev, |
| 43 |
struct hk_descriptor_table *table, |
| 44 |
const void *desc_data, size_t desc_size, |
| 45 |
uint32_t *index_out); |
| 46 |
|
| 47 |
void hk_descriptor_table_remove(struct hk_device *dev, |
| 48 |
struct hk_descriptor_table *table, |
| 49 |
uint32_t index); |