From 37525c11d133a94fcda904bae37bfa106572a599 Mon Sep 17 00:00:00 2001 From: Friedrich Vock Date: Tue, 25 Oct 2022 16:10:55 +0200 Subject: [PATCH] radv: Rename emulated float helpers Use only conversion functions now. Reviewed-by: Konstantin Seurer Part-of: --- src/amd/vulkan/bvh/build_helpers.h | 16 ++++------------ src/amd/vulkan/bvh/leaf.comp | 12 ++++++------ src/amd/vulkan/bvh/morton.comp | 12 ++++++------ 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/amd/vulkan/bvh/build_helpers.h b/src/amd/vulkan/bvh/build_helpers.h index d59c1805033..947e845e10f 100644 --- a/src/amd/vulkan/bvh/build_helpers.h +++ b/src/amd/vulkan/bvh/build_helpers.h @@ -203,24 +203,16 @@ align(uint32_t value, uint32_t alignment) return (value + alignment - 1) & ~(alignment - 1); } -void -min_float_emulated(REF(int32_t) addr, float f) +int32_t +to_emulated_float(float f) { int32_t bits = floatBitsToInt(f); - atomicMin(DEREF(addr), f < 0 ? -2147483648 - bits : bits); -} - -void -max_float_emulated(REF(int32_t) addr, float f) -{ - int32_t bits = floatBitsToInt(f); - atomicMax(DEREF(addr), f < 0 ? -2147483648 - bits : bits); + return f < 0 ? -2147483648 - bits : bits; } float -load_minmax_float_emulated(VOID_REF addr) +from_emulated_float(int32_t bits) { - int32_t bits = DEREF(REF(int32_t)(addr)); return intBitsToFloat(bits < 0 ? -2147483648 - bits : bits); } diff --git a/src/amd/vulkan/bvh/leaf.comp b/src/amd/vulkan/bvh/leaf.comp index 987125e7e41..b5aadd546b2 100644 --- a/src/amd/vulkan/bvh/leaf.comp +++ b/src/amd/vulkan/bvh/leaf.comp @@ -310,10 +310,10 @@ main(void) DEREF(id_ptr).id = is_active ? pack_ir_node_id(dst_offset, node_type) : RADV_BVH_INVALID_NODE; - min_float_emulated(INDEX(int32_t, args.bounds, 0), bounds.min.x); - min_float_emulated(INDEX(int32_t, args.bounds, 1), bounds.min.y); - min_float_emulated(INDEX(int32_t, args.bounds, 2), bounds.min.z); - max_float_emulated(INDEX(int32_t, args.bounds, 3), bounds.max.x); - max_float_emulated(INDEX(int32_t, args.bounds, 4), bounds.max.y); - max_float_emulated(INDEX(int32_t, args.bounds, 5), bounds.max.z); + atomicMin(DEREF(INDEX(int32_t, args.bounds, 0)), to_emulated_float(bounds.min.x)); + atomicMin(DEREF(INDEX(int32_t, args.bounds, 1)), to_emulated_float(bounds.min.y)); + atomicMin(DEREF(INDEX(int32_t, args.bounds, 2)), to_emulated_float(bounds.min.z)); + atomicMax(DEREF(INDEX(int32_t, args.bounds, 3)), to_emulated_float(bounds.max.x)); + atomicMax(DEREF(INDEX(int32_t, args.bounds, 4)), to_emulated_float(bounds.max.y)); + atomicMax(DEREF(INDEX(int32_t, args.bounds, 5)), to_emulated_float(bounds.max.z)); } diff --git a/src/amd/vulkan/bvh/morton.comp b/src/amd/vulkan/bvh/morton.comp index 8c82d68ad5e..a78a077143a 100644 --- a/src/amd/vulkan/bvh/morton.comp +++ b/src/amd/vulkan/bvh/morton.comp @@ -78,12 +78,12 @@ main(void) vec3 center = (bounds.min + bounds.max) * 0.5; AABB bvh_bounds; - bvh_bounds.min.x = load_minmax_float_emulated(VOID_REF(args.bounds)); - bvh_bounds.min.y = load_minmax_float_emulated(OFFSET(args.bounds, 4)); - bvh_bounds.min.z = load_minmax_float_emulated(OFFSET(args.bounds, 8)); - bvh_bounds.max.x = load_minmax_float_emulated(OFFSET(args.bounds, 12)); - bvh_bounds.max.y = load_minmax_float_emulated(OFFSET(args.bounds, 16)); - bvh_bounds.max.z = load_minmax_float_emulated(OFFSET(args.bounds, 20)); + bvh_bounds.min.x = from_emulated_float(DEREF(INDEX(int32_t, args.bounds, 0))); + bvh_bounds.min.y = from_emulated_float(DEREF(INDEX(int32_t, args.bounds, 1))); + bvh_bounds.min.z = from_emulated_float(DEREF(INDEX(int32_t, args.bounds, 2))); + bvh_bounds.max.x = from_emulated_float(DEREF(INDEX(int32_t, args.bounds, 3))); + bvh_bounds.max.y = from_emulated_float(DEREF(INDEX(int32_t, args.bounds, 4))); + bvh_bounds.max.z = from_emulated_float(DEREF(INDEX(int32_t, args.bounds, 5))); vec3 normalized_center = (center - bvh_bounds.min) / (bvh_bounds.max - bvh_bounds.min);