Debian Codegraph @

src/kosmickrisp/vulkan/kk_query_table.h

raw symbols SCIP
1 /*
2 * Copyright © 2022 Collabora Ltd. and Red Hat Inc.
3 * Copyright 2025 LunarG, Inc.
4 * Copyright 2025 Google LLC
5 * SPDX-License-Identifier: MIT
6 */
7
8 #ifndef KK_QUERY_TABLE_H
9 #define KK_QUERY_TABLE_H 1
10
11 #include "kk_private.h"
12
13 #include "kk_bo.h"
14
15 #include "util/bitset.h"
16 #include "util/simple_mtx.h"
17
18 struct kk_device;
19
20 struct kk_query_table {
21 simple_mtx_t mutex;
22
23 uint32_t max_alloc; /**< Maximum possible number of queries */
24 uint32_t next_query; /**< Next unallocated query */
25 uint32_t free_count; /**< Size of free_table */
26
27 struct kk_bo *bo; /**< Memoery where queries are stored */
28
29 /* Bitset of all queries currently in use. This is the single source
30 * of truth for what is and isn't free. The free_table and next_query are
31 * simply hints to make finding a free descrptor fast. Every free
32 * query will either be above next_query or in free_table but not
33 * everything which satisfies those two criteria is actually free.
34 */
35 BITSET_WORD *in_use;
36
37 /* Stack for free query elements */
38 uint32_t *free_table;
39 };
40
41 VkResult kk_query_table_init(struct kk_device *dev,
42 struct kk_query_table *table,
43 uint32_t query_count);
44
45 void kk_query_table_finish(struct kk_device *dev, struct kk_query_table *table);
46
47 VkResult kk_query_table_add(struct kk_device *dev, struct kk_query_table *table,
48 uint64_t value, uint32_t *index_out);
49
50 VkResult kk_query_table_insert(struct kk_device *dev,
51 struct kk_query_table *table, uint32_t index,
52 uint64_t value);
53
54 void kk_query_table_remove(struct kk_device *dev, struct kk_query_table *table,
55 uint32_t index);
56
57 #endif /* KK_QUERY_TABLE_H */