PxWindowsIntrinsics.h
Go to the documentation of this file.
1 //
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions
4 // are met:
5 // * Redistributions of source code must retain the above copyright
6 // notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright
8 // notice, this list of conditions and the following disclaimer in the
9 // documentation and/or other materials provided with the distribution.
10 // * Neither the name of NVIDIA CORPORATION nor the names of its
11 // contributors may be used to endorse or promote products derived
12 // from this software without specific prior written permission.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
27 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29 
30 #ifndef PXFOUNDATION_PXWINDOWSINTRINSICS_H
31 #define PXFOUNDATION_PXWINDOWSINTRINSICS_H
32 
33 #include "foundation/Px.h"
34 #include "foundation/PxAssert.h"
35 
36 #if !PX_WINDOWS_FAMILY
37 #error "This file should only be included by Windows builds!!"
38 #endif
39 
40 #include <math.h>
41 #include <float.h>
42 
43 #if !PX_DOXYGEN
44 namespace physx
45 {
46 namespace intrinsics
47 {
48 #endif
49 
52 {
53  return ::fabsf(a);
54 }
55 
57 PX_CUDA_CALLABLE PX_FORCE_INLINE float fsel(float a, float b, float c)
58 {
59  return (a >= 0.0f) ? b : c;
60 }
61 
64 {
65  return (a >= 0.0f) ? 1.0f : -1.0f;
66 }
67 
70 {
71  return 1.0f / a;
72 }
73 
76 {
77  return 1.0f / a;
78 }
79 
82 {
83  return ::sqrtf(a);
84 }
85 
88 {
89  return 1.0f / ::sqrtf(a);
90 }
91 
94 {
95  return 1.0f / ::sqrtf(a);
96 }
97 
100 {
101  return ::sinf(a);
102 }
103 
106 {
107  return ::cosf(a);
108 }
109 
112 {
113  return a < b ? a : b;
114 }
115 
118 {
119  return a > b ? a : b;
120 }
121 
124 {
125 #ifdef __CUDACC__
126  return !!isfinite(a);
127 #else
128  return (0 == ((_FPCLASS_SNAN | _FPCLASS_QNAN | _FPCLASS_NINF | _FPCLASS_PINF) & _fpclass(a)));
129 #endif
130 }
131 
134 {
135 #ifdef __CUDACC__
136  return !!isfinite(a);
137 #else
138  return (0 == ((_FPCLASS_SNAN | _FPCLASS_QNAN | _FPCLASS_NINF | _FPCLASS_PINF) & _fpclass(a)));
139 #endif
140 }
141 
145 PX_FORCE_INLINE void* memZero(void* dest, uint32_t count)
146 {
147  return memset(dest, 0, count);
148 }
149 
153 PX_FORCE_INLINE void* memSet(void* dest, int32_t c, uint32_t count)
154 {
155  return memset(dest, c, count);
156 }
157 
161 PX_FORCE_INLINE void* memCopy(void* dest, const void* src, uint32_t count)
162 {
163  return memcpy(dest, src, count);
164 }
165 
169 PX_FORCE_INLINE void* memMove(void* dest, const void* src, uint32_t count)
170 {
171  return memmove(dest, src, count);
172 }
173 
177 PX_FORCE_INLINE void memZero128(void* dest, uint32_t offset = 0)
178 {
179  PX_ASSERT(((size_t(dest) + offset) & 0x7f) == 0);
180  memSet(reinterpret_cast<char*>(dest) + offset, 0, 128);
181 }
182 
183 #if !PX_DOXYGEN
184 } // namespace intrinsics
185 } // namespace physx
186 #endif
187 
188 #endif // #ifndef PXFOUNDATION_PXWINDOWSINTRINSICS_H
Definition: GuContactBuffer.h:37
PX_CUDA_CALLABLE PX_FORCE_INLINE float recip(float a)
platform-specific reciprocal
Definition: PxUnixIntrinsics.h:74
PX_CUDA_CALLABLE PX_FORCE_INLINE float sqrt(float a)
platform-specific square root
Definition: PxUnixIntrinsics.h:86
PX_CUDA_CALLABLE PX_FORCE_INLINE float recipSqrt(float a)
platform-specific reciprocal square root
Definition: PxUnixIntrinsics.h:92
#define PX_FORCE_INLINE
Definition: PxPreprocessor.h:364
PX_CUDA_CALLABLE PX_FORCE_INLINE float selectMin(float a, float b)
platform-specific minimum
Definition: PxUnixIntrinsics.h:115
PX_CUDA_CALLABLE PX_FORCE_INLINE float selectMax(float a, float b)
platform-specific maximum
Definition: PxUnixIntrinsics.h:121
PX_FORCE_INLINE void * memCopy(void *dest, const void *src, uint32_t count)
Definition: PxUnixIntrinsics.h:160
PX_CUDA_CALLABLE PX_FORCE_INLINE float sign(float a)
platform-specific sign
Definition: PxUnixIntrinsics.h:68
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isFinite(float a)
platform-specific finiteness check (not INF or NAN)
Definition: PxUnixIntrinsics.h:127
PX_CUDA_CALLABLE PX_FORCE_INLINE float cos(float a)
platform-specific cosine
Definition: PxUnixIntrinsics.h:109
PX_CUDA_CALLABLE PX_FORCE_INLINE float recipSqrtFast(float a)
Definition: PxUnixIntrinsics.h:97
PX_CUDA_CALLABLE PX_FORCE_INLINE float fsel(float a, float b, float c)
platform-specific select float
Definition: PxUnixIntrinsics.h:62
PX_CUDA_CALLABLE PX_FORCE_INLINE float abs(float a)
platform-specific absolute value
Definition: PxUnixIntrinsics.h:56
PX_FORCE_INLINE void * memMove(void *dest, const void *src, uint32_t count)
Definition: PxUnixIntrinsics.h:168
PX_CUDA_CALLABLE PX_FORCE_INLINE float recipFast(float a)
platform-specific reciprocal estimate
Definition: PxUnixIntrinsics.h:80
PX_FORCE_INLINE void * memSet(void *dest, int32_t c, uint32_t count)
Definition: PxUnixIntrinsics.h:152
PX_FORCE_INLINE void memZero128(void *dest, uint32_t offset=0)
Definition: PxUnixIntrinsics.h:176
PX_FORCE_INLINE void * memZero(void *dest, uint32_t count)
Definition: PxUnixIntrinsics.h:144
PX_CUDA_CALLABLE PX_FORCE_INLINE float sin(float a)
platform-specific sine
Definition: PxUnixIntrinsics.h:103
#define PX_ASSERT(exp)
Definition: PxAssert.h:61
#define PX_CUDA_CALLABLE
Definition: PxPreprocessor.h:473