• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2022 Konstantin Seurer
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #ifndef BVH_BUILD_INTERFACE_H
25 #define BVH_BUILD_INTERFACE_H
26 
27 #ifdef VULKAN
28 #include "build_helpers.h"
29 #else
30 #include <stdint.h>
31 #include "bvh.h"
32 #define REF(type) uint64_t
33 #define VOID_REF  uint64_t
34 #endif
35 
36 struct leaf_args {
37    VOID_REF ir;
38    VOID_REF bvh;
39    REF(radv_ir_header) header;
40    REF(key_id_pair) ids;
41 
42    radv_bvh_geometry_data geom_data;
43 };
44 
45 struct morton_args {
46    VOID_REF bvh;
47    REF(radv_ir_header) header;
48    REF(key_id_pair) ids;
49 };
50 
51 #define LBVH_RIGHT_CHILD_BIT_SHIFT 29
52 #define LBVH_RIGHT_CHILD_BIT       (1 << LBVH_RIGHT_CHILD_BIT_SHIFT)
53 
54 struct lbvh_node_info {
55    /* Number of children that have been processed (or are invalid/leaves) in
56     * the lbvh_generate_ir pass.
57     */
58    uint32_t path_count;
59 
60    uint32_t children[2];
61    uint32_t parent;
62 };
63 
64 struct lbvh_main_args {
65    VOID_REF bvh;
66    REF(key_id_pair) src_ids;
67    VOID_REF node_info;
68    uint32_t id_count;
69    uint32_t internal_node_base;
70 };
71 
72 struct lbvh_generate_ir_args {
73    VOID_REF bvh;
74    VOID_REF node_info;
75    VOID_REF header;
76    uint32_t internal_node_base;
77 };
78 
79 #define RADV_COPY_MODE_COPY        0
80 #define RADV_COPY_MODE_SERIALIZE   1
81 #define RADV_COPY_MODE_DESERIALIZE 2
82 
83 struct copy_args {
84    VOID_REF src_addr;
85    VOID_REF dst_addr;
86    uint32_t mode;
87 };
88 
89 struct encode_args {
90    VOID_REF intermediate_bvh;
91    VOID_REF output_bvh;
92    REF(radv_ir_header) header;
93    uint32_t output_bvh_offset;
94    uint32_t leaf_node_count;
95    uint32_t geometry_type;
96 };
97 
98 struct ploc_prefix_scan_partition {
99    uint32_t aggregate;
100    uint32_t inclusive_sum;
101 };
102 
103 #define PLOC_WORKGROUP_SIZE 1024
104 
105 struct ploc_args {
106    VOID_REF bvh;
107    VOID_REF prefix_scan_partitions;
108    REF(radv_ir_header) header;
109    VOID_REF ids_0;
110    VOID_REF ids_1;
111    uint32_t internal_node_offset;
112 };
113 
114 struct header_args {
115    REF(radv_ir_header) src;
116    REF(radv_accel_struct_header) dst;
117    uint32_t bvh_offset;
118    uint32_t instance_count;
119 };
120 
121 struct update_args {
122    REF(radv_accel_struct_header) src;
123    REF(radv_accel_struct_header) dst;
124    REF(radv_aabb) leaf_bounds;
125    REF(uint32_t) internal_ready_count;
126    uint32_t leaf_node_count;
127 
128    radv_bvh_geometry_data geom_data;
129 };
130 
131 #endif
132