radv/bvh: Implement compact encoding

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20818>
This commit is contained in:
Konstantin Seurer 2023-01-20 19:29:05 +01:00 committed by Marge Bot
parent 71ccc8d600
commit 07c1b23022
3 changed files with 11 additions and 1 deletions

View file

@ -165,6 +165,7 @@ struct radv_ir_header {
uint32_t dispatch_size_y;
uint32_t dispatch_size_z;
radv_global_sync_data sync_data;
uint32_t dst_node_offset;
};
struct radv_bvh_triangle_node {

View file

@ -233,9 +233,13 @@ main()
uint32_t dst_offset;
if (type == radv_ir_node_internal) {
#if COMPACT
dst_offset = atomicAdd(DEREF(args.header).dst_node_offset, SIZEOF(radv_bvh_box32_node));
#else
uint32_t offset_in_internal_nodes = offset - intermediate_leaf_nodes_size;
uint32_t child_index = offset_in_internal_nodes / SIZEOF(radv_ir_box_node);
dst_offset = dst_internal_offset + child_index * SIZEOF(radv_bvh_box32_node);
#endif
REF(radv_ir_box_node) child_node = REF(radv_ir_box_node)OFFSET(args.intermediate_bvh, offset);
DEREF(child_node).bvh_offset = dst_offset;

View file

@ -28,7 +28,12 @@ bvh_shaders = [
[
'encode.comp',
'encode',
[],
['COMPACT=0'],
],
[
'encode.comp',
'encode_compact',
['COMPACT=1'],
],
[
'lbvh_generate_ir.comp',