From 95598153802e0c689ad8d65d3342c9492df206ee Mon Sep 17 00:00:00 2001 From: Myles Busig Date: Tue, 8 Oct 2024 00:21:38 -0700 Subject: [PATCH] Add conditional test includes and fix inconsistent file naming --- CMakeLists.txt | 4 +++- include/{ => test}/mtl/test.hpp | 0 include/{mtl/tests => test/mtl/test}/fixed.hpp | 0 include/{mtl/tests => test/mtl/test}/mat.hpp | 0 include/{mtl/tests => test/mtl/test}/vec.hpp | 0 src/{tests => test}/fixed.cpp | 2 +- src/{tests => test}/mat.cpp | 6 +++--- src/{tests => test}/vec.cpp | 2 +- 8 files changed, 8 insertions(+), 6 deletions(-) rename include/{ => test}/mtl/test.hpp (100%) rename include/{mtl/tests => test/mtl/test}/fixed.hpp (100%) rename include/{mtl/tests => test/mtl/test}/mat.hpp (100%) rename include/{mtl/tests => test/mtl/test}/vec.hpp (100%) rename src/{tests => test}/fixed.cpp (97%) rename src/{tests => test}/mat.cpp (97%) rename src/{tests => test}/vec.cpp (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb201e1..d8d6364 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,9 +14,10 @@ message("Compiling MTL for ${CMAKE_SYSTEM_PROCESSOR}") file(GLOB mtl_sources_common LIST_DIRECTORIES false CONFIGURE_DEPENDS src/common/*.cpp src/common/*.c src/common/*.s) file(GLOB mtl_sources_armv4t LIST_DIRECTORIES false CONFIGURE_DEPENDS src/armv4t/*.cpp src/armv4t/*.c src/armv4t/*.s) file(GLOB mtl_sources_gba LIST_DIRECTORIES false CONFIGURE_DEPENDS src/gba/*.cpp src/gba/*.c src/gba/*.s) -file(GLOB mtl_sources_test LIST_DIRECTORIES false CONFIGURE_DEPENDS src/tests/*.cpp) +file(GLOB mtl_sources_test LIST_DIRECTORIES false CONFIGURE_DEPENDS src/test/*.cpp) set(mtl_include_common "include") +set(mtl_include_test "include/test") set(mtl_include_gba "include/gba") set(mtl_include_armv4t "include/armv4t") @@ -46,6 +47,7 @@ if (BUILD_TESTS STREQUAL "ON") add_library(${PROJECT_NAME}_test OBJECT) target_sources(${PROJECT_NAME}_test PRIVATE "${mtl_sources_test}") target_include_directories(${PROJECT_NAME}_test PUBLIC "${mtl_include_common}") + target_include_directories(${PROJECT_NAME}_test PUBLIC "${mtl_include_test}") target_link_libraries(${PROJECT_NAME} PUBLIC ${PROJECT_NAME}_test) endif() diff --git a/include/mtl/test.hpp b/include/test/mtl/test.hpp similarity index 100% rename from include/mtl/test.hpp rename to include/test/mtl/test.hpp diff --git a/include/mtl/tests/fixed.hpp b/include/test/mtl/test/fixed.hpp similarity index 100% rename from include/mtl/tests/fixed.hpp rename to include/test/mtl/test/fixed.hpp diff --git a/include/mtl/tests/mat.hpp b/include/test/mtl/test/mat.hpp similarity index 100% rename from include/mtl/tests/mat.hpp rename to include/test/mtl/test/mat.hpp diff --git a/include/mtl/tests/vec.hpp b/include/test/mtl/test/vec.hpp similarity index 100% rename from include/mtl/tests/vec.hpp rename to include/test/mtl/test/vec.hpp diff --git a/src/tests/fixed.cpp b/src/test/fixed.cpp similarity index 97% rename from src/tests/fixed.cpp rename to src/test/fixed.cpp index 853a8b8..e1b90f4 100644 --- a/src/tests/fixed.cpp +++ b/src/test/fixed.cpp @@ -1,4 +1,4 @@ -#include "mtl/tests/fixed.hpp" +#include "mtl/test/fixed.hpp" #include "mtl/target.hpp" #include "mtl/fixed.hpp" diff --git a/src/tests/mat.cpp b/src/test/mat.cpp similarity index 97% rename from src/tests/mat.cpp rename to src/test/mat.cpp index e8ca815..597bba8 100644 --- a/src/tests/mat.cpp +++ b/src/test/mat.cpp @@ -1,4 +1,4 @@ -#include "mtl/tests/mat.hpp" +#include "mtl/test/mat.hpp" #include "mtl/target.hpp" #include "mtl/mat.hpp" @@ -398,7 +398,7 @@ bool mat_suite::projection_build_m4() { NOINLINE GBA_IWRAM ARM_MODE mat<4, 4> operator()(vec4 b) { start_timer(); - mat<4, 4> r = b * b.transpose() / b.magnitude_sqr(); + mat<4, 4> r = b * b.transpose() * (fixed(64) / b.magnitude_sqr()) * fixed(1.0 / 64.0); end_timer(); return r; } @@ -424,7 +424,7 @@ bool mat_suite::projection_calc_m4() { vec4 a(8, 3, 7, 0); vec4 b(-3, 4, 14, 0); - mat<4, 4> A = b * b.transpose() / b.magnitude_sqr(); + mat<4, 4> A = b * b.transpose() * (fixed(64) / b.magnitude_sqr()) * fixed(1.0 / 64.0); vec4 c = f(A, a); diff --git a/src/tests/vec.cpp b/src/test/vec.cpp similarity index 99% rename from src/tests/vec.cpp rename to src/test/vec.cpp index 5efeac5..7d1a346 100644 --- a/src/tests/vec.cpp +++ b/src/test/vec.cpp @@ -1,4 +1,4 @@ -#include "mtl/tests/vec.hpp" +#include "mtl/test/vec.hpp" #include "mtl/target.hpp" #include "mtl/vec.hpp"