From 9df38a458fae00ad21c840f3cfa4d323593ae33f Mon Sep 17 00:00:00 2001 From: Eddy Jansson Date: Sat, 9 Nov 2024 15:07:39 +0100 Subject: [PATCH] Test the AVX builder too. This greatly increases the chance of catching breakage. --- tiny_bvh_test.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/tiny_bvh_test.cpp b/tiny_bvh_test.cpp index 7b7b8c9..424e145 100644 --- a/tiny_bvh_test.cpp +++ b/tiny_bvh_test.cpp @@ -44,17 +44,31 @@ int main() v2.z = z + 0.1f * uniform_rand(); } - // build a BVH over the scene - tinybvh::BVH bvh; - bvh.Build( (tinybvh::bvhvec4*)triangles, TRIANGLE_COUNT ); - - // from here: play with the BVH! tinybvh::bvhvec3 O( 0.5f, 0.5f, -1 ); tinybvh::bvhvec3 D( 0.1f, 0, 2 ); tinybvh::Ray ray( O, D ); - int steps = bvh.Intersect( ray ); - printf( "nearest intersection: %f (found in %i traversal steps).\n", ray.hit.t, steps ); + + // build a BVH over the scene + { + tinybvh::BVH bvh; + bvh.Build( (tinybvh::bvhvec4*)triangles, TRIANGLE_COUNT ); + + // from here: play with the BVH! + int steps = bvh.Intersect( ray ); + printf( "std: nearest intersection: %f (found in %i traversal steps).\n", ray.hit.t, steps ); + } + +#if defined(BVH_USEAVX) + // Same thing, using the AVX builder. + { + tinybvh::BVH bvh; + bvh.BuildAVX( (tinybvh::bvhvec4*)triangles, TRIANGLE_COUNT ); + + int steps = bvh.Intersect( ray ); + printf( "avx: nearest intersection: %f (found in %i traversal steps).\n", ray.hit.t, steps ); + } +#endif // all done. return 0; -} \ No newline at end of file +}