mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-02 20:58:04 +02:00
radv: Pack and encode geometry id and flags on the CPU
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>
This commit is contained in:
parent
8391639b5f
commit
f791cd9e43
3 changed files with 13 additions and 15 deletions
|
|
@ -157,8 +157,6 @@
|
|||
#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
|
||||
|
|
|
|||
|
|
@ -50,16 +50,6 @@ void set_parent(uint32_t child, uint32_t parent)
|
|||
DEREF(REF(uint32_t)(addr)) = parent;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -86,7 +76,7 @@ encode_leaf_node(uint32_t type, uint64_t src_node, uint64_t dst_node)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
@ -96,7 +86,7 @@ encode_leaf_node(uint32_t type, uint64_t src_node, uint64_t dst_node)
|
|||
|
||||
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: {
|
||||
|
|
|
|||
|
|
@ -647,6 +647,16 @@ struct bvh_state {
|
|||
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,
|
||||
|
|
@ -673,7 +683,7 @@ build_leaves(VkCommandBuffer commandBuffer, uint32_t infoCount,
|
|||
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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue