radv: Improve the BVH size estimation
authorKonstantin Seurer <konstantin.seurer@gmail.com>
Mon, 30 Jan 2023 15:12:28 +0000 (16:12 +0100)
committerMarge Bot <emma+marge@anholt.net>
Wed, 1 Feb 2023 10:34:36 +0000 (10:34 +0000)
The previous estimation was from before we had proper LBVH and PLOC.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20988>

src/amd/vulkan/radv_acceleration_structure.c

index f69a64e..b81f587 100644 (file)
@@ -126,13 +126,7 @@ get_build_layout(struct radv_device *device, uint32_t leaf_count,
                  const VkAccelerationStructureBuildGeometryInfoKHR *build_info,
                  struct acceleration_structure_layout *accel_struct, struct scratch_layout *scratch)
 {
-   /* Initialize to 1 to have enought space for the root node. */
-   uint32_t child_count = leaf_count;
-   uint32_t internal_count = 1;
-   while (child_count > 1) {
-      child_count = DIV_ROUND_UP(child_count, 2);
-      internal_count += child_count;
-   }
+   uint32_t internal_count = MAX2(leaf_count, 2) - 1;
 
    VkGeometryTypeKHR geometry_type = VK_GEOMETRY_TYPE_TRIANGLES_KHR;