radv: Remove aabb bounds from instance nodes.
I need space ... Furthermore, this only gets used during the build, and we can eat the cost of generating the AABB a second time there. Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18692>
This commit is contained in:

committed by
Marge Bot

parent
b1ddb35040
commit
0f9fb8e15f
@@ -257,6 +257,25 @@ pack_node_id(uint32_t offset, uint32_t type)
|
||||
|
||||
#define NULL_NODE_ID 0xFFFFFFFF
|
||||
|
||||
AABB
|
||||
calculate_instance_node_bounds(radv_bvh_instance_node instance)
|
||||
{
|
||||
AABB aabb;
|
||||
radv_accel_struct_header header = DEREF(REF(radv_accel_struct_header)(instance.base_ptr));
|
||||
|
||||
for (uint32_t comp = 0; comp < 3; ++comp) {
|
||||
aabb.min[comp] = instance.wto_matrix[3 + 4 * comp];
|
||||
aabb.max[comp] = instance.wto_matrix[3 + 4 * comp];
|
||||
for (uint32_t col = 0; col < 3; ++col) {
|
||||
aabb.min[comp] += min(instance.otw_matrix[col + comp * 3] * header.aabb[0][col],
|
||||
instance.otw_matrix[col + comp * 3] * header.aabb[1][col]);
|
||||
aabb.max[comp] += max(instance.otw_matrix[col + comp * 3] * header.aabb[0][col],
|
||||
instance.otw_matrix[col + comp * 3] * header.aabb[1][col]);
|
||||
}
|
||||
}
|
||||
return aabb;
|
||||
}
|
||||
|
||||
AABB
|
||||
calculate_node_bounds(VOID_REF bvh, uint32_t id)
|
||||
{
|
||||
@@ -292,14 +311,7 @@ calculate_node_bounds(VOID_REF bvh, uint32_t id)
|
||||
}
|
||||
case radv_bvh_node_instance: {
|
||||
radv_bvh_instance_node instance = DEREF(REF(radv_bvh_instance_node)(node));
|
||||
|
||||
aabb.min.x = instance.aabb[0][0];
|
||||
aabb.min.y = instance.aabb[0][1];
|
||||
aabb.min.z = instance.aabb[0][2];
|
||||
|
||||
aabb.max.x = instance.aabb[1][0];
|
||||
aabb.max.y = instance.aabb[1][1];
|
||||
aabb.max.z = instance.aabb[1][2];
|
||||
aabb = calculate_instance_node_bounds(instance);
|
||||
break;
|
||||
}
|
||||
case radv_bvh_node_aabb: {
|
||||
|
@@ -100,7 +100,7 @@ struct radv_bvh_instance_node {
|
||||
* post-translation of the object->world matrix so this way we can share data between both
|
||||
* matrices. */
|
||||
float wto_matrix[12];
|
||||
float aabb[2][3];
|
||||
uint32_t reserved[6];
|
||||
uint32_t instance_id;
|
||||
|
||||
/* Object to world matrix transposed from the initial transform. Translate part is store in the
|
||||
|
@@ -213,28 +213,12 @@ build_instance(inout AABB bounds, VOID_REF src_ptr, VOID_REF dst_ptr, uint32_t g
|
||||
DEREF(REF(radv_accel_struct_header)(instance.accelerationStructureReference));
|
||||
DEREF(node).base_ptr = instance.accelerationStructureReference;
|
||||
|
||||
for (uint32_t comp = 0; comp < 3; ++comp) {
|
||||
bounds.min[comp] = transform[3][comp];
|
||||
bounds.max[comp] = transform[3][comp];
|
||||
for (uint32_t col = 0; col < 3; ++col) {
|
||||
bounds.min[comp] += min(transform[col][comp] * instance_header.aabb[0][col],
|
||||
transform[col][comp] * instance_header.aabb[1][col]);
|
||||
bounds.max[comp] += max(transform[col][comp] * instance_header.aabb[0][col],
|
||||
transform[col][comp] * instance_header.aabb[1][col]);
|
||||
}
|
||||
}
|
||||
bounds = calculate_instance_node_bounds(DEREF(node));
|
||||
|
||||
DEREF(node).custom_instance_and_mask = instance.custom_instance_and_mask;
|
||||
DEREF(node).sbt_offset_and_flags = instance.sbt_offset_and_flags;
|
||||
DEREF(node).instance_id = global_id;
|
||||
|
||||
DEREF(node).aabb[0][0] = bounds.min.x;
|
||||
DEREF(node).aabb[0][1] = bounds.min.y;
|
||||
DEREF(node).aabb[0][2] = bounds.min.z;
|
||||
DEREF(node).aabb[1][0] = bounds.max.x;
|
||||
DEREF(node).aabb[1][1] = bounds.max.y;
|
||||
DEREF(node).aabb[1][2] = bounds.max.z;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user