From bb01733bfcfa0c4fbd94551ca55cd671992a302a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 26 Jun 2014 22:36:04 -0700 Subject: [PATCH] PNaCl vector intrisics WIP. --- .../UnitTest++/src/Posix/SignalTranslator.cpp | 11 ++++++ .../UnitTest++/src/Posix/SignalTranslator.h | 19 +++++++---- include/bx/float4_neon.h | 2 +- include/bx/float4_ni.h | 34 ++++++++++++++----- include/bx/float4_ref.h | 6 ++-- include/bx/float4_sse.h | 2 +- include/bx/float4_swizzle.inl | 2 +- include/bx/float4_t.h | 4 ++- include/bx/float4x4_t.h | 2 +- premake/premake4.lua | 2 ++ tests/float4_t.cpp | 2 +- tests/main.cpp | 21 +++++++++++- 12 files changed, 82 insertions(+), 25 deletions(-) diff --git a/3rdparty/UnitTest++/src/Posix/SignalTranslator.cpp b/3rdparty/UnitTest++/src/Posix/SignalTranslator.cpp index 3689c8c..d0415ad 100644 --- a/3rdparty/UnitTest++/src/Posix/SignalTranslator.cpp +++ b/3rdparty/UnitTest++/src/Posix/SignalTranslator.cpp @@ -2,6 +2,16 @@ namespace UnitTest { +#if defined(__native_client__) +SignalTranslator::SignalTranslator() +{ +} + +SignalTranslator::~SignalTranslator() +{ +} +#else + sigjmp_buf* SignalTranslator::s_jumpTarget = 0; namespace { @@ -42,5 +52,6 @@ SignalTranslator::~SignalTranslator() s_jumpTarget = m_oldJumpTarget; } +#endif // defined(__native_client__) } diff --git a/3rdparty/UnitTest++/src/Posix/SignalTranslator.h b/3rdparty/UnitTest++/src/Posix/SignalTranslator.h index d313d02..5de677e 100644 --- a/3rdparty/UnitTest++/src/Posix/SignalTranslator.h +++ b/3rdparty/UnitTest++/src/Posix/SignalTranslator.h @@ -12,6 +12,8 @@ public: SignalTranslator(); ~SignalTranslator(); +#if defined(__native_client__) +#else static sigjmp_buf* s_jumpTarget; private: @@ -24,18 +26,23 @@ private: struct sigaction m_old_SIGBUS_action; // struct sigaction m_old_SIGABRT_action; // struct sigaction m_old_SIGALRM_action; +#endif // defined(__native_client__) }; #if !defined(__GNUC__) && !defined(__clang__) - #define UNITTEST_EXTENSION +# define UNITTEST_EXTENSION #else - #define UNITTEST_EXTENSION __extension__ +# define UNITTEST_EXTENSION __extension__ #endif -#define UNITTEST_THROW_SIGNALS \ - UnitTest::SignalTranslator sig; \ - if (UNITTEST_EXTENSION sigsetjmp(*UnitTest::SignalTranslator::s_jumpTarget, 1) != 0) \ - throw ("Unhandled system exception"); +#if defined(__native_client__) +# define UNITTEST_THROW_SIGNALS +#else +# define UNITTEST_THROW_SIGNALS \ + UnitTest::SignalTranslator sig; \ + if (UNITTEST_EXTENSION sigsetjmp(*UnitTest::SignalTranslator::s_jumpTarget, 1) != 0) \ + throw ("Unhandled system exception"); +#endif // defined(__native_client__) } diff --git a/include/bx/float4_neon.h b/include/bx/float4_neon.h index 23fcca1..f8f67d1 100644 --- a/include/bx/float4_neon.h +++ b/include/bx/float4_neon.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2013 Branimir Karadzic. All rights reserved. + * Copyright 2010-2014 Branimir Karadzic. All rights reserved. * License: http://www.opensource.org/licenses/BSD-2-Clause */ diff --git a/include/bx/float4_ni.h b/include/bx/float4_ni.h index 10ec73d..4786e7f 100644 --- a/include/bx/float4_ni.h +++ b/include/bx/float4_ni.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2013 Branimir Karadzic. All rights reserved. + * Copyright 2010-2014 Branimir Karadzic. All rights reserved. * License: http://www.opensource.org/licenses/BSD-2-Clause */ @@ -42,6 +42,14 @@ namespace bx return result; } + BX_FLOAT4_INLINE float4_t float4_rcp_ni(float4_t _a) + { + const float4_t one = float4_splat(1.0f); + const float4_t result = float4_div(one, _a); + + return result; + } + BX_FLOAT4_INLINE float4_t float4_div_nr_ni(float4_t _a, float4_t _b) { const float4_t oneish = float4_isplat(0x3f800001); @@ -53,14 +61,6 @@ namespace bx return result; } - BX_FLOAT4_INLINE float4_t float4_rcp_ni(float4_t _a) - { - const float4_t one = float4_splat(1.0f); - const float4_t result = float4_div(one, _a); - - return result; - } - BX_FLOAT4_INLINE float4_t float4_orx_ni(float4_t _a) { const float4_t zwxy = float4_swiz_zwxy(_a); @@ -115,6 +115,22 @@ namespace bx return result; } + BX_FLOAT4_INLINE float4_t float4_min_ni(float4_t _a, float4_t _b) + { + const float4_t mask = float4_cmplt(_a, _b); + const float4_t result = float4_selb(mask, _a, _b); + + return result; + } + + BX_FLOAT4_INLINE float4_t float4_max_ni(float4_t _a, float4_t _b) + { + const float4_t mask = float4_cmpgt(_a, _b); + const float4_t result = float4_selb(mask, _a, _b); + + return result; + } + BX_FLOAT4_INLINE float4_t float4_abs_ni(float4_t _a) { const float4_t a_neg = float4_neg(_a); diff --git a/include/bx/float4_ref.h b/include/bx/float4_ref.h index fe54a0d..9b29f75 100644 --- a/include/bx/float4_ref.h +++ b/include/bx/float4_ref.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2013 Branimir Karadzic. All rights reserved. + * Copyright 2010-2014 Branimir Karadzic. All rights reserved. * License: http://www.opensource.org/licenses/BSD-2-Clause */ @@ -47,7 +47,7 @@ namespace bx uint32_t tmp = ( (_test.uxyzw[3]>>31)<<3) \ | ( (_test.uxyzw[2]>>31)<<2) \ | ( (_test.uxyzw[1]>>31)<<1) \ - | (_test.uxyzw[0]>>31) \ + | ( _test.uxyzw[0]>>31) \ ; \ return 0 != (tmp&(_mask) ); \ } \ @@ -57,7 +57,7 @@ namespace bx uint32_t tmp = ( (_test.uxyzw[3]>>31)<<3) \ | ( (_test.uxyzw[2]>>31)<<2) \ | ( (_test.uxyzw[1]>>31)<<1) \ - | (_test.uxyzw[0]>>31) \ + | ( _test.uxyzw[0]>>31) \ ; \ return (_mask) == (tmp&(_mask) ); \ } diff --git a/include/bx/float4_sse.h b/include/bx/float4_sse.h index c011e66..a9600a0 100644 --- a/include/bx/float4_sse.h +++ b/include/bx/float4_sse.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2013 Branimir Karadzic. All rights reserved. + * Copyright 2010-2014 Branimir Karadzic. All rights reserved. * License: http://www.opensource.org/licenses/BSD-2-Clause */ diff --git a/include/bx/float4_swizzle.inl b/include/bx/float4_swizzle.inl index cd9ddbd..73e0c88 100644 --- a/include/bx/float4_swizzle.inl +++ b/include/bx/float4_swizzle.inl @@ -1,5 +1,5 @@ /* - * Copyright 2010-2013 Branimir Karadzic. All rights reserved. + * Copyright 2010-2014 Branimir Karadzic. All rights reserved. * License: http://www.opensource.org/licenses/BSD-2-Clause */ diff --git a/include/bx/float4_t.h b/include/bx/float4_t.h index da3c370..545ec48 100644 --- a/include/bx/float4_t.h +++ b/include/bx/float4_t.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2013 Branimir Karadzic. All rights reserved. + * Copyright 2010-2014 Branimir Karadzic. All rights reserved. * License: http://www.opensource.org/licenses/BSD-2-Clause */ @@ -15,6 +15,8 @@ # include "float4_sse.h" #elif __ARM_NEON__ && !BX_COMPILER_CLANG # include "float4_neon.h" +#elif 0 // BX_COMPILER_CLANG +# include "float4_langext.h" #else # pragma message("************************************\nUsing SIMD reference implementation!\n************************************") # include "float4_ref.h" diff --git a/include/bx/float4x4_t.h b/include/bx/float4x4_t.h index e70f539..fa12925 100644 --- a/include/bx/float4x4_t.h +++ b/include/bx/float4x4_t.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2013 Branimir Karadzic. All rights reserved. + * Copyright 2010-2014 Branimir Karadzic. All rights reserved. * License: http://www.opensource.org/licenses/BSD-2-Clause */ diff --git a/premake/premake4.lua b/premake/premake4.lua index 7be9ad9..eeacf1c 100644 --- a/premake/premake4.lua +++ b/premake/premake4.lua @@ -90,3 +90,5 @@ project "bx.test" } configuration {} + + strip() diff --git a/tests/float4_t.cpp b/tests/float4_t.cpp index 9f113e2..b0a14a2 100644 --- a/tests/float4_t.cpp +++ b/tests/float4_t.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2013 Branimir Karadzic. All rights reserved. + * Copyright 2010-2014 Branimir Karadzic. All rights reserved. * License: http://www.opensource.org/licenses/BSD-2-Clause */ diff --git a/tests/main.cpp b/tests/main.cpp index 84ca60d..b9b951e 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -38,12 +38,31 @@ int runAllTests() } #if BX_PLATFORM_ANDROID -#include +# include void ANativeActivity_onCreate(ANativeActivity*, void*, size_t) { exit(runAllTests() ); } +#elif BX_PLATFORM_NACL +# include +# include + +PP_EXPORT const void* PPP_GetInterface(const char* /*_name*/) +{ + return NULL; +} + +PP_EXPORT int32_t PPP_InitializeModule(PP_Module /*_module*/, PPB_GetInterface /*_interface*/) +{ + DBG("PPAPI version: %d", PPAPI_RELEASE); + runAllTests(); + return PP_ERROR_NOINTERFACE; +} + +PP_EXPORT void PPP_ShutdownModule() +{ +} #else int main() {