• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 Google LLC
3  * SPDX-License-Identifier: MIT
4  */
5 
6 #ifndef VN_RENDERER_UTIL_H
7 #define VN_RENDERER_UTIL_H
8 
9 #include "vn_renderer.h"
10 
11 /* for suballocations of short-lived shmems, not thread-safe */
12 struct vn_renderer_shmem_pool {
13    size_t min_alloc_size;
14 
15    struct vn_renderer_shmem *shmem;
16    size_t size;
17    size_t used;
18 };
19 
20 static inline VkResult
vn_renderer_submit_simple(struct vn_renderer * renderer,const void * cs_data,size_t cs_size)21 vn_renderer_submit_simple(struct vn_renderer *renderer,
22                           const void *cs_data,
23                           size_t cs_size)
24 {
25    const struct vn_renderer_submit submit = {
26       .batches =
27          &(const struct vn_renderer_submit_batch){
28             .cs_data = cs_data,
29             .cs_size = cs_size,
30          },
31       .batch_count = 1,
32    };
33    return vn_renderer_submit(renderer, &submit);
34 }
35 
36 VkResult
37 vn_renderer_submit_simple_sync(struct vn_renderer *renderer,
38                                const void *cs_data,
39                                size_t cs_size);
40 
41 void
42 vn_renderer_shmem_pool_init(struct vn_renderer *renderer,
43                             struct vn_renderer_shmem_pool *pool,
44                             size_t min_alloc_size);
45 
46 void
47 vn_renderer_shmem_pool_fini(struct vn_renderer *renderer,
48                             struct vn_renderer_shmem_pool *pool);
49 
50 struct vn_renderer_shmem *
51 vn_renderer_shmem_pool_alloc(struct vn_renderer *renderer,
52                              struct vn_renderer_shmem_pool *pool,
53                              size_t size,
54                              size_t *out_offset);
55 
56 #endif /* VN_RENDERER_UTIL_H */
57