diff --git a/src/vulkan/runtime/bvh/hploc_internal.comp b/src/vulkan/runtime/bvh/hploc_internal.comp index b733899aca0..98a554e9181 100644 --- a/src/vulkan/runtime/bvh/hploc_internal.comp +++ b/src/vulkan/runtime/bvh/hploc_internal.comp @@ -39,8 +39,8 @@ delta(uint32_t index) uint32_t left_index = index; uint32_t right_index = index + 1; - uint32_t left_key = DEREF(INDEX(key_id_pair, args.ids, left_index)).key; - uint32_t right_key = DEREF(INDEX(key_id_pair, args.ids, right_index)).key; + uint32_t left_key = DEREF(INDEX(key32_id_pair, args.ids, left_index)).key; + uint32_t right_key = DEREF(INDEX(key32_id_pair, args.ids, right_index)).key; return left_key != right_key ? (32 + findMSB(left_key ^ right_key)) : findMSB(left_index ^ right_index); } @@ -67,7 +67,7 @@ main(void) uint32_t child_id = VK_BVH_INVALID_NODE; vk_ir_node child = vk_ir_node(vk_aabb(vec3(0.0), vec3(0.0))); if (active_leaf_count > 0) { - REF(key_id_pair) key_id = INDEX(key_id_pair, args.ids, global_id); + REF(key32_id_pair) key_id = INDEX(key32_id_pair, args.ids, global_id); child_id = DEREF(key_id).id; child = DEREF(REF(vk_ir_node)(OFFSET(args.bvh, ir_id_to_offset(child_id)))); } @@ -143,7 +143,7 @@ main(void) uint32_t node_id_index = load_base + load_index; uint32_t node_id = VK_BVH_INVALID_NODE; if (load_index < index_range) - node_id = DEREF(INDEX(key_id_pair, args.ids, node_id_index)).id; + node_id = DEREF(INDEX(key32_id_pair, args.ids, node_id_index)).id; uvec4 node_valid_mask = subgroupBallot(node_id != VK_BVH_INVALID_NODE); uint32_t node_prefix_sum = subgroupBallotExclusiveBitCount(node_valid_mask); @@ -225,7 +225,7 @@ main(void) if (gl_SubgroupInvocationID < min(end - start + 1, cluster_threshold)) { uint32_t dst_node = gl_SubgroupInvocationID < node_count ? node_ids[gl_SubgroupInvocationID] : VK_BVH_INVALID_NODE; - DEREF(INDEX(key_id_pair, args.ids, start + gl_SubgroupInvocationID)).id = dst_node; + DEREF(INDEX(key32_id_pair, args.ids, start + gl_SubgroupInvocationID)).id = dst_node; } memoryBarrier(gl_ScopeDevice, gl_StorageSemanticsBuffer, diff --git a/src/vulkan/runtime/bvh/lbvh_main.comp b/src/vulkan/runtime/bvh/lbvh_main.comp index 1d8cdf67686..fa021c49f47 100644 --- a/src/vulkan/runtime/bvh/lbvh_main.comp +++ b/src/vulkan/runtime/bvh/lbvh_main.comp @@ -40,7 +40,7 @@ longest_common_prefix(int32_t i, uint32_t key_i, int32_t j, uint32_t active_leaf if (j < 0 || j >= active_leaf_count) return -1; - uint32_t key_j = DEREF(INDEX(key_id_pair, args.src_ids, j)).key; + uint32_t key_j = DEREF(INDEX(key32_id_pair, args.src_ids, j)).key; uint32_t diff = key_i ^ key_j; int32_t ret = 0; @@ -85,7 +85,7 @@ main() DEREF(dst).parent = VK_BVH_INVALID_NODE; DEREF(dst).path_count = 2; DEREF(dst).children[0] = - active_leaf_count == 1 ? DEREF(INDEX(key_id_pair, args.src_ids, 0)).id : VK_BVH_INVALID_NODE; + active_leaf_count == 1 ? DEREF(INDEX(key32_id_pair, args.src_ids, 0)).id : VK_BVH_INVALID_NODE; DEREF(dst).children[1] = VK_BVH_INVALID_NODE; return; } @@ -95,7 +95,7 @@ main() if (id >= internal_node_count) return; - uint32_t id_key = DEREF(INDEX(key_id_pair, args.src_ids, id)).key; + uint32_t id_key = DEREF(INDEX(key32_id_pair, args.src_ids, id)).key; int32_t left_lcp = longest_common_prefix(id, id_key, id - 1, active_leaf_count); int32_t right_lcp = longest_common_prefix(id, id_key, id + 1, active_leaf_count); @@ -145,8 +145,8 @@ main() REF(lbvh_node_info) dst = INDEX(lbvh_node_info, args.node_info, id); DEREF(dst).path_count = (left_leaf ? 1 : 0) + (right_leaf ? 1 : 0); - DEREF(dst).children[0] = DEREF(INDEX(key_id_pair, args.src_ids, left)).id; - DEREF(dst).children[1] = DEREF(INDEX(key_id_pair, args.src_ids, right)).id; + DEREF(dst).children[0] = DEREF(INDEX(key32_id_pair, args.src_ids, left)).id; + DEREF(dst).children[1] = DEREF(INDEX(key32_id_pair, args.src_ids, right)).id; if (id == 0) DEREF(dst).parent = VK_BVH_INVALID_NODE; } diff --git a/src/vulkan/runtime/bvh/leaf.h b/src/vulkan/runtime/bvh/leaf.h index 8a65f422f7a..5ced463fecd 100644 --- a/src/vulkan/runtime/bvh/leaf.h +++ b/src/vulkan/runtime/bvh/leaf.h @@ -204,7 +204,7 @@ main(void) uint32_t global_id = gl_GlobalInvocationID.x; uint32_t primitive_id = args.geom_data.first_id + global_id; - REF(key_id_pair) id_ptr = INDEX(key_id_pair, args.ids, primitive_id); + REF(key32_id_pair) id_ptr = INDEX(key32_id_pair, args.ids, primitive_id); uint32_t src_offset = global_id * args.geom_data.stride; uint32_t dst_stride; diff --git a/src/vulkan/runtime/bvh/morton.comp b/src/vulkan/runtime/bvh/morton.comp index 793fc2c0272..c3b39e6e3fa 100644 --- a/src/vulkan/runtime/bvh/morton.comp +++ b/src/vulkan/runtime/bvh/morton.comp @@ -57,7 +57,7 @@ main(void) { uint32_t global_id = gl_GlobalInvocationID.x; - REF(key_id_pair) key_id = INDEX(key_id_pair, args.ids, global_id); + REF(key32_id_pair) key_id = INDEX(key32_id_pair, args.ids, global_id); uint32_t id = DEREF(key_id).id; diff --git a/src/vulkan/runtime/bvh/ploc_internal.comp b/src/vulkan/runtime/bvh/ploc_internal.comp index a158b1fd947..a5dc4c89214 100644 --- a/src/vulkan/runtime/bvh/ploc_internal.comp +++ b/src/vulkan/runtime/bvh/ploc_internal.comp @@ -178,7 +178,7 @@ uint32_t load_id(VOID_REF ids, uint32_t iter, uint32_t index) { if (iter == 0) - return DEREF(REF(key_id_pair)(INDEX(key_id_pair, ids, index))).id; + return DEREF(REF(key32_id_pair)(INDEX(key32_id_pair, ids, index))).id; else return DEREF(REF(uint32_t)(INDEX(uint32_t, ids, index))); } @@ -231,7 +231,7 @@ main(void) uint32_t i = 0; for (; i < DEREF(args.header).active_leaf_count; i++) { - uint32_t child_id = DEREF(INDEX(key_id_pair, src_ids, i)).id; + uint32_t child_id = DEREF(INDEX(key32_id_pair, src_ids, i)).id; if (child_id != VK_BVH_INVALID_NODE) { VOID_REF node = OFFSET(args.bvh, ir_id_to_offset(child_id)); diff --git a/src/vulkan/runtime/bvh/vk_build_helpers.h b/src/vulkan/runtime/bvh/vk_build_helpers.h index dd5795855b2..e67e2194b20 100644 --- a/src/vulkan/runtime/bvh/vk_build_helpers.h +++ b/src/vulkan/runtime/bvh/vk_build_helpers.h @@ -234,11 +234,7 @@ from_emulated_float(int32_t bits) TYPE(vk_aabb, 4); -struct key_id_pair { - uint32_t id; - uint32_t key; -}; -TYPE(key_id_pair, 4); +TYPE(key32_id_pair, 4); TYPE(vk_accel_struct_serialization_header, 8); diff --git a/src/vulkan/runtime/bvh/vk_build_interface.h b/src/vulkan/runtime/bvh/vk_build_interface.h index d4745c6dfe4..f9fc0504c45 100644 --- a/src/vulkan/runtime/bvh/vk_build_interface.h +++ b/src/vulkan/runtime/bvh/vk_build_interface.h @@ -53,7 +53,7 @@ layout (constant_id = ROOT_FLAGS_OFFSET_ID) const int ROOT_FLAGS_OFFSET = -1; struct leaf_args { VOID_REF bvh; REF(vk_ir_header) header; - REF(key_id_pair) ids; + VOID_REF ids; vk_bvh_geometry_data geom_data; }; @@ -61,7 +61,7 @@ struct leaf_args { struct morton_args { VOID_REF bvh; REF(vk_ir_header) header; - REF(key_id_pair) ids; + VOID_REF ids; }; #define LBVH_RIGHT_CHILD_BIT_SHIFT 29 @@ -79,7 +79,7 @@ struct lbvh_node_info { struct lbvh_main_args { VOID_REF bvh; - REF(key_id_pair) src_ids; + VOID_REF src_ids; VOID_REF node_info; REF(vk_ir_header) header; uint32_t internal_node_base; @@ -113,7 +113,7 @@ struct ploc_args { struct hploc_args { REF(vk_ir_header) header; VOID_REF bvh; - REF(key_id_pair) ids; + REF(key32_id_pair) ids; VOID_REF ranges; uint32_t internal_node_base; }; diff --git a/src/vulkan/runtime/bvh/vk_bvh.h b/src/vulkan/runtime/bvh/vk_bvh.h index 3cee4f0e596..40e69c7c250 100644 --- a/src/vulkan/runtime/bvh/vk_bvh.h +++ b/src/vulkan/runtime/bvh/vk_bvh.h @@ -169,4 +169,9 @@ struct vk_bvh_geometry_data { uint32_t index_format; }; +struct key32_id_pair { + uint32_t id; + uint32_t key; +}; + #endif diff --git a/src/vulkan/runtime/vk_acceleration_structure.c b/src/vulkan/runtime/vk_acceleration_structure.c index 7ff39d8acdf..a4874a995b3 100644 --- a/src/vulkan/runtime/vk_acceleration_structure.c +++ b/src/vulkan/runtime/vk_acceleration_structure.c @@ -135,7 +135,6 @@ vk_common_GetAccelerationStructureDeviceAddressKHR( return vk_acceleration_structure_get_va(accel_struct); } -#define KEY_ID_PAIR_SIZE 8 #define MORTON_BIT_SIZE 24 static void