1 /* 2 * Copyright © 2022 Konstantin Seurer 3 * 4 * SPDX-License-Identifier: MIT 5 */ 6 7 #ifndef BVH_BUILD_INTERFACE_H 8 #define BVH_BUILD_INTERFACE_H 9 10 #ifdef VULKAN 11 #include "build_helpers.h" 12 #else 13 #include <stdint.h> 14 #include "bvh.h" 15 #define REF(type) uint64_t 16 #define VOID_REF uint64_t 17 #endif 18 19 struct leaf_args { 20 VOID_REF ir; 21 VOID_REF bvh; 22 REF(radv_ir_header) header; 23 REF(key_id_pair) ids; 24 25 radv_bvh_geometry_data geom_data; 26 }; 27 28 struct morton_args { 29 VOID_REF bvh; 30 REF(radv_ir_header) header; 31 REF(key_id_pair) ids; 32 }; 33 34 #define LBVH_RIGHT_CHILD_BIT_SHIFT 29 35 #define LBVH_RIGHT_CHILD_BIT (1 << LBVH_RIGHT_CHILD_BIT_SHIFT) 36 37 struct lbvh_node_info { 38 /* Number of children that have been processed (or are invalid/leaves) in 39 * the lbvh_generate_ir pass. 40 */ 41 uint32_t path_count; 42 43 uint32_t children[2]; 44 uint32_t parent; 45 }; 46 47 struct lbvh_main_args { 48 VOID_REF bvh; 49 REF(key_id_pair) src_ids; 50 VOID_REF node_info; 51 uint32_t id_count; 52 uint32_t internal_node_base; 53 }; 54 55 struct lbvh_generate_ir_args { 56 VOID_REF bvh; 57 VOID_REF node_info; 58 VOID_REF header; 59 uint32_t internal_node_base; 60 }; 61 62 #define RADV_COPY_MODE_COPY 0 63 #define RADV_COPY_MODE_SERIALIZE 1 64 #define RADV_COPY_MODE_DESERIALIZE 2 65 66 struct copy_args { 67 VOID_REF src_addr; 68 VOID_REF dst_addr; 69 uint32_t mode; 70 }; 71 72 struct encode_args { 73 VOID_REF intermediate_bvh; 74 VOID_REF output_bvh; 75 REF(radv_ir_header) header; 76 uint32_t output_bvh_offset; 77 uint32_t leaf_node_count; 78 uint32_t geometry_type; 79 }; 80 81 struct ploc_prefix_scan_partition { 82 uint32_t aggregate; 83 uint32_t inclusive_sum; 84 }; 85 86 #define PLOC_WORKGROUP_SIZE 1024 87 88 struct ploc_args { 89 VOID_REF bvh; 90 VOID_REF prefix_scan_partitions; 91 REF(radv_ir_header) header; 92 VOID_REF ids_0; 93 VOID_REF ids_1; 94 uint32_t internal_node_offset; 95 }; 96 97 struct header_args { 98 REF(radv_ir_header) src; 99 REF(radv_accel_struct_header) dst; 100 uint32_t bvh_offset; 101 uint32_t instance_count; 102 }; 103 104 struct update_args { 105 REF(radv_accel_struct_header) src; 106 REF(radv_accel_struct_header) dst; 107 REF(radv_aabb) leaf_bounds; 108 REF(uint32_t) internal_ready_count; 109 uint32_t leaf_node_count; 110 111 radv_bvh_geometry_data geom_data; 112 }; 113 114 #endif /* BUILD_INTERFACE_H */ 115