There is no need to do it on the GPU.
Change in average build time (Control):
84.80691 ms -> 84.69471 ms
Reviewed-by: Friedrich Vock <friedrich.vock@gmx.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22400>
#define VK_GEOMETRY_TYPE_TRIANGLES_KHR 0
#define VK_GEOMETRY_TYPE_AABBS_KHR 1
-#define VK_GEOMETRY_OPAQUE_BIT_KHR 1
-
#define VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR 1
#define VK_GEOMETRY_INSTANCE_TRIANGLE_FLIP_FACING_BIT_KHR 2
#define VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_KHR 4
}
uint32_t
-encode_geometry_id_and_flags(uint32_t src)
-{
- uint32_t flags = src >> 28;
- uint32_t ret = src & 0xfffffffu;
- if ((flags & VK_GEOMETRY_OPAQUE_BIT_KHR) != 0)
- ret |= RADV_GEOMETRY_OPAQUE;
- return ret;
-}
-
-uint32_t
encode_sbt_offset_and_flags(uint32_t src)
{
uint32_t flags = src >> 24;
DEREF(dst).coords = src.coords;
DEREF(dst).triangle_id = src.triangle_id;
- DEREF(dst).geometry_id_and_flags = encode_geometry_id_and_flags(src.geometry_id_and_flags);
+ DEREF(dst).geometry_id_and_flags = src.geometry_id_and_flags;
DEREF(dst).id = src.id;
break;
}
DEREF(dst).aabb = src.base.aabb;
DEREF(dst).primitive_id = src.primitive_id;
- DEREF(dst).geometry_id_and_flags = encode_geometry_id_and_flags(src.geometry_id_and_flags);
+ DEREF(dst).geometry_id_and_flags = src.geometry_id_and_flags;
break;
}
case radv_ir_node_instance: {
struct build_config config;
};
+static uint32_t
+pack_geometry_id_and_flags(uint32_t geometry_id, uint32_t flags)
+{
+ uint32_t geometry_id_and_flags = geometry_id;
+ if (flags & VK_GEOMETRY_OPAQUE_BIT_KHR)
+ geometry_id_and_flags |= RADV_GEOMETRY_OPAQUE;
+
+ return geometry_id_and_flags;
+}
+
static void
build_leaves(VkCommandBuffer commandBuffer, uint32_t infoCount,
const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
leaf_consts.first_id = bvh_states[i].node_count;
leaf_consts.geometry_type = geom->geometryType;
- leaf_consts.geometry_id = j | (geom->flags << 28);
+ leaf_consts.geometry_id = pack_geometry_id_and_flags(j, geom->flags);
unsigned prim_size;
switch (geom->geometryType) {
case VK_GEOMETRY_TYPE_TRIANGLES_KHR: