From 0e622822e7f0beb84f45359f9d131ab559f99131 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 7 Sep 2011 17:16:58 +0000 Subject: [PATCH] test: add a few Visual Studio 2010 project files and fix testsuite code so that it builds properly. --- test/half.cpp | 6 +-- test/lol-bench.cpp | 27 +++++++++++ test/lol-test.cpp | 9 +++- test/trig.cpp | 34 +++++++++++++ win32/Contribs.props | 66 ++++++++----------------- win32/lol-bench.vcxproj | 8 ++-- win32/lol-test.vcxproj | 103 ++++++++++++++++++++++++++++++++++++++++ win32/lolcore.vcxproj | 5 +- win32/lolengine.sln | 20 ++++++++ win32/quad.vcxproj | 2 +- 10 files changed, 226 insertions(+), 54 deletions(-) create mode 100644 win32/lol-test.vcxproj diff --git a/test/half.cpp b/test/half.cpp index 8c2c496c..886df578 100644 --- a/test/half.cpp +++ b/test/half.cpp @@ -324,9 +324,9 @@ HalfTest::TestPair const HalfTest::pairs[] = { 0.5f, 0x3800 }, { 0.125f, 0x3000 }, { 15.9375f, 0x4bf8 }, - { 0x1.fp-10, 0x17c0 }, - { 0x1.fp-14, 0x07c0 }, /* denormal */ - { 0x1.fp-15, 0x03e0 }, /* denormal */ + { 31.0f / (1 << 14), 0x17c0 }, /* 0x1.fp-10 */ + { 31.0f / (1 << 18), 0x07c0 }, /* 0x1.fp-14, denormal */ + { 31.0f / (1 << 19), 0x03e0 }, /* 0x1.fp-15, denormal */ }; CPPUNIT_TEST_SUITE_REGISTRATION(HalfTest); diff --git a/test/lol-bench.cpp b/test/lol-bench.cpp index abd768c1..88fbfb1f 100644 --- a/test/lol-bench.cpp +++ b/test/lol-bench.cpp @@ -12,6 +12,12 @@ # include "config.h" #endif +#ifdef WIN32 +# define _USE_MATH_DEFINES /* for M_PI */ +# define WIN32_LEAN_AND_MEAN +# include +#endif + #include #if defined HAVE_FASTMATH_H @@ -69,6 +75,10 @@ int main(int argc, char **argv) Log::Info("-----------------------------------\n"); bench_half(2); +#if defined _WIN32 + getchar(); +#endif + return EXIT_SUCCESS; } @@ -103,7 +113,11 @@ static void bench_trig(int mode) /* Sin */ timer.GetMs(); for (size_t i = 0; i < TRIG_TABLE_SIZE; i++) +#if defined __GNUC__ pf2[i] = __builtin_sinf(pf[i]); +#else + pf2[i] = sinf(pf[i]); +#endif result[0] += timer.GetMs(); /* Fast sin */ @@ -125,7 +139,11 @@ static void bench_trig(int mode) /* Cos */ timer.GetMs(); for (size_t i = 0; i < TRIG_TABLE_SIZE; i++) +#if defined __GNUC__ pf2[i] = __builtin_cosf(pf[i]); +#else + pf2[i] = cosf(pf[i]); +#endif result[3] += timer.GetMs(); /* Fast cos */ @@ -148,8 +166,13 @@ static void bench_trig(int mode) timer.GetMs(); for (size_t i = 0; i < TRIG_TABLE_SIZE; i++) { +#if defined __GNUC__ pf2[i] = __builtin_sinf(pf[i]); pf3[i] = __builtin_cosf(pf[i]); +#else + pf2[i] = sinf(pf[i]); + pf3[i] = cosf(pf[i]); +#endif } result[6] += timer.GetMs(); @@ -176,7 +199,11 @@ static void bench_trig(int mode) /* Tan */ timer.GetMs(); for (size_t i = 0; i < TRIG_TABLE_SIZE; i++) +#if defined __GNUC__ pf2[i] = __builtin_tanf(pf[i]); +#else + pf2[i] = tanf(pf[i]); +#endif result[9] += timer.GetMs(); /* Fast tan */ diff --git a/test/lol-test.cpp b/test/lol-test.cpp index a7984764..a03eb9b3 100644 --- a/test/lol-test.cpp +++ b/test/lol-test.cpp @@ -12,6 +12,8 @@ # include "config.h" #endif +#include + #include #include @@ -20,6 +22,11 @@ int main(int argc, char *argv[]) CppUnit::TextTestRunner runner; runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); - return !runner.run(); + int ret = !runner.run(); + +#if defined _WIN32 + getchar(); +#endif + return ret; } diff --git a/test/trig.cpp b/test/trig.cpp index 31f01154..d1643abd 100644 --- a/test/trig.cpp +++ b/test/trig.cpp @@ -42,7 +42,11 @@ public: for (int i = -10000; i < 10000; i++) { double f = (double)i * (1.0 / 1000.0); +#if defined __GNUC__ double a = __builtin_sin(f); +#else + double a = sin(f); +#endif double b = lol_sin(f); CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); } @@ -50,7 +54,11 @@ public: for (int i = -10000; i < 10000; i++) { double f = (double)i * (1.0 / 100000.0); +#if defined __GNUC__ double a = __builtin_sin(f); +#else + double a = sin(f); +#endif double b = lol_sin(f); CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); } @@ -58,7 +66,11 @@ public: for (int i = -10000; i < 10000; i++) { double f = (double)i * (1.0 / 1000.0); +#if defined __GNUC__ double a = __builtin_cos(f); +#else + double a = cos(f); +#endif double b = lol_cos(f); CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); } @@ -66,7 +78,11 @@ public: for (int i = -10000; i < 10000; i++) { double f = (double)i * (1.0 / 100000.0); +#if defined __GNUC__ double a = __builtin_cos(f); +#else + double a = cos(f); +#endif double b = lol_cos(f); CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11); } @@ -74,8 +90,13 @@ public: for (int i = -10000; i < 10000; i++) { double f = (double)i * (1.0 / 1000.0); +#if defined __GNUC__ double a1 = __builtin_sin(f); double a2 = __builtin_cos(f); +#else + double a1 = sin(f); + double a2 = cos(f); +#endif double b1, b2; lol_sincos(f, &b1, &b2); CPPUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11); @@ -85,8 +106,13 @@ public: for (int i = -10000; i < 10000; i++) { double f = (double)i * (1.0 / 100000.0); +#if defined __GNUC__ double a1 = __builtin_sin(f); double a2 = __builtin_cos(f); +#else + double a1 = sin(f); + double a2 = cos(f); +#endif double b1, b2; lol_sincos(f, &b1, &b2); CPPUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11); @@ -96,7 +122,11 @@ public: for (int i = -100000; i < 100000; i++) { double f = (double)i * (1.0 / 10000.0); +#if defined __GNUC__ double a = __builtin_tan(f); +#else + double a = tan(f); +#endif double b = lol_tan(f); if (fabs(a) > 1e4) CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * fabs(a) * 1e-11); @@ -109,7 +139,11 @@ public: for (int i = -10000; i < 10000; i++) { double f = (double)i * (1.0 / 100000.0); +#if defined __GNUC__ double a = __builtin_tan(f); +#else + double a = tan(f); +#endif double b = lol_tan(f); if (fabs(a) > 1e4) CPPUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * fabs(a) * 1e-11); diff --git a/win32/Contribs.props b/win32/Contribs.props index cae28590..3944681f 100644 --- a/win32/Contribs.props +++ b/win32/Contribs.props @@ -3,15 +3,18 @@ $(SolutionDir)\..\contrib + $(ContribDir)\cppunit-1.12.2 $(ContribDir)\glew-1.6.0 $(ContribDir)\gtk-2.22.1 $(ContribDir)\gtkglarea-2.0.1 $(ContribDir)\sdl-1.2.14 $(ContribDir)\sdl-image-1.2.10 $(ContribDir)\sdl-mixer-1.2.11 + $(CppUnitDir)\include $(GlewDir)\include $(GtkDir)\lib\glib-2.0\include;$(GtkDir)\lib\gtk-2.0\include;$(GtkDir)\include\glib-2.0;$(GtkDir)\include\gtk-2.0;$(GtkDir)\include\cairo;$(GtkDir)\include\pango-1.0;$(GtkDir)\include\gdk-pixbuf-2.0;$(GtkDir)\include\atk-1.0;$(GtkGlDir)\include $(SdlDir)\include;$(SdlImageDir)\include;$(SdlMixerDir)\include + $(CppUnitDir)\lib $(GlewDir)\lib $(GtkDir)\lib;$(GtkDir)\bin;$(GtkGlDir)\lib $(SdlDir)\lib;$(SdlImageDir)\lib;$(SdlMixerDir)\lib @@ -24,51 +27,24 @@ $(ContribDir) + $(CppUnitDir) $(GlewDir) - - $(GtkDir) - - - $(GtkGlDir) - - - $(SdlDir) - - - $(SdlImageDir) - - - $(SdlMixerDir) - - - $(GlIncludes) - - - $(GtkIncludes) - - - $(SdlIncludes) - - - $(GlLibs) - - - $(GtkLibs) - - - $(SdlLibs) - - - $(GlDeps) - - - $(GtkDeps) - - - $(SdlDeps) - - - $(LolDefines) - + $(GtkDir) + $(GtkGlDir) + $(SdlDir) + $(SdlImageDir) + $(SdlMixerDir) + $(CppUnitIncludes) + $(GlIncludes) + $(GtkIncludes) + $(SdlIncludes) + $(CppUnitLibss) + $(GlLibs) + $(GtkLibs) + $(SdlLibs) + $(GlDeps) + $(GtkDeps) + $(SdlDeps) + $(LolDefines) diff --git a/win32/lol-bench.vcxproj b/win32/lol-bench.vcxproj index 68ec0cb1..88b34d39 100644 --- a/win32/lol-bench.vcxproj +++ b/win32/lol-bench.vcxproj @@ -14,7 +14,7 @@ - {53D9D96F-55C0-4044-BDB1-4A5E8EDBDF0E} + {B1E10086-A1DA-401A-834D-969C9DBB5CC1} Win32Proj testmap @@ -60,6 +60,7 @@ Disabled WIN32;_DEBUG;_CONSOLE;$(LolDefines);%(PreprocessorDefinitions) $(SolutionDir)\..\src;$(GlIncludes);$(SdlIncludes);%(AdditionalIncludeDirectories) + Fast Console @@ -81,13 +82,14 @@ true WIN32;NDEBUG;_CONSOLE;$(LolDefines);%(PreprocessorDefinitions) $(SolutionDir)\..\src;$(GlIncludes);$(SdlIncludes);%(AdditionalIncludeDirectories) + Fast Console true true true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(SdlDeps);$(GlDeps) + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(SdlDeps);$(GlDeps);$(OutDir)\lolcore.lib $(SdlLibs);$(GlLibs);%(AdditionalLibraryDirectories) @@ -97,4 +99,4 @@ - + \ No newline at end of file diff --git a/win32/lol-test.vcxproj b/win32/lol-test.vcxproj new file mode 100644 index 00000000..7b9e5a1c --- /dev/null +++ b/win32/lol-test.vcxproj @@ -0,0 +1,103 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + {80F81C11-8DA2-4990-91CB-9807783BA46E} + Win32Proj + testmap + + + + Application + true + Unicode + Dynamic + + + Application + false + true + Unicode + Dynamic + + + + + + + + + + + + + + + Debug\$(ProjectName)\ + true + + + Release\$(ProjectName)\ + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;$(LolDefines);%(PreprocessorDefinitions) + $(SolutionDir)\..\src;$(CppUnitIncludes);$(GlIncludes);$(SdlIncludes);%(AdditionalIncludeDirectories) + + + Console + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(SdlDeps);libcppunit_msvcd.lib;$(GlDeps);$(OutDir)\lolcore.lib + $(SdlLibs);$(CppUnitLibs);$(GlLibs);%(AdditionalLibraryDirectories) + + + for %%I in ($(SdlLibs)) do xcopy /y /c /d %%I\*.dll $(TargetDir) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;$(LolDefines);%(PreprocessorDefinitions) + $(SolutionDir)\..\src;$(CppUnitIncludes);$(GlIncludes);$(SdlIncludes);%(AdditionalIncludeDirectories) + + + Console + true + true + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(SdlDeps);libcppunit_msvc.lib;$(GlDeps);$(OutDir)\lolcore.lib + $(SdlLibs);$(CppUnitLibs);$(GlLibs);%(AdditionalLibraryDirectories) + + + for %%I in ($(SdlLibs)) do xcopy /y /c /d %%I\*.dll $(TargetDir) + + + + + + diff --git a/win32/lolcore.vcxproj b/win32/lolcore.vcxproj index bb7406b5..422a9b46 100644 --- a/win32/lolcore.vcxproj +++ b/win32/lolcore.vcxproj @@ -48,6 +48,7 @@ Disabled WIN32;_DEBUG;_LIB;$(LolDefines);%(PreprocessorDefinitions) $(SolutionDir)\..\src;$(GlIncludes);%(AdditionalIncludeDirectories) + Fast Windows @@ -64,6 +65,8 @@ true WIN32;NDEBUG;_LIB;$(LolDefines);%(PreprocessorDefinitions) $(SolutionDir)\..\src;$(GlIncludes);%(AdditionalIncludeDirectories) + Speed + Fast Windows @@ -163,4 +166,4 @@ - + \ No newline at end of file diff --git a/win32/lolengine.sln b/win32/lolengine.sln index 7aae6d02..c4aa8e14 100644 --- a/win32/lolengine.sln +++ b/win32/lolengine.sln @@ -29,6 +29,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "quad", "quad.vcxproj", "{53 {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} = {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lol-bench", "lol-bench.vcxproj", "{B1E10086-A1DA-401A-834D-969C9DBB5CC1}" + ProjectSection(ProjectDependencies) = postProject + {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} = {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lol-test", "lol-test.vcxproj", "{80F81C11-8DA2-4990-91CB-9807783BA46E}" + ProjectSection(ProjectDependencies) = postProject + {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} = {9E62F2FE-3408-4EAE-8238-FD84238CEEDA} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -55,6 +65,14 @@ Global {53D9D96F-55C0-4044-BDB1-4A5E8EDBDF0E}.Debug|Win32.Build.0 = Debug|Win32 {53D9D96F-55C0-4044-BDB1-4A5E8EDBDF0E}.Release|Win32.ActiveCfg = Release|Win32 {53D9D96F-55C0-4044-BDB1-4A5E8EDBDF0E}.Release|Win32.Build.0 = Release|Win32 + {B1E10086-A1DA-401A-834D-969C9DBB5CC1}.Debug|Win32.ActiveCfg = Debug|Win32 + {B1E10086-A1DA-401A-834D-969C9DBB5CC1}.Debug|Win32.Build.0 = Debug|Win32 + {B1E10086-A1DA-401A-834D-969C9DBB5CC1}.Release|Win32.ActiveCfg = Release|Win32 + {B1E10086-A1DA-401A-834D-969C9DBB5CC1}.Release|Win32.Build.0 = Release|Win32 + {80F81C11-8DA2-4990-91CB-9807783BA46E}.Debug|Win32.ActiveCfg = Debug|Win32 + {80F81C11-8DA2-4990-91CB-9807783BA46E}.Debug|Win32.Build.0 = Debug|Win32 + {80F81C11-8DA2-4990-91CB-9807783BA46E}.Release|Win32.ActiveCfg = Release|Win32 + {80F81C11-8DA2-4990-91CB-9807783BA46E}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -64,5 +82,7 @@ Global {EF1A4E80-63FA-4EB0-B834-12B6C500F31C} = {08C6A854-533D-4A1E-924E-C4A62281869F} {17F0F184-4436-4D08-B8AA-16572EA238DB} = {2F87CEAB-4818-443C-A5E3-6C34E7D967EC} {53D9D96F-55C0-4044-BDB1-4A5E8EDBDF0E} = {E0491194-35E3-4513-9D31-608EA3165ECF} + {B1E10086-A1DA-401A-834D-969C9DBB5CC1} = {E0491194-35E3-4513-9D31-608EA3165ECF} + {80F81C11-8DA2-4990-91CB-9807783BA46E} = {E0491194-35E3-4513-9D31-608EA3165ECF} EndGlobalSection EndGlobal diff --git a/win32/quad.vcxproj b/win32/quad.vcxproj index 3209f07f..e622a277 100644 --- a/win32/quad.vcxproj +++ b/win32/quad.vcxproj @@ -87,7 +87,7 @@ true true true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(SdlDeps);$(GlDeps) + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(SdlDeps);$(GlDeps);$(OutDir)\lolcore.lib $(SdlLibs);$(GlLibs);%(AdditionalLibraryDirectories)