diff options
Diffstat (limited to 'PxShared/src/foundation')
23 files changed, 63 insertions, 167 deletions
diff --git a/PxShared/src/foundation/include/PsArray.h b/PxShared/src/foundation/include/PsArray.h index 8433fbe..2121c30 100644 --- a/PxShared/src/foundation/include/PsArray.h +++ b/PxShared/src/foundation/include/PsArray.h @@ -35,17 +35,6 @@ #include "PsAllocator.h" #include "PsBasicTemplates.h" -#if PX_LIBCPP -#include <type_traits> -#else -#include <tr1/type_traits> -#endif - -#if PX_VC == 9 || PX_VC == 10 -#pragma warning(push) -#pragma warning(disable : 4347) // behavior change: 'function template' is called instead of 'function' -#endif - namespace physx { namespace shdfnd @@ -158,15 +147,6 @@ class Array : protected Alloc return operator=<Alloc>(t); } - PX_FORCE_INLINE static bool isArrayOfPOD() - { -#if PX_LIBCPP - return std::is_trivially_copyable<T>::value; -#else - return std::tr1::is_pod<T>::value; -#endif - } - /*! Array indexing operator. \param i @@ -338,14 +318,7 @@ class Array : protected Alloc PX_ASSERT(mSize); T t = mData[mSize - 1]; - if(!isArrayOfPOD()) - { - mData[--mSize].~T(); - } - else - { - --mSize; - } + mData[--mSize].~T(); return t; } @@ -379,10 +352,7 @@ class Array : protected Alloc PX_ASSERT(i < mSize); mData[i] = mData[--mSize]; - if(!isArrayOfPOD()) - { - mData[mSize].~T(); - } + mData[mSize].~T(); } PX_INLINE void replaceWithLast(Iterator i) @@ -424,24 +394,14 @@ class Array : protected Alloc { PX_ASSERT(i < mSize); - if(isArrayOfPOD()) - { - if(i + 1 != mSize) - { - physx::intrinsics::memMove(mData + i, mData + i + 1, (mSize - i - 1) * sizeof(T)); - } - } - else - { - T* it = mData + i; + T* it = mData + i; + it->~T(); + while (++i < mSize) + { + new (it) T(mData[i]); + ++it; it->~T(); - while (++i < mSize) - { - new (it) T(mData[i]); - ++it; - it->~T(); - } - } + } --mSize; } @@ -460,31 +420,19 @@ class Array : protected Alloc PX_ASSERT(begin < mSize); PX_ASSERT((begin + count) <= mSize); - if(!isArrayOfPOD()) - { - for(uint32_t i = 0; i < count; i++) - { - mData[begin + i].~T(); // call the destructor on the ones being removed first. - } - } + for(uint32_t i = 0; i < count; i++) + mData[begin + i].~T(); // call the destructor on the ones being removed first. T* dest = &mData[begin]; // location we are copying the tail end objects to T* src = &mData[begin + count]; // start of tail objects uint32_t move_count = mSize - (begin + count); // compute remainder that needs to be copied down - if(isArrayOfPOD()) - { - physx::intrinsics::memMove(dest, src, move_count * sizeof(T)); - } - else + for(uint32_t i = 0; i < move_count; i++) { - for(uint32_t i = 0; i < move_count; i++) - { - new (dest) T(*src); // copy the old one to the new location - src->~T(); // call the destructor on the old location - dest++; - src++; - } + new (dest) T(*src); // copy the old one to the new location + src->~T(); // call the destructor on the old location + dest++; + src++; } mSize -= count; } @@ -624,29 +572,10 @@ definition for serialized classes is complete in checked builds. Alloc::deallocate(mem); } - static PX_INLINE bool isZeroInit(const T& object) - { - if (!isArrayOfPOD()) - return false; - char ZeroBuffOnStack[sizeof(object)] = {}; - // bgaldrikian - casting to void* to avoid compiler error: - // error : first operand of this 'memcmp' call is a pointer to dynamic class [...]; vtable pointer will be compared [-Werror,-Wdynamic-class-memaccess] - // even though POD check prevents memcmp from being used on a dynamic class - return memcmp(reinterpret_cast<const void*>(&object), ZeroBuffOnStack, sizeof(object)) == 0; - } - static PX_INLINE void create(T* first, T* last, const T& a) { - if(isZeroInit(a)) - { - if(last > first) - physx::intrinsics::memZero(first, uint32_t((last - first) * sizeof(T))); - } - else - { - for(; first < last; ++first) - ::new (first) T(a); - } + for(; first < last; ++first) + ::new (first) T(a); } static PX_INLINE void copy(T* first, T* last, const T* src) @@ -654,24 +583,14 @@ definition for serialized classes is complete in checked builds. if(last <= first) return; - if(isArrayOfPOD()) - { - physx::intrinsics::memCopy(first, src, uint32_t((last - first) * sizeof(T))); - } - else - { - for(; first < last; ++first, ++src) - ::new (first) T(*src); - } + for(; first < last; ++first, ++src) + ::new (first) T(*src); } static PX_INLINE void destroy(T* first, T* last) { - if(!isArrayOfPOD()) - { - for(; first < last; ++first) - first->~T(); - } + for(; first < last; ++first) + first->~T(); } /*! @@ -799,8 +718,4 @@ PX_INLINE void swap(Array<T, Alloc>& x, Array<T, Alloc>& y) } // namespace shdfnd } // namespace physx -#if PX_VC == 9 || PX_VC == 10 -#pragma warning(pop) -#endif - #endif // #ifndef PSFOUNDATION_PSARRAY_H diff --git a/PxShared/src/foundation/include/PsMathUtils.h b/PxShared/src/foundation/include/PsMathUtils.h index 794419b..789cf3f 100644 --- a/PxShared/src/foundation/include/PsMathUtils.h +++ b/PxShared/src/foundation/include/PsMathUtils.h @@ -493,9 +493,6 @@ PX_FORCE_INLINE void normalToTangents(const PxVec3& normal, PxVec3& tangent0, Px tangent1 = normal.cross(tangent0); } -// todo: what is this function doing? -PX_FOUNDATION_API PxQuat computeQuatFromNormal(const PxVec3& n); - /** \brief computes a oriented bounding box around the scaled basis. \param basis Input = skewed basis, Output = (normalized) orthogonal basis. diff --git a/PxShared/src/foundation/include/PsMutex.h b/PxShared/src/foundation/include/PsMutex.h index 7c93796..23033d0 100644 --- a/PxShared/src/foundation/include/PsMutex.h +++ b/PxShared/src/foundation/include/PsMutex.h @@ -82,7 +82,7 @@ class PX_FOUNDATION_API MutexImpl /** Size of this class. */ - static const uint32_t& getSize(); + static uint32_t getSize(); }; template <typename Alloc = ReflectionAllocator<MutexImpl> > diff --git a/PxShared/src/foundation/include/PsSList.h b/PxShared/src/foundation/include/PsSList.h index f811c37..961010b 100644 --- a/PxShared/src/foundation/include/PsSList.h +++ b/PxShared/src/foundation/include/PsSList.h @@ -91,7 +91,7 @@ struct PX_FOUNDATION_API SListImpl void push(SListEntry* entry); SListEntry* pop(); SListEntry* flush(); - static const uint32_t& getSize(); + static uint32_t getSize(); }; template <typename Alloc = ReflectionAllocator<SListImpl> > diff --git a/PxShared/src/foundation/include/PsSync.h b/PxShared/src/foundation/include/PsSync.h index 8b99731..1fd72f5 100644 --- a/PxShared/src/foundation/include/PsSync.h +++ b/PxShared/src/foundation/include/PsSync.h @@ -70,9 +70,9 @@ class PX_FOUNDATION_API SyncImpl void reset(); /** - Size of this class. - */ - static const uint32_t& getSize(); + Size of this class. + */ + static uint32_t getSize(); }; /*! diff --git a/PxShared/src/foundation/include/PsThread.h b/PxShared/src/foundation/include/PsThread.h index 4e7c104..ec9f999 100644 --- a/PxShared/src/foundation/include/PsThread.h +++ b/PxShared/src/foundation/include/PsThread.h @@ -206,9 +206,9 @@ class PX_FOUNDATION_API ThreadImpl static uint32_t getNbPhysicalCores(); /** - Size of this class. - */ - static const uint32_t& getSize(); + Size of this class. + */ + static uint32_t getSize(); }; /** diff --git a/PxShared/src/foundation/include/PsUtilities.h b/PxShared/src/foundation/include/PsUtilities.h index 32fe4ec..cd0f200 100644 --- a/PxShared/src/foundation/include/PsUtilities.h +++ b/PxShared/src/foundation/include/PsUtilities.h @@ -122,7 +122,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE void order(T& x, T& y, E1& xe1, E1& ye1) } } -#if PX_GCC_FAMILY && !PX_EMSCRIPTEN +#if PX_GCC_FAMILY && !PX_EMSCRIPTEN && !PX_LINUX __attribute__((noreturn)) #endif PX_INLINE void debugBreak() @@ -132,7 +132,11 @@ __attribute__((noreturn)) #elif PX_ANDROID raise(SIGTRAP); // works better than __builtin_trap. Proper call stack and can be continued. #elif PX_LINUX - asm("int $3"); + #if (PX_X64 || PX_X64) + asm("int $3"); + #else + raise(SIGTRAP); + #endif #elif PX_GCC_FAMILY __builtin_trap(); #else diff --git a/PxShared/src/foundation/include/PsVecMathAoSScalar.h b/PxShared/src/foundation/include/PsVecMathAoSScalar.h index beb6cdc..b7fe8e4 100644 --- a/PxShared/src/foundation/include/PsVecMathAoSScalar.h +++ b/PxShared/src/foundation/include/PsVecMathAoSScalar.h @@ -34,9 +34,6 @@ #error Scalar version should not be included when using vector intrinsics. #endif -// Remove this define when all platforms use simd solver. -#define PX_SUPPORT_SIMD - struct VecI16V; struct VecU16V; struct VecI32V; diff --git a/PxShared/src/foundation/include/unix/PsUnixInlineAoS.h b/PxShared/src/foundation/include/unix/PsUnixInlineAoS.h index e54f2c8..74002d5 100644 --- a/PxShared/src/foundation/include/unix/PsUnixInlineAoS.h +++ b/PxShared/src/foundation/include/unix/PsUnixInlineAoS.h @@ -34,9 +34,6 @@ #error Vector intrinsics should not be included when using scalar implementation. #endif -// Remove this define when all platforms use simd solver. -#define PX_SUPPORT_SIMD - #if PX_INTEL_FAMILY #include "sse2/PsUnixSse2InlineAoS.h" #elif PX_NEON diff --git a/PxShared/src/foundation/include/unix/PsUnixIntrinsics.h b/PxShared/src/foundation/include/unix/PsUnixIntrinsics.h index 4c6c892..e15b3b5 100644 --- a/PxShared/src/foundation/include/unix/PsUnixIntrinsics.h +++ b/PxShared/src/foundation/include/unix/PsUnixIntrinsics.h @@ -34,7 +34,7 @@ #include "foundation/PxAssert.h" #include <math.h> -#if PX_ANDROID +#if PX_ANDROID || (PX_LINUX && !(PX_X64 || PX_X64)) // x86[_64] Linux uses inline assembly for debug break #include <signal.h> // for Ns::debugBreak() { raise(SIGTRAP); } #endif diff --git a/PxShared/src/foundation/include/unix/neon/PsUnixNeonInlineAoS.h b/PxShared/src/foundation/include/unix/neon/PsUnixNeonInlineAoS.h index a97f821..4df3ff6 100644 --- a/PxShared/src/foundation/include/unix/neon/PsUnixNeonInlineAoS.h +++ b/PxShared/src/foundation/include/unix/neon/PsUnixNeonInlineAoS.h @@ -53,9 +53,6 @@ #define VECMATH_AOS_EPSILON (1e-3f) -// Remove this define when all platforms use simd solver. -#define PX_SUPPORT_SIMD - ////////////////////////////////////////////////////////////////////// //Test that Vec3V and FloatV are legal ////////////////////////////////// diff --git a/PxShared/src/foundation/include/unix/sse2/PsUnixSse2InlineAoS.h b/PxShared/src/foundation/include/unix/sse2/PsUnixSse2InlineAoS.h index 0355538..cdb20fa 100644 --- a/PxShared/src/foundation/include/unix/sse2/PsUnixSse2InlineAoS.h +++ b/PxShared/src/foundation/include/unix/sse2/PsUnixSse2InlineAoS.h @@ -34,9 +34,6 @@ #error Vector intrinsics should not be included when using scalar implementation. #endif -// Remove this define when all platforms use simd solver. -#define PX_SUPPORT_SIMD - #ifdef __SSE4_2__ #include "smmintrin.h" #endif diff --git a/PxShared/src/foundation/include/windows/PsWindowsInlineAoS.h b/PxShared/src/foundation/include/windows/PsWindowsInlineAoS.h index 14a311f..5fd1b8d 100644 --- a/PxShared/src/foundation/include/windows/PsWindowsInlineAoS.h +++ b/PxShared/src/foundation/include/windows/PsWindowsInlineAoS.h @@ -34,9 +34,6 @@ #error Vector intrinsics should not be included when using scalar implementation. #endif -// Remove this define when all platforms use simd solver. -#define PX_SUPPORT_SIMD - #include "../PsVecMathSSE.h" ////////////////////////////////////////////////////////////////////// diff --git a/PxShared/src/foundation/src/PsString.cpp b/PxShared/src/foundation/src/PsString.cpp index adb29d6..8204051 100644 --- a/PxShared/src/foundation/src/PsString.cpp +++ b/PxShared/src/foundation/src/PsString.cpp @@ -37,7 +37,7 @@ #pragma warning(disable : 4996) // unsafe string functions #endif -#if PX_PS4 || PX_APPLE_FAMILY +#if PX_PS4 || PX_APPLE_FAMILY || (PX_LINUX && PX_X86 && PX_CLANG) #pragma clang diagnostic push // error : format string is not a string literal #pragma clang diagnostic ignored "-Wformat-nonliteral" @@ -176,7 +176,7 @@ void printFormatted(const char* format, ...) } } -#if PX_PS4 || PX_APPLE_FAMILY +#if PX_PS4 || PX_APPLE_FAMILY || (PX_LINUX && PX_X86 && PX_CLANG) #pragma clang diagnostic pop #endif diff --git a/PxShared/src/foundation/src/unix/PsUnixMutex.cpp b/PxShared/src/foundation/src/unix/PsUnixMutex.cpp index 092ec1e..23b6549 100644 --- a/PxShared/src/foundation/src/unix/PsUnixMutex.cpp +++ b/PxShared/src/foundation/src/unix/PsUnixMutex.cpp @@ -113,10 +113,9 @@ void MutexImpl::unlock() PX_UNUSED(err); } -const uint32_t gSize = sizeof(MutexUnixImpl); -const uint32_t& MutexImpl::getSize() +uint32_t MutexImpl::getSize() { - return gSize; + return sizeof(MutexUnixImpl); } class ReadWriteLockImpl diff --git a/PxShared/src/foundation/src/unix/PsUnixSList.cpp b/PxShared/src/foundation/src/unix/PsUnixSList.cpp index 5dd8ac3..c2da1bb 100644 --- a/PxShared/src/foundation/src/unix/PsUnixSList.cpp +++ b/PxShared/src/foundation/src/unix/PsUnixSList.cpp @@ -147,11 +147,9 @@ SListEntry* SListImpl::flush() return result; } -static const uint32_t gSize = sizeof(SListDetail); - -const uint32_t& SListImpl::getSize() +uint32_t SListImpl::getSize() { - return gSize; + return sizeof(SListDetail); } } // namespace shdfnd diff --git a/PxShared/src/foundation/src/unix/PsUnixSync.cpp b/PxShared/src/foundation/src/unix/PsUnixSync.cpp index aedbbe0..a488743 100644 --- a/PxShared/src/foundation/src/unix/PsUnixSync.cpp +++ b/PxShared/src/foundation/src/unix/PsUnixSync.cpp @@ -61,10 +61,9 @@ _SyncImpl* getSync(SyncImpl* impl) } } -static const uint32_t gSize = sizeof(_SyncImpl); -const uint32_t& SyncImpl::getSize() +uint32_t SyncImpl::getSize() { - return gSize; + return sizeof(_SyncImpl); } struct PxUnixScopeLock diff --git a/PxShared/src/foundation/src/unix/PsUnixThread.cpp b/PxShared/src/foundation/src/unix/PsUnixThread.cpp index cb369e0..749ae1d 100644 --- a/PxShared/src/foundation/src/unix/PsUnixThread.cpp +++ b/PxShared/src/foundation/src/unix/PsUnixThread.cpp @@ -135,10 +135,9 @@ void* PxThreadStart(void* arg) } } -static const uint32_t gSize = sizeof(_ThreadImpl); -const uint32_t& ThreadImpl::getSize() +uint32_t ThreadImpl::getSize() { - return gSize; + return sizeof(_ThreadImpl); } ThreadImpl::Id ThreadImpl::getId() @@ -314,10 +313,16 @@ uint32_t ThreadImpl::setAffinityMask(uint32_t mask) return uint32_t(prevMask); } +#if PX_PS4 +int32_t setNamePS4(pthread_t, const char*); +#endif + void ThreadImpl::setName(const char* name) { -#if(defined(ANDROID) && (__ANDROID_API__ > 8)) +#if (defined(ANDROID) && (__ANDROID_API__ > 8)) pthread_setname_np(getThread(this)->thread, name); +#elif PX_PS4 + setNamePS4(getThread(this)->thread, name); #else // not implemented because most unix APIs expect setName() // to be called from the thread's context. Example see next comment: diff --git a/PxShared/src/foundation/src/windows/PsWindowsMutex.cpp b/PxShared/src/foundation/src/windows/PsWindowsMutex.cpp index 6174b96..e62de47 100644 --- a/PxShared/src/foundation/src/windows/PsWindowsMutex.cpp +++ b/PxShared/src/foundation/src/windows/PsWindowsMutex.cpp @@ -99,11 +99,9 @@ void MutexImpl::unlock() LeaveCriticalSection(&getMutex(this)->mLock); } -static const uint32_t gSize = sizeof(MutexWinImpl); - -const uint32_t& MutexImpl::getSize() +uint32_t MutexImpl::getSize() { - return gSize; + return sizeof(MutexWinImpl); } class ReadWriteLockImpl diff --git a/PxShared/src/foundation/src/windows/PsWindowsSList.cpp b/PxShared/src/foundation/src/windows/PsWindowsSList.cpp index 146785e..5e57b8f 100644 --- a/PxShared/src/foundation/src/windows/PsWindowsSList.cpp +++ b/PxShared/src/foundation/src/windows/PsWindowsSList.cpp @@ -68,11 +68,9 @@ SListEntry* SListImpl::flush() return reinterpret_cast<SListEntry*>(InterlockedFlushSList(getDetail(this))); } -static const uint32_t gSize = sizeof(SLIST_HEADER); - -const uint32_t& SListImpl::getSize() +uint32_t SListImpl::getSize() { - return gSize; + return sizeof(SLIST_HEADER); } } // namespace shdfnd diff --git a/PxShared/src/foundation/src/windows/PsWindowsSocket.cpp b/PxShared/src/foundation/src/windows/PsWindowsSocket.cpp index bd253b9..8654a7e 100644 --- a/PxShared/src/foundation/src/windows/PsWindowsSocket.cpp +++ b/PxShared/src/foundation/src/windows/PsWindowsSocket.cpp @@ -95,8 +95,8 @@ class SocketImpl SocketImpl::SocketImpl(bool isBlocking) : mSocket(INVALID_SOCKET) , mListenSocket(INVALID_SOCKET) -, mPort(0) , mHost(NULL) +, mPort(0) , mIsConnected(false) , mIsBlocking(isBlocking) , mListenMode(false) diff --git a/PxShared/src/foundation/src/windows/PsWindowsSync.cpp b/PxShared/src/foundation/src/windows/PsWindowsSync.cpp index 5ce8122..81ae0e5 100644 --- a/PxShared/src/foundation/src/windows/PsWindowsSync.cpp +++ b/PxShared/src/foundation/src/windows/PsWindowsSync.cpp @@ -44,10 +44,9 @@ HANDLE& getSync(SyncImpl* impl) } } -static const uint32_t gSize = sizeof(HANDLE); -const uint32_t& SyncImpl::getSize() +uint32_t SyncImpl::getSize() { - return gSize; + return sizeof(HANDLE); } SyncImpl::SyncImpl() diff --git a/PxShared/src/foundation/src/windows/PsWindowsThread.cpp b/PxShared/src/foundation/src/windows/PsWindowsThread.cpp index 18ad5ee..9c5728a 100644 --- a/PxShared/src/foundation/src/windows/PsWindowsThread.cpp +++ b/PxShared/src/foundation/src/windows/PsWindowsThread.cpp @@ -104,10 +104,9 @@ DWORD WINAPI PxThreadStart(LPVOID arg) uint32_t gPhysicalCoreCount = 0; } -static const uint32_t gSize = sizeof(_ThreadImpl); -const uint32_t& ThreadImpl::getSize() +uint32_t ThreadImpl::getSize() { - return gSize; + return sizeof(_ThreadImpl); } ThreadImpl::Id ThreadImpl::getId() |