RavEngine
Loading...
Searching...
No Matches
PxWindowsIntrinsics.h
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-2021 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/PxSharedAssert.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
44namespace physx
45{
46namespace intrinsics
47{
48#endif
49
51PX_CUDA_CALLABLE PX_FORCE_INLINE float abs(float a)
52{
53 return ::fabsf(a);
54}
55
57PX_CUDA_CALLABLE PX_FORCE_INLINE float fsel(float a, float b, float c)
58{
59 return (a >= 0.0f) ? b : c;
60}
61
63PX_CUDA_CALLABLE PX_FORCE_INLINE float sign(float a)
64{
65 return (a >= 0.0f) ? 1.0f : -1.0f;
66}
67
69PX_CUDA_CALLABLE PX_FORCE_INLINE float recip(float a)
70{
71 return 1.0f / a;
72}
73
75PX_CUDA_CALLABLE PX_FORCE_INLINE float recipFast(float a)
76{
77 return 1.0f / a;
78}
79
81PX_CUDA_CALLABLE PX_FORCE_INLINE float sqrt(float a)
82{
83 return ::sqrtf(a);
84}
85
87PX_CUDA_CALLABLE PX_FORCE_INLINE float recipSqrt(float a)
88{
89 return 1.0f / ::sqrtf(a);
90}
91
93PX_CUDA_CALLABLE PX_FORCE_INLINE float recipSqrtFast(float a)
94{
95 return 1.0f / ::sqrtf(a);
96}
97
99PX_CUDA_CALLABLE PX_FORCE_INLINE float sin(float a)
100{
101 return ::sinf(a);
102}
103
105PX_CUDA_CALLABLE PX_FORCE_INLINE float cos(float a)
106{
107 return ::cosf(a);
108}
109
111PX_CUDA_CALLABLE PX_FORCE_INLINE float selectMin(float a, float b)
112{
113 return a < b ? a : b;
114}
115
117PX_CUDA_CALLABLE PX_FORCE_INLINE float selectMax(float a, float b)
118{
119 return a > b ? a : b;
120}
121
123PX_CUDA_CALLABLE PX_FORCE_INLINE bool isFinite(float a)
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
133PX_CUDA_CALLABLE PX_FORCE_INLINE bool isFinite(double a)
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
145PX_FORCE_INLINE void* memZero(void* dest, uint32_t count)
146{
147 return memset(dest, 0, count);
148}
149
153PX_FORCE_INLINE void* memSet(void* dest, int32_t c, uint32_t count)
154{
155 return memset(dest, c, count);
156}
157
161PX_FORCE_INLINE void* memCopy(void* dest, const void* src, uint32_t count)
162{
163 return memcpy(dest, src, count);
164}
165
169PX_FORCE_INLINE void* memMove(void* dest, const void* src, uint32_t count)
170{
171 return memmove(dest, src, count);
172}
173
177PX_FORCE_INLINE void memZero128(void* dest, uint32_t offset = 0)
178{
179 PX_SHARED_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
GLM_FUNC_QUALIFIER vec< L, T, Q > sqrt(vec< L, T, Q > const &x)
Definition func_exponential.inl:128
GLM_FUNC_QUALIFIER vec< L, T, Q > sin(vec< L, T, Q > const &v)
Definition func_trigonometric.inl:41
GLM_FUNC_QUALIFIER vec< L, T, Q > cos(vec< L, T, Q > const &v)
Definition func_trigonometric.inl:50
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39