feat(physics): wire physx sdk into build
This commit is contained in:
382
engine/third_party/physx/source/gpucommon/include/AlignedMat33.h
vendored
Normal file
382
engine/third_party/physx/source/gpucommon/include/AlignedMat33.h
vendored
Normal file
@@ -0,0 +1,382 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_ALIGNED_MAT33_H
|
||||
#define PX_ALIGNED_MAT33_H
|
||||
|
||||
#include "vector_types.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "cutil_math.h"
|
||||
#include "AlignedQuat.h"
|
||||
#include "mathsExtensions.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
/*!
|
||||
\brief 3x3 matrix class
|
||||
|
||||
Some clarifications, as there have been much confusion about matrix formats etc in the past.
|
||||
|
||||
Short:
|
||||
- Matrix have base vectors in columns (vectors are column matrices, 3x1 matrices).
|
||||
- Matrix is physically stored in column major format
|
||||
- Matrices are concaternated from left
|
||||
|
||||
Long:
|
||||
Given three base vectors a, b and c the matrix is stored as
|
||||
|
||||
|a.x b.x c.x|
|
||||
|a.y b.y c.y|
|
||||
|a.z b.z c.z|
|
||||
|
||||
Vectors are treated as columns, so the vector v is
|
||||
|
||||
|x|
|
||||
|y|
|
||||
|z|
|
||||
|
||||
And matrices are applied _before_ the vector (pre-multiplication)
|
||||
v' = M*v
|
||||
|
||||
|x'| |a.x b.x c.x| |x| |a.x*x + b.x*y + c.x*z|
|
||||
|y'| = |a.y b.y c.y| * |y| = |a.y*x + b.y*y + c.y*z|
|
||||
|z'| |a.z b.z c.z| |z| |a.z*x + b.z*y + c.z*z|
|
||||
|
||||
|
||||
Physical storage and indexing:
|
||||
To be compatible with popular 3d rendering APIs (read D3d and OpenGL)
|
||||
the physical indexing is
|
||||
|
||||
|0 3 6|
|
||||
|1 4 7|
|
||||
|2 5 8|
|
||||
|
||||
index = column*3 + row
|
||||
|
||||
which in C++ translates to M[column][row]
|
||||
|
||||
The mathematical indexing is M_row,column and this is what is used for _-notation
|
||||
so _12 is 1st row, second column and operator(row, column)!
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class PxAlignedMat33
|
||||
{
|
||||
public:
|
||||
//! Default constructor
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedMat33()
|
||||
{}
|
||||
|
||||
//! identity constructor
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedMat33(PxIDENTITY r)
|
||||
: column0(make_float4(1.0f,0.0f,0.0f, 0.f)), column1(make_float4(0.0f,1.0f,0.0f, 0.f)), column2(make_float4(0.0f,0.0f,1.0f, 0.f))
|
||||
{
|
||||
PX_UNUSED(r);
|
||||
}
|
||||
|
||||
//! zero constructor
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedMat33(PxZERO r)
|
||||
: column0(make_float4(0.0f)), column1(make_float4(0.0f)), column2(make_float4(0.0f))
|
||||
{
|
||||
PX_UNUSED(r);
|
||||
}
|
||||
|
||||
|
||||
//! Construct from three base vectors
|
||||
PX_CUDA_CALLABLE PxAlignedMat33(const float4& col0, const float4& col1, const float4& col2)
|
||||
: column0(col0), column1(col1), column2(col2)
|
||||
{}
|
||||
|
||||
|
||||
//! Construct from a quaternion
|
||||
explicit PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedMat33(const PxAlignedQuat& q)
|
||||
{
|
||||
const PxReal x = q.q.x;
|
||||
const PxReal y = q.q.y;
|
||||
const PxReal z = q.q.z;
|
||||
const PxReal w = q.q.w;
|
||||
|
||||
const PxReal x2 = x + x;
|
||||
const PxReal y2 = y + y;
|
||||
const PxReal z2 = z + z;
|
||||
|
||||
const PxReal xx = x2*x;
|
||||
const PxReal yy = y2*y;
|
||||
const PxReal zz = z2*z;
|
||||
|
||||
const PxReal xy = x2*y;
|
||||
const PxReal xz = x2*z;
|
||||
const PxReal xw = x2*w;
|
||||
|
||||
const PxReal yz = y2*z;
|
||||
const PxReal yw = y2*w;
|
||||
const PxReal zw = z2*w;
|
||||
|
||||
column0 = make_float4(1.0f - yy - zz, xy + zw, xz - yw, 0.f);
|
||||
column1 = make_float4(xy - zw, 1.0f - xx - zz, yz + xw, 0.f);
|
||||
column2 = make_float4(xz + yw, yz - xw, 1.0f - xx - yy, 0.f);
|
||||
}
|
||||
|
||||
//! Copy constructor
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedMat33(const PxAlignedMat33& other)
|
||||
: column0(other.column0), column1(other.column1), column2(other.column2)
|
||||
{}
|
||||
|
||||
//! Assignment operator
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedMat33& operator=(const PxAlignedMat33& other)
|
||||
{
|
||||
column0 = other.column0;
|
||||
column1 = other.column1;
|
||||
column2 = other.column2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Construct from diagonal, off-diagonals are zero.
|
||||
PX_CUDA_CALLABLE PX_INLINE static PxAlignedMat33 createDiagonal(const PxVec3& d)
|
||||
{
|
||||
return PxAlignedMat33(make_float4(d.x,0.0f,0.0f, 0.f), make_float4(0.0f,d.y,0.0f, 0.f), make_float4(0.0f,0.0f,d.z, 0.f));
|
||||
}
|
||||
|
||||
|
||||
//! Get transposed matrix
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedMat33 getTranspose() const
|
||||
{
|
||||
const float4 v0(make_float4(column0.x, column1.x, column2.x, 0.f));
|
||||
const float4 v1(make_float4(column0.y, column1.y, column2.y, 0.f));
|
||||
const float4 v2(make_float4(column0.z, column1.z, column2.z, 0.f));
|
||||
|
||||
return PxAlignedMat33(v0,v1,v2);
|
||||
}
|
||||
|
||||
//! Get determinant
|
||||
PX_CUDA_CALLABLE PX_INLINE PxReal getDeterminant() const
|
||||
{
|
||||
return dot3(column0, cross3(column1, column2));
|
||||
}
|
||||
|
||||
//! Unary minus
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedMat33 operator-() const
|
||||
{
|
||||
return PxAlignedMat33(-column0, -column1, -column2);
|
||||
}
|
||||
|
||||
//! Add
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedMat33 operator+(const PxAlignedMat33& other) const
|
||||
{
|
||||
return PxAlignedMat33( column0+other.column0,
|
||||
column1+other.column1,
|
||||
column2+other.column2);
|
||||
}
|
||||
|
||||
//! Subtract
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedMat33 operator-(const PxAlignedMat33& other) const
|
||||
{
|
||||
return PxAlignedMat33( column0-other.column0,
|
||||
column1-other.column1,
|
||||
column2-other.column2);
|
||||
}
|
||||
|
||||
//! Scalar multiplication
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedMat33 operator*(PxReal scalar) const
|
||||
{
|
||||
return PxAlignedMat33(column0*scalar, column1*scalar, column2*scalar);
|
||||
}
|
||||
|
||||
friend PxAlignedMat33 operator*(PxReal, const PxAlignedMat33&);
|
||||
|
||||
//! Matrix vector multiplication (returns 'this->transform(vec)')
|
||||
PX_CUDA_CALLABLE PX_INLINE float4 operator*(const float4& vec) const
|
||||
{
|
||||
return transform(vec);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_INLINE PxVec3 operator*(const PxVec3& vec) const
|
||||
{
|
||||
return transform(vec);
|
||||
}
|
||||
|
||||
|
||||
// a <op>= b operators
|
||||
|
||||
//! Matrix multiplication
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedMat33 operator*(const PxAlignedMat33& other) const
|
||||
{
|
||||
//Rows from this <dot> columns from other
|
||||
//column0 = transform(other.column0) etc
|
||||
return PxAlignedMat33(transform(other.column0), transform(other.column1), transform(other.column2));
|
||||
}
|
||||
|
||||
//! Equals-add
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedMat33& operator+=(const PxAlignedMat33& other)
|
||||
{
|
||||
column0 += other.column0;
|
||||
column1 += other.column1;
|
||||
column2 += other.column2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Equals-sub
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedMat33& operator-=(const PxAlignedMat33& other)
|
||||
{
|
||||
column0 -= other.column0;
|
||||
column1 -= other.column1;
|
||||
column2 -= other.column2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Equals scalar multiplication
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedMat33& operator*=(PxReal scalar)
|
||||
{
|
||||
column0 *= scalar;
|
||||
column1 *= scalar;
|
||||
column2 *= scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Equals matrix multiplication
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedMat33& operator*=(const PxAlignedMat33 &other)
|
||||
{
|
||||
*this = *this * other;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//! Element access, mathematical way!
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal operator()(unsigned int row, unsigned int col) const
|
||||
{
|
||||
return (&((*this)[col]).x)[row];
|
||||
}
|
||||
|
||||
//! Element access, mathematical way!
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal& operator()(unsigned int row, unsigned int col)
|
||||
{
|
||||
return (&((*this)[col]).x)[row];
|
||||
}
|
||||
|
||||
// Transform etc
|
||||
|
||||
//! Transform vector by matrix, equal to v' = M*v
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE float4 transform(const float4& other) const
|
||||
{
|
||||
return column0*other.x + column1*other.y + column2*other.z;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 transform(const PxVec3& other) const
|
||||
{
|
||||
return PxVec3( column0.x*other.x + column1.x*other.y + column2.x*other.z,
|
||||
column0.y*other.x + column1.y*other.y + column2.y*other.z,
|
||||
column0.z*other.x + column1.z*other.y + column2.z*other.z);
|
||||
}
|
||||
|
||||
//! Transform vector by matrix transpose, v' = M^t*v
|
||||
PX_CUDA_CALLABLE PX_INLINE float4 transformTranspose(const float4& other) const
|
||||
{
|
||||
return make_float4( dot3(column0, other),
|
||||
dot3(column1, other),
|
||||
dot3(column2, other),
|
||||
0.f);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxReal* front() const
|
||||
{
|
||||
return &column0.x;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE float4& operator[](unsigned int num) {return (&column0)[num];}
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE const float4& operator[](unsigned int num) const {return (&column0)[num];}
|
||||
|
||||
//Data, see above for format!
|
||||
|
||||
float4 column0, column1, column2; //the three base vectors
|
||||
};
|
||||
|
||||
// implementation from PxQuat.h
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedQuat::PxAlignedQuat(const PxAlignedMat33& m)
|
||||
{
|
||||
PxReal tr = m(0,0) + m(1,1) + m(2,2), h;
|
||||
if(tr >= 0)
|
||||
{
|
||||
h = PxSqrt(tr +1);
|
||||
q.w = 0.5f * h;
|
||||
h = 0.5f / h;
|
||||
|
||||
q.x = (m(2,1) - m(1,2)) * h;
|
||||
q.y = (m(0,2) - m(2,0)) * h;
|
||||
q.z = (m(1,0) - m(0,1)) * h;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int i = 0;
|
||||
if (m(1,1) > m(0,0))
|
||||
i = 1;
|
||||
if (m(2,2) > m(i,i))
|
||||
i = 2;
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
h = PxSqrt((m(0,0) - (m(1,1) + m(2,2))) + 1);
|
||||
q.x = 0.5f * h;
|
||||
h = 0.5f / h;
|
||||
|
||||
q.y = (m(0,1) + m(1,0)) * h;
|
||||
q.z = (m(2,0) + m(0,2)) * h;
|
||||
q.w = (m(2,1) - m(1,2)) * h;
|
||||
break;
|
||||
case 1:
|
||||
h = PxSqrt((m(1,1) - (m(2,2) + m(0,0))) + 1);
|
||||
q.y = 0.5f * h;
|
||||
h = 0.5f / h;
|
||||
|
||||
q.z = (m(1,2) + m(2,1)) * h;
|
||||
q.x = (m(0,1) + m(1,0)) * h;
|
||||
q.w = (m(0,2) - m(2,0)) * h;
|
||||
break;
|
||||
case 2:
|
||||
h = PxSqrt((m(2,2) - (m(0,0) + m(1,1))) + 1);
|
||||
q.z = 0.5f * h;
|
||||
h = 0.5f / h;
|
||||
|
||||
q.x = (m(2,0) + m(0,2)) * h;
|
||||
q.y = (m(1,2) + m(2,1)) * h;
|
||||
q.w = (m(1,0) - m(0,1)) * h;
|
||||
break;
|
||||
default: // Make compiler happy
|
||||
q.x = q.y = q.z = q.w = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif // PX_FOUNDATION_PX_MAT33_H
|
||||
407
engine/third_party/physx/source/gpucommon/include/AlignedQuat.h
vendored
Normal file
407
engine/third_party/physx/source/gpucommon/include/AlignedQuat.h
vendored
Normal file
@@ -0,0 +1,407 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_ALIGNED_QUAT_H
|
||||
#define PX_ALIGNED_QUAT_H
|
||||
|
||||
|
||||
#include "vector_types.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
#include "foundation/PxQuat.h"
|
||||
#include "cutil_math.h"
|
||||
#include "foundation/PxQuat.h"
|
||||
#include "foundation/PxAssert.h"
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
namespace physx
|
||||
{
|
||||
#endif
|
||||
|
||||
class PxAlignedMat33;
|
||||
|
||||
/**
|
||||
\brief This is a quaternion class. For more information on quaternion mathematics
|
||||
consult a mathematics source on complex numbers.
|
||||
|
||||
*/
|
||||
PX_ALIGN_PREFIX(16)
|
||||
class PxAlignedQuat
|
||||
{
|
||||
public:
|
||||
/**
|
||||
\brief Default constructor, does not do any initialization.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedQuat() { }
|
||||
|
||||
|
||||
//! identity constructor
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedQuat(PxIDENTITY r)
|
||||
: q(make_float4(0.0f, 0.0f, 0.0f, 1.0f))
|
||||
{
|
||||
PX_UNUSED(r);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Constructor from a scalar: sets the real part w to the scalar value, and the imaginary parts (x,y,z) to zero
|
||||
*/
|
||||
explicit PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedQuat(PxReal r)
|
||||
: q(make_float4(0.0f, 0.0f, 0.0f, r))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Constructor. Take note of the order of the elements!
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedQuat(PxReal nx, PxReal ny, PxReal nz, PxReal nw) : q(make_float4(nx, ny, nz, nw)) {}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedQuat(const PxQuat& q0) : q(make_float4(q0.x, q0.y, q0.z, q0.w)) {}
|
||||
|
||||
/**
|
||||
\brief Creates from angle-axis representation.
|
||||
|
||||
Axis must be normalized!
|
||||
|
||||
Angle is in radians!
|
||||
|
||||
<b>Unit:</b> Radians
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedQuat(PxReal angleRadians, const PxVec3& unitAxis)
|
||||
{
|
||||
PX_ASSERT(PxAbs(1.0f-unitAxis.magnitude())<1e-3f);
|
||||
const PxReal a = angleRadians * 0.5f;
|
||||
const PxReal s = PxSin(a);
|
||||
q.w = PxCos(a);
|
||||
q.x = unitAxis.x * s;
|
||||
q.y = unitAxis.y * s;
|
||||
q.z = unitAxis.z * s;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedQuat(const float4 v) : q(v) {}
|
||||
|
||||
/**
|
||||
\brief Copy ctor.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedQuat(const PxAlignedQuat& v): q(v.q) {}
|
||||
|
||||
/**
|
||||
\brief Creates from orientation matrix.
|
||||
|
||||
\param[in] m Rotation matrix to extract quaternion from.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_INLINE explicit PxAlignedQuat(const PxAlignedMat33& m); /* defined in PxAlignedMat33.h */
|
||||
|
||||
/**
|
||||
\brief returns true if all elements are finite (not NAN or INF, etc.)
|
||||
*/
|
||||
PX_CUDA_CALLABLE bool isFinite() const
|
||||
{
|
||||
return PxIsFinite(q.x)
|
||||
&& PxIsFinite(q.y)
|
||||
&& PxIsFinite(q.z)
|
||||
&& PxIsFinite(q.w);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief returns true if finite and magnitude is close to unit
|
||||
*/
|
||||
|
||||
PX_CUDA_CALLABLE bool isUnit() const
|
||||
{
|
||||
const PxReal unitTolerance = 1e-4f;
|
||||
return isFinite() && PxAbs(magnitude()-1)<unitTolerance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief returns true if finite and magnitude is reasonably close to unit to allow for some accumulation of error vs isValid
|
||||
*/
|
||||
|
||||
PX_CUDA_CALLABLE bool isSane() const
|
||||
{
|
||||
const PxReal unitTolerance = 1e-2f;
|
||||
return isFinite() && PxAbs(magnitude()-1)<unitTolerance;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief returns true if the two quaternions are exactly equal
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_INLINE bool operator==(const PxAlignedQuat&q2) const { return q.x == q2.q.x && q.y == q2.q.y && q.z == q2.q.z && q.w == q2.q.w; }
|
||||
|
||||
|
||||
/**
|
||||
\brief This is the squared 4D vector length, should be 1 for unit quaternions.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal magnitudeSquared() const
|
||||
{
|
||||
return ::dot(q,q);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief returns the scalar product of this and other.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal dot(const PxAlignedQuat& v) const
|
||||
{
|
||||
return ::dot(q,v.q);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedQuat getNormalized() const
|
||||
{
|
||||
const PxReal s = 1.0f/magnitude();
|
||||
return PxAlignedQuat(q.x*s, q.y*s, q.z*s, q.w*s);
|
||||
}
|
||||
|
||||
|
||||
PX_CUDA_CALLABLE PX_INLINE float magnitude() const
|
||||
{
|
||||
return PxSqrt(magnitudeSquared());
|
||||
}
|
||||
|
||||
//modifiers:
|
||||
/**
|
||||
\brief maps to the closest unit quaternion.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_INLINE PxReal normalize() // convert this PxAlignedQuat to a unit quaternion
|
||||
{
|
||||
const PxReal mag = magnitude();
|
||||
if (mag != 0.0f)
|
||||
{
|
||||
const PxReal imag = 1.0f / mag;
|
||||
|
||||
q.x *= imag;
|
||||
q.y *= imag;
|
||||
q.z *= imag;
|
||||
q.w *= imag;
|
||||
}
|
||||
return mag;
|
||||
}
|
||||
|
||||
/*
|
||||
\brief returns the conjugate.
|
||||
|
||||
\note for unit quaternions, this is the inverse.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedQuat getConjugate() const
|
||||
{
|
||||
return PxAlignedQuat(-q.x,-q.y,-q.z,q.w);
|
||||
}
|
||||
|
||||
/*
|
||||
\brief returns imaginary part.
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_INLINE PxVec3 getImaginaryPart() const
|
||||
{
|
||||
return PxVec3(q.x,q.y,q.z);
|
||||
}
|
||||
|
||||
/** brief computes rotation of x-axis */
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 getBasisVector0() const
|
||||
{
|
||||
const PxF32 x2 = q.x*2.0f;
|
||||
const PxF32 w2 = q.w*2.0f;
|
||||
return PxVec3( (q.w * w2) - 1.0f + q.x*x2,
|
||||
(q.z * w2) + q.y*x2,
|
||||
(-q.y * w2) + q.z*x2);
|
||||
}
|
||||
|
||||
/** brief computes rotation of y-axis */
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 getBasisVector1() const
|
||||
{
|
||||
const PxF32 y2 = q.y*2.0f;
|
||||
const PxF32 w2 = q.w*2.0f;
|
||||
return PxVec3( (-q.z * w2) + q.x*y2,
|
||||
(q.w * w2) - 1.0f + q.y*y2,
|
||||
(q.x * w2) + q.z*y2);
|
||||
}
|
||||
|
||||
|
||||
/** brief computes rotation of z-axis */
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 getBasisVector2() const
|
||||
{
|
||||
const PxF32 z2 = q.z*2.0f;
|
||||
const PxF32 w2 = q.w*2.0f;
|
||||
return PxVec3( (q.y * w2) + q.x*z2,
|
||||
(-q.x * w2) + q.y*z2,
|
||||
(q.w * w2) - 1.0f + q.z*z2);
|
||||
}
|
||||
|
||||
/**
|
||||
rotates passed vec by this (assumed unitary)
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxVec3 rotate(const PxVec3& v) const
|
||||
{
|
||||
const PxF32 vx = 2.0f*v.x;
|
||||
const PxF32 vy = 2.0f*v.y;
|
||||
const PxF32 vz = 2.0f*v.z;
|
||||
const PxF32 w2 = q.w*q.w-0.5f;
|
||||
const PxF32 dot2 = (q.x*vx + q.y*vy +q.z*vz);
|
||||
return PxVec3
|
||||
(
|
||||
(vx*w2 + (q.y * vz - q.z * vy)*q.w + q.x*dot2),
|
||||
(vy*w2 + (q.z * vx - q.x * vz)*q.w + q.y*dot2),
|
||||
(vz*w2 + (q.x * vy - q.y * vx)*q.w + q.z*dot2)
|
||||
);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE const float4 rotate(const float4& v) const
|
||||
{
|
||||
const PxF32 vx = 2.0f*v.x;
|
||||
const PxF32 vy = 2.0f*v.y;
|
||||
const PxF32 vz = 2.0f*v.z;
|
||||
const PxF32 w2 = q.w*q.w-0.5f;
|
||||
const PxF32 dot2 = (q.x*vx + q.y*vy +q.z*vz);
|
||||
return make_float4
|
||||
(
|
||||
(vx*w2 + (q.y * vz - q.z * vy)*q.w + q.x*dot2),
|
||||
(vy*w2 + (q.z * vx - q.x * vz)*q.w + q.y*dot2),
|
||||
(vz*w2 + (q.x * vy - q.y * vx)*q.w + q.z*dot2),
|
||||
0.f
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
inverse rotates passed vec by this (assumed unitary)
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE const PxVec3 rotateInv(const PxVec3& v) const
|
||||
{
|
||||
const PxF32 vx = 2.0f*v.x;
|
||||
const PxF32 vy = 2.0f*v.y;
|
||||
const PxF32 vz = 2.0f*v.z;
|
||||
const PxF32 w2 = q.w*q.w-0.5f;
|
||||
const PxF32 dot2 = (q.x*vx + q.y*vy +q.z*vz);
|
||||
return PxVec3
|
||||
(
|
||||
(vx*w2 - (q.y * vz - q.z * vy)*q.w + q.x*dot2),
|
||||
(vy*w2 - (q.z * vx - q.x * vz)*q.w + q.y*dot2),
|
||||
(vz*w2 - (q.x * vy - q.y * vx)*q.w + q.z*dot2)
|
||||
);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE const float4 rotateInv(const float4& v) const
|
||||
{
|
||||
const PxF32 vx = 2.0f*v.x;
|
||||
const PxF32 vy = 2.0f*v.y;
|
||||
const PxF32 vz = 2.0f*v.z;
|
||||
const PxF32 w2 = q.w*q.w-0.5f;
|
||||
const PxF32 dot2 = (q.x*vx + q.y*vy +q.z*vz);
|
||||
return make_float4
|
||||
(
|
||||
(vx*w2 - (q.y * vz - q.z * vy)*q.w + q.x*dot2),
|
||||
(vy*w2 - (q.z * vx - q.x * vz)*q.w + q.y*dot2),
|
||||
(vz*w2 - (q.x * vy - q.y * vx)*q.w + q.z*dot2),
|
||||
0.f
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Assignment operator
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedQuat& operator=(const PxAlignedQuat& p) { q = p.q; return *this; }
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedQuat& operator*= (const PxAlignedQuat& q2)
|
||||
{
|
||||
const PxReal tx = q.w*q2.q.x + q2.q.w*q.x + q.y*q2.q.z - q2.q.y*q.z;
|
||||
const PxReal ty = q.w*q2.q.y + q2.q.w*q.y + q.z*q2.q.x - q2.q.z*q.x;
|
||||
const PxReal tz = q.w*q2.q.z + q2.q.w*q.z + q.x*q2.q.y - q2.q.x*q.y;
|
||||
|
||||
q.w = q.w*q2.q.w - q2.q.x*q.x - q.y*q2.q.y - q2.q.z*q.z;
|
||||
q.x = tx;
|
||||
q.y = ty;
|
||||
q.z = tz;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedQuat& operator+= (const PxAlignedQuat& q2)
|
||||
{
|
||||
q += q2.q;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedQuat& operator-= (const PxAlignedQuat& q2)
|
||||
{
|
||||
q -= q2.q;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedQuat& operator*= (const PxReal s)
|
||||
{
|
||||
q *= s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** quaternion multiplication */
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedQuat operator*(const PxAlignedQuat& q2) const
|
||||
{
|
||||
return PxAlignedQuat(q.w*q2.q.x + q2.q.w*q.x + q.y*q2.q.z - q2.q.y*q.z,
|
||||
q.w*q2.q.y + q2.q.w*q.y + q.z*q2.q.x - q2.q.z*q.x,
|
||||
q.w*q2.q.z + q2.q.w*q.z + q.x*q2.q.y - q2.q.x*q.y,
|
||||
q.w*q2.q.w - q.x*q2.q.x - q.y*q2.q.y - q.z*q2.q.z);
|
||||
}
|
||||
|
||||
/** quaternion addition */
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedQuat operator+(const PxAlignedQuat& q2) const
|
||||
{
|
||||
return PxAlignedQuat(q + q2.q);
|
||||
}
|
||||
|
||||
/** quaternion subtraction */
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedQuat operator-() const
|
||||
{
|
||||
return PxAlignedQuat(-q.x,-q.y,-q.z,-q.w);
|
||||
}
|
||||
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedQuat operator-(const PxAlignedQuat& q2) const
|
||||
{
|
||||
return PxAlignedQuat(q - q2.q);
|
||||
}
|
||||
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedQuat operator*(PxReal r) const
|
||||
{
|
||||
return PxAlignedQuat(q*r);
|
||||
}
|
||||
|
||||
// TODO avoroshilov: check if it's OK
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE operator PxQuat() const
|
||||
{
|
||||
return PxQuat(q.x, q.y, q.z, q.w);
|
||||
}
|
||||
|
||||
/** the quaternion elements */
|
||||
float4 q;
|
||||
}
|
||||
PX_ALIGN_SUFFIX(16);
|
||||
|
||||
#if !PX_DOXYGEN
|
||||
} // namespace physx
|
||||
#endif
|
||||
|
||||
#endif // PX_FOUNDATION_PX_QUAT_H
|
||||
254
engine/third_party/physx/source/gpucommon/include/AlignedTransform.h
vendored
Normal file
254
engine/third_party/physx/source/gpucommon/include/AlignedTransform.h
vendored
Normal file
@@ -0,0 +1,254 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_ALIGNED_TRANSFORM_H
|
||||
#define PX_ALIGNED_TRANSFORM_H
|
||||
|
||||
#include "AlignedQuat.h"
|
||||
#include "foundation/PxPlane.h"
|
||||
#include "foundation/PxTransform.h"
|
||||
|
||||
|
||||
namespace physx
|
||||
{
|
||||
|
||||
class PxAlignedTransform
|
||||
{
|
||||
public:
|
||||
PxAlignedQuat q;
|
||||
float4 p;
|
||||
|
||||
//#define PxAlignedTransform_DEFAULT_CONSTRUCT_NAN
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedTransform()
|
||||
#ifdef PXTRANSFORM_DEFAULT_CONSTRUCT_IDENTITY
|
||||
: q(0, 0, 0, 1), p(0, 0, 0)
|
||||
#elif defined(PXTRANSFORM_DEFAULT_CONSTRUCT_NAN)
|
||||
#define invalid PxSqrt(-1.0f)
|
||||
: q(invalid, invalid, invalid, invalid), p(invalid, invalid, invalid)
|
||||
#undef invalid
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE explicit PxAlignedTransform(const float4& position): q(PxIdentity), p(position)
|
||||
{
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE explicit PxAlignedTransform(PxIDENTITY r)
|
||||
: q(PxIdentity), p(make_float4(0.f))
|
||||
{
|
||||
PX_UNUSED(r);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE explicit PxAlignedTransform(const PxAlignedQuat& orientation): q(orientation), p(make_float4(0.f))
|
||||
{
|
||||
PX_ASSERT(orientation.isSane());
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedTransform(PxReal x, PxReal y, PxReal z)
|
||||
: q(PxIdentity), p(make_float4(x, y, z, 0.f))
|
||||
{
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedTransform(PxReal x, PxReal y, PxReal z, const PxAlignedQuat& aQ)
|
||||
: q(aQ), p(make_float4(x, y, z, 0.f))
|
||||
{
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedTransform(const float4& p0, const PxAlignedQuat& q0): q(q0), p(p0)
|
||||
{
|
||||
PX_ASSERT(q0.isSane());
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedTransform(const PxTransform& x)
|
||||
{
|
||||
PX_ASSERT(x.isSane());
|
||||
q = PxAlignedQuat( x.q );
|
||||
p = make_float4(x.p.x, x.p.y, x.p.z, 0.f);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxTransform getTransform() const
|
||||
{
|
||||
return PxTransform(PxVec3(p.x, p.y, p.z), PxQuat(q.q.x, q.q.y, q.q.z, q.q.w));
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedTransform operator*(const PxAlignedTransform& x) const
|
||||
{
|
||||
PX_ASSERT(x.isSane());
|
||||
return transform(x);
|
||||
}
|
||||
|
||||
//! Equals matrix multiplication
|
||||
PX_CUDA_CALLABLE PX_INLINE PxAlignedTransform& operator*=(PxAlignedTransform &other)
|
||||
{
|
||||
*this = *this * other;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE bool operator==(const PxAlignedTransform &other) const
|
||||
{
|
||||
return (p.x == other.p.x) && (p.y == other.p.y) && (p.z == other.p.z) && (q == other.q);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE bool operator!=(const PxAlignedTransform &other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedTransform getInverse() const
|
||||
{
|
||||
PX_ASSERT(isFinite());
|
||||
return PxAlignedTransform(q.rotateInv(make_float4(-p.x, -p.y, -p.z, -p.w)),q.getConjugate());
|
||||
}
|
||||
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 transform(const PxVec3& input) const
|
||||
{
|
||||
PX_ASSERT(isFinite());
|
||||
return q.rotate(input) + PxVec3(p.x, p.y, p.z);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 transformInv(const PxVec3& input) const
|
||||
{
|
||||
PX_ASSERT(isFinite());
|
||||
return q.rotateInv(input-PxVec3(p.x, p.y, p.z));
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE float4 transform(const float4& input) const
|
||||
{
|
||||
PX_ASSERT(isFinite());
|
||||
return q.rotate(input) + p;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE float4 transformInv(const float4& input) const
|
||||
{
|
||||
PX_ASSERT(isFinite());
|
||||
return q.rotateInv(input-p);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 rotate(const PxVec3& input) const
|
||||
{
|
||||
PX_ASSERT(isFinite());
|
||||
return q.rotate(input);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 rotateInv(const PxVec3& input) const
|
||||
{
|
||||
PX_ASSERT(isFinite());
|
||||
return q.rotateInv(input);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE float4 rotate(const float4& input) const
|
||||
{
|
||||
PX_ASSERT(isFinite());
|
||||
return q.rotate(input);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE float4 rotateInv(const float4& input) const
|
||||
{
|
||||
PX_ASSERT(isFinite());
|
||||
return q.rotateInv(input);
|
||||
}
|
||||
|
||||
//! Transform transform to parent (returns compound transform: first src, then *this)
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedTransform transform(const PxAlignedTransform& src) const
|
||||
{
|
||||
PX_ASSERT(src.isSane());
|
||||
PX_ASSERT(isSane());
|
||||
// src = [srct, srcr] -> [r*srct + t, r*srcr]
|
||||
return PxAlignedTransform(q.rotate(src.p) + p, q*src.q);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief returns true if finite and q is a unit quaternion
|
||||
*/
|
||||
|
||||
PX_CUDA_CALLABLE bool isValid() const
|
||||
{
|
||||
return PxIsFinite(p.x) && PxIsFinite(p.y) && PxIsFinite(p.z) && q.isFinite() && q.isUnit();
|
||||
}
|
||||
|
||||
/**
|
||||
\brief returns true if finite and quat magnitude is reasonably close to unit to allow for some accumulation of error vs isValid
|
||||
*/
|
||||
|
||||
PX_CUDA_CALLABLE bool isSane() const
|
||||
{
|
||||
return isFinite() && q.isSane();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief returns true if all elems are finite (not NAN or INF, etc.)
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isFinite() const { return PxIsFinite(p.x) && PxIsFinite(p.y) && PxIsFinite(p.z) && q.isFinite(); }
|
||||
|
||||
//! Transform transform from parent (returns compound transform: first src, then this->inverse)
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedTransform transformInv(const PxAlignedTransform& src) const
|
||||
{
|
||||
PX_ASSERT(src.isSane());
|
||||
PX_ASSERT(isFinite());
|
||||
// src = [srct, srcr] -> [r^-1*(srct-t), r^-1*srcr]
|
||||
PxAlignedQuat qinv = q.getConjugate();
|
||||
return PxAlignedTransform(qinv.rotate(src.p - p), qinv*src.q);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief transform plane
|
||||
*/
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxPlane transform(const PxPlane& plane) const
|
||||
{
|
||||
PxVec3 transformedNormal = rotate(plane.n);
|
||||
return PxPlane(transformedNormal, plane.d - PxVec3(p.x, p.y, p.z).dot(transformedNormal));
|
||||
}
|
||||
|
||||
/**
|
||||
\brief inverse-transform plane
|
||||
*/
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxPlane inverseTransform(const PxPlane& plane) const
|
||||
{
|
||||
PxVec3 transformedNormal = rotateInv(plane.n);
|
||||
return PxPlane(transformedNormal, plane.d + PxVec3(p.x, p.y, p.z).dot(plane.n));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief return a normalized transform (i.e. one in which the quaternion has unit magnitude)
|
||||
*/
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxAlignedTransform getNormalized() const
|
||||
{
|
||||
return PxAlignedTransform(p, q.getNormalized());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
291
engine/third_party/physx/source/gpucommon/include/PxSpatialMatrix.h
vendored
Normal file
291
engine/third_party/physx/source/gpucommon/include/PxSpatialMatrix.h
vendored
Normal file
@@ -0,0 +1,291 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PX_SPATIAL_MATRIX_H
|
||||
#define PX_SPATIAL_MATRIX_H
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxMat33.h"
|
||||
#include "CmSpatialVector.h"
|
||||
|
||||
namespace physx
|
||||
{
|
||||
struct PxSpatialMatrix33
|
||||
{
|
||||
PxReal column[3][3];
|
||||
};
|
||||
|
||||
struct PxSpatialMatrix63
|
||||
{
|
||||
PxReal column[6][3];
|
||||
};
|
||||
struct PxSpatialMatrix36
|
||||
{
|
||||
PxReal column[3][6];
|
||||
};
|
||||
|
||||
//144 bytes
|
||||
struct PxSpatialMatrix
|
||||
{
|
||||
public:
|
||||
PxReal column[6][6];
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE Cm::UnAlignedSpatialVector operator * (const Cm::UnAlignedSpatialVector& s) const
|
||||
{
|
||||
PxReal st[6];
|
||||
st[0] = s.top.x; st[1] = s.top.y; st[2] = s.top.z;
|
||||
st[3] = s.bottom.x; st[4] = s.bottom.y; st[5] = s.bottom.z;
|
||||
|
||||
PxReal result[6];
|
||||
for (PxU32 i = 0; i < 6; ++i)
|
||||
{
|
||||
result[i] = 0.f;
|
||||
for (PxU32 j = 0; j < 6; ++j)
|
||||
{
|
||||
result[i] += column[j][i] * st[j];
|
||||
}
|
||||
}
|
||||
|
||||
Cm::UnAlignedSpatialVector temp;
|
||||
temp.top.x = result[0]; temp.top.y = result[1]; temp.top.z = result[2];
|
||||
temp.bottom.x = result[3]; temp.bottom.y = result[4]; temp.bottom.z = result[5];
|
||||
return temp;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxMat33 invertSym33(const PxMat33& in)
|
||||
{
|
||||
PxVec3 v0 = in[1].cross(in[2]),
|
||||
v1 = in[2].cross(in[0]),
|
||||
v2 = in[0].cross(in[1]);
|
||||
|
||||
PxReal det = v0.dot(in[0]);
|
||||
|
||||
if (det != 0)
|
||||
{
|
||||
PxReal recipDet = 1.0f / det;
|
||||
|
||||
return PxMat33(v0 * recipDet,
|
||||
PxVec3(v0.y, v1.y, v1.z) * recipDet,
|
||||
PxVec3(v0.z, v1.z, v2.z) * recipDet);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PxMat33(PxIdentity);
|
||||
}
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE void initialize(const PxMat33& inertia, const PxReal mass)
|
||||
{
|
||||
column[0][0] = 0.f; column[0][1] = 0.f; column[0][2] = 0.f;
|
||||
column[1][0] = 0.f; column[1][1] = 0.f; column[1][2] = 0.f;
|
||||
column[2][0] = 0.f; column[2][1] = 0.f; column[2][2] = 0.f;
|
||||
|
||||
column[0][3] = mass; column[0][4] = 0.f; column[0][5] = 0.f;
|
||||
column[1][3] = 0.f; column[1][4] = mass; column[1][5] = 0.f;
|
||||
column[2][3] = 0.f; column[2][4] = 0.f; column[2][5] = mass;
|
||||
|
||||
column[3][0] = inertia.column0.x; column[3][1] = inertia.column0.y; column[3][2] = inertia.column0.z;
|
||||
column[4][0] = inertia.column1.x; column[4][1] = inertia.column1.y; column[4][2] = inertia.column1.z;
|
||||
column[5][0] = inertia.column2.x; column[5][1] = inertia.column2.y; column[5][2] = inertia.column2.z;
|
||||
|
||||
column[3][3] = 0.f; column[3][4] = 0.f; column[3][5] = 0.f;
|
||||
column[4][3] = 0.f; column[4][4] = 0.f; column[4][5] = 0.f;
|
||||
column[5][3] = 0.f; column[5][4] = 0.f; column[5][5] = 0.f;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PxMat33 topLeft() const
|
||||
{
|
||||
return PxMat33( PxVec3(column[0][0], column[0][1], column[0][2]),
|
||||
PxVec3(column[1][0], column[1][1], column[1][2]),
|
||||
PxVec3(column[2][0], column[2][1], column[2][2]));
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE void setTopLeft(const PxMat33& m)
|
||||
{
|
||||
column[0][0] = m.column0.x; column[0][1] = m.column0.y; column[0][2] = m.column0.z;
|
||||
column[1][0] = m.column1.x; column[1][1] = m.column1.y; column[1][2] = m.column1.z;
|
||||
column[2][0] = m.column2.x; column[2][1] = m.column2.y; column[2][2] = m.column2.z;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PxMat33 bottomLeft() const
|
||||
{
|
||||
return PxMat33( PxVec3(column[0][3], column[0][4], column[0][5]),
|
||||
PxVec3(column[1][3], column[1][4], column[1][5]),
|
||||
PxVec3(column[2][3], column[2][4], column[2][5]));
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE void setBottomLeft(const PxMat33& m)
|
||||
{
|
||||
column[0][3] = m.column0.x; column[0][4] = m.column0.y; column[0][5] = m.column0.z;
|
||||
column[1][3] = m.column1.x; column[1][4] = m.column1.y; column[1][5] = m.column1.z;
|
||||
column[2][3] = m.column2.x; column[2][4] = m.column2.y; column[2][5] = m.column2.z;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PxMat33 topRight() const
|
||||
{
|
||||
return PxMat33( PxVec3(column[3][0], column[3][1], column[3][2]),
|
||||
PxVec3(column[4][0], column[4][1], column[4][2]),
|
||||
PxVec3(column[5][0], column[5][1], column[5][2]));
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE void setTopRight(const PxMat33& m)
|
||||
{
|
||||
column[3][0] = m.column0.x; column[3][1] = m.column0.y; column[3][2] = m.column0.z;
|
||||
column[4][0] = m.column1.x; column[4][1] = m.column1.y; column[4][2] = m.column1.z;
|
||||
column[5][0] = m.column2.x; column[5][1] = m.column2.y; column[5][2] = m.column2.z;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PxMat33 bottomRight() const
|
||||
{
|
||||
return PxMat33( PxVec3(column[3][3], column[3][4], column[3][5]),
|
||||
PxVec3(column[4][3], column[4][4], column[4][5]),
|
||||
PxVec3(column[5][3], column[5][4], column[5][5]));
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE void setBottomRight(const PxMat33& m)
|
||||
{
|
||||
column[3][3] = m.column0.x; column[3][4] = m.column0.y; column[3][5] = m.column0.z;
|
||||
column[4][3] = m.column1.x; column[4][4] = m.column1.y; column[4][5] = m.column1.z;
|
||||
column[5][3] = m.column2.x; column[5][4] = m.column2.y; column[5][5] = m.column2.z;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxSpatialMatrix invertInertia()
|
||||
{
|
||||
//bottom left
|
||||
PxMat33 aa( PxVec3(column[0][3], column[0][4], column[0][5]),
|
||||
PxVec3(column[1][3], column[1][4], column[1][5]),
|
||||
PxVec3(column[2][3], column[2][4], column[2][5]));
|
||||
|
||||
|
||||
// top right
|
||||
PxMat33 ll(PxVec3(column[3][0], column[3][1], column[3][2]),
|
||||
PxVec3(column[4][0], column[4][1], column[4][2]),
|
||||
PxVec3(column[5][0], column[5][1], column[5][2]));
|
||||
|
||||
//top left
|
||||
PxMat33 la(PxVec3(column[0][0], column[0][1], column[0][2]),
|
||||
PxVec3(column[1][0], column[1][1], column[1][2]),
|
||||
PxVec3(column[2][0], column[2][1], column[2][2]));
|
||||
|
||||
aa = (aa + aa.getTranspose())*0.5f;
|
||||
ll = (ll + ll.getTranspose())*0.5f;
|
||||
|
||||
PxMat33 AAInv = invertSym33(aa);
|
||||
|
||||
PxMat33 z = -la * AAInv;
|
||||
PxMat33 S = ll + z * la.getTranspose(); // Schur complement of mAA
|
||||
|
||||
PxMat33 LL = invertSym33(S);
|
||||
|
||||
PxMat33 LA = LL * z;
|
||||
PxMat33 AA = AAInv + z.getTranspose() * LA;
|
||||
|
||||
PxSpatialMatrix result;
|
||||
PxMat33 topleft = LA.getTranspose();
|
||||
//top left
|
||||
result.column[0][0] = topleft.column0[0];
|
||||
result.column[0][1] = topleft.column0[1];
|
||||
result.column[0][2] = topleft.column0[2];
|
||||
|
||||
result.column[1][0] = topleft.column1[0];
|
||||
result.column[1][1] = topleft.column1[1];
|
||||
result.column[1][2] = topleft.column1[2];
|
||||
|
||||
result.column[2][0] = topleft.column2[0];
|
||||
result.column[2][1] = topleft.column2[1];
|
||||
result.column[2][2] = topleft.column2[2];
|
||||
|
||||
//top right
|
||||
result.column[3][0] = AA.column0[0];
|
||||
result.column[3][1] = AA.column0[1];
|
||||
result.column[3][2] = AA.column0[2];
|
||||
|
||||
result.column[4][0] = AA.column1[0];
|
||||
result.column[4][1] = AA.column1[1];
|
||||
result.column[4][2] = AA.column1[2];
|
||||
|
||||
result.column[5][0] = AA.column2[0];
|
||||
result.column[5][1] = AA.column2[1];
|
||||
result.column[5][2] = AA.column2[2];
|
||||
|
||||
//bottom left
|
||||
result.column[0][3] = LL.column0[0];
|
||||
result.column[0][4] = LL.column0[1];
|
||||
result.column[0][5] = LL.column0[2];
|
||||
|
||||
result.column[1][3] = LL.column1[0];
|
||||
result.column[1][4] = LL.column1[1];
|
||||
result.column[1][5] = LL.column1[2];
|
||||
|
||||
result.column[2][3] = LL.column2[0];
|
||||
result.column[2][4] = LL.column2[1];
|
||||
result.column[2][5] = LL.column2[2];
|
||||
|
||||
//bottom right
|
||||
result.column[3][3] = LA.column0[0];
|
||||
result.column[3][4] = LA.column0[1];
|
||||
result.column[3][5] = LA.column0[2];
|
||||
|
||||
result.column[4][3] = LA.column1[0];
|
||||
result.column[4][4] = LA.column1[1];
|
||||
result.column[4][5] = LA.column1[2];
|
||||
|
||||
result.column[5][3] = LA.column2[0];
|
||||
result.column[5][4] = LA.column2[1];
|
||||
result.column[5][5] = LA.column2[2];
|
||||
return result;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal& operator()(PxU32 row, PxU32 col)
|
||||
{
|
||||
return column[col][row];
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal operator()(PxU32 row, PxU32 col) const
|
||||
{
|
||||
return column[col][row];
|
||||
}
|
||||
|
||||
//A bit of a misuse. In featherstone articulations, we use this matrix to store
|
||||
//the invMass/sqrtInvInertia of a rigid body in a way that is compatible with the
|
||||
//response matrix produced by our articulation code. In order for this to work,
|
||||
//we must also scale the angular term by the inertia tensor for rigid bodies.
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 multiplyInertia(const PxVec3& v) const
|
||||
{
|
||||
return PxVec3( column[3][0] * v.x + column[3][1] * v.y + column[3][2] * v.z,
|
||||
column[4][0] * v.x + column[4][1] * v.y + column[4][2] * v.z,
|
||||
column[5][0] * v.x + column[5][1] * v.y + column[5][2] * v.z
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
38
engine/third_party/physx/source/gpucommon/include/PxgCommon.h
vendored
Normal file
38
engine/third_party/physx/source/gpucommon/include/PxgCommon.h
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_COMMON_H
|
||||
#define PXG_COMMON_H
|
||||
|
||||
namespace physx
|
||||
{
|
||||
//this is needed to force PhysXCommonGpu linkage as Static Library!
|
||||
void createPxgCommon();
|
||||
}
|
||||
|
||||
#endif
|
||||
42
engine/third_party/physx/source/gpucommon/include/PxgCommonDefines.h
vendored
Normal file
42
engine/third_party/physx/source/gpucommon/include/PxgCommonDefines.h
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_COMMON_DEFINES_H
|
||||
#define PXG_COMMON_DEFINES_H
|
||||
|
||||
// !! No includes here, only preprocessor definitions!
|
||||
|
||||
// A place for shared defines for the GPU libs
|
||||
|
||||
#define PXG_MAX_NUM_POINTS_PER_CONTACT_PATCH 6 // corresponding CPU define is CONTACT_REDUCTION_MAX_CONTACTS
|
||||
#define LOG2_WARP_SIZE 5
|
||||
#define WARP_SIZE (1U << LOG2_WARP_SIZE)
|
||||
#define FULL_MASK 0xffffffff //full mask for 32 thread in a warp
|
||||
|
||||
|
||||
#endif
|
||||
35
engine/third_party/physx/source/gpucommon/include/PxgContactsDebug.h
vendored
Normal file
35
engine/third_party/physx/source/gpucommon/include/PxgContactsDebug.h
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_CONTACTS_DEBUG_H
|
||||
#define PXG_CONTACTS_DEBUG_H
|
||||
|
||||
//if we turn on this flag, we sync the contact data in fetchNarrowPhaseResults. So, we can exam the data in validateContactPairs function in the CPU
|
||||
#define PXG_CONTACT_VALIDATION 0
|
||||
|
||||
#endif
|
||||
92
engine/third_party/physx/source/gpucommon/include/PxgCopyManager.h
vendored
Normal file
92
engine/third_party/physx/source/gpucommon/include/PxgCopyManager.h
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_COPY_MANAGER_H
|
||||
#define PXG_COPY_MANAGER_H
|
||||
|
||||
#include "foundation/PxPinnedArray.h"
|
||||
#include "cudamanager/PxCudaTypes.h"
|
||||
|
||||
#define COPY_KERNEL_WARPS_PER_BLOCK 4
|
||||
|
||||
namespace physx
|
||||
{
|
||||
class PxCudaContextManager;
|
||||
class PxCudaContext;
|
||||
class KernelWrangler;
|
||||
class PxgHeapMemoryAllocatorManager;
|
||||
|
||||
class PxgCopyManager
|
||||
{
|
||||
PX_NOCOPY(PxgCopyManager)
|
||||
public:
|
||||
|
||||
PX_ALIGN_PREFIX(16)
|
||||
struct CopyDesc
|
||||
{
|
||||
size_t dest;
|
||||
size_t source;
|
||||
size_t bytes;
|
||||
size_t pad;
|
||||
|
||||
PX_CUDA_CALLABLE void operator= (const CopyDesc& ref) volatile
|
||||
{
|
||||
dest = ref.dest;
|
||||
source = ref.source;
|
||||
bytes = ref.bytes;
|
||||
}
|
||||
} PX_ALIGN_SUFFIX(16);
|
||||
|
||||
public:
|
||||
|
||||
PxgCopyManager(PxgHeapMemoryAllocatorManager* heapMemoryManager);
|
||||
|
||||
~PxgCopyManager(){}
|
||||
|
||||
void waitAndReset(PxCudaContext* cudaContext);
|
||||
void pushDeferredHtoD(const CopyDesc& desc);
|
||||
void dispatchCopy(CUstream stream, PxCudaContextManager* cudaContextManager, KernelWrangler* kernelWrangler);
|
||||
void createFinishedEvent(PxCudaContext* cudaContext);
|
||||
void destroyFinishedEvent(PxCudaContext* cudaContext);
|
||||
|
||||
protected:
|
||||
|
||||
void resetUnsafe() { mNumDescriptors = 0; }
|
||||
bool hasFinishedCopying(PxCudaContext* cudaContext) const;
|
||||
|
||||
PxInt8ArrayPinned mDescriptorsQueue;
|
||||
PxU32 mNumDescriptors;
|
||||
CUevent mFinishedEvent;
|
||||
bool mEventRecorded;
|
||||
PxgHeapMemoryAllocatorManager* mHeapMemoryManager;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
157
engine/third_party/physx/source/gpucommon/include/PxgCudaBuffer.h
vendored
Normal file
157
engine/third_party/physx/source/gpucommon/include/PxgCudaBuffer.h
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_CUDA_BUFFER_H
|
||||
#define PXG_CUDA_BUFFER_H
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
#if PX_LINUX && PX_CLANG
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdocumentation"
|
||||
#pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
|
||||
#endif
|
||||
#include "cuda.h"
|
||||
#if PX_LINUX && PX_CLANG
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#include "PxgHeapMemAllocator.h"
|
||||
#include "PxgDevicePointer.h"
|
||||
|
||||
namespace physx
|
||||
{
|
||||
class PxCudaContext;
|
||||
|
||||
class PxgCudaBuffer
|
||||
{
|
||||
PX_NOCOPY(PxgCudaBuffer)
|
||||
public:
|
||||
PxgCudaBuffer(PxgHeapMemoryAllocatorManager* heapMemoryManager, PxsHeapStats::Enum statGroup)
|
||||
: mPtr(0)
|
||||
, mHeapMemoryAllocator(heapMemoryManager->mDeviceMemoryAllocators)
|
||||
, mSize(0)
|
||||
, mStatGroup(statGroup)
|
||||
{
|
||||
}
|
||||
|
||||
~PxgCudaBuffer();
|
||||
|
||||
void allocate(const PxU64 size, const char* filename, PxI32 line);
|
||||
void allocateCopyOldDataAsync(const PxU64 size, PxCudaContext* cudaContext, CUstream stream, const char* filename, PxI32 line);
|
||||
|
||||
void deallocate();
|
||||
|
||||
/* defer deallocation until the beginning of the next simulation step */
|
||||
void deallocateDeferred();
|
||||
|
||||
PX_FORCE_INLINE CUdeviceptr getDevicePtr() const { return (mPtr + 127) & (~127); }
|
||||
PX_FORCE_INLINE PxU64 getSize() const { return mSize; }
|
||||
PX_FORCE_INLINE void set(CUdeviceptr ptr, PxU64 size) { mPtr = ptr; mSize = size; }
|
||||
|
||||
static void swapBuffer(PxgCudaBuffer& buf0, PxgCudaBuffer& buf1)
|
||||
{
|
||||
const CUdeviceptr tempPtr = buf0.getDevicePtr();
|
||||
const PxU64 tempSize = buf0.getSize();
|
||||
|
||||
buf0.set(buf1.getDevicePtr(), buf1.getSize());
|
||||
buf1.set(tempPtr, tempSize);
|
||||
}
|
||||
|
||||
void assign(PxgCudaBuffer& b1)
|
||||
{
|
||||
PX_ASSERT(mHeapMemoryAllocator == b1.mHeapMemoryAllocator);
|
||||
PX_ASSERT(mStatGroup == b1.mStatGroup);
|
||||
|
||||
deallocate();
|
||||
|
||||
mPtr = b1.mPtr;
|
||||
mSize = b1.mSize;
|
||||
|
||||
b1.mPtr = 0;
|
||||
b1.mSize = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
CUdeviceptr mPtr;
|
||||
PxgHeapMemoryAllocator* mHeapMemoryAllocator;
|
||||
PxU64 mSize;
|
||||
const PxsHeapStats::Enum mStatGroup;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class PxgTypedCudaBuffer : public PxgCudaBuffer
|
||||
{
|
||||
public:
|
||||
PxgTypedCudaBuffer(PxgHeapMemoryAllocatorManager* heapMemoryManager, PxsHeapStats::Enum statGroup)
|
||||
: PxgCudaBuffer(heapMemoryManager, statGroup)
|
||||
{ }
|
||||
|
||||
PX_FORCE_INLINE void allocateElements(const PxU64 nbElements, const char* filename, PxI32 line) { allocate(nbElements * sizeof(T), filename, line); }
|
||||
|
||||
PX_FORCE_INLINE PxU64 getNbElements() const { return mSize / sizeof(T); }
|
||||
|
||||
PX_FORCE_INLINE PxgDevicePointer<T> getTypedDevicePtr() const { return PxgDevicePointer<T>(getDevicePtr()); }
|
||||
|
||||
PX_FORCE_INLINE T* getTypedPtr() const { return reinterpret_cast<T*>(getDevicePtr()); }
|
||||
};
|
||||
|
||||
template <unsigned int NbBuffers>
|
||||
class PxgCudaBufferN
|
||||
{
|
||||
PxU8 mCudaArrays[sizeof(PxgCudaBuffer)*NbBuffers];
|
||||
public:
|
||||
PxgCudaBufferN(PxgHeapMemoryAllocatorManager* heapMemoryManager, PxsHeapStats::Enum statGroup)
|
||||
{
|
||||
PxgCudaBuffer* buffers = reinterpret_cast<PxgCudaBuffer*>(mCudaArrays);
|
||||
for (PxU32 i = 0; i < NbBuffers; ++i)
|
||||
{
|
||||
PX_PLACEMENT_NEW(&buffers[i], PxgCudaBuffer)(heapMemoryManager, statGroup);
|
||||
}
|
||||
}
|
||||
|
||||
~PxgCudaBufferN()
|
||||
{
|
||||
PxgCudaBuffer* buffers = reinterpret_cast<PxgCudaBuffer*>(mCudaArrays);
|
||||
for (PxU32 i = 0; i < NbBuffers; ++i)
|
||||
{
|
||||
buffers[i].~PxgCudaBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
PxgCudaBuffer& operator [](PxU32 index) { PX_ASSERT(index < NbBuffers); return reinterpret_cast<PxgCudaBuffer*>(mCudaArrays)[index]; }
|
||||
|
||||
const PxgCudaBuffer& operator [](PxU32 index) const { PX_ASSERT(index < NbBuffers); return reinterpret_cast<const PxgCudaBuffer*>(mCudaArrays)[index]; }
|
||||
|
||||
PxgCudaBuffer* begin(){ return reinterpret_cast<PxgCudaBuffer*>(mCudaArrays); }
|
||||
|
||||
PxU32 size() { return NbBuffers; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
254
engine/third_party/physx/source/gpucommon/include/PxgCudaHelpers.h
vendored
Normal file
254
engine/third_party/physx/source/gpucommon/include/PxgCudaHelpers.h
vendored
Normal file
@@ -0,0 +1,254 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_CUDA_HELPERS_H
|
||||
#define PXG_CUDA_HELPERS_H
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
|
||||
#if PX_LINUX && PX_CLANG
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdocumentation"
|
||||
#endif
|
||||
#include <cuda.h>
|
||||
#if PX_LINUX && PX_CLANG
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#include "cudamanager/PxCudaContextManager.h"
|
||||
#include "cudamanager/PxCudaContext.h"
|
||||
#include "foundation/PxFoundation.h"
|
||||
|
||||
namespace physx
|
||||
{
|
||||
|
||||
/**
|
||||
* Templated static functions to simplify common CUDA operations.
|
||||
*
|
||||
* General guidelines:
|
||||
*
|
||||
* - If you want automatic context acquisition, use the functions that take the context manager as a parameter.
|
||||
* - Otherwise, directly use the ones that take a cudaContext, but don't forget to acquire the context.
|
||||
* - For allocations/deallocations, see PxgCudaMemoryAllocator. Use the functions provided there.
|
||||
* - For anything outside the core SDK, use the helpers provided in the extensions.
|
||||
*
|
||||
*/
|
||||
|
||||
class PxgCudaHelpers
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* \brief Copies a device buffer to the host
|
||||
*
|
||||
* The cuda context needs to be acquired by the user!
|
||||
*/
|
||||
template<typename T>
|
||||
static void copyDToH(PxCudaContext& cudaContext, T* hostBuffer, const T* deviceBuffer, PxU64 numElements)
|
||||
{
|
||||
if (!deviceBuffer || !hostBuffer)
|
||||
return;
|
||||
|
||||
PxU64 numBytes = numElements * sizeof(T);
|
||||
PxCUresult result = cudaContext.memcpyDtoH(hostBuffer, CUdeviceptr(deviceBuffer), numBytes);
|
||||
if (result != CUDA_SUCCESS)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "copyDtoH set failed with error code %i!\n", PxI32(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Copies a device buffer to the host
|
||||
*
|
||||
* The cuda context will get acquired automatically
|
||||
*/
|
||||
template<typename T>
|
||||
static void copyDToH(PxCudaContextManager& cudaContextManager, T* hostBuffer, const T* deviceBuffer, PxU64 numElements)
|
||||
{
|
||||
PxScopedCudaLock _lock(cudaContextManager);
|
||||
copyDToH(*cudaContextManager.getCudaContext(), hostBuffer, deviceBuffer, numElements);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Copies a host buffer to the device
|
||||
*
|
||||
* The cuda context needs to be acquired by the user!
|
||||
*/
|
||||
template<typename T>
|
||||
static void copyHToD(PxCudaContext& cudaContext, T* deviceBuffer, const T* hostBuffer, PxU64 numElements)
|
||||
{
|
||||
if (!deviceBuffer || !hostBuffer)
|
||||
return;
|
||||
|
||||
PxU64 numBytes = numElements * sizeof(T);
|
||||
|
||||
PxCUresult result = cudaContext.memcpyHtoD(CUdeviceptr(deviceBuffer), hostBuffer, numBytes);
|
||||
if (result != CUDA_SUCCESS)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "copyHtoD set failed with error code %i!\n", PxI32(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Copies a host buffer to the device
|
||||
*
|
||||
* The cuda context will get acquired automatically
|
||||
*/
|
||||
template<typename T>
|
||||
static void copyHToD(PxCudaContextManager& cudaContextManager, T* deviceBuffer, const T* hostBuffer, PxU64 numElements)
|
||||
{
|
||||
PxScopedCudaLock _lock(cudaContextManager);
|
||||
copyHToD(*cudaContextManager.getCudaContext(), deviceBuffer, hostBuffer, numElements);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Schedules device to host copy operation on the specified stream
|
||||
*
|
||||
* The cuda context needs to be acquired by the user!
|
||||
*/
|
||||
template<typename T>
|
||||
static void copyDToHAsync(PxCudaContext& cudaContext, T* hostBuffer, const T* deviceBuffer, PxU64 numElements, CUstream stream)
|
||||
{
|
||||
if (!deviceBuffer || !hostBuffer)
|
||||
return;
|
||||
|
||||
PxU64 numBytes = numElements * sizeof(T);
|
||||
PxCUresult result = cudaContext.memcpyDtoHAsync(hostBuffer, CUdeviceptr(deviceBuffer), numBytes, stream);
|
||||
if (result != CUDA_SUCCESS)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "copyDtoHAsync set failed with error code %i!\n", PxI32(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Schedules device to host copy operation on the specified stream
|
||||
*
|
||||
* The cuda context will get acquired automatically
|
||||
*/
|
||||
template<typename T>
|
||||
static void copyDToHAsync(PxCudaContextManager& cudaContextManager, T* hostBuffer, const T* deviceBuffer, PxU64 numElements, CUstream stream)
|
||||
{
|
||||
PxScopedCudaLock _lock(cudaContextManager);
|
||||
copyDToHAsync(*cudaContextManager.getCudaContext(), hostBuffer, deviceBuffer, numElements, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Schedules host to device copy operation on the specified stream
|
||||
*
|
||||
* The cuda context needs to be acquired by the user!
|
||||
*/
|
||||
template<typename T>
|
||||
static void copyHToDAsync(PxCudaContext& cudaContext, T* deviceBuffer, const T* hostBuffer, PxU64 numElements, CUstream stream)
|
||||
{
|
||||
if (!deviceBuffer || !hostBuffer)
|
||||
return;
|
||||
|
||||
PxU64 numBytes = numElements * sizeof(T);
|
||||
|
||||
PxCUresult result = cudaContext.memcpyHtoDAsync(CUdeviceptr(deviceBuffer), hostBuffer, numBytes, stream);
|
||||
if (result != CUDA_SUCCESS)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "copyHtoDAsync set failed with error code %i!\n", PxI32(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Schedules host to device copy operation on the specified stream
|
||||
*
|
||||
* The cuda context will get acquired automatically
|
||||
*/
|
||||
template<typename T>
|
||||
static void copyHToDAsync(PxCudaContextManager& cudaContextManager, T* deviceBuffer, const T* hostBuffer, PxU64 numElements, CUstream stream)
|
||||
{
|
||||
PxScopedCudaLock _lock(cudaContextManager);
|
||||
copyHToDAsync(*cudaContextManager.getCudaContext(), deviceBuffer, hostBuffer, numElements, stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Schedules device to device copy operation on the specified stream
|
||||
*
|
||||
* The cuda context needs to be acquired by the user!
|
||||
*/
|
||||
template<typename T>
|
||||
static void copyDToDAsync(PxCudaContext& cudaContext, T* dstDeviceBuffer, const T* srcDeviceBuffer, PxU64 numElements, CUstream stream)
|
||||
{
|
||||
if (!srcDeviceBuffer || !dstDeviceBuffer)
|
||||
return;
|
||||
|
||||
PxU64 numBytes = numElements * sizeof(T);
|
||||
|
||||
PxCUresult result = cudaContext.memcpyDtoDAsync(CUdeviceptr(dstDeviceBuffer), CUdeviceptr(srcDeviceBuffer), numBytes, stream);
|
||||
if (result != CUDA_SUCCESS)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "copyDtoDAsync set failed with error code %i!\n", PxI32(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Schedules device to device copy operation on the specified stream
|
||||
*
|
||||
* The cuda context will get acquired automatically
|
||||
*/
|
||||
template<typename T>
|
||||
static void copyDToDAsync(PxCudaContextManager& cudaContextManager, T* dstDeviceBuffer, const T* srcDeviceBuffer, PxU64 numElements, CUstream stream)
|
||||
{
|
||||
PxScopedCudaLock _lock(cudaContextManager);
|
||||
copyDToDAsync(*cudaContextManager.getCudaContext(), dstDeviceBuffer, srcDeviceBuffer, numElements * sizeof(T), stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Schedules a memset operation on the device on the specified stream. Only supported for 1 and 4 byte types.
|
||||
*
|
||||
* The cuda context needs to be acquired by the user!
|
||||
*/
|
||||
template<typename T>
|
||||
static void memsetAsync(PxCudaContext& cudaContext, T* dstDeviceBuffer, const T& value, PxU64 numElements, CUstream stream)
|
||||
{
|
||||
PX_COMPILE_TIME_ASSERT(sizeof(T) == sizeof(PxU32) || sizeof(T) == sizeof(PxU8));
|
||||
|
||||
if (!dstDeviceBuffer)
|
||||
return;
|
||||
|
||||
PxU64 numBytes = numElements * sizeof(T);
|
||||
|
||||
PxCUresult result = CUDA_SUCCESS;
|
||||
if (sizeof(T) == sizeof(PxU32))
|
||||
result = cudaContext.memsetD32Async(CUdeviceptr(dstDeviceBuffer), reinterpret_cast<const PxU32&>(value), numBytes >> 2, stream);
|
||||
else
|
||||
result = cudaContext.memsetD8Async(CUdeviceptr(dstDeviceBuffer), reinterpret_cast<const PxU8&>(value), numBytes, stream);
|
||||
|
||||
if (result != CUDA_SUCCESS)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "Memset failed with error code %i!\n", PxI32(result));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Schedules a memset operation on the device on the specified stream. Only supported for 1 byte or 4 byte data types.
|
||||
*
|
||||
* The cuda context will get acquired automatically
|
||||
*/
|
||||
template<typename T>
|
||||
static void memsetAsync(PxCudaContextManager& cudaContextManager, T* dstDeviceBuffer, const T& value, PxU64 numElements, CUstream stream)
|
||||
{
|
||||
PxScopedCudaLock _lock(cudaContextManager);
|
||||
memsetAsync(*cudaContextManager.getCudaContext(), dstDeviceBuffer, value, numElements, stream);
|
||||
}
|
||||
};
|
||||
|
||||
}; // namespace physx
|
||||
#endif
|
||||
127
engine/third_party/physx/source/gpucommon/include/PxgCudaMemoryAllocator.h
vendored
Normal file
127
engine/third_party/physx/source/gpucommon/include/PxgCudaMemoryAllocator.h
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_CUDA_MEMORY_ALLOCATOR_H
|
||||
#define PXG_CUDA_MEMORY_ALLOCATOR_H
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
|
||||
#include "foundation/PxAllocator.h"
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxUserAllocated.h"
|
||||
|
||||
#include "cudamanager/PxCudaContextManager.h"
|
||||
|
||||
namespace physx
|
||||
{
|
||||
class PxCudaContext;
|
||||
|
||||
// Whenever possible, use the macros provided below instead of these functions.
|
||||
void* PxgCudaDeviceMemoryAllocate(PxCudaContext& cudaContext, size_t size, const char* filename, PxI32 line);
|
||||
void PxgCudaDeviceMemoryDeallocate(PxCudaContext& cudaContext, void* ptr);
|
||||
void* PxgPinnedMemoryAllocate(PxCudaContext& cudaContext, size_t size, const char* filename, PxI32 line);
|
||||
void PxgPinnedMemoryDeallocate(PxCudaContext& cudaContext, void* ptr);
|
||||
|
||||
// AD: templated easy-access to the allocation functions:
|
||||
template<typename T>
|
||||
T* PxgCudaDeviceMemoryAllocate(PxCudaContextManager& cudaContextManager, PxU64 numElements, const char* filename, PxI32 line)
|
||||
{
|
||||
PxScopedCudaLock _lock(cudaContextManager);
|
||||
return reinterpret_cast<T*>(PxgCudaDeviceMemoryAllocate(*cudaContextManager.getCudaContext(), numElements * sizeof(T), filename, line));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void PxgCudaDeviceMemoryDeallocate(PxCudaContextManager& cudaContextManager, T*& ptr)
|
||||
{
|
||||
if (ptr)
|
||||
{
|
||||
PxScopedCudaLock _lock(cudaContextManager);
|
||||
PxgCudaDeviceMemoryDeallocate(*cudaContextManager.getCudaContext(), ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T* PxgPinnedMemoryAllocate(PxCudaContextManager& cudaContextManager, PxU64 numElements, const char* filename, PxI32 line)
|
||||
{
|
||||
PxScopedCudaLock _lock(cudaContextManager);
|
||||
return reinterpret_cast<T*>(PxgPinnedMemoryAllocate(*cudaContextManager.getCudaContext(), numElements * sizeof(T), filename, line));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void PxgPinnedMemoryDeallocate(PxCudaContextManager& cudaContextManager, T*& ptr)
|
||||
{
|
||||
if (ptr)
|
||||
{
|
||||
PxScopedCudaLock _lock(cudaContextManager);
|
||||
PxgPinnedMemoryDeallocate(*cudaContextManager.getCudaContext(), ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Pinned Memory allocator - allocates a large block of memory and then suballocates to consumers.
|
||||
// Can only be grown using reserveAndGrow - no copy will be performed and the grow operation is most
|
||||
// likely a large allocation - think about performance.
|
||||
// Grows linearly, only possible to release all the memory at once at the end.
|
||||
// Consider this a stack-based allocator for all means.
|
||||
//
|
||||
// We use this for contact/patch/force streams.
|
||||
class PxgPinnedHostLinearMemoryAllocator : public PxUserAllocated
|
||||
{
|
||||
public:
|
||||
|
||||
PxgPinnedHostLinearMemoryAllocator(PxCudaContextManager* contextManager, const PxU64 size);
|
||||
|
||||
~PxgPinnedHostLinearMemoryAllocator();
|
||||
|
||||
// both of these reserve* operations will invalidate all existing allocations.
|
||||
void reserve(const PxU64 size);
|
||||
void reserveAndGrow(const PxU64 size);
|
||||
|
||||
void reset(); // will invalidate all allocations.
|
||||
void* allocate(const PxU64 size, const PxU64 alignment);
|
||||
|
||||
private:
|
||||
void deallocate(); // will deallocate the large base allocation, not the individual chunks!
|
||||
|
||||
PxCudaContext* mCudaContext;
|
||||
|
||||
public:
|
||||
PxU8* mStart;
|
||||
PxU64 mCurrentSize;
|
||||
PxU64 mTotalSize;
|
||||
};
|
||||
}
|
||||
|
||||
#define PX_DEVICE_MEMORY_ALLOC(T, cudaContextManager, numElements) PxgCudaDeviceMemoryAllocate<T>(cudaContextManager, numElements, PX_FL)
|
||||
#define PX_DEVICE_MEMORY_FREE(cudaContextManager, deviceBuffer) PxgCudaDeviceMemoryDeallocate(cudaContextManager, deviceBuffer)
|
||||
|
||||
#define PX_PINNED_MEMORY_ALLOC(T, cudaContextManager, numElements) PxgPinnedMemoryAllocate<T>(cudaContextManager, numElements, PX_FL)
|
||||
#define PX_PINNED_MEMORY_FREE(cudaContextManager, ptr) PxgPinnedMemoryDeallocate(cudaContextManager, ptr)
|
||||
|
||||
#endif
|
||||
773
engine/third_party/physx/source/gpucommon/include/PxgCudaPagedFirstFitHoleAllocator.h
vendored
Normal file
773
engine/third_party/physx/source/gpucommon/include/PxgCudaPagedFirstFitHoleAllocator.h
vendored
Normal file
@@ -0,0 +1,773 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_PAGED_FIRST_FIT_HOLE_ALLOCATOR_H
|
||||
#define PXG_PAGED_FIRST_FIT_HOLE_ALLOCATOR_H
|
||||
|
||||
#include "foundation/PxArray.h"
|
||||
|
||||
namespace physx
|
||||
{
|
||||
namespace cudaMappedMemAllocatorInternal
|
||||
{
|
||||
template<typename PointedToT>
|
||||
struct Pointer
|
||||
{
|
||||
PX_FORCE_INLINE Pointer() {}
|
||||
PX_FORCE_INLINE Pointer(const Pointer& ref) : hostPtr(ref.hostPtr), devPtr(ref.devPtr) {}
|
||||
PX_FORCE_INLINE explicit Pointer(const PxZERO&) : hostPtr(NULL), devPtr(0) {}
|
||||
|
||||
PX_FORCE_INLINE Pointer& operator=(const Pointer& ref)
|
||||
{
|
||||
if (&ref != this)
|
||||
{
|
||||
hostPtr = ref.hostPtr;
|
||||
devPtr = ref.devPtr;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE Pointer& operator+=(const ptrdiff_t& ref)
|
||||
{
|
||||
hostPtr += ref;
|
||||
devPtr += ref * sizeof(PointedToT);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE Pointer& operator-=(const ptrdiff_t& ref)
|
||||
{
|
||||
hostPtr -= ref;
|
||||
devPtr -= ref * sizeof(PointedToT);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE Pointer operator+(const ptrdiff_t& ref) const
|
||||
{
|
||||
Pointer ret;
|
||||
ret.hostPtr = hostPtr + ref;
|
||||
ret.devPtr = devPtr + ref * sizeof(PointedToT);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE Pointer operator-(const ptrdiff_t& ref) const
|
||||
{
|
||||
Pointer ret;
|
||||
ret.hostPtr = hostPtr - ref;
|
||||
ret.devPtr = devPtr - ref * sizeof(PointedToT);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE ptrdiff_t operator-(const Pointer& ref) const
|
||||
{
|
||||
ptrdiff_t ret;
|
||||
ret = hostPtr - ref.hostPtr;
|
||||
PX_ASSERT(static_cast<ptrdiff_t>(ret * sizeof(PointedToT)) ==
|
||||
(static_cast<ptrdiff_t>(devPtr)-static_cast<ptrdiff_t>(ref.devPtr)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator<(const Pointer& ref) const
|
||||
{
|
||||
PX_ASSERT(hostPtr < ref.hostPtr == devPtr < ref.devPtr);
|
||||
|
||||
return devPtr < ref.devPtr;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator>(const Pointer& ref) const
|
||||
{
|
||||
return ref.operator<(*this);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator<=(const Pointer& ref) const
|
||||
{
|
||||
return !(operator>(ref));
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator>=(const Pointer& ref) const
|
||||
{
|
||||
return !(operator<(ref));
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator==(const Pointer& ref) const
|
||||
{
|
||||
PX_ASSERT((hostPtr == ref.hostPtr) == (devPtr == ref.devPtr));
|
||||
|
||||
return devPtr == ref.devPtr;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator!=(const Pointer& ref) const
|
||||
{
|
||||
return !(operator==(ref));
|
||||
}
|
||||
|
||||
//this is to allow NULL ptr comparison
|
||||
PX_FORCE_INLINE bool operator==(int i) const
|
||||
{
|
||||
PX_ASSERT((hostPtr == NULL) == (devPtr == 0));
|
||||
|
||||
return i == 0 && devPtr == 0;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator!=(int i) const
|
||||
{
|
||||
return !(operator==(i));
|
||||
}
|
||||
|
||||
PointedToT* hostPtr;
|
||||
CUdeviceptr devPtr;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Pointer < void >
|
||||
{
|
||||
PX_FORCE_INLINE Pointer() {}
|
||||
PX_FORCE_INLINE Pointer(const Pointer& ref) : hostPtr(ref.hostPtr), devPtr(ref.devPtr) {}
|
||||
PX_FORCE_INLINE explicit Pointer(const PxZERO&) : hostPtr(NULL), devPtr(0) {}
|
||||
PX_FORCE_INLINE Pointer& operator=(const Pointer& ref)
|
||||
{
|
||||
if (&ref != this)
|
||||
{
|
||||
hostPtr = ref.hostPtr;
|
||||
devPtr = ref.devPtr;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator<(const Pointer& ref) const
|
||||
{
|
||||
PX_ASSERT((hostPtr < ref.hostPtr) == (devPtr < ref.devPtr));
|
||||
|
||||
return devPtr < ref.devPtr;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator>(const Pointer& ref) const
|
||||
{
|
||||
return ref.operator<(*this);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator<=(const Pointer& ref) const
|
||||
{
|
||||
return !(operator>(ref));
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator>=(const Pointer& ref) const
|
||||
{
|
||||
return !(operator<(ref));
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator==(const Pointer& ref) const
|
||||
{
|
||||
PX_ASSERT((hostPtr == ref.hostPtr) == (devPtr == ref.devPtr));
|
||||
|
||||
return devPtr == ref.devPtr;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator!=(const Pointer& ref) const
|
||||
{
|
||||
return !(operator==(ref));
|
||||
}
|
||||
|
||||
//this is to allow NULL ptr comparison
|
||||
PX_FORCE_INLINE bool operator==(int i) const
|
||||
{
|
||||
PX_ASSERT((hostPtr == NULL) == (devPtr == 0));
|
||||
|
||||
return i == 0 && devPtr == 0;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator!=(int i) const
|
||||
{
|
||||
return !(operator==(i));
|
||||
}
|
||||
|
||||
void* hostPtr;
|
||||
CUdeviceptr devPtr;
|
||||
};
|
||||
|
||||
|
||||
template<typename PointedToT>
|
||||
Pointer<PointedToT> operator+(const ptrdiff_t& argL,
|
||||
const Pointer<PointedToT>& argR)
|
||||
{
|
||||
Pointer<PointedToT> ret;
|
||||
ret.hostPtr = argR.hostPtr + argL;
|
||||
ret.devPtr = argR.devPtr + argL * sizeof(PointedToT);
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename PointedToT>
|
||||
static PX_FORCE_INLINE cudaMappedMemAllocatorInternal::Pointer<void> castTo(const cudaMappedMemAllocatorInternal::Pointer<PointedToT>& toPtr)
|
||||
{
|
||||
cudaMappedMemAllocatorInternal::Pointer<void> ret;
|
||||
ret.hostPtr = static_cast<void *>(toPtr.hostPtr);
|
||||
ret.devPtr = toPtr.devPtr;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename PointedToT>
|
||||
static PX_FORCE_INLINE cudaMappedMemAllocatorInternal::Pointer<PointedToT> castTo(const cudaMappedMemAllocatorInternal::Pointer<void>& ref)
|
||||
{
|
||||
cudaMappedMemAllocatorInternal::Pointer<PointedToT> ret;
|
||||
ret.hostPtr = static_cast<PointedToT *>(ref.hostPtr);
|
||||
ret.devPtr = ref.devPtr;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace physx
|
||||
{
|
||||
namespace cudaPagedFirstFitHoleAllocatorInternal
|
||||
{
|
||||
template<typename AllocT, typename PointedToT>
|
||||
struct Pointer
|
||||
{
|
||||
PX_FORCE_INLINE Pointer() {}
|
||||
PX_FORCE_INLINE Pointer(const Pointer& ref) : ptr(ref.hostPtr), sz(ref.sz) {}
|
||||
PX_FORCE_INLINE explicit Pointer(const PxZERO&) : ptr(PxZERO()), sz(0) {}
|
||||
|
||||
PX_FORCE_INLINE Pointer& operator=(const Pointer& ref)
|
||||
{
|
||||
if (&ref != this)
|
||||
{
|
||||
ptr = ref.hostPtr;
|
||||
sz = ref.sz;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE Pointer& operator+=(const ptrdiff_t& ref)
|
||||
{
|
||||
ptr += ref;
|
||||
sz = (size_t)-1;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE Pointer& operator-=(const ptrdiff_t& ref)
|
||||
{
|
||||
ptr -= ref;
|
||||
sz = (size_t)-1;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE Pointer operator+(const ptrdiff_t& ref) const
|
||||
{
|
||||
Pointer ret;
|
||||
ret.ptr = ptr + ref;
|
||||
ret.sz = (size_t)-1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE Pointer operator-(const ptrdiff_t& ref) const
|
||||
{
|
||||
Pointer ret;
|
||||
ret.ptr = ptr - ref;
|
||||
ret.sz = (size_t)-1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE ptrdiff_t operator-(const Pointer& ref) const
|
||||
{
|
||||
ptrdiff_t ret;
|
||||
ret = ptr - ref.ptr;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator<(const Pointer& ref) const
|
||||
{
|
||||
return ptr < ref.ptr;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator>(const Pointer& ref) const
|
||||
{
|
||||
return ref.operator<(*this);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator<=(const Pointer& ref) const
|
||||
{
|
||||
return !(operator>(ref));
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator>=(const Pointer& ref) const
|
||||
{
|
||||
return !(operator<(ref));
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator==(const Pointer& ref) const
|
||||
{
|
||||
return ptr == ref.ptr;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator!=(const Pointer& ref) const
|
||||
{
|
||||
return !(operator==(ref));
|
||||
}
|
||||
|
||||
//this is to allow NULL ptr comparison
|
||||
PX_FORCE_INLINE bool operator==(int i) const
|
||||
{
|
||||
return i == 0 && ptr == NULL;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator!=(int i) const
|
||||
{
|
||||
return !(operator==(i));
|
||||
}
|
||||
|
||||
typename AllocT::template PointerType<PointedToT>::type ptr;
|
||||
size_t sz;
|
||||
};
|
||||
|
||||
template<typename AllocT>
|
||||
struct Pointer <AllocT, void >
|
||||
{
|
||||
PX_FORCE_INLINE Pointer() {}
|
||||
PX_FORCE_INLINE Pointer(const Pointer& ref) : ptr(ref.ptr), sz(ref.sz) {}
|
||||
PX_FORCE_INLINE explicit Pointer(const PxZERO&) : ptr(PxZERO()), sz(0) {}
|
||||
PX_FORCE_INLINE Pointer& operator=(const Pointer& ref)
|
||||
{
|
||||
if (&ref != this)
|
||||
{
|
||||
ptr = ref.ptr;
|
||||
sz = ref.sz;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator<(const Pointer& ref) const
|
||||
{
|
||||
return ptr < ref.ptr;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator>(const Pointer& ref) const
|
||||
{
|
||||
return ref.operator<(*this);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator<=(const Pointer& ref) const
|
||||
{
|
||||
return !(operator>(ref));
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator>=(const Pointer& ref) const
|
||||
{
|
||||
return !(operator<(ref));
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator==(const Pointer& ref) const
|
||||
{
|
||||
return ptr == ref.ptr;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator!=(const Pointer& ref) const
|
||||
{
|
||||
return !(operator==(ref));
|
||||
}
|
||||
|
||||
//this is to allow NULL ptr comparison
|
||||
PX_FORCE_INLINE bool operator==(int i) const
|
||||
{
|
||||
return i == 0 && ptr == NULL;
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool operator!=(int i) const
|
||||
{
|
||||
return !(operator==(i));
|
||||
}
|
||||
|
||||
typename AllocT::template PointerType<void>::type ptr;
|
||||
size_t sz;
|
||||
};
|
||||
}
|
||||
|
||||
template<typename AllocT, size_t defaultPageBytesize = 1024, size_t holeAlignment = 256>
|
||||
class PxgCudaPagedFirstFitHoleAllocator
|
||||
{
|
||||
PX_NOCOPY(PxgCudaPagedFirstFitHoleAllocator)
|
||||
public:
|
||||
//this is a workaround to enable allocators with typedefed pointer types
|
||||
template<typename PointedToT>
|
||||
struct PointerType
|
||||
{
|
||||
typedef cudaPagedFirstFitHoleAllocatorInternal::Pointer<AllocT ,PointedToT> type;
|
||||
};
|
||||
|
||||
PxgCudaPagedFirstFitHoleAllocator(AllocT& alloc): mAlloc(alloc),
|
||||
mFirstHoleIdx(-1),
|
||||
mLastHoleIdx(-1),
|
||||
mFirstDeinitializedHoleIdx(-1)
|
||||
{}
|
||||
|
||||
virtual ~PxgCudaPagedFirstFitHoleAllocator()
|
||||
{
|
||||
resetAndRelease();
|
||||
}
|
||||
|
||||
void resetAndRelease()
|
||||
{
|
||||
for (typename PxArray<typename AllocT::template PointerType<PxU8>::type >::Iterator it = mPages.begin(), end = mPages.end(); it != end; ++it)
|
||||
{
|
||||
mAlloc.deallocate(castTo<PxU8>(*it));
|
||||
}
|
||||
|
||||
mPages.resize(0);
|
||||
mHoles.resize(0);
|
||||
mFirstHoleIdx = -1;
|
||||
mLastHoleIdx = -1;
|
||||
mFirstDeinitializedHoleIdx = -1;
|
||||
}
|
||||
|
||||
typename PointerType<void>::type allocate(size_t byteSize)
|
||||
{
|
||||
byteSize = (byteSize + holeAlignment - 1) & ~(holeAlignment - 1);
|
||||
|
||||
PxI32 idx = mFirstHoleIdx;
|
||||
|
||||
while (idx != -1)
|
||||
{
|
||||
Hole& hole = mHoles[(PxU32)idx];
|
||||
|
||||
if (hole.byteSize >= byteSize)
|
||||
break;
|
||||
|
||||
idx = hole.nextIndex;
|
||||
}
|
||||
|
||||
if (idx == -1)
|
||||
{
|
||||
idx = addNewPage(byteSize);
|
||||
|
||||
if (idx == -1)
|
||||
{
|
||||
return typename PointerType<void>::type(PxZERO());
|
||||
}
|
||||
}
|
||||
|
||||
Hole& hole = mHoles[(PxU32)idx];
|
||||
typename PointerType<void>::type ret;
|
||||
ret.ptr = castTo<PxU8>(hole.ptr);
|
||||
ret.sz = byteSize;
|
||||
hole.ptr += (ptrdiff_t)byteSize;
|
||||
PX_ASSERT(hole.byteSize >= byteSize);
|
||||
hole.byteSize -= byteSize;
|
||||
|
||||
if (hole.byteSize == 0)
|
||||
{
|
||||
PxI32& prevIdx = hole.prevIndex != -1 ? mHoles[(PxU32)hole.prevIndex].nextIndex : mFirstHoleIdx;
|
||||
PxI32& nextIdx = hole.nextIndex != -1 ? mHoles[(PxU32)hole.nextIndex].prevIndex : mLastHoleIdx;
|
||||
|
||||
prevIdx = hole.nextIndex;
|
||||
nextIdx = hole.prevIndex;
|
||||
|
||||
deallocateHole(idx);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void deallocate(const typename PointerType<void>::type& ptr)
|
||||
{
|
||||
//don't try to deallocate pointers that were calculated, only those obtained from allocate()
|
||||
PX_ASSERT(ptr.sz != (size_t) -1);
|
||||
|
||||
//we don't want to have zero-sized holes from deleting zero-sized allocations (which are valid)
|
||||
if (ptr.sz == 0 || ptr.sz == (size_t) -1)
|
||||
return;
|
||||
|
||||
deallocateInternal(castTo<PxU8>(ptr.ptr), ptr.sz);
|
||||
}
|
||||
|
||||
#if PX_CHECKED
|
||||
bool consistencyCheck()
|
||||
{
|
||||
for (PxU32 i = 0; i < mHoles.size(); ++i)
|
||||
{
|
||||
if (mHoles[i].ptr != NULL && mHoles[i].byteSize == 0)
|
||||
{
|
||||
PX_ASSERT(false);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
PxI32 prevI = -1;
|
||||
PxU32 holeCtr = 0;
|
||||
|
||||
for (PxI32 i = mFirstHoleIdx; i != -1; prevI = i, i = mHoles[(PxU32)i].nextIndex)
|
||||
{
|
||||
++holeCtr;
|
||||
}
|
||||
|
||||
if (prevI != mLastHoleIdx)
|
||||
{
|
||||
PX_ASSERT(false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
prevI = -1;
|
||||
PxU32 holeCtr2 = 0;
|
||||
|
||||
for (PxI32 i = mLastHoleIdx; i != -1; prevI = i, i = mHoles[(PxU32)i].prevIndex)
|
||||
{
|
||||
++holeCtr2;
|
||||
}
|
||||
|
||||
if (prevI != mFirstHoleIdx)
|
||||
{
|
||||
PX_ASSERT(false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (holeCtr2 != holeCtr)
|
||||
{
|
||||
PX_ASSERT(false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
PxU32 holeCtr3 = 0;
|
||||
for (PxI32 i = mFirstDeinitializedHoleIdx; i != -1; i = mHoles[(PxU32)i].nextIndex)
|
||||
{
|
||||
++holeCtr3;
|
||||
}
|
||||
|
||||
if (holeCtr2 + holeCtr3 != mHoles.size())
|
||||
{
|
||||
PX_ASSERT(false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
prevI = mFirstHoleIdx;
|
||||
|
||||
if (prevI != -1)
|
||||
{
|
||||
for (PxI32 i = mHoles[(PxU32) prevI].nextIndex; i != -1; prevI = i, i = mHoles[(PxU32) i].nextIndex)
|
||||
{
|
||||
if (mHoles[(PxU32) prevI].ptr + (ptrdiff_t) mHoles[(PxU32) prevI].byteSize >= mHoles[(PxU32) i].ptr)
|
||||
{
|
||||
PX_ASSERT(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
struct Hole
|
||||
{
|
||||
Hole(): ptr(PxZERO()), byteSize(0), prevIndex(-1), nextIndex(-1) {}
|
||||
Hole(PxI32 prev, PxI32 next):
|
||||
ptr(PxZERO()),
|
||||
byteSize(0),
|
||||
prevIndex(prev),
|
||||
nextIndex(next)
|
||||
{
|
||||
}
|
||||
|
||||
void initForUse(const typename AllocT::template PointerType<PxU8>::type& p, size_t sz, PxI32 prev, PxI32 next)
|
||||
{
|
||||
ptr = p;
|
||||
byteSize = sz;
|
||||
prevIndex = prev;
|
||||
nextIndex = next;
|
||||
}
|
||||
|
||||
void initForPool(PxI32 next)
|
||||
{
|
||||
ptr = typename AllocT::template PointerType<PxU8>::type(PxZERO());
|
||||
byteSize = 0;
|
||||
prevIndex = -1;
|
||||
nextIndex = next;
|
||||
}
|
||||
|
||||
typename AllocT::template PointerType<PxU8>::type ptr;
|
||||
size_t byteSize;
|
||||
PxI32 prevIndex;
|
||||
PxI32 nextIndex;
|
||||
};
|
||||
|
||||
PxI32 allocateHole()
|
||||
{
|
||||
PxI32 retIdx;
|
||||
|
||||
if (mFirstDeinitializedHoleIdx != -1)
|
||||
{
|
||||
retIdx = mFirstDeinitializedHoleIdx;
|
||||
mFirstDeinitializedHoleIdx = mHoles[(PxU32) retIdx].nextIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
mHoles.pushBack(Hole(-1, -1));
|
||||
retIdx = (PxI32) mHoles.size() - 1;
|
||||
}
|
||||
|
||||
return retIdx;
|
||||
}
|
||||
|
||||
void deallocateHole(PxI32 idx)
|
||||
{
|
||||
PX_ASSERT(idx < (PxI32) mHoles.size());
|
||||
|
||||
mHoles[(PxU32) idx].initForPool(mFirstDeinitializedHoleIdx);
|
||||
mFirstDeinitializedHoleIdx = idx;
|
||||
}
|
||||
|
||||
PxPair<PxI32, PxI32> findPrevAndNextHoles(const typename AllocT::template PointerType<PxU8>::type& ptr)
|
||||
{
|
||||
PxI32 i = mFirstHoleIdx;
|
||||
|
||||
while (i != -1 && ptr > mHoles[(PxU32) i].ptr)
|
||||
i = mHoles[(PxU32) i].nextIndex;
|
||||
|
||||
if (i == -1)
|
||||
{
|
||||
return PxPair<PxI32, PxI32>(mLastHoleIdx, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PxPair<PxI32, PxI32>(mHoles[(PxU32) i].prevIndex, i);
|
||||
}
|
||||
}
|
||||
|
||||
PxI32 deallocateInternal(const typename AllocT::template PointerType<PxU8>::type& ptr, size_t sz)
|
||||
{
|
||||
PxPair<PxI32, PxI32> prevAndNext = findPrevAndNextHoles(ptr);
|
||||
|
||||
PxI32 newHole = -1;
|
||||
|
||||
if (prevAndNext.first != -1)
|
||||
{
|
||||
Hole& prevHole = mHoles[(PxU32) prevAndNext.first];
|
||||
|
||||
PX_ASSERT(prevHole.ptr + (ptrdiff_t) prevHole.byteSize <= ptr);
|
||||
|
||||
if (prevHole.ptr + (ptrdiff_t) prevHole.byteSize == ptr)
|
||||
{
|
||||
prevHole.byteSize += sz;
|
||||
newHole = prevAndNext.first;
|
||||
}
|
||||
}
|
||||
|
||||
if (newHole == -1)
|
||||
{
|
||||
newHole = allocateHole();
|
||||
Hole& hole = mHoles[(PxU32) newHole];
|
||||
hole.initForUse(ptr, sz, prevAndNext.first, prevAndNext.second);
|
||||
PxI32& prevIdx = prevAndNext.first != -1 ? mHoles[(PxU32) prevAndNext.first].nextIndex : mFirstHoleIdx;
|
||||
prevIdx = newHole;
|
||||
PxI32& nextIdx = prevAndNext.second != -1 ? mHoles[(PxU32) prevAndNext.second].prevIndex : mLastHoleIdx;
|
||||
nextIdx = newHole;
|
||||
}
|
||||
|
||||
Hole& hole = mHoles[(PxU32) newHole];
|
||||
|
||||
if (prevAndNext.second != -1)
|
||||
{
|
||||
Hole& nextHole = mHoles[(PxU32) prevAndNext.second];
|
||||
|
||||
PX_ASSERT(ptr + (ptrdiff_t) sz <= nextHole.ptr);
|
||||
|
||||
if (ptr + (ptrdiff_t) sz == nextHole.ptr)
|
||||
{
|
||||
hole.byteSize += nextHole.byteSize;
|
||||
hole.nextIndex = nextHole.nextIndex;
|
||||
PxI32& nextIdx = hole.nextIndex != -1 ? mHoles[(PxU32) hole.nextIndex].prevIndex : mLastHoleIdx;
|
||||
nextIdx = newHole;
|
||||
deallocateHole(prevAndNext.second);
|
||||
}
|
||||
}
|
||||
|
||||
return newHole;
|
||||
}
|
||||
|
||||
PxI32 addNewPage(size_t requestedAllocByteSize)
|
||||
{
|
||||
size_t sz = PxMax(requestedAllocByteSize, defaultPageBytesize);
|
||||
mPages.pushBack(castTo<PxU8>(mAlloc.allocate(sz)));
|
||||
PX_ASSERT(mPages.back() != 0);
|
||||
|
||||
if (mPages.back() == 0)
|
||||
{
|
||||
mPages.popBack();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//by "deallocating" the newly allocated mem we put into the sorted free mem list - holes management inside
|
||||
PxI32 newHole = deallocateInternal(mPages.back(), sz);
|
||||
|
||||
return newHole;
|
||||
}
|
||||
|
||||
AllocT& mAlloc;
|
||||
PxArray<typename AllocT::template PointerType<PxU8>::type > mPages;
|
||||
PxArray<Hole> mHoles;
|
||||
PxI32 mFirstHoleIdx;
|
||||
PxI32 mLastHoleIdx;
|
||||
PxI32 mFirstDeinitializedHoleIdx; //pool of holes
|
||||
};
|
||||
|
||||
template<typename AllocT, size_t defaultPageBytesize, size_t holeAlignment, typename PointedToT>
|
||||
typename PxgCudaPagedFirstFitHoleAllocator<AllocT, defaultPageBytesize, holeAlignment>::template PointerType<PointedToT>::type operator+(const ptrdiff_t& argL,
|
||||
const typename PxgCudaPagedFirstFitHoleAllocator<AllocT, defaultPageBytesize, holeAlignment>::template PointerType<PointedToT>::type& argR)
|
||||
{
|
||||
typename PxgCudaPagedFirstFitHoleAllocator<AllocT, defaultPageBytesize, holeAlignment>::template PointerType<PointedToT>::type ret;
|
||||
ret.ptr = argR.ptr + argL;
|
||||
ret.sz = (size_t) -1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
188
engine/third_party/physx/source/gpucommon/include/PxgCudaPagedLinearAllocator.h
vendored
Normal file
188
engine/third_party/physx/source/gpucommon/include/PxgCudaPagedLinearAllocator.h
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_CUDA_PAGED_LINEAR_ALLOCATOR_H
|
||||
#define PXG_CUDA_PAGED_LINEAR_ALLOCATOR_H
|
||||
|
||||
#include "foundation/PxArray.h"
|
||||
#include "foundation/PxMath.h"
|
||||
#include "foundation/PxMutex.h"
|
||||
|
||||
namespace physx
|
||||
{
|
||||
|
||||
template<typename AllocT>
|
||||
class PxgCudaPagedLinearAllocator
|
||||
{
|
||||
PX_NOCOPY(PxgCudaPagedLinearAllocator)
|
||||
public:
|
||||
|
||||
PxgCudaPagedLinearAllocator(AllocT& alloc, const size_t defaultPageBytesize = 1024 * 1024 ) :
|
||||
mAlloc(alloc),
|
||||
mCurrOffsetBytes(0),
|
||||
mCurrPage(0),
|
||||
mDefaultPageBytesize(defaultPageBytesize)
|
||||
{}
|
||||
|
||||
virtual ~PxgCudaPagedLinearAllocator()
|
||||
{
|
||||
resetAndRelease();
|
||||
}
|
||||
|
||||
void resetAndRelease()
|
||||
{
|
||||
reset();
|
||||
|
||||
for (PxU32 i = 0; i < mPages.size(); ++i)
|
||||
{
|
||||
mAlloc.deallocate(mPages[i]);
|
||||
}
|
||||
|
||||
mPages.resize(0);
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
mCurrPage = 0;
|
||||
mCurrOffsetBytes = 0;
|
||||
mCurrPageSize = mPagesSize.size() == 0 ? 0 : mPagesSize[0];
|
||||
}
|
||||
|
||||
//attention: no alignment!
|
||||
void* allocate(size_t byteSize)
|
||||
{
|
||||
bool outOfMem = false;
|
||||
|
||||
bool empty = mPages.empty();
|
||||
|
||||
if (!empty && (mCurrOffsetBytes + byteSize) >= mCurrPageSize)
|
||||
{
|
||||
mCurrOffsetBytes = 0;
|
||||
++mCurrPage;
|
||||
if (mCurrPage < mPages.size())
|
||||
mCurrPageSize = mPagesSize[mCurrPage];
|
||||
else
|
||||
mCurrPageSize = 0;
|
||||
}
|
||||
|
||||
if (empty || mCurrOffsetBytes + byteSize >= mCurrPageSize)
|
||||
{
|
||||
//Let's first iterate through all the pages to find if any are large-enough
|
||||
bool found = false;
|
||||
for (PxU32 i = mCurrPage; i < mPages.size(); ++i)
|
||||
{
|
||||
if (mPagesSize[i] >= byteSize)
|
||||
{
|
||||
found = true;
|
||||
mCurrPage = i;
|
||||
mCurrPageSize = mPagesSize[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
outOfMem = !addNewPage(byteSize);
|
||||
}
|
||||
|
||||
if (outOfMem)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ptrdiff_t offs = (ptrdiff_t)mCurrOffsetBytes;
|
||||
mCurrOffsetBytes += byteSize;
|
||||
|
||||
return mPages[mCurrPage] + offs;
|
||||
}
|
||||
|
||||
void* allocateAligned(size_t alignment, size_t byteSize)
|
||||
{
|
||||
#if 0
|
||||
size_t pad = alignment - 1 + sizeof(size_t); // store offset for delete.
|
||||
#else
|
||||
size_t pad = alignment - 1;
|
||||
#endif
|
||||
size_t newByteSize = byteSize + pad;
|
||||
|
||||
PxU8* basePtr = reinterpret_cast<PxU8*>(allocate(newByteSize));
|
||||
|
||||
#if 0
|
||||
size_t ptrAligningOffset = basePtr.getAligningOffset(alignment, sizeof(size_t));
|
||||
typename AllocT::template Pointer<PxU8> offsetPtr = basePtr + ptrAligningOffset;
|
||||
|
||||
// wide mask
|
||||
((size_t*)ptr)[-1] = size_t(ptr - base); // store offset
|
||||
#else
|
||||
size_t alignOffs = alignment - (size_t(basePtr) & (alignment - 1));
|
||||
|
||||
size_t ptrAligningOffset = (alignOffs & (alignment - 1));
|
||||
|
||||
PxU8* offsetPtr = basePtr + (ptrdiff_t) ptrAligningOffset;
|
||||
#endif
|
||||
|
||||
return offsetPtr;
|
||||
}
|
||||
|
||||
PxMutex mMutex;
|
||||
|
||||
protected:
|
||||
|
||||
bool addNewPage(size_t requestedAllocByteSize)
|
||||
{
|
||||
const size_t size = PxMax(requestedAllocByteSize, mDefaultPageBytesize);
|
||||
mPages.pushBack(reinterpret_cast<PxU8*>(mAlloc.allocate(size, 0, PX_FL)));
|
||||
mPagesSize.pushBack(size);
|
||||
PX_ASSERT(mPages.back() != 0);
|
||||
|
||||
if (mPages.back() == 0)
|
||||
{
|
||||
mPages.popBack();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
mCurrOffsetBytes = 0;
|
||||
mCurrPage = mPages.size() - 1;
|
||||
mCurrPageSize = size;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
AllocT& mAlloc;
|
||||
PxArray<PxU8*> mPages;
|
||||
PxArray<size_t> mPagesSize;
|
||||
size_t mCurrOffsetBytes;
|
||||
PxU32 mCurrPage;
|
||||
size_t mCurrPageSize;
|
||||
size_t mDefaultPageBytesize;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
116
engine/third_party/physx/source/gpucommon/include/PxgCudaUtils.h
vendored
Normal file
116
engine/third_party/physx/source/gpucommon/include/PxgCudaUtils.h
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_CUDA_UTILS_H
|
||||
#define PXG_CUDA_UTILS_H
|
||||
|
||||
#include "cuda.h"
|
||||
|
||||
#include "foundation/PxErrors.h"
|
||||
#include "foundation/PxAssert.h"
|
||||
#include "foundation/PxFoundation.h"
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
#include "foundation/PxTime.h"
|
||||
|
||||
#include "cudamanager/PxCudaContext.h"
|
||||
|
||||
namespace physx
|
||||
{
|
||||
|
||||
/**
|
||||
Utility function to synchronize 2 streams. This causes dependentStream to wait for parentStream to complete its current queued workload before proceeding further.
|
||||
*/
|
||||
PX_INLINE void synchronizeStreams(PxCudaContext* cudaContext, const CUstream& parentStream, const CUstream& dependentStream)
|
||||
{
|
||||
CUevent ev = 0;
|
||||
cudaContext->eventCreate(&ev, CU_EVENT_DISABLE_TIMING);
|
||||
|
||||
CUresult result = cudaContext->eventRecord(ev, parentStream);
|
||||
|
||||
if (result != CUDA_SUCCESS)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "SynchronizeStreams cuEventRecord failed with error %i\n", result);
|
||||
PX_ASSERT(result == CUDA_SUCCESS);
|
||||
|
||||
result = cudaContext->streamWaitEvent(dependentStream, ev);
|
||||
|
||||
if (result != CUDA_SUCCESS)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "SynchronizeStreams cuStreamWaitEvent failed with error %i\n", result);
|
||||
PX_ASSERT(result == CUDA_SUCCESS);
|
||||
|
||||
cudaContext->eventDestroy(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
Utility function to synchronize 2 streams. This causes dependentStream to wait for parentStream to complete its current queued workload before proceeding further.
|
||||
*/
|
||||
PX_INLINE void synchronizeStreams(PxCudaContext* cudaContext, CUstream& parentStream, CUstream& dependentStream, CUevent& ev)
|
||||
{
|
||||
//CUevent ev;
|
||||
//mCudaContext->eventCreate(&ev, CU_EVENT_DISABLE_TIMING);
|
||||
|
||||
CUresult result = cudaContext->eventRecord(ev, parentStream);
|
||||
if (result != CUDA_SUCCESS)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "SynchronizeStreams cuEventRecord failed with error %i\n", result);
|
||||
|
||||
PX_ASSERT(result == CUDA_SUCCESS);
|
||||
|
||||
result = cudaContext->streamWaitEvent(dependentStream, ev);
|
||||
if (result != CUDA_SUCCESS)
|
||||
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "SynchronizeStreams cuStreamWaitEvent failed with error %i\n", result);
|
||||
|
||||
PX_ASSERT(result == CUDA_SUCCESS);
|
||||
|
||||
|
||||
//mCudaContext->eventDestroy(ev);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE void* getMappedDevicePtr(PxCudaContext* cudaContext, void* cpuPtr)
|
||||
{
|
||||
CUdeviceptr dPtr = 0;
|
||||
cudaContext->memHostGetDevicePointer(&dPtr, cpuPtr, 0);
|
||||
return reinterpret_cast<void*>(dPtr);
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE const void* getMappedDeviceConstPtr(PxCudaContext* cudaContext, const void* cpuPtr)
|
||||
{
|
||||
return getMappedDevicePtr(cudaContext, const_cast<void*>(cpuPtr));
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE bool spinWait(volatile PxU32& waitValue, const PxReal timeoutValue)
|
||||
{
|
||||
PxTime time;
|
||||
while (waitValue == 0)
|
||||
{
|
||||
if (PxReal(time.peekElapsedSeconds()) >= timeoutValue)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
54
engine/third_party/physx/source/gpucommon/include/PxgDevicePointer.h
vendored
Normal file
54
engine/third_party/physx/source/gpucommon/include/PxgDevicePointer.h
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_DEVICE_POINTER_H
|
||||
#define PXG_DEVICE_POINTER_H
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
|
||||
namespace physx
|
||||
{
|
||||
|
||||
//This should be a basic pointer wrapper that has the same memory footprint as a raw pointer. Please don't add additional members to the struct.
|
||||
template <typename T>
|
||||
struct PxgDevicePointer
|
||||
{
|
||||
CUdeviceptr mPtr;
|
||||
|
||||
PxgDevicePointer(CUdeviceptr ptr) : mPtr(ptr) {}
|
||||
|
||||
operator CUdeviceptr& () { return mPtr; }
|
||||
operator CUdeviceptr() const { return mPtr; }
|
||||
|
||||
T* getPointer() const { return reinterpret_cast<T*>(mPtr); }
|
||||
};
|
||||
|
||||
PX_COMPILE_TIME_ASSERT(sizeof(PxgDevicePointer<PxU32>) == sizeof(CUdeviceptr));
|
||||
}
|
||||
|
||||
#endif
|
||||
178
engine/third_party/physx/source/gpucommon/include/PxgHeapMemAllocator.h
vendored
Normal file
178
engine/third_party/physx/source/gpucommon/include/PxgHeapMemAllocator.h
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_HEAP_MEM_ALLOCATOR_H
|
||||
#define PXG_HEAP_MEM_ALLOCATOR_H
|
||||
|
||||
#include "foundation/PxAssert.h"
|
||||
#include "foundation/PxBitUtils.h"
|
||||
#include "foundation/PxHashMap.h"
|
||||
#include "foundation/PxArray.h"
|
||||
#include "foundation/PxPool.h"
|
||||
#include "foundation/PxMutex.h"
|
||||
#include "PxsHeapMemoryAllocator.h"
|
||||
#include "common/PxPhysXCommonConfig.h"
|
||||
|
||||
#if PX_DEBUG
|
||||
#include "PxgMemoryTracker.h"
|
||||
#endif
|
||||
|
||||
namespace physx
|
||||
{
|
||||
class PxsMemoryManager;
|
||||
|
||||
class BlockHeader
|
||||
{
|
||||
public:
|
||||
PX_FORCE_INLINE BlockHeader(const PxU32 offset, PxU32 rootIndex) : mOffset(offset), mRootIndex(rootIndex), mPrev(NULL), mNext(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
PX_FORCE_INLINE void initialize(const PxU32 rootIndex, const PxU32 offset)
|
||||
{
|
||||
mOffset = offset;
|
||||
mRootIndex = rootIndex;
|
||||
mPrev = NULL;
|
||||
mNext = NULL;
|
||||
}
|
||||
|
||||
PxU32 mOffset;
|
||||
PxU32 mRootIndex;
|
||||
BlockHeader* mPrev;
|
||||
BlockHeader* mNext;
|
||||
};
|
||||
|
||||
#define PXG_INVALID_BLOCK 0xFFFFFFFF
|
||||
|
||||
class Block
|
||||
{
|
||||
public:
|
||||
PX_FORCE_INLINE Block() : mStartHeader(NULL), mEndHeader(NULL), mHeaderSizes(0) {}
|
||||
|
||||
PX_FORCE_INLINE bool isEmpty() { return mHeaderSizes == 0; }
|
||||
void insertBlockHeader(const PxU32 rootIndex, const PxU32 offset, PxPool<BlockHeader>& pool);
|
||||
void removeBlockHeader(BlockHeader* header, PxPool<BlockHeader>& pool);
|
||||
BlockHeader* findBuddy(const PxU32 offsetToFind, const PxU32 rootIndex);
|
||||
BlockHeader* getFreeBlocks(){ return mEndHeader; }
|
||||
|
||||
bool isValid();
|
||||
|
||||
BlockHeader* mStartHeader;
|
||||
BlockHeader* mEndHeader;
|
||||
PxU32 mHeaderSizes;
|
||||
PxU32 mBlockSize;
|
||||
PxU32 mBlockIndex;
|
||||
};
|
||||
|
||||
class AllocationValue
|
||||
{
|
||||
public:
|
||||
PX_FORCE_INLINE AllocationValue(const PxU32 blockIndex, const PxU32 rootIndex, const size_t byteSize, const int group)
|
||||
: mBlockIndex(blockIndex), mRootIndex(rootIndex), mByteSize(byteSize), mGroup(group)
|
||||
{}
|
||||
PxU32 mBlockIndex;
|
||||
PxU32 mRootIndex;
|
||||
size_t mByteSize;
|
||||
int mGroup;
|
||||
};
|
||||
|
||||
struct ExceptionalAlloc
|
||||
{
|
||||
void* address;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
class PxgHeapMemoryAllocator : public PxsHeapMemoryAllocator
|
||||
{
|
||||
public:
|
||||
|
||||
PxgHeapMemoryAllocator(const PxU32 byteSize, PxVirtualAllocatorCallback* allocator);
|
||||
~PxgHeapMemoryAllocator();
|
||||
|
||||
void initializeBlocks(const PxU32 rootIndex);
|
||||
//return a free block index
|
||||
PxU32 getNextFreeBlock(const PxU32 blockIndex, const PxU32 allocationSize, const char* file, const int line);
|
||||
|
||||
// PxVirtualAllocatorCallback
|
||||
virtual void* allocate(const size_t byteSize, const int group, const char* file, const int line) PX_OVERRIDE;
|
||||
virtual void deallocate(void* ptr) PX_OVERRIDE;
|
||||
//~PxVirtualAllocatorCallback
|
||||
|
||||
void deallocateDeferred(void* ptr);
|
||||
|
||||
void flushDeferredDeallocs();
|
||||
|
||||
PxU64 getTotalSize();
|
||||
PxsHeapStats& getHeapStats() { return mHeapStats; }
|
||||
|
||||
#if PX_DEBUG || PX_STOMP_ALLOCATED_MEMORY
|
||||
PxVirtualAllocatorCallback* getAllocator() { return mAllocator; } //Used for memcheck support
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
PxHashMap<void*, AllocationValue> mHashMap;//this is used to look up where the block is
|
||||
PxArray<Block> mBlocks; //this is used to store fix size slots
|
||||
PxVirtualAllocatorCallback* mAllocator;
|
||||
PxArray<void*> mRoots;
|
||||
PxArray<ExceptionalAlloc> mExceptionalAllocs;
|
||||
PxArray<void*> deferredDeallocs;
|
||||
PxU32 mAllocationSize;
|
||||
PxU32 mBitfield;
|
||||
PxU64 mTotalMem;
|
||||
PxsHeapStats mHeapStats;
|
||||
|
||||
PxPool<BlockHeader> mBlockHeaderPool;
|
||||
|
||||
PxMutex mMutex;
|
||||
|
||||
#if PX_DEBUG
|
||||
MemTracker mMemTracker;
|
||||
#endif
|
||||
|
||||
PX_NOCOPY(PxgHeapMemoryAllocator)
|
||||
};
|
||||
|
||||
class PxgHeapMemoryAllocatorManager : public PxsHeapMemoryAllocatorManager
|
||||
{
|
||||
public:
|
||||
PxgHeapMemoryAllocatorManager(PxU32 heapCapacity, PxsMemoryManager* memoryManager);
|
||||
|
||||
virtual ~PxgHeapMemoryAllocatorManager();
|
||||
|
||||
// PxsHeapMemoryAllocatorManager
|
||||
virtual PxU64 getDeviceMemorySize() const PX_OVERRIDE PX_FINAL;
|
||||
virtual PxsHeapStats getDeviceHeapStats() const PX_OVERRIDE PX_FINAL;
|
||||
virtual void flushDeferredDeallocs() PX_OVERRIDE PX_FINAL;
|
||||
//~PxsHeapMemoryAllocatorManager
|
||||
|
||||
PxgHeapMemoryAllocator* mDeviceMemoryAllocators;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
104
engine/third_party/physx/source/gpucommon/include/PxgIntrinsics.h
vendored
Normal file
104
engine/third_party/physx/source/gpucommon/include/PxgIntrinsics.h
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_INTRINSICS_H
|
||||
#define PXG_INTRINSICS_H
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "cuda.h"
|
||||
|
||||
#if (defined(_MSC_VER) && defined(_WIN64)) || defined(__LP64__) || defined(__CUDACC_RTC__)
|
||||
#define __STG_PTR "l"
|
||||
#else
|
||||
#define __STG_PTR "r"
|
||||
#endif
|
||||
|
||||
namespace physx
|
||||
{
|
||||
#if __CUDA_ARCH__ >= 350
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE T Pxldca(const T& t) { return __ldca(&t); } //Cache all levels
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE T Pxldcg(const T& t) { return __ldcg(&t); } //Cache at global level (not L1)
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE T Pxldg(const T& t) { return __ldg(&t); } //Load global
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE T Pxldcs(const T& t) { return __ldcs(&t); } //Cache streaming, likely to touch once
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE T Pxldlu(const T& t) { return __ldlu(&t); } // Last use
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE T Pxldcv(const T& t) { return __ldcv(&t); } //Don't catch and fetch again
|
||||
|
||||
#if __CUDACC_VER_MAJOR__ >= 11
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE void Pxstwb(T* dst, const T& src) { __stwb(dst, src); } //Cache write-back all levels
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE void Pxstcg(T* dst, const T& src) { __stcg(dst, src); } //Cache at global (not L1)
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE void Pxstcs(T* dst, const T& src) { __stcs(dst, src); } // Cache streaming (accessed once)
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE void Pxstwt(T* dst, const T& src) { __stwt(dst, src); } // Cache write through (no caching)
|
||||
#else
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE void Pxstwb(T* dst, const T& src) { *dst = src; } //Cache write-back all levels
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE void Pxstcg(T* dst, const T& src) { *dst = src; } //Cache at global (not L1)
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE void Pxstcs(T* dst, const T& src) { *dst = src; } // Cache streaming (accessed once)
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE void Pxstwt(T* dst, const T& src) { *dst = src; } // Cache write through (no caching)
|
||||
#endif
|
||||
#else
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE T Pxldca(const T& t) { return t; } //Cache all levels
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE T Pxldcg(const T& t) { return t; } //Cache at global level (not L1)
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE T Pxldg(const T& t) { return t; } //Load global
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE T Pxldcs(const T& t) { return t; } //Cache streaming, likely to touch once
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE T Pxldlu(const T& t) { return t; } // Last use
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE T Pxldcv(const T& t) { return t; } //Don't catch and fetch again
|
||||
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE void Pxstwb(T* dst, const T& src) { *dst = src; } //Cache write-back all levels
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE void Pxstcg(T* dst, const T& src) { *dst = src; } //Cache at global (not L1)
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE void Pxstcs(T* dst, const T& src) { *dst = src; } // Cache streaming (accessed once)
|
||||
template <typename T>
|
||||
PX_FORCE_INLINE PX_CUDA_CALLABLE void Pxstwt(T* dst, const T& src) { *dst = src; } // Cache write through (no caching)
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
47
engine/third_party/physx/source/gpucommon/include/PxgKernelIndices.h
vendored
Normal file
47
engine/third_party/physx/source/gpucommon/include/PxgKernelIndices.h
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_KERNEL_INDICES_H
|
||||
#define PXG_KERNEL_INDICES_H
|
||||
|
||||
namespace physx
|
||||
{
|
||||
struct PxgKernelIds
|
||||
{
|
||||
enum
|
||||
{
|
||||
|
||||
#define KERNEL_DEF(id, name) id,
|
||||
#include "PxgKernelNames.h"
|
||||
#undef KERNEL_DEF
|
||||
|
||||
KERNEL_COUNT
|
||||
};
|
||||
};
|
||||
}
|
||||
#endif
|
||||
618
engine/third_party/physx/source/gpucommon/include/PxgKernelNames.h
vendored
Normal file
618
engine/third_party/physx/source/gpucommon/include/PxgKernelNames.h
vendored
Normal file
@@ -0,0 +1,618 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_KERNEL_NAMES_H
|
||||
#define PXG_KERNEL_NAMES_H
|
||||
|
||||
///////////////////////////////////////////////
|
||||
//simulation controller kernels
|
||||
///////////////////////////////////////////////
|
||||
KERNEL_DEF(MERGE_AABBMGR_HANDLES, "mergeChangedAABBMgrHandlesLaunch")
|
||||
KERNEL_DEF(UPDATE_BODY_EXTERNAL_VELOCITIES, "updateBodyExternalVelocitiesLaunch")
|
||||
KERNEL_DEF(UPDATE_SHAPES, "updateShapesLaunch")
|
||||
KERNEL_DEF(UPDATE_BODIES, "updateBodiesLaunch")
|
||||
KERNEL_DEF(UPDATE_BODIES_DIRECT_API, "updateBodiesLaunchDirectAPI")
|
||||
KERNEL_DEF(NEW_ARTICULATIONS, "newArticulationsLaunch")
|
||||
KERNEL_DEF(UPDATE_ARTICULATIONS, "updateArticulationsLaunch")
|
||||
KERNEL_DEF(UPDATE_JOINTS, "updateJointsLaunch")
|
||||
KERNEL_DEF(UPDATE_TRANSFORMCACHE_AND_BOUNDARRAY, "updateTransformCacheAndBoundArrayLaunch")
|
||||
KERNEL_DEF(MERGE_TRANSFORMCACHE_AND_BOUNDARRAY_CHANGES, "mergeTransformCacheAndBoundArrayChanges")
|
||||
KERNEL_DEF(UPDATE_AABBMGR_HANDLES, "updateChangedAABBMgrHandlesLaunch")
|
||||
KERNEL_DEF(COMPUTE_FROZEN_UNFROZEN_HISTOGRAM, "computeFrozenAndUnfrozenHistogramLaunch")
|
||||
KERNEL_DEF(OUTPUT_FROZEN_UNFROZEN_HISTOGRAM, "outputFrozenAndUnfrozenHistogram")
|
||||
KERNEL_DEF(CREATE_FROZEN_UNFROZEN_ARRAY, "createFrozenAndUnfrozenArray")
|
||||
|
||||
//////////////////////////////////////////////
|
||||
//broad phase kernels
|
||||
/////////////////////////////////////////////
|
||||
KERNEL_DEF(BP_TRANSLATE_AABBS, "translateAABBsLaunch")
|
||||
KERNEL_DEF(BP_MARK_DELETEDPAIRS, "markRemovedPairsLaunch")
|
||||
KERNEL_DEF(BP_UPDATE_DELETEDPAIRS, "markRemovedPairsProjectionsLaunch")
|
||||
KERNEL_DEF(BP_UPDATE_UPDATEDPAIRS, "markUpdatedPairsLaunch")
|
||||
KERNEL_DEF(BP_UPDATE_UPDATEDPAIRS2, "markUpdatedPairsLaunch2")
|
||||
KERNEL_DEF(BP_UPDATE_CREATEDPAIRS, "markCreatedPairsLaunch")
|
||||
KERNEL_DEF(BP_INITIALIZE_SAPBOX, "initializeSapBox1DLaunch")
|
||||
KERNEL_DEF(BP_COMPUTE_ENDPT_HISTOGRAM, "computeEndPtsHistogram")
|
||||
KERNEL_DEF(BP_OUTPUT_ENDPT_HISTOGRAM, "outputEndPtsHistogram")
|
||||
KERNEL_DEF(BP_CREATE_REGIONS, "createRegionsKernel")
|
||||
KERNEL_DEF(BP_COMPUTE_START_REGION_HISTOGRAM, "computeStartRegionsHistogram")
|
||||
KERNEL_DEF(BP_OUTPUT_START_REGION_HISTOGRAM, "outputStartRegionsHistogram")
|
||||
KERNEL_DEF(BP_COMPUTE_REGION_HISTOGRAM, "computeRegionsHistogram")
|
||||
KERNEL_DEF(BP_OUTPUT_REGION_HISTOGRAM, "outputRegionsHistogram")
|
||||
KERNEL_DEF(BP_WRITEOUT_ACTIVE_HISTOGRAM, "writeOutStartAndActiveRegionHistogram")
|
||||
KERNEL_DEF(BP_COMPUTE_ACTIVE_HISTOGRAM, "computeStartAndActiveRegionHistogram")
|
||||
KERNEL_DEF(BP_OUTPUT_ACTIVE_HISTOGRAM, "outputOrderedActiveRegionHistogram")
|
||||
KERNEL_DEF(BP_COMPUTE_OVERLAPCHECKS_HISTOGRAM, "computeOverlapChecksForRegionsHistogram")
|
||||
KERNEL_DEF(BP_OUTPUT_OVERLAPCHECKS_HISTOGRAM, "outputOverlapChecksForRegionHistogram")
|
||||
KERNEL_DEF(BP_CLEAR_NEWFLAG, "clearNewFlagLaunch")
|
||||
KERNEL_DEF(BP_INITIALIZE_RANKS, "initializeRadixRanks")
|
||||
KERNEL_DEF(BP_UDPATE_HANDLES, "updateHandles")
|
||||
KERNEL_DEF(BP_COMPUTE_INCREMENTAL_CMP_COUNTS1, "computeIncrementalComparisonHistograms_Stage1")
|
||||
KERNEL_DEF(BP_COMPUTE_INCREMENTAL_CMP_COUNTS2, "computeIncrementalComparisonHistograms_Stage2")
|
||||
KERNEL_DEF(BP_INCREMENTAL_SAP, "performIncrementalSAP")
|
||||
KERNEL_DEF(BP_GENERATE_FOUNDPAIR_NEWBOUNDS, "generateFoundPairsForNewBoundsRegion")
|
||||
KERNEL_DEF(BP_WRITEOUT_OVERLAPCHECKS_HISTOGRAM_NEWBOUNDS, "writeOutOverlapChecksForInsertedBoundsRegionsHistogram")
|
||||
KERNEL_DEF(BP_ACCUMULATE_REPORT_STAGE_1, "accumulateReportsStage_1")
|
||||
KERNEL_DEF(BP_ACCUMULATE_REPORT_STAGE_2, "accumulateReportsStage_2")
|
||||
KERNEL_DEF(BP_COPY_REPORTS, "copyReports")
|
||||
|
||||
///////////////////////////////////////////////
|
||||
//narrow phase kernels
|
||||
//////////////////////////////////////////////
|
||||
KERNEL_DEF(FINISH_CONTACTS_KERNEL, "finishContactsKernel")
|
||||
KERNEL_DEF(MEM_COPY_BALANCED_KERNEL, "MemCopyBalanced")
|
||||
KERNEL_DEF(REMOVE_CONTACT_MANAGERS_1, "removeContactManagers_Stage1")
|
||||
KERNEL_DEF(REMOVE_CONTACT_MANAGERS_2, "removeContactManagers_Stage2")
|
||||
KERNEL_DEF(REMOVE_CONTACT_MANAGERS_3, "removeContactManagers_Stage3")
|
||||
KERNEL_DEF(REMOVE_CONTACT_MANAGERS_4, "removeContactManagers_Stage4")
|
||||
KERNEL_DEF(REMOVE_CONTACT_MANAGERS_5, "removeContactManagers_Stage5")
|
||||
KERNEL_DEF(COMPACT_LOST_FOUND_PAIRS_1, "prepareLostFoundPairs_Stage1")
|
||||
KERNEL_DEF(COMPACT_LOST_FOUND_PAIRS_2, "prepareLostFoundPairs_Stage2")
|
||||
KERNEL_DEF(SPHERE_KERNEL_MAIN, "sphereNphase_Kernel")
|
||||
KERNEL_DEF(BOX_BOX_KERNEL_MAIN, "boxBoxNphase_Kernel")
|
||||
KERNEL_DEF(CONVEX_PLANE_KERNEL_MAIN, "convexPlaneNphase_Kernel")
|
||||
KERNEL_DEF(CONVEXCORE_PLANE_KERNEL_MAIN, "convexCorePlaneNphase_Kernel")
|
||||
KERNEL_DEF(CONVEXCORE_CONVEX_KERNEL_MAIN, "convexCoreConvexNphase_Kernel")
|
||||
KERNEL_DEF(CONVEXCORE_TRIMESH_KERNEL32_MAIN, "convexCoreTrimeshNphase_Kernel32")
|
||||
KERNEL_DEF(CONVEXCORE_TETMESH_KERNEL32_MAIN, "convexCoreTetmeshNphase_Kernel32")
|
||||
KERNEL_DEF(CONVEXCORE_CLOTHMESH_KERNEL32_MAIN, "convexCoreClothmeshNphase_Kernel32")
|
||||
KERNEL_DEF(CONVEX_CONVEX_KERNEL_EARLY_OUT, "convexConvexNphase_stage1Kernel")
|
||||
KERNEL_DEF(CONVEX_CONVEX_KERNEL_MAIN, "convexConvexNphase_stage2Kernel")
|
||||
KERNEL_DEF(REMOVE_CONTACT_MANAGERS_5_CVXTRI, "removeContactManagers_Stage5_CvxTri")
|
||||
KERNEL_DEF(INITIALIZE_MANIFOLDS, "initializeManifolds")
|
||||
KERNEL_DEF(CONVEX_TRIMESH_MIDPHASE, "midphaseGeneratePairs")
|
||||
KERNEL_DEF(CONVEX_TRIMESH_CORE, "convexTrimeshNarrowphase")
|
||||
KERNEL_DEF(CONVEX_TRIMESH_SORT_TRIANGLES, "sortTriangleIndices")
|
||||
KERNEL_DEF(CONVEX_TRIMESH_POST_PROCESS, "convexTrimeshPostProcess")
|
||||
KERNEL_DEF(CONVEX_HEIGHTFIELD_POST_PROCESS, "convexHeightfieldPostProcess")
|
||||
KERNEL_DEF(CONVEX_TRIMESH_CORRELATE, "convexTrimeshCorrelate")
|
||||
KERNEL_DEF(CONVEX_TRIMESH_FINISHCONTACTS, "convexTrimeshFinishContacts")
|
||||
KERNEL_DEF(CONVEX_HEIGHTFIELD_MIDPHASE, "convexHeightFieldMidphase")
|
||||
KERNEL_DEF(CONVEX_HEIGHTFIELD_CORE, "convexHeightfieldNarrowphase")
|
||||
KERNEL_DEF(SPHERE_TRIMESH_CORE, "sphereTrimeshNarrowphase")
|
||||
KERNEL_DEF(SPHERE_HEIGHTFIELD_CORE, "sphereHeightfieldNarrowphase")
|
||||
KERNEL_DEF(TRIMESH_PLANE_CORE, "trimeshPlaneNarrowphase")
|
||||
KERNEL_DEF(TRIMESH_HEIGHTFIELD_CORE, "trimeshHeightfieldNarrowphase")
|
||||
KERNEL_DEF(TRIMESH_TRIMESH_CORE, "triangleTriangleCollision")
|
||||
KERNEL_DEF(TRIMESH_TRIMESH_OVERLAP, "triangleTriangleOverlaps")
|
||||
|
||||
KERNEL_DEF(EVALUATE_POINT_DISTANCES_SDF, "evaluatePointDistancesSDFBatch")
|
||||
|
||||
KERNEL_DEF(UPDATE_FRICTION_PATCHES, "updateFrictionPatches")
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//solver kernels
|
||||
///////////////////////////////////////////////////////////////
|
||||
KERNEL_DEF(PRE_INTEGRATION, "preIntegrationLaunch")
|
||||
KERNEL_DEF(CONTACT_CONSTRAINT_PREPREP_BLOCK, "constraintContactBlockPrePrepLaunch")
|
||||
KERNEL_DEF(JOINT_CONSTRAINT_PREPREP, "constraint1DPrePrepLaunch")
|
||||
KERNEL_DEF(JOINT_CONSTRAINT_PREPREP_BLOCK, "constraint1DBlockPrePrepLaunch")
|
||||
KERNEL_DEF(JOINT_CONSTRAINT_PREPARE_BLOCK_PARALLEL, "jointConstraintBlockPrepareParallelLaunch")
|
||||
KERNEL_DEF(CONTACT_CONSTRAINT_PREPARE_BLOCK_PARALLEL, "contactConstraintBlockPrepareParallelLaunch")
|
||||
KERNEL_DEF(ZERO_BODIES, "ZeroBodies")
|
||||
KERNEL_DEF(SOLVE_BLOCK_PARTITION, "solveBlockPartition")
|
||||
KERNEL_DEF(CONCLUDE_BLOCKS, "concludeBlocks")
|
||||
KERNEL_DEF(WRITEBACK_BLOCKS, "writebackBlocks")
|
||||
KERNEL_DEF(WRITE_BACK_BODIES, "writeBackBodies")
|
||||
KERNEL_DEF(COMPUTE_AVERAGE_VELOCITY, "computeAverageSolverBodyVelocity")
|
||||
KERNEL_DEF(PROPAGATE_BODY_VELOCITY, "propagateSolverBodyVelocity")
|
||||
KERNEL_DEF(INITIALIZE_INPUT_AND_RANKS_B, "initialRanksAndBodyIndexB")
|
||||
KERNEL_DEF(INITIALIZE_INPUT_AND_RANKS_A, "initialRanksAndBodyIndexA")
|
||||
KERNEL_DEF(RADIXSORT_SINGLEBLOCK, "bodyInputAndRanksSingleBlockLaunch")
|
||||
KERNEL_DEF(RADIXSORT_CALCULATERANKS, "bodyInputAndRanksBlocksLaunch")
|
||||
KERNEL_DEF(REORGANIZE_THRESHOLDSTREAM, "reorganizeThresholdElements")
|
||||
KERNEL_DEF(COMPUTE_ACCUMULATED_THRESHOLDSTREAM, "computeAccumulateThresholdStream")
|
||||
KERNEL_DEF(OUTPUT_ACCUMULATED_THRESHOLDSTREAM, "outputAccumulateThresholdStream")
|
||||
KERNEL_DEF(WRITEOUT_ACCUMULATEDFORCEPEROBJECT, "writeoutAccumulatedForcePerObject")
|
||||
KERNEL_DEF(COMPUTE_EXCEEDEDFORCE_THRESHOLDELEMENT_INDICE, "computeExceededForceThresholdElementIndice")
|
||||
KERNEL_DEF(OUTPUT_EXCEEDEDFORCE_THRESHOLDELEMENT_INDICE, "outputExceededForceThresholdElementIndice")
|
||||
KERNEL_DEF(SET_THRESHOLDELEMENT_MASK, "setThresholdElementsMask")
|
||||
KERNEL_DEF(COMPUTE_THRESHOLDELEMENT_MASK_INDICES, "computeThresholdElementMaskIndices")
|
||||
KERNEL_DEF(OUTPUT_THRESHOLDELEMENT_MASK_INDICES, "outputThresholdPairsMaskIndices")
|
||||
KERNEL_DEF(CREATE_FORCECHANGE_THRESHOLDELEMENTS, "createForceChangeThresholdElements")
|
||||
KERNEL_DEF(SOLVE_UNIFIED, "solveBlockUnified")
|
||||
KERNEL_DEF(PROPAGATE_STATIC_SOLVER_VELOCITIES, "propagateStaticSolverBodyVelocities")
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//integration kernels
|
||||
///////////////////////////////////////////////////////////////
|
||||
KERNEL_DEF(INTEGRATE_CORE_PARALLEL, "integrateCoreParallelLaunch")
|
||||
KERNEL_DEF(CLEAR_FRICTION_PATCH_COUNTS, "clearFrictionPatchCounts")
|
||||
KERNEL_DEF(DMA_CHANGED_ELEMS, "dmaBackChangedElems")
|
||||
KERNEL_DEF(BP_SIGNAL_COMPLETE, "bpSignalComplete")
|
||||
|
||||
KERNEL_DEF(DMA_CONSTRAINT_RESIDUAL, "dmaConstraintResidual")
|
||||
KERNEL_DEF(DMA_ARTICULATION_RESIDUAL, "dmaArticulationResidual")
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//articulation kernels
|
||||
//////////////////////////////////////////////////////////////
|
||||
KERNEL_DEF(ARTI_DMA_DATA, "dmaBackArticulationDataLaunch")
|
||||
KERNEL_DEF(ARTI_STATIC_BATCH_PREP_FIRST, "artiSumInternalContactAndJointBatches1Launch")
|
||||
KERNEL_DEF(ARTI_STATIC_BATCH_PREP_SECOND, "artiSumInternalContactAndJointBatches2Launch")
|
||||
KERNEL_DEF(ARTI_SOLVE_INTERNAL_CONSTRAINTS, "artiSolveInternalConstraints1T")
|
||||
KERNEL_DEF(ARTI_SOLVE_INTERNAL_CONSTRAINTS_TGS, "artiSolveInternalConstraintsTGS1T")
|
||||
KERNEL_DEF(ARTI_SOLVE_INTERNAL_TENDON_AND_MIMIC_JOINT, "artiSolveInternalTendonAndMimicJointConstraints1T")
|
||||
KERNEL_DEF(ARTI_COMPUTE_UNCONSTRAINED, "computeUnconstrainedVelocities1TLaunch")
|
||||
KERNEL_DEF(ARTI_COMPUTE_SPATIAL_PARTIAL, "computeUnconstrainedSpatialInertiaLaunchPartial1T")
|
||||
KERNEL_DEF(ARTI_COMPUTE_UNCONSTRAINED_SPATIAL_INERTIA, "computeUnconstrainedSpatialInertiaLaunch1T")
|
||||
KERNEL_DEF(ARTI_COMPUTE_MASS_MATRIX, "computeMassMatrix1T")
|
||||
KERNEL_DEF(ARTI_COMPUTE_UNCONSTRAINED_ACCEL, "computeUnconstrainedAccelerationsLaunch1T")
|
||||
KERNEL_DEF(ARTI_SAVE_VELOCITY_PGS, "artiSaveVelocity1TPGS")
|
||||
KERNEL_DEF(ARTI_UPDATE_BODIES, "updateBodiesLaunch1T")
|
||||
KERNEL_DEF(ARTI_UPDATE_BODIES2, "updateBodiesLaunch_Part2")
|
||||
KERNEL_DEF(ARTI_UPDATE_BODIES3, "updateBodiesLaunch_Part3")
|
||||
KERNEL_DEF(ARTI_SETUP_INTERNAL, "setupInternalConstraintLaunch1T")
|
||||
KERNEL_DEF(ARTI_CONTACT_PREP, "artiContactConstraintBlockPrepareLaunch")
|
||||
KERNEL_DEF(ARTI_JOINT_PREP, "artiJointConstraintBlockPrepareParallelLaunch")
|
||||
KERNEL_DEF(ARTI_SOLVE_BLOCK_PARTITION, "artiSolveBlockPartition")
|
||||
KERNEL_DEF(ARTI_UPDATE_KINEMATIC, "artiUpdateKinematic")
|
||||
KERNEL_DEF(ARTI_STEP_TGS, "stepArticulation1TTGS")
|
||||
KERNEL_DEF(ARTI_CONTACT_PREP_TGS, "artiTGSContactConstraintBlockPrepareLaunch")
|
||||
KERNEL_DEF(ARTI_JOINT_PREP_TGS, "artiTGSJointConstraintBlockPrepareParallelLaunch")
|
||||
KERNEL_DEF(ARTI_OUTPUT_VELOCITY, "artiOutputVelocity")
|
||||
KERNEL_DEF(ARTI_PUSH_IMPULSE, "artiPushImpulse")
|
||||
KERNEL_DEF(ARTI_COMPUTE_DEPENDENCIES, "artiComputeDependencies")
|
||||
KERNEL_DEF(ARTI_PROPAGATE_IMPULSE_PGS, "artiPropagateImpulses2PGS")
|
||||
KERNEL_DEF(ARTI_PROPAGATE_IMPULSE_TGS, "artiPropagateImpulses2TGS")
|
||||
KERNEL_DEF(ARTI_PROPAGATE_VELOCITY, "artiPropagateVelocity")
|
||||
KERNEL_DEF(ARTI_PROPAGATE_VELOCITY_TGS, "artiPropagateVelocityTGS")
|
||||
KERNEL_DEF(ARTI_SUM_SELF, "artiSumSelfContactAndJointBatches")
|
||||
KERNEL_DEF(ARTI_PROPAGATE_RIGID_IMPULSES_AND_SOLVE_SELF, "artiPropagateRigidImpulsesAndSolveSelfConstraints1T")
|
||||
KERNEL_DEF(ARTI_PROPAGATE_RIGID_IMPULSES_AND_SOLVE_SELF_TGS, "artiPropagateRigidImpulsesAndSolveSelfConstraintsTGS1T")
|
||||
KERNEL_DEF(ARTI_APPLY_TGS_SUBSTEP_FORCES, "artiApplyTgsSubstepForces")
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//TGS solver kernels
|
||||
///////////////////////////////////////////////////////////////
|
||||
KERNEL_DEF(ZERO_BODIES_TGS, "ZeroBodiesTGS")
|
||||
KERNEL_DEF(CONCLUDE_BLOCKS_TGS, "concludeBlocksTGS")
|
||||
KERNEL_DEF(WRITEBACK_BLOCKS_TGS, "writebackBlocksTGS")
|
||||
KERNEL_DEF(WRITE_BACK_BODIES_TGS, "writeBackBodiesTGS")
|
||||
KERNEL_DEF(COMPUTE_AVERAGE_VELOCITY_TGS, "computeAverageSolverBodyVelocityTGS")
|
||||
KERNEL_DEF(INTEGRATE_CORE_PARALLEL_TGS, "integrateCoreParallelLaunchTGS")
|
||||
KERNEL_DEF(INIT_STATIC_KINEMATICS, "initStaticKinematics")
|
||||
KERNEL_DEF(TGS_PRE_INTEGRATION, "preIntegrationLaunchTGS")
|
||||
KERNEL_DEF(TGS_INIT_SOLVER_VELS, "initializeSolverVelocitiesTGS")
|
||||
KERNEL_DEF(TGS_JOINT_CONSTRAINT_PREPARE_BLOCK_PARALLEL, "jointConstraintBlockPrepareParallelLaunchTGS")
|
||||
KERNEL_DEF(TGS_CONTACT_CONSTRAINT_PREPARE_BLOCK_PARALLEL, "contactConstraintBlockPrepareParallelLaunchTGS")
|
||||
KERNEL_DEF(PROPAGATE_AVERAGE_VELOCITY_TGS, "propagateAverageSolverBodyVelocityTGS")
|
||||
KERNEL_DEF(PROPAGATE_STATIC_SOLVER_VELOCITIES_TGS, "propagateStaticSolverBodyVelocitiesTGS")
|
||||
KERNEL_DEF(APPLY_TGS_SUBSTEP_GRAVITY, "applyTGSSubstepGravity")
|
||||
KERNEL_DEF(MARK_ACTIVE_SLAB_PGS, "markActiveSlabPGS")
|
||||
KERNEL_DEF(MARK_ACTIVE_SLAB_TGS, "markActiveSlabTGS")
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//radix sort kernels
|
||||
//////////////////////////////////////////////////////////////////
|
||||
KERNEL_DEF(RS_MULTIBLOCK, "radixSortMultiBlockLaunch")
|
||||
KERNEL_DEF(RS_CALCULATERANKS_MULTIBLOCK, "radixSortMultiCalculateRanksLaunch")
|
||||
KERNEL_DEF(RS_MULTIBLOCK_COUNT, "radixSortMultiBlockLaunchWithCount")
|
||||
KERNEL_DEF(RS_CALCULATERANKS_MULTIBLOCK_COUNT, "radixSortMultiCalculateRanksLaunchWithCount")
|
||||
KERNEL_DEF(RS_MULTIBLOCK_NO_COUNT, "radixSortMultiBlockLaunchWithoutCount")
|
||||
KERNEL_DEF(RS_CALCULATERANKS_MULTIBLOCK_NO_COUNT, "radixSortMultiCalculateRanksLaunchWithoutCount")
|
||||
KERNEL_DEF(RS_COPY_HIGH_32BITS, "radixSortCopyHigh32Bits")
|
||||
KERNEL_DEF(RS_DOUBLE_COPY_HIGH_32BITS2, "radixSortDoubleCopyHigh32Bits")
|
||||
KERNEL_DEF(RS_COPY_VALUE, "radixSortCopy")
|
||||
KERNEL_DEF(RS_DOUBLE_COPY_VALUE, "radixSortDoubleCopy")
|
||||
KERNEL_DEF(RS_COPY_BITS2, "radixSortCopyBits2")
|
||||
KERNEL_DEF(RS_COPY_VALUE2, "radixSortCopy2")
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//accumulate rigid body delta velocity kernels
|
||||
//those are shared by soft body and particle system
|
||||
////////////////////////////////////////////////////////////////
|
||||
KERNEL_DEF(ACCUMULATE_DELTAVEL_RIGIDBODY_FIRST, "accumulateDeltaVRigidFirstLaunch")
|
||||
KERNEL_DEF(ACCUMULATE_DELTAVEL_RIGIDBODY_SECOND, "accumulateDeltaVRigidSecondLaunch")
|
||||
KERNEL_DEF(ACCUMULATE_DELTAVEL_RIGIDBODY_SECOND_MULTI1, "accumulateDeltaVRigidSecondLaunchMultiStage1")
|
||||
KERNEL_DEF(ACCUMULATE_DELTAVEL_RIGIDBODY_SECOND_MULTI2, "accumulateDeltaVRigidSecondLaunchMultiStage2")
|
||||
KERNEL_DEF(ACCUMULATE_DELTAVEL_RIGIDBODY_MULTI_CLEAR, "clearDeltaVRigidSecondLaunchMulti")
|
||||
|
||||
|
||||
|
||||
KERNEL_DEF(RIGID_SUM_STATIC_CONTACT1, "rigidSumInternalContactAndJointBatches1")
|
||||
KERNEL_DEF(RIGID_SUM_STATIC_CONTACT2, "rigidSumInternalContactAndJointBatches2")
|
||||
KERNEL_DEF(RIGID_SOLVE_STATIC_CONSTRAINTS, "solveStaticBlock")
|
||||
KERNEL_DEF(RIGID_SOLVE_STATIC_CONSTRAINTS_TGS, "solveStaticBlockTGS")
|
||||
KERNEL_DEF(RIGID_SOLVE_WHOLE_ISLAND_TGS, "solveWholeIslandTGS")
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//particle system kernels
|
||||
///////////////////////////////////////////////////////////////
|
||||
KERNEL_DEF(PS_UPDATE_UNSORTED_ARRAY, "ps_updateUnsortedArrayLaunch")
|
||||
KERNEL_DEF(PS_UPDATE_BUFFER_DATA, "ps_updateUserBufferLaunch")
|
||||
KERNEL_DEF(PS_UPDATE_DIFFUSE_UNSORTED_ARRAY, "ps_updateUnsortedDiffuseArrayLaunch")
|
||||
KERNEL_DEF(PS_PREINTEGRATION, "ps_preIntegrateLaunch")
|
||||
KERNEL_DEF(PS_PRE_DIFFUSE_INTEGRATION, "ps_preDiffuseIntegrateLaunch")
|
||||
KERNEL_DEF(PS_UPDATE_BOUND_FRIST, "ps_updateBoundFirstPassLaunch")
|
||||
KERNEL_DEF(PS_UPDATE_BOUND_SECOND, "ps_updateBoundSecondPassLaunch")
|
||||
KERNEL_DEF(PS_CALCULATE_HASH, "ps_calculateHashLaunch")
|
||||
KERNEL_DEF(PS_CALCULATE_HASH_FOR_DIFFUSE_PARTICLES, "ps_calculateHashForDiffuseParticlesLaunch")
|
||||
KERNEL_DEF(PS_REORDER_PARTICLE_FIND_CELLSTARTEND, "ps_reorderDataAndFindCellStartLaunch")
|
||||
KERNEL_DEF(PS_PARTICLE_SELF_COLLISION, "ps_selfCollisionLaunch")
|
||||
KERNEL_DEF(PS_PRIMITIVES_BOUND_FIRST, "ps_primitivesBoundFirstPassLaunch")
|
||||
KERNEL_DEF(PS_PRIMITIVES_BOUND_SECOND, "ps_primitivesBoundSecondPassLaunch")
|
||||
KERNEL_DEF(PS_PRIMITIVES_COLLISION, "ps_primitivesCollisionLaunch")
|
||||
KERNEL_DEF(PS_CONVEX_COLLISION, "ps_convexCollisionLaunch")
|
||||
KERNEL_DEF(PS_PRIMITIVES_DIFFUSE_COLLISION, "ps_primitivesDiffuseCollisionLaunch")
|
||||
KERNEL_DEF(PS_CONVEX_DIFFUSE_COLLISION, "ps_convexDiffuseCollisionLaunch")
|
||||
KERNEL_DEF(PS_TRIMESH_COLLISION, "ps_meshCollisonLaunch")
|
||||
KERNEL_DEF(PS_SDF_TRIMESH_COLLISION, "ps_sdfMeshCollisonLaunch")
|
||||
KERNEL_DEF(PS_HEIGHTFIELD_COLLISION, "ps_heightfieldCollisonLaunch")
|
||||
KERNEL_DEF(PS_REORDER_PRIMITIVE_CONTACTS, "ps_reorderPrimitiveContactsLaunch")
|
||||
KERNEL_DEF(PS_CONTACT_PREPARE, "ps_contactPrepareLaunch")
|
||||
KERNEL_DEF(PS_SOLVE_PC_PARTICLE, "ps_solvePCOutputParticleDeltaVLaunch")
|
||||
KERNEL_DEF(PS_SOLVE_PC_RIGID, "ps_solvePCOutputRigidDeltaVLaunch")
|
||||
KERNEL_DEF(PS_SOLVE_ONEWAY_CONTACTS, "ps_solveOneWayContactDeltaVLaunch")
|
||||
KERNEL_DEF(PS_FIND_RANGESTARTEND_PARTICLE_FIRST, "ps_findStartEndParticleFirstLaunch")
|
||||
KERNEL_DEF(PS_FIND_RANGESTARTEND_PARTICLE_SECONE, "ps_findStartEndParticleSecondLaunch")
|
||||
KERNEL_DEF(PS_ACCUMULATE_DELTAVEL_PARTICLE, "ps_accumulateDeltaVParticleLaunch")
|
||||
KERNEL_DEF(PS_UPDATE_PARTICLE, "ps_updateParticleLaunch")
|
||||
KERNEL_DEF(PS_INTEGRATION, "ps_integrateLaunch")
|
||||
KERNEL_DEF(PS_CALCULATE_DENSITIES_AND_POTENTIALS, "ps_calculateDensityAndPotentialLaunch")
|
||||
KERNEL_DEF(PS_SOLVE_DENSITIES, "ps_solveDensityLaunch")
|
||||
KERNEL_DEF(PS_APPLY_DELTAS, "ps_applyDeltaLaunch")
|
||||
KERNEL_DEF(PS_VORTICITY_CONFINEMENT, "ps_vorticityConfinementLaunch")
|
||||
KERNEL_DEF(PS_SOLVE_VELOCITIES, "ps_solveVelocityLaunch")
|
||||
KERNEL_DEF(PS_UPDATE_REMAP_VERTS, "ps_updateRemapVertsLaunch")
|
||||
KERNEL_DEF(PS_SOLVE_SPRINGS, "ps_solveSpringsLaunch")
|
||||
KERNEL_DEF(PS_INITIALIZE_SPRINGS, "ps_initializeSpringsLaunch")
|
||||
KERNEL_DEF(PS_AVERAGEVERTS, "ps_averageVertsLaunch")
|
||||
KERNEL_DEF(PS_AERODYNAMIC_1, "ps_solveAerodynamics1Launch")
|
||||
KERNEL_DEF(PS_AERODYNAMIC_2, "ps_solveAerodynamics2Launch")
|
||||
KERNEL_DEF(PS_CALCULATE_INFLATABLE_VOLUME, "ps_calculateInflatableVolume")
|
||||
KERNEL_DEF(PS_SOLVE_INFLATABLE_VOLUME, "ps_solveInflatableVolume")
|
||||
KERNEL_DEF(PS_SOLVE_SHAPES, "ps_solveShapes")
|
||||
KERNEL_DEF(PS_PREP_RIGID_ATTACHMENTS, "ps_rigidAttachmentPrepareLaunch")
|
||||
KERNEL_DEF(PS_SOLVE_RIGID_ATTACHMENTS, "ps_solveRigidAttachmentsLaunch")
|
||||
KERNEL_DEF(PS_UPDATE_VOLUME_BOUND, "ps_update_volume_bound")
|
||||
KERNEL_DEF(PS_UPDATE_SPRING, "ps_updateSprings")
|
||||
KERNEL_DEF(PS_ACCUMULATE_STATIC_DENSITY, "ps_accumulateStaticDensity")
|
||||
KERNEL_DEF(PS_ACCUMULATE_RIGID_DENSITY, "ps_accumulateRigidDensity")
|
||||
KERNEL_DEF(PS_DIFFUSE_PARTICLES_ONE_WAY_COLLISION, "ps_diffuseParticleOneWayCollision")
|
||||
KERNEL_DEF(PS_DIFFUSE_PARTICLES_UPDATE_PBF, "ps_diffuseParticleUpdatePBF")
|
||||
KERNEL_DEF(PS_DIFFUSE_PARTICLES_COMPACT, "ps_diffuseParticleCompact")
|
||||
KERNEL_DEF(PS_DIFFUSE_PARTICLES_CREATE, "ps_diffuseParticleCreate")
|
||||
KERNEL_DEF(PS_DIFFUSE_PARTICLES_COPY, "ps_diffuseParticleCopy")
|
||||
KERNEL_DEF(PS_DIFFUSE_PARTICLES_SUM, "ps_diffuseParticleSum")
|
||||
KERNEL_DEF(PS_FIND_RANGESTARTEND_FEM_FIRST, "ps_findStartEndFEMFirstLaunch")
|
||||
KERNEL_DEF(PS_RANGESTARTEND_FEM_SECONE, "ps_findStartEndFEMSecondLaunch")
|
||||
KERNEL_DEF(PS_ACCUMULATE_FEM_PARTICLE_DELTA, "ps_accumulateFEMParticleDeltaVLaunch")
|
||||
KERNEL_DEF(PS_STEP_PARTICLES, "ps_stepParticlesLaunch")
|
||||
KERNEL_DEF(PS_SOLVE_PC_PARTICLE_TGS, "ps_solvePCOutputParticleDeltaVTGSLaunch")
|
||||
KERNEL_DEF(PS_SOLVE_PC_RIGID_TGS, "ps_solvePCOutputRigidDeltaVTGSLaunch")
|
||||
KERNEL_DEF(PS_SOLVE_RIGID_ATTACHMENTS_TGS, "ps_solveRigidAttachmentsTGSLaunch")
|
||||
KERNEL_DEF(PS_FINALIZE_PARTICLES, "ps_finalizeParticlesLaunch")
|
||||
KERNEL_DEF(PS_UPDATE_MATERIALS, "ps_updateMaterials")
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//fem shared kernel names
|
||||
//////////////////////////////////////////////////////////
|
||||
KERNEL_DEF(FEM_ATTACHMENT_CONSTRAINT_PREP, "femAttachmentPrepareLaunch")
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//softbody kernel names
|
||||
//////////////////////////////////////////////////////////
|
||||
KERNEL_DEF(SB_SIM_PREINTEGRATION, "sb_gm_preIntegrateLaunch")
|
||||
KERNEL_DEF(SB_REFITBOUND, "sb_refitBoundLaunch")
|
||||
KERNEL_DEF(SB_MIDPHASE_PRIMITIVES, "sb_midphaseGeneratePairsLaunch")
|
||||
KERNEL_DEF(SB_PRIMITIVES_CG, "sb_primitiveContactGenLaunch")
|
||||
KERNEL_DEF(SB_SB_MIDPHASE, "sb_sbMidphaseGeneratePairsLaunch")
|
||||
KERNEL_DEF(SB_PS_MIDPHASE, "sb_psMidphaseGeneratePairsLaunch")
|
||||
KERNEL_DEF(SB_PS_CG, "sb_psContactGenLaunch")
|
||||
KERNEL_DEF(SB_CLOTH_MIDPHASE, "sb_clothMidphaseGeneratePairsLaunch")
|
||||
KERNEL_DEF(SB_CLOTH_CG, "sb_clothContactGenLaunch")
|
||||
KERNEL_DEF(SB_CLOTH_VERT_MIDPHASE, "sb_clothVertMidphaseGeneratePairsLaunch")
|
||||
KERNEL_DEF(SB_CLOTH_VERT_CG, "sb_clothVertContactGenLaunch")
|
||||
KERNEL_DEF(SB_MESH_MIDPHASE, "sb_meshMidphaseGeneratePairsLaunch")
|
||||
KERNEL_DEF(SB_SDF_MESH_MIDPHASE, "sb_sdfMeshMidphaseGeneratePairsLaunch")
|
||||
KERNEL_DEF(SB_MESH_CG, "sb_meshContactGenLaunch")
|
||||
KERNEL_DEF(SB_HF_MIDPHASE, "sb_heightfieldMidphaseGeneratePairsLaunch")
|
||||
KERNEL_DEF(SB_HF_CG, "sb_heightfieldContactGenLaunch")
|
||||
KERNEL_DEF(SB_SELFCOLLISION_MIDPHASE, "sb_selfCollisionMidphaseGeneratePairsLaunch")
|
||||
KERNEL_DEF(SB_REORDER_PS_CONTACTS, "sb_reorderPSContactsLaunch")
|
||||
KERNEL_DEF(SB_RIGID_ATTACHMENT_CONSTRAINT_PREP, "sb_rigidAttachmentPrepareLaunch")
|
||||
KERNEL_DEF(SB_RS_CONTACTPREPARE, "sb_rigidContactPrepareLaunch")
|
||||
KERNEL_DEF(SB_SS_CONTACTPREPARE, "sb_softbodyContactPrepareLaunch")
|
||||
KERNEL_DEF(SB_SC_CONTACTPREPARE, "sb_clothContactPrepareLaunch")
|
||||
KERNEL_DEF(SB_SP_CONTACTPREPARE, "sb_particleContactPrepareLaunch")
|
||||
KERNEL_DEF(SB_SOLVE_RIGID_SOFT_ATTACHMENT, "sb_solveRigidSoftAttachmentLaunch")
|
||||
KERNEL_DEF(SB_SOLVE_SOFTBODY_ATTACHMENT_DELTA, "sb_solveOutputSoftBodyAttachmentDeltaVLaunch")
|
||||
KERNEL_DEF(SB_SOLVE_CLOTH_ATTACHMENT_DELTA, "sb_solveOutputClothAttachmentDeltaVLaunch")
|
||||
KERNEL_DEF(SB_SOLVE_PARTICLE_ATTACHMENT_DELTA, "sb_solveOutputParticleAttachmentDeltaVLaunch")
|
||||
KERNEL_DEF(SB_QUERY_RIGID_SOFT_REFERENCE_COUNT, "sb_queryRigidSoftContactReferenceCountLaunch")
|
||||
KERNEL_DEF(SB_SOLVE_RIGID_SOFT_COLLISION, "sb_solveRigidSoftCollisionLaunch")
|
||||
KERNEL_DEF(SB_SOLVE_SOFT_SOFT_BOTH_DELTA, "sb_solveOutputSSDeltaVLaunch")
|
||||
KERNEL_DEF(SB_SOLVE_SOFT_CLOTH_BOTH_DELTA, "sb_solveOutputSCDeltaVLaunch")
|
||||
KERNEL_DEF(SB_SOLVE_PARTICLE_SOFT_DELTA, "sb_solveOutputSPDeltaVLaunch")
|
||||
KERNEL_DEF(SB_SOLVE_PARTICLE_PARTICLE_DELTA, "sb_solveOutputParticleDeltaVLaunch")
|
||||
KERNEL_DEF(SB_GM_CP_SOLVE_TETRA, "sb_gm_cp_solveTetrahedronsPartitionLaunch")
|
||||
KERNEL_DEF(SB_GM_CP_SOLVE_TETRA_JACOBI_PARTITION, "sb_gm_cp_solveTetrahedronsJacobiPartitionLaunch")
|
||||
KERNEL_DEF(SB_GM_UPDATETETMODELVERTS, "sb_gm_updateTetModelVertsLaunch")
|
||||
KERNEL_DEF(SB_GM_ZERO_TETMULTIPLIERS, "sb_gm_zeroTetMultipliers")
|
||||
KERNEL_DEF(SB_GM_CP_AVERAGEVERTS, "sb_gm_cp_averageVertsLaunch")
|
||||
KERNEL_DEF(SB_UPDATETETRAROTATIONS, "sb_updateTetrahedraRotationsLaunch")
|
||||
KERNEL_DEF(SB_GM_UPDATETETRAROTATIONS, "sb_gm_updateTetrahedraRotationsLaunch")
|
||||
KERNEL_DEF(SB_GM_APPLY_EXTERNAL_DELTAS, "sb_gm_applyExternalDeltasLaunch")
|
||||
KERNEL_DEF(SB_GM_APPLY_DEFORMATION_DELTAS, "sb_gm_applyDeformationDeltasLaunch")
|
||||
KERNEL_DEF(SB_OTHER_CONTACT_REMAP_TO_SIM, "sb_other_contact_remap_to_simLaunch")
|
||||
KERNEL_DEF(SB_FEM_CONTACT_REMAP_TO_SIM, "sb_fem_contact_remap_to_simLaunch")
|
||||
KERNEL_DEF(SB_GM_STEPSOFTBODY, "sb_gm_stepSoftbodyLaunch")
|
||||
KERNEL_DEF(SB_SOLVE_RIGID_SOFT_ATTACHMENT_TGS, "sb_solveRigidSoftAttachmentLaunchTGS")
|
||||
KERNEL_DEF(SB_QUERY_RIGID_SOFT_REFERENCE_COUNT_TGS, "sb_queryRigidSoftContactReferenceCountLaunchTGS")
|
||||
KERNEL_DEF(SB_SOLVE_RIGID_SOFT_COLLISION_TGS, "sb_solveRigidSoftCollisionLaunchTGS")
|
||||
KERNEL_DEF(SB_SOLVE_SOFT_SOFT_BOTH_DELTA_TGS, "sb_solveOutputSSDeltaVLaunchTGS")
|
||||
KERNEL_DEF(SB_CALC_STRESS, "sb_calculateStressLaunch")
|
||||
KERNEL_DEF(SB_PLASTIC_DEFORM, "sb_plasticDeformLaunch")
|
||||
KERNEL_DEF(SB_INIT_PLASTIC_DEFORM, "sb_initPlasticDeformLaunch")
|
||||
KERNEL_DEF(SB_PLASTIC_DEFORM2, "sb_plasticDeformLaunch2")
|
||||
KERNEL_DEF(SB_COPY_OR_APPLY_SOFTBODY_DATA_DEPRECATED, "sb_copyOrApplySoftBodyDataDEPRECATED")
|
||||
KERNEL_DEF(SB_GM_FINALIZE_VELOCITIES, "sb_gm_finalizeVelocitiesLaunch")
|
||||
KERNEL_DEF(SB_SLEEPING, "sb_sleeping")
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// Direct API
|
||||
//////////////////////////////////////////////////////////
|
||||
KERNEL_DEF(COMPRESS_CONTACT_STAGE_1, "compressContactStage1")
|
||||
KERNEL_DEF(COMPRESS_CONTACT_STAGE_2, "compressContactStage2")
|
||||
KERNEL_DEF(COMPUTE_ARTI_DENSE_JACOBIANS, "computeArtiDenseJacobians")
|
||||
KERNEL_DEF(COMPUTE_ARTI_MASS_MATRICES, "computeArtiMassMatrices")
|
||||
KERNEL_DEF(COMPUTE_ARTI_GRAVITY_FORCES, "computeArtiGravityForces")
|
||||
KERNEL_DEF(COMPUTE_ARTI_CENTRIFUGAL_FORCES, "computeArtiCentrifugalForces")
|
||||
KERNEL_DEF(COMPUTE_ARTI_COM, "computeArtiCOM")
|
||||
KERNEL_DEF(COMPUTE_ARTI_CENTROIDAL_MATRICES, "computeArtiCentroidalMomentumMatrices")
|
||||
KERNEL_DEF(APPLY_PARTICLE_BUFFER_DATA_DEPRECATED, "applyParticleBufferDataDEPRECATED")
|
||||
KERNEL_DEF(RIGID_DYNAMIC_GET_GLOBAL_POSE, "getRigidDynamicGlobalPose")
|
||||
KERNEL_DEF(RIGID_DYNAMIC_GET_LINVEL, "getRigidDynamicLinearVelocity")
|
||||
KERNEL_DEF(RIGID_DYNAMIC_GET_ANGVEL, "getRigidDynamicAngularVelocity")
|
||||
KERNEL_DEF(RIGID_DYNAMIC_GET_LINACCEL, "getRigidDynamicLinearAcceleration")
|
||||
KERNEL_DEF(RIGID_DYNAMIC_GET_ANGACCEL, "getRigidDynamicAngularAcceleration")
|
||||
KERNEL_DEF(RIGID_DYNAMIC_SET_GLOBAL_POSE, "setRigidDynamicGlobalPose")
|
||||
KERNEL_DEF(RIGID_DYNAMIC_SET_LINVEL, "setRigidDynamicLinearVelocity")
|
||||
KERNEL_DEF(RIGID_DYNAMIC_SET_ANGVEL, "setRigidDynamicAngularVelocity")
|
||||
KERNEL_DEF(RIGID_DYNAMIC_SET_FORCE, "setRigidDynamicForce")
|
||||
KERNEL_DEF(RIGID_DYNAMIC_SET_TORQUE, "setRigidDynamicTorque")
|
||||
KERNEL_DEF(ARTI_GET_DOF_STATES, "getArtiDofStates")
|
||||
KERNEL_DEF(ARTI_GET_TRANSFORM_STATES, "getArtiTransformStates")
|
||||
KERNEL_DEF(ARTI_GET_VELOCITY_STATES, "getArtiVelocityStates")
|
||||
KERNEL_DEF(ARTI_GET_SPATIAL_FORCE_STATES, "getArtiSpatialForceStates")
|
||||
KERNEL_DEF(ARTI_SET_DOF_STATES, "setArtiDofStates")
|
||||
KERNEL_DEF(ARTI_SET_ROOT_GLOBAL_POSE_STATE, "setArtiRootGlobalPoseState")
|
||||
KERNEL_DEF(ARTI_SET_ROOT_VELOCITY_STATE, "setArtiRootVelocityState")
|
||||
KERNEL_DEF(ARTI_SET_LINK_FORCE_STATE, "setArtiLinkForceState")
|
||||
KERNEL_DEF(ARTI_SET_LINK_TORQUE_STATE, "setArtiLinkTorqueState")
|
||||
KERNEL_DEF(ARTI_SET_TENDON_STATE, "setArtiTendonState")
|
||||
KERNEL_DEF(ARTI_SET_SPATIAL_TENDON_ATTACHMENT_STATE, "setArtiSpatialTendonAttachmentState")
|
||||
KERNEL_DEF(ARTI_SET_FIXED_TENDON_JOINT_STATE, "setArtiFixedTendonJointState")
|
||||
KERNEL_DEF(ARTI_GET_TENDON_STATE, "getArtiTendonState")
|
||||
KERNEL_DEF(ARTI_GET_SPATIAL_TENDON_ATTACHMENT_STATE, "getArtiSpatialTendonAttachmentState")
|
||||
KERNEL_DEF(ARTI_GET_FIXED_TENDON_JOINT_STATE, "getArtiFixedTendonJointState")
|
||||
KERNEL_DEF(D6_JOINT_GET_FORCE, "getD6JointForces")
|
||||
KERNEL_DEF(D6_JOINT_GET_TORQUE, "getD6JointTorques")
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// Aggregate kernels
|
||||
/////////////////////////////////////////////////////////
|
||||
KERNEL_DEF(UPDATE_DIRTY_AGGREGATE, "updateDirtyAggregate")
|
||||
KERNEL_DEF(UPDATE_AGGREGATE_BOUND, "updateAggregateBounds")
|
||||
KERNEL_DEF(MARK_AGGREGATE_BOUND_BITMAP, "markAggregateBoundsUpdatedBitmap")
|
||||
KERNEL_DEF(AGG_SORT_UPDATE_PROJECTIONS, "sortAndUpdateAggregateProjections")
|
||||
KERNEL_DEF(AGG_SELF_COLLISION, "doSelfCollision")
|
||||
KERNEL_DEF(AGG_ADD_AGGPAIRS_STAGE_1, "addAggPairsStage1")
|
||||
KERNEL_DEF(AGG_ADD_AGGPAIRS_STAGE_2, "addAggPairsStage2")
|
||||
KERNEL_DEF(AGG_PAIR_COLLISION, "doAggPairCollisions")
|
||||
KERNEL_DEF(AGG_REMOVE_AGGPAIRS_STAGE_1, "removeAggPairsStage1")
|
||||
KERNEL_DEF(AGG_REMOVE_AGGPAIRS_STAGE_2, "removeAggPairsStage2")
|
||||
KERNEL_DEF(AGG_REMOVE_AGGPAIRS_STAGE_3, "removeAggPairsStage3")
|
||||
KERNEL_DEF(AGG_COPY_REPORTS, "aggCopyReports")
|
||||
KERNEL_DEF(CLEAR_DIRTY_AGGS, "clearDirtyAggregates")
|
||||
KERNEL_DEF(COPY_USER_DATA, "copyUserData")
|
||||
KERNEL_DEF(AGG_MARK_ADDED_DELETED_AGGREGATED_BOUNDS, "markAddedAndDeletedAggregatedBounds")
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//FEM-cloth kernel names
|
||||
//////////////////////////////////////////////////////////
|
||||
KERNEL_DEF(CLOTH_SIM_PREINTEGRATION, "cloth_preIntegrateLaunch")
|
||||
KERNEL_DEF(CLOTH_REFIT_BOUND, "cloth_refitBoundLaunch")
|
||||
KERNEL_DEF(CLOTH_MIDPHASE_PRIMITIVES, "cloth_midphaseGeneratePairsLaunch")
|
||||
KERNEL_DEF(CLOTH_SPHERE_CG, "cloth_SphereContactGenLaunch")
|
||||
KERNEL_DEF(CLOTH_BOX_TRIANGLE_CG, "cloth_boxTriangleContactGenLaunch")
|
||||
KERNEL_DEF(CLOTH_CONVEX_CG, "cloth_convexContactGenLaunch")
|
||||
KERNEL_DEF(CLOTH_VERT_SPHERE_CG, "cloth_SphereVertexContactGenLaunch")
|
||||
KERNEL_DEF(CLOTH_PLANE_VERTEX_CG, "cloth_planeVertContactGenLaunch")
|
||||
KERNEL_DEF(CLOTH_MIDPHASE_VERTEX_PRIMS, "cloth_midphaseGenerateVertexPairsLaunch")
|
||||
KERNEL_DEF(CLOTH_BOX_VERTEX_COLLISION, "cloth_boxVertexContactGenLaunch")
|
||||
KERNEL_DEF(CLOTH_CONVEX_VERTEX_COLLISION, "cloth_convexVertexContactGenLaunch")
|
||||
KERNEL_DEF(CLOTH_SELFCOLLISION_MIDPHASE_VT, "cloth_selfCollisionMidphaseVTLaunch")
|
||||
KERNEL_DEF(CLOTH_SELFCOLLISION_MIDPHASE_EE, "cloth_selfCollisionMidphaseEELaunch")
|
||||
KERNEL_DEF(CLOTH_DIFFERENTCLOTHCOLLISION_MIDPHASE_VT, "cloth_differentClothCollisionVTLaunch")
|
||||
KERNEL_DEF(CLOTH_DIFFERENTCLOTHCOLLISION_MIDPHASE_EE, "cloth_differentClothCollisionEELaunch")
|
||||
KERNEL_DEF(CLOTH_CLOTH_MIDPHASE, "cloth_clothMidphaseGeneratePairsLaunch")
|
||||
KERNEL_DEF(CLOTH_PS_MIDPHASE, "cloth_psMidphaseGeneratePairsLaunch")
|
||||
KERNEL_DEF(CLOTH_PS_CG, "cloth_psContactGenLaunch")
|
||||
KERNEL_DEF(CLOTH_MESH_MIDPHASE, "cloth_meshMidphaseGeneratePairsLaunch")
|
||||
KERNEL_DEF(CLOTH_MESH_CG, "cloth_meshContactGenLaunch")
|
||||
KERNEL_DEF(CLOTH_SDF_MESH_CG, "cloth_sdfMeshContactGenLaunch")
|
||||
KERNEL_DEF(CLOTH_MIDPHASE_VERTEX_MESH, "cloth_midphaseVertexMeshLaunch")
|
||||
KERNEL_DEF(CLOTH_MESH_VERTEX_CG, "cloth_meshVertexContactGenLaunch")
|
||||
KERNEL_DEF(CLOTH_HF_MIDPHASE, "cloth_heightfieldMidphaseGeneratePairsLaunch")
|
||||
KERNEL_DEF(CLOTH_HF_CG, "cloth_heightfieldContactGenLaunch")
|
||||
KERNEL_DEF(CLOTH_MIDPHASE_VERTEX_HF, "cloth_midphaseVertexHeightfieldLaunch")
|
||||
KERNEL_DEF(CLOTH_HF_VERTEX_CG, "cloth_heightfieldVertexContactGenLaunch")
|
||||
KERNEL_DEF(CLOTH_RIGID_ATTACHMENT_CONSTRAINT_PREP, "cloth_rigidAttachmentPrepareLaunch")
|
||||
KERNEL_DEF(CLOTH_RIGID_CONTACTPREPARE, "cloth_rigidContactPrepareLaunch")
|
||||
KERNEL_DEF(CLOTH_CLOTH_CONTACTPREPARE, "cloth_clothContactPrepareLaunch")
|
||||
KERNEL_DEF(CLOTH_PARTICLE_CONTACTPREPARE, "cloth_particleContactPrepareLaunch")
|
||||
KERNEL_DEF(CLOTH_SIM_NONSHARED_TRIANGLE_ENERGY_SOLVE, "cloth_solveNonSharedTriangleEnergyLaunch")
|
||||
KERNEL_DEF(CLOTH_SIM_NONSHARED_TRIANGLE_ENERGY_SOLVE_CLUSTER, "cloth_solveNonSharedTriangleEnergyClusterLaunch")
|
||||
KERNEL_DEF(CLOTH_SIM_TRIANGLEPAIR_ENERGY_SOLVE, "cloth_solveTrianglePairEnergyLaunch")
|
||||
KERNEL_DEF(CLOTH_SIM_TRIANGLEPAIR_ENERGY_SOLVE_CLUSTER, "cloth_solveTrianglePairEnergyClusterLaunch")
|
||||
KERNEL_DEF(CLOTH_SIM_TRIANGLEPAIR_AVERAGE_VERTS, "cloth_averageTrianglePairVertsLaunch")
|
||||
KERNEL_DEF(CLOTH_SIM_STEP, "cloth_stepLaunch")
|
||||
KERNEL_DEF(CLOTH_QUERY_RIGID_CLOTH_REFERENCE_COUNT, "cloth_queryRigidClothContactReferenceCountLaunch")
|
||||
KERNEL_DEF(CLOTH_SOLVE_RIGID_CLOTH_COLLISION, "cloth_solveRigidClothCollisionLaunch")
|
||||
KERNEL_DEF(CLOTH_SOLVE_CLOTH_VT_COLLISION, "cloth_solveClothClothDeltaVTLaunch")
|
||||
KERNEL_DEF(CLOTH_SOLVE_CLOTH_EE_COLLISION, "cloth_solveClothClothDeltaEELaunch")
|
||||
KERNEL_DEF(CLOTH_QUERY_CLOTH_CONTACT_VT_COUNT, "cloth_queryClothClothContactVTCountLaunch")
|
||||
KERNEL_DEF(CLOTH_QUERY_CLOTH_CONTACT_EE_COUNT, "cloth_queryClothClothContactEECountLaunch")
|
||||
KERNEL_DEF(CLOTH_APPLY_EXTERNAL_DELTAS, "cloth_applyExternalDeltasLaunch")
|
||||
KERNEL_DEF(CLOTH_UPDATE_CLOTH_CONTACT_VALIDITY, "cloth_updateClothContactValidityLaunch")
|
||||
KERNEL_DEF(CLOTH_PARTICLE_CLOTH_DELTA, "cloth_solveCPOutputClothDeltaVLaunch")
|
||||
KERNEL_DEF(CLOTH_PARTICLE_PARTICLE_DELTA, "cloth_solveCPOutputParticleDeltaVLaunch")
|
||||
KERNEL_DEF(CLOTH_SOLVE_RIGID_CLOTH_ATTACHMENT, "cloth_solveRigidClothAttachmentLaunch")
|
||||
KERNEL_DEF(CLOTH_SOLVE_ATTACHMENT_CLOTH_CLOTH_DELTA, "cloth_solveOutputAttachmentClothClothDeltaVLaunch")
|
||||
KERNEL_DEF(CLOTH_FINALIZE_VELOCITIES, "cloth_finalizeVelocitiesLaunch")
|
||||
KERNEL_DEF(CLOTH_SOLVE_RIGID_CLOTH_COLLISION_TGS, "cloth_solveRigidClothCollisionTGSLaunch")
|
||||
KERNEL_DEF(CLOTH_QUERY_RIGID_CLOTH_REFERENCE_COUNT_TGS, "cloth_queryRigidClothContactReferenceCountTGSLaunch")
|
||||
KERNEL_DEF(CLOTH_SOLVE_RIGID_CLOTH_ATTACHMENT_TGS, "cloth_solveRigidClothAttachmentTGSLaunch")
|
||||
KERNEL_DEF(CLOTH_SLEEPING, "cloth_sleeping")
|
||||
KERNEL_DEF(CLOTH_IN_PLANE_DAMPING, "cloth_accumulateInPlaneDampingDeltaVelocity")
|
||||
KERNEL_DEF(CLOTH_BENDING_DAMPING, "cloth_accumulateBendingDampingDeltaVelocity")
|
||||
KERNEL_DEF(CLOTH_APPLY_ACCUMULATED_DAMPING, "cloth_applyAccumulatedDeltaVelocity")
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//FEM common kernel
|
||||
////////////////////////////////////////////////////////////
|
||||
KERNEL_DEF(FEM_REORDER_RS_CONTACTS, "fem_reorderRigidContactsLaunch")
|
||||
KERNEL_DEF(CLAMP_MAX_VALUE, "clampMaxValue")
|
||||
KERNEL_DEF(CLAMP_MAX_VALUES, "clampMaxValues")
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Gpu Extension Kernels
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
KERNEL_DEF(scanPerBlockKernel, "scanPerBlockKernel")
|
||||
KERNEL_DEF(scanPerBlockKernel4x4, "scanPerBlockKernel4x4")
|
||||
KERNEL_DEF(addBlockSumsKernel, "addBlockSumsKernel")
|
||||
KERNEL_DEF(addBlockSumsKernel4x4, "addBlockSumsKernel4x4")
|
||||
KERNEL_DEF(radixFourBitCountPerBlockKernel, "radixFourBitCountPerBlockKernel")
|
||||
KERNEL_DEF(radixFourBitReorderKernel, "radixFourBitReorderKernel")
|
||||
KERNEL_DEF(reorderKernel, "reorderKernel")
|
||||
|
||||
KERNEL_DEF(smoothPositionsLaunch, "smoothPositionsLaunch")
|
||||
KERNEL_DEF(calculateAnisotropyLaunch, "calculateAnisotropyLaunch")
|
||||
KERNEL_DEF(anisotropyKernel, "anisotropyKernel")
|
||||
KERNEL_DEF(smoothPositionsKernel, "smoothPositionsKernel")
|
||||
|
||||
KERNEL_DEF(iso_ComputeParticleDensityUsingSDF, "iso_ComputeParticleDensityUsingSDF")
|
||||
KERNEL_DEF(iso_ComputeParticleDensityUsingSDFSparse, "iso_ComputeParticleDensityUsingSDFSparse")
|
||||
KERNEL_DEF(iso_ComputeParticleDensity, "iso_ComputeParticleDensity")
|
||||
KERNEL_DEF(iso_ComputeParticleDensitySparse, "iso_ComputeParticleDensitySparse")
|
||||
KERNEL_DEF(iso_CountCellVerts, "iso_CountCellVerts")
|
||||
KERNEL_DEF(iso_CountCellVertsSparse, "iso_CountCellVertsSparse")
|
||||
KERNEL_DEF(iso_CountCellVertsDC, "iso_CountCellVertsDC")
|
||||
KERNEL_DEF(iso_CountCellVertsDCSparse, "iso_CountCellVertsDCSparse")
|
||||
KERNEL_DEF(iso_CreateVerts, "iso_CreateVerts")
|
||||
KERNEL_DEF(iso_CreateVertsSparse, "iso_CreateVertsSparse")
|
||||
KERNEL_DEF(iso_CreateVertsDC, "iso_CreateVertsDC")
|
||||
KERNEL_DEF(iso_CreateVertsDCSparse, "iso_CreateVertsDCSparse")
|
||||
KERNEL_DEF(iso_CountTriIds, "iso_CountTriIds")
|
||||
KERNEL_DEF(iso_CountTriIdsSparse, "iso_CountTriIdsSparse")
|
||||
KERNEL_DEF(iso_CountTriIdsDC, "iso_CountTriIdsDC")
|
||||
KERNEL_DEF(iso_CountTriIdsDCSparse, "iso_CountTriIdsDCSparse")
|
||||
KERNEL_DEF(iso_CreateTriIds, "iso_CreateTriIds")
|
||||
KERNEL_DEF(iso_CreateTriIdsSparse, "iso_CreateTriIdsSparse")
|
||||
KERNEL_DEF(iso_CreateTriIdsDC, "iso_CreateTriIdsDC")
|
||||
KERNEL_DEF(iso_CreateTriIdsDCSparse, "iso_CreateTriIdsDCSparse")
|
||||
KERNEL_DEF(iso_SmoothVerts, "iso_SmoothVerts")
|
||||
KERNEL_DEF(iso_AverageVerts, "iso_AverageVerts")
|
||||
KERNEL_DEF(iso_SmoothNormals, "iso_SmoothNormals")
|
||||
KERNEL_DEF(iso_SmoothNormalsSparse, "iso_SmoothNormalsSparse")
|
||||
KERNEL_DEF(iso_SmoothNormalsNormalize, "iso_SmoothNormalsNormalize")
|
||||
KERNEL_DEF(iso_SmoothNormalsNormalizeSparse, "iso_SmoothNormalsNormalizeSparse")
|
||||
KERNEL_DEF(iso_ComputeNormals, "iso_ComputeNormals")
|
||||
KERNEL_DEF(iso_ComputeNormalsSparse, "iso_ComputeNormalsSparse")
|
||||
KERNEL_DEF(iso_NormalizeNormals, "iso_NormalizeNormals")
|
||||
KERNEL_DEF(iso_NormalizeNormalsSparse, "iso_NormalizeNormalsSparse")
|
||||
KERNEL_DEF(iso_GridFilterGauss, "iso_GridFilterGauss")
|
||||
KERNEL_DEF(iso_GridFilterGaussSparse, "iso_GridFilterGaussSparse")
|
||||
KERNEL_DEF(iso_GridFilterDilateErode, "iso_GridFilterDilateErode")
|
||||
KERNEL_DEF(iso_GridFilterDilateErodeSparse, "iso_GridFilterDilateErodeSparse")
|
||||
|
||||
KERNEL_DEF(sg_SparseGridCalcSubgridHashes, "sg_SparseGridCalcSubgridHashes")
|
||||
KERNEL_DEF(sg_SparseGridMarkRequiredNeighbors, "sg_SparseGridMarkRequiredNeighbors")
|
||||
KERNEL_DEF(sg_SparseGridSortedArrayToDelta, "sg_SparseGridSortedArrayToDelta")
|
||||
KERNEL_DEF(sg_SparseGridGetUniqueValues, "sg_SparseGridGetUniqueValues")
|
||||
KERNEL_DEF(sg_SparseGridClearDensity, "sg_SparseGridClearDensity")
|
||||
KERNEL_DEF(sg_SparseGridBuildSubgridNeighbors, "sg_SparseGridBuildSubgridNeighbors")
|
||||
KERNEL_DEF(sg_MarkSubgridEndIndices, "sg_MarkSubgridEndIndices")
|
||||
KERNEL_DEF(sg_ReuseSubgrids, "sg_ReuseSubgrids")
|
||||
KERNEL_DEF(sg_AddReleasedSubgridsToUnusedStack, "sg_AddReleasedSubgridsToUnusedStack")
|
||||
KERNEL_DEF(sg_AllocateNewSubgrids, "sg_AllocateNewSubgrids")
|
||||
|
||||
KERNEL_DEF(util_InterleaveBuffers, "interleaveBuffers")
|
||||
KERNEL_DEF(util_InterpolateSkinnedClothVertices, "interpolateSkinnedClothVertices")
|
||||
KERNEL_DEF(util_InterpolateSkinnedSoftBodyVertices, "interpolateSkinnedSoftBodyVertices")
|
||||
|
||||
KERNEL_DEF(util_ComputeNormals, "normalVectorsAreaWeighted")
|
||||
KERNEL_DEF(util_NormalizeNormals, "normalizeNormals")
|
||||
KERNEL_DEF(util_ZeroNormals, "zeroNormals")
|
||||
|
||||
//BVH construction kernels
|
||||
KERNEL_DEF(bvh_ComputeTriangleBounds, "bvhComputeTriangleBounds")
|
||||
KERNEL_DEF(bvh_ComputeTotalBounds, "bvhComputeTotalBounds")
|
||||
KERNEL_DEF(bvh_ComputeTotalInvEdges, "bvhComputeTotalInvEdges")
|
||||
KERNEL_DEF(bvh_CalculateMortonCodes, "bvhCalculateMortonCodes")
|
||||
KERNEL_DEF(bvh_CalculateKeyDeltas, "bvhCalculateKeyDeltas")
|
||||
KERNEL_DEF(bvh_CalculateKeyDeltasSquaredDistance, "bvhCalculateKeyDeltasSquaredDistance")
|
||||
KERNEL_DEF(bvh_BuildLeaves, "bvhBuildLeaves")
|
||||
KERNEL_DEF(bvh_BuildHierarchy, "bvhBuildHierarchy")
|
||||
KERNEL_DEF(bvh_BuildHierarchyAndWindingClusters, "bvhBuildHierarchyAndWindingClusters")
|
||||
|
||||
//SDF Construction kernels
|
||||
KERNEL_DEF(sdf_CalculateDenseGridBlocks, "sdfCalculateDenseGridBlocks")
|
||||
KERNEL_DEF(sdf_CalculateDenseGridHybrid, "sdfCalculateDenseGridHybrid")
|
||||
KERNEL_DEF(sdf_PopulateBackgroundSDF, "sdfPopulateBackgroundSDF")
|
||||
KERNEL_DEF(sdf_MarkRequiredSdfSubgrids, "sdfMarkRequiredSdfSubgrids")
|
||||
KERNEL_DEF(sdf_PopulateSdfSubgrids, "sdfPopulateSdfSubgrids")
|
||||
KERNEL_DEF(sdf_CountHoles, "sdfCountHoles")
|
||||
KERNEL_DEF(sdf_FindHoles, "sdfFindHoles")
|
||||
KERNEL_DEF(sdf_ApplyHoleCorrections, "sdfApplyHoleCorrections")
|
||||
KERNEL_DEF(sdf_CalculateDenseGridPointCloud, "sdfCalculateDenseGridPointCloud")
|
||||
|
||||
#endif
|
||||
51
engine/third_party/physx/source/gpucommon/include/PxgKernelWrangler.h
vendored
Normal file
51
engine/third_party/physx/source/gpucommon/include/PxgKernelWrangler.h
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
|
||||
#ifndef PXG_KERNEL_WRANGLER_H
|
||||
#define PXG_KERNEL_WRANGLER_H
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
#include "PxsKernelWrangler.h"
|
||||
#include "foundation/PxArray.h"
|
||||
|
||||
namespace physx
|
||||
{
|
||||
class PxCudaContextManager;
|
||||
class KernelWrangler;
|
||||
class PxErrorCallback;
|
||||
|
||||
class PxgCudaKernelWranglerManager : public PxsKernelWranglerManager
|
||||
{
|
||||
public:
|
||||
PxgCudaKernelWranglerManager(PxCudaContextManager& cudaContextManager, PxErrorCallback& errorCallback);
|
||||
~PxgCudaKernelWranglerManager();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
70
engine/third_party/physx/source/gpucommon/include/PxgMemCopyDispatcher.h
vendored
Normal file
70
engine/third_party/physx/source/gpucommon/include/PxgMemCopyDispatcher.h
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
#ifndef PXG_MEM_COPY_DISPATCHER
|
||||
#define PXG_MEM_COPY_DISPATCHER
|
||||
|
||||
#include "foundation/PxUserAllocated.h"
|
||||
#include "foundation/PxPinnedArray.h"
|
||||
#include "PxgCudaBuffer.h"
|
||||
|
||||
namespace physx
|
||||
{
|
||||
class PxCudaContext;
|
||||
class KernelWrangler;
|
||||
|
||||
struct PxgPtrPair
|
||||
{
|
||||
void* src;
|
||||
void* dst;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
class PxgMemCopyDispatcher : public PxUserAllocated
|
||||
{
|
||||
PxPinnedArray<PxgPtrPair> mPinnedCopyBuffer;
|
||||
PxgCudaBuffer mDeviceCopyCommands;
|
||||
size_t mMaxSize;
|
||||
|
||||
public:
|
||||
|
||||
PxgMemCopyDispatcher(PxgHeapMemoryAllocatorManager* gpuHeapAllocator, PxVirtualAllocatorCallback* hostAllocator) :
|
||||
mPinnedCopyBuffer(PxVirtualAllocator(hostAllocator)), mDeviceCopyCommands(gpuHeapAllocator, PxsHeapStats::eOTHER),
|
||||
mMaxSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
void addCommand(PxgPtrPair& command)
|
||||
{
|
||||
mPinnedCopyBuffer.pushBack(command);
|
||||
mMaxSize = PxMax(mMaxSize, command.size);
|
||||
}
|
||||
|
||||
void flushCommands(CUstream stream, PxCudaContext* cudaContext, KernelWrangler* kernelWrangler);
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
54
engine/third_party/physx/source/gpucommon/include/PxgMemoryManager.h
vendored
Normal file
54
engine/third_party/physx/source/gpucommon/include/PxgMemoryManager.h
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_MEMORY_ALLOCATOR_H
|
||||
#define PXG_MEMORY_ALLOCATOR_H
|
||||
|
||||
#include "PxsMemoryManager.h"
|
||||
#include "foundation/PxArray.h"
|
||||
|
||||
namespace physx
|
||||
{
|
||||
class PxCudaContextManager;
|
||||
class PxCudaContext;
|
||||
|
||||
// PT: this is for GPU, see createDefaultMemoryManager for CPU
|
||||
PxsMemoryManager* createPxgMemoryManager(PxCudaContextManager* cudaContextManager);
|
||||
|
||||
|
||||
class PxgCudaAllocatorCallbackBase : public PxVirtualAllocatorCallback, public PxUserAllocated
|
||||
{
|
||||
public:
|
||||
PxgCudaAllocatorCallbackBase(PxCudaContextManager* contextManager);
|
||||
virtual ~PxgCudaAllocatorCallbackBase() {}
|
||||
PxCudaContextManager* mContextManager;
|
||||
PxCudaContext* mCudaContext;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
57
engine/third_party/physx/source/gpucommon/include/PxgRadixSortDesc.h
vendored
Normal file
57
engine/third_party/physx/source/gpucommon/include/PxgRadixSortDesc.h
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_RADIXSORT_DESC_H
|
||||
#define PXG_RADIXSORT_DESC_H
|
||||
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
|
||||
#define NUM_RADIX_SORT_DESC 2
|
||||
|
||||
namespace physx
|
||||
{
|
||||
|
||||
struct PxgRadixSortDesc
|
||||
{
|
||||
PxU32* inputKeys;
|
||||
PxU32* inputRanks;
|
||||
PxU32* outputKeys;
|
||||
PxU32* outputRanks;
|
||||
PxU32* radixBlockCounts; //store the each radix's total number different different blocks
|
||||
PxU32 count;
|
||||
};
|
||||
|
||||
struct PxgRadixSortBlockDesc : public PxgRadixSortDesc
|
||||
{
|
||||
public:
|
||||
PxU32* numKeys;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
53
engine/third_party/physx/source/gpucommon/include/PxgRadixSortKernelIndices.h
vendored
Normal file
53
engine/third_party/physx/source/gpucommon/include/PxgRadixSortKernelIndices.h
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef PXG_RADIX_SORT_KERNEL_INDICES_H
|
||||
#define PXG_RADIX_SORT_KERNEL_INDICES_H
|
||||
|
||||
namespace physx
|
||||
{
|
||||
|
||||
struct PxgRadixSortKernelBlockDim
|
||||
{
|
||||
enum
|
||||
{
|
||||
RADIX_SORT = 1024,
|
||||
};
|
||||
};
|
||||
|
||||
struct PxgRadixSortKernelGridDim
|
||||
{
|
||||
enum
|
||||
{
|
||||
RADIX_SORT = 32,
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
796
engine/third_party/physx/source/gpucommon/include/cutil_math.h
vendored
Normal file
796
engine/third_party/physx/source/gpucommon/include/cutil_math.h
vendored
Normal file
@@ -0,0 +1,796 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
|
||||
|
||||
/*
|
||||
This file implements common mathematical operations on vector types
|
||||
(float3, float4 etc.) since these are not provided as standard by CUDA.
|
||||
|
||||
The syntax is modelled on the Cg standard library.
|
||||
*/
|
||||
|
||||
#ifndef CUTIL_MATH_H
|
||||
#define CUTIL_MATH_H
|
||||
|
||||
#include "foundation/PxPreprocessor.h"
|
||||
|
||||
#if PX_LINUX && PX_CLANG
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdocumentation"
|
||||
#endif
|
||||
#include <vector_types.h>
|
||||
#include "vector_functions.h" // why does this pull in the runtime api?
|
||||
#if PX_LINUX && PX_CLANG
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned char uchar;
|
||||
|
||||
// float functions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !PX_CUDA_COMPILER
|
||||
#ifndef PX_MIN_MAX
|
||||
#define PX_MIN_MAX
|
||||
#if PX_VC
|
||||
PX_FORCE_INLINE __device__ __host__ float fmaxf(float a, float b) { return a > b ? a : b; }
|
||||
PX_FORCE_INLINE __device__ __host__ float fminf(float a, float b) { return a < b ? a : b; }
|
||||
#endif
|
||||
PX_FORCE_INLINE __device__ __host__ int max(int a, int b) { return a > b ? a : b; }
|
||||
PX_FORCE_INLINE __device__ __host__ unsigned int max(unsigned int a, unsigned int b) { return a > b ? a : b; }
|
||||
PX_FORCE_INLINE __device__ __host__ int min(int a, int b) { return a < b ? a : b; }
|
||||
PX_FORCE_INLINE __device__ __host__ unsigned int min(unsigned int a, unsigned int b) { return a < b ? a : b; }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// lerp
|
||||
inline __device__ __host__ float lerp(float a, float b, float t)
|
||||
{
|
||||
return a + t*(b-a);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
__device__ inline T bilerp(const T f00, const T f10, const T f01, const T f11, const float tx, const float ty)
|
||||
{
|
||||
return lerp(lerp(f00, f10, tx), lerp(f01, f11, tx), ty);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
__device__ inline T trilerp(const T f000, const T f100, const T f010, const T f110, const T f001, const T f101, const T f011, const T f111,
|
||||
const float tx, const float ty, const float tz)
|
||||
{
|
||||
return lerp(bilerp(f000, f100, f010, f110, tx, ty), bilerp(f001, f101, f011, f111, tx, ty), tz);
|
||||
}
|
||||
|
||||
// clamp
|
||||
inline __device__ __host__ float clamp(float f, float a, float b)
|
||||
{
|
||||
return fmaxf(a, fminf(f, b));
|
||||
}
|
||||
|
||||
// int2 functions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// addition
|
||||
inline __host__ __device__ int2 operator+(int2 a, int2 b)
|
||||
{
|
||||
return make_int2(a.x + b.x, a.y + b.y);
|
||||
}
|
||||
inline __host__ __device__ void operator+=(int2 &a, int2 b)
|
||||
{
|
||||
a.x += b.x; a.y += b.y;
|
||||
}
|
||||
|
||||
// subtract
|
||||
inline __host__ __device__ int2 operator-(int2 a, int2 b)
|
||||
{
|
||||
return make_int2(a.x - b.x, a.y - b.y);
|
||||
}
|
||||
inline __host__ __device__ void operator-=(int2 &a, int2 b)
|
||||
{
|
||||
a.x -= b.x; a.y -= b.y;
|
||||
}
|
||||
|
||||
// multiply
|
||||
inline __host__ __device__ int2 operator*(int2 a, int2 b)
|
||||
{
|
||||
return make_int2(a.x * b.x, a.y * b.y);
|
||||
}
|
||||
inline __host__ __device__ int2 operator*(int2 a, int s)
|
||||
{
|
||||
return make_int2(a.x * s, a.y * s);
|
||||
}
|
||||
inline __host__ __device__ int2 operator*(int s, int2 a)
|
||||
{
|
||||
return make_int2(a.x * s, a.y * s);
|
||||
}
|
||||
inline __host__ __device__ void operator*=(int2 &a, int s)
|
||||
{
|
||||
a.x *= s; a.y *= s;
|
||||
}
|
||||
|
||||
// float2 functions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// additional constructors
|
||||
inline __host__ __device__ float2 make_float2(float s)
|
||||
{
|
||||
return make_float2(s, s);
|
||||
}
|
||||
inline __host__ __device__ float2 make_float2(int2 a)
|
||||
{
|
||||
return make_float2(float(a.x), float(a.y));
|
||||
}
|
||||
|
||||
// addition
|
||||
inline __host__ __device__ float2 operator+(float2 a, float2 b)
|
||||
{
|
||||
return make_float2(a.x + b.x, a.y + b.y);
|
||||
}
|
||||
inline __host__ __device__ void operator+=(float2 &a, float2 b)
|
||||
{
|
||||
a.x += b.x; a.y += b.y;
|
||||
}
|
||||
|
||||
// subtract
|
||||
inline __host__ __device__ float2 operator-(float2 a, float2 b)
|
||||
{
|
||||
return make_float2(a.x - b.x, a.y - b.y);
|
||||
}
|
||||
inline __host__ __device__ void operator-=(float2 &a, float2 b)
|
||||
{
|
||||
a.x -= b.x; a.y -= b.y;
|
||||
}
|
||||
|
||||
// multiply
|
||||
inline __host__ __device__ float2 operator*(float2 a, float2 b)
|
||||
{
|
||||
return make_float2(a.x * b.x, a.y * b.y);
|
||||
}
|
||||
inline __host__ __device__ float2 operator*(float2 a, float s)
|
||||
{
|
||||
return make_float2(a.x * s, a.y * s);
|
||||
}
|
||||
inline __host__ __device__ float2 operator*(float s, float2 a)
|
||||
{
|
||||
return make_float2(a.x * s, a.y * s);
|
||||
}
|
||||
inline __host__ __device__ void operator*=(float2 &a, float s)
|
||||
{
|
||||
a.x *= s; a.y *= s;
|
||||
}
|
||||
|
||||
// divide
|
||||
inline __host__ __device__ float2 operator/(float2 a, float2 b)
|
||||
{
|
||||
return make_float2(a.x / b.x, a.y / b.y);
|
||||
}
|
||||
inline __host__ __device__ float2 operator/(float2 a, float s)
|
||||
{
|
||||
float inv = 1.0f / s;
|
||||
return a * inv;
|
||||
}
|
||||
inline __host__ __device__ float2 operator/(float s, float2 a)
|
||||
{
|
||||
float inv = 1.0f / s;
|
||||
return a * inv;
|
||||
}
|
||||
inline __host__ __device__ void operator/=(float2 &a, float s)
|
||||
{
|
||||
float inv = 1.0f / s;
|
||||
a *= inv;
|
||||
}
|
||||
|
||||
// lerp
|
||||
inline __device__ __host__ float2 lerp(float2 a, float2 b, float t)
|
||||
{
|
||||
return a + t*(b-a);
|
||||
}
|
||||
|
||||
// clamp
|
||||
inline __device__ __host__ float2 clamp(float2 v, float a, float b)
|
||||
{
|
||||
return make_float2(clamp(v.x, a, b), clamp(v.y, a, b));
|
||||
}
|
||||
|
||||
inline __device__ __host__ float2 clamp(float2 v, float2 a, float2 b)
|
||||
{
|
||||
return make_float2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y));
|
||||
}
|
||||
|
||||
// dot product
|
||||
inline __host__ __device__ float dot(float2 a, float2 b)
|
||||
{
|
||||
return a.x * b.x + a.y * b.y;
|
||||
}
|
||||
|
||||
// length
|
||||
inline __host__ __device__ float length(float2 v)
|
||||
{
|
||||
return sqrtf(dot(v, v));
|
||||
}
|
||||
|
||||
// normalize
|
||||
inline __host__ __device__ float2 normalize(float2 v)
|
||||
{
|
||||
float invLen = 1.0f / sqrtf(dot(v, v));
|
||||
return v * invLen;
|
||||
}
|
||||
|
||||
// floor
|
||||
inline __host__ __device__ float2 floor(const float2 v)
|
||||
{
|
||||
return make_float2(floorf(v.x), floorf(v.y));
|
||||
}
|
||||
|
||||
//validate
|
||||
inline __host__ __device__ bool validate(const float2 v0, const float2 v1)
|
||||
{
|
||||
return (v0.x == v1.x && v0.y == v1.y);
|
||||
}
|
||||
|
||||
|
||||
// float3 functions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// additional constructors
|
||||
inline __host__ __device__ float3 make_float3(float s)
|
||||
{
|
||||
return make_float3(s, s, s);
|
||||
}
|
||||
inline __host__ __device__ float3 make_float3(float2 a)
|
||||
{
|
||||
return make_float3(a.x, a.y, 0.0f);
|
||||
}
|
||||
inline __host__ __device__ float3 make_float3(float2 a, float s)
|
||||
{
|
||||
return make_float3(a.x, a.y, s);
|
||||
}
|
||||
inline __host__ __device__ float3 make_float3(float4 a)
|
||||
{
|
||||
return make_float3(a.x, a.y, a.z); // discards w
|
||||
}
|
||||
inline __host__ __device__ float3 make_float3(int3 a)
|
||||
{
|
||||
return make_float3(float(a.x), float(a.y), float(a.z));
|
||||
}
|
||||
|
||||
// min
|
||||
static __inline__ __host__ __device__ float3 fminf(float3 a, float3 b)
|
||||
{
|
||||
return make_float3(fminf(a.x,b.x), fminf(a.y,b.y), fminf(a.z,b.z));
|
||||
}
|
||||
|
||||
// max
|
||||
static __inline__ __host__ __device__ float3 fmaxf(float3 a, float3 b)
|
||||
{
|
||||
return make_float3(fmaxf(a.x,b.x), fmaxf(a.y,b.y), fmaxf(a.z,b.z));
|
||||
}
|
||||
|
||||
// addition
|
||||
inline __host__ __device__ float3 operator+(float3 a, float3 b)
|
||||
{
|
||||
return make_float3(a.x + b.x, a.y + b.y, a.z + b.z);
|
||||
}
|
||||
inline __host__ __device__ void operator+=(float3 &a, float3 b)
|
||||
{
|
||||
a.x += b.x; a.y += b.y; a.z += b.z;
|
||||
}
|
||||
|
||||
// subtract
|
||||
inline __host__ __device__ float3 operator-(float3 a, float3 b)
|
||||
{
|
||||
return make_float3(a.x - b.x, a.y - b.y, a.z - b.z);
|
||||
}
|
||||
inline __host__ __device__ void operator-=(float3 &a, float3 b)
|
||||
{
|
||||
a.x -= b.x; a.y -= b.y; a.z -= b.z;
|
||||
}
|
||||
|
||||
// multiply
|
||||
inline __host__ __device__ float3 operator*(float3 a, float3 b)
|
||||
{
|
||||
return make_float3(a.x * b.x, a.y * b.y, a.z * b.z);
|
||||
}
|
||||
inline __host__ __device__ float3 operator*(float3 a, float s)
|
||||
{
|
||||
return make_float3(a.x * s, a.y * s, a.z * s);
|
||||
}
|
||||
inline __host__ __device__ float3 operator*(float s, float3 a)
|
||||
{
|
||||
return make_float3(a.x * s, a.y * s, a.z * s);
|
||||
}
|
||||
inline __host__ __device__ void operator*=(float3 &a, float s)
|
||||
{
|
||||
a.x *= s; a.y *= s; a.z *= s;
|
||||
}
|
||||
|
||||
// divide
|
||||
inline __host__ __device__ float3 operator/(float3 a, float3 b)
|
||||
{
|
||||
return make_float3(a.x / b.x, a.y / b.y, a.z / b.z);
|
||||
}
|
||||
inline __host__ __device__ float3 operator/(float3 a, float s)
|
||||
{
|
||||
float inv = 1.0f / s;
|
||||
return a * inv;
|
||||
}
|
||||
inline __host__ __device__ float3 operator/(float s, float3 a)
|
||||
{
|
||||
float inv = 1.0f / s;
|
||||
return a * inv;
|
||||
}
|
||||
inline __host__ __device__ void operator/=(float3 &a, float s)
|
||||
{
|
||||
float inv = 1.0f / s;
|
||||
a *= inv;
|
||||
}
|
||||
|
||||
// lerp
|
||||
inline __device__ __host__ float3 lerp(float3 a, float3 b, float t)
|
||||
{
|
||||
return a + t*(b-a);
|
||||
}
|
||||
|
||||
// clamp
|
||||
inline __device__ __host__ float3 clamp(float3 v, float a, float b)
|
||||
{
|
||||
return make_float3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
|
||||
}
|
||||
|
||||
inline __device__ __host__ float3 clamp(float3 v, float3 a, float3 b)
|
||||
{
|
||||
return make_float3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
|
||||
}
|
||||
|
||||
// dot product
|
||||
inline __host__ __device__ float dot(float3 a, float3 b)
|
||||
{
|
||||
return a.x * b.x + a.y * b.y + a.z * b.z;
|
||||
}
|
||||
|
||||
// cross product
|
||||
inline __host__ __device__ float3 cross(float3 a, float3 b)
|
||||
{
|
||||
return make_float3(a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x);
|
||||
}
|
||||
|
||||
// length
|
||||
inline __host__ __device__ float length(float3 v)
|
||||
{
|
||||
return sqrtf(dot(v, v));
|
||||
}
|
||||
|
||||
// normalize
|
||||
inline __host__ __device__ float3 normalize(float3 v)
|
||||
{
|
||||
float invLen = 1.0f / sqrtf(dot(v, v));
|
||||
return v * invLen;
|
||||
}
|
||||
|
||||
// floor
|
||||
inline __host__ __device__ float3 floor(const float3 v)
|
||||
{
|
||||
return make_float3(floorf(v.x), floorf(v.y), floorf(v.z));
|
||||
}
|
||||
|
||||
//validate
|
||||
inline __host__ __device__ bool validate(const float3 v0, const float3 v1)
|
||||
{
|
||||
return (v0.x == v1.x && v0.y == v1.y && v0.z == v1.z);
|
||||
}
|
||||
|
||||
|
||||
// float4 functions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// additional constructors
|
||||
inline __host__ __device__ float4 make_float4(float s)
|
||||
{
|
||||
return make_float4(s, s, s, s);
|
||||
}
|
||||
inline __host__ __device__ float4 make_float4(float3 a)
|
||||
{
|
||||
return make_float4(a.x, a.y, a.z, 0.0f);
|
||||
}
|
||||
inline __host__ __device__ float4 make_float4(float3 a, float w)
|
||||
{
|
||||
return make_float4(a.x, a.y, a.z, w);
|
||||
}
|
||||
inline __host__ __device__ float4 make_float4(int4 a)
|
||||
{
|
||||
return make_float4(float(a.x), float(a.y), float(a.z), float(a.w));
|
||||
}
|
||||
|
||||
// min
|
||||
static __inline__ __host__ __device__ float4 fminf(float4 a, float4 b)
|
||||
{
|
||||
return make_float4(fminf(a.x,b.x), fminf(a.y,b.y), fminf(a.z,b.z), fminf(a.w,b.w));
|
||||
}
|
||||
|
||||
// max
|
||||
static __inline__ __host__ __device__ float4 fmaxf(float4 a, float4 b)
|
||||
{
|
||||
return make_float4(fmaxf(a.x,b.x), fmaxf(a.y,b.y), fmaxf(a.z,b.z), fmaxf(a.w,b.w));
|
||||
}
|
||||
|
||||
// addition
|
||||
inline __host__ __device__ float4 operator+(float4 a, float4 b)
|
||||
{
|
||||
return make_float4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
|
||||
}
|
||||
inline __host__ __device__ void operator+=(float4 &a, float4 b)
|
||||
{
|
||||
a.x += b.x; a.y += b.y; a.z += b.z; a.w += b.w;
|
||||
}
|
||||
|
||||
// subtract
|
||||
inline __host__ __device__ float4 operator-(float4 a, float4 b)
|
||||
{
|
||||
return make_float4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
|
||||
}
|
||||
inline __host__ __device__ void operator-=(float4 &a, float4 b)
|
||||
{
|
||||
a.x -= b.x; a.y -= b.y; a.z -= b.z; a.w -= b.w;
|
||||
}
|
||||
|
||||
// multiply
|
||||
inline __host__ __device__ float4 operator*(float4 a, float s)
|
||||
{
|
||||
return make_float4(a.x * s, a.y * s, a.z * s, a.w * s);
|
||||
}
|
||||
inline __host__ __device__ float4 operator*(float s, float4 a)
|
||||
{
|
||||
return make_float4(a.x * s, a.y * s, a.z * s, a.w * s);
|
||||
}
|
||||
inline __host__ __device__ void operator*=(float4 &a, float s)
|
||||
{
|
||||
a.x *= s; a.y *= s; a.z *= s; a.w *= s;
|
||||
}
|
||||
|
||||
// divide
|
||||
inline __host__ __device__ float4 operator/(float4 a, float4 b)
|
||||
{
|
||||
return make_float4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
|
||||
}
|
||||
inline __host__ __device__ float4 operator/(float4 a, float s)
|
||||
{
|
||||
float inv = 1.0f / s;
|
||||
return a * inv;
|
||||
}
|
||||
inline __host__ __device__ float4 operator/(float s, float4 a)
|
||||
{
|
||||
float inv = 1.0f / s;
|
||||
return a * inv;
|
||||
}
|
||||
inline __host__ __device__ void operator/=(float4 &a, float s)
|
||||
{
|
||||
float inv = 1.0f / s;
|
||||
a *= inv;
|
||||
}
|
||||
|
||||
// lerp
|
||||
inline __device__ __host__ float4 lerp(float4 a, float4 b, float t)
|
||||
{
|
||||
return a + t*(b-a);
|
||||
}
|
||||
|
||||
// clamp
|
||||
inline __device__ __host__ float4 clamp(float4 v, float a, float b)
|
||||
{
|
||||
return make_float4(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b));
|
||||
}
|
||||
|
||||
inline __device__ __host__ float4 clamp(float4 v, float4 a, float4 b)
|
||||
{
|
||||
return make_float4(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z), clamp(v.w, a.w, b.w));
|
||||
}
|
||||
|
||||
// dot product
|
||||
inline __host__ __device__ float dot(float4 a, float4 b)
|
||||
{
|
||||
return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
|
||||
}
|
||||
|
||||
// length
|
||||
inline __host__ __device__ float length(float4 r)
|
||||
{
|
||||
return sqrtf(dot(r, r));
|
||||
}
|
||||
|
||||
// normalize
|
||||
inline __host__ __device__ float4 normalize(float4 v)
|
||||
{
|
||||
float invLen = 1.0f / sqrtf(dot(v, v));
|
||||
return v * invLen;
|
||||
}
|
||||
|
||||
// floor
|
||||
inline __host__ __device__ float4 floor(const float4 v)
|
||||
{
|
||||
return make_float4(floorf(v.x), floorf(v.y), floorf(v.z), floorf(v.w));
|
||||
}
|
||||
|
||||
//validate
|
||||
inline __host__ __device__ bool validate(const float4 v0, const float4 v1)
|
||||
{
|
||||
return (v0.x == v1.x && v0.y == v1.y && v0.z == v1.z && v0.w == v1.w);
|
||||
}
|
||||
|
||||
// int3 functions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// additional constructors
|
||||
inline __host__ __device__ int3 make_int3(int s)
|
||||
{
|
||||
return make_int3(s, s, s);
|
||||
}
|
||||
inline __host__ __device__ int3 make_int3(float3 a)
|
||||
{
|
||||
return make_int3(int(a.x), int(a.y), int(a.z));
|
||||
}
|
||||
|
||||
// min
|
||||
inline __host__ __device__ int3 min(int3 a, int3 b)
|
||||
{
|
||||
return make_int3(min(a.x,b.x), min(a.y,b.y), min(a.z,b.z));
|
||||
}
|
||||
|
||||
// max
|
||||
inline __host__ __device__ int3 max(int3 a, int3 b)
|
||||
{
|
||||
return make_int3(max(a.x,b.x), max(a.y,b.y), max(a.z,b.z));
|
||||
}
|
||||
|
||||
// addition
|
||||
inline __host__ __device__ int3 operator+(int3 a, int3 b)
|
||||
{
|
||||
return make_int3(a.x + b.x, a.y + b.y, a.z + b.z);
|
||||
}
|
||||
inline __host__ __device__ void operator+=(int3 &a, int3 b)
|
||||
{
|
||||
a.x += b.x; a.y += b.y; a.z += b.z;
|
||||
}
|
||||
|
||||
// subtract
|
||||
inline __host__ __device__ int3 operator-(int3 a, int3 b)
|
||||
{
|
||||
return make_int3(a.x - b.x, a.y - b.y, a.z - b.z);
|
||||
}
|
||||
|
||||
inline __host__ __device__ void operator-=(int3 &a, int3 b)
|
||||
{
|
||||
a.x -= b.x; a.y -= b.y; a.z -= b.z;
|
||||
}
|
||||
|
||||
// multiply
|
||||
inline __host__ __device__ int3 operator*(int3 a, int3 b)
|
||||
{
|
||||
return make_int3(a.x * b.x, a.y * b.y, a.z * b.z);
|
||||
}
|
||||
inline __host__ __device__ int3 operator*(int3 a, int s)
|
||||
{
|
||||
return make_int3(a.x * s, a.y * s, a.z * s);
|
||||
}
|
||||
inline __host__ __device__ int3 operator*(int s, int3 a)
|
||||
{
|
||||
return make_int3(a.x * s, a.y * s, a.z * s);
|
||||
}
|
||||
inline __host__ __device__ void operator*=(int3 &a, int s)
|
||||
{
|
||||
a.x *= s; a.y *= s; a.z *= s;
|
||||
}
|
||||
|
||||
// divide
|
||||
inline __host__ __device__ int3 operator/(int3 a, int3 b)
|
||||
{
|
||||
return make_int3(a.x / b.x, a.y / b.y, a.z / b.z);
|
||||
}
|
||||
inline __host__ __device__ int3 operator/(int3 a, int s)
|
||||
{
|
||||
return make_int3(a.x / s, a.y / s, a.z / s);
|
||||
}
|
||||
inline __host__ __device__ int3 operator/(int s, int3 a)
|
||||
{
|
||||
return make_int3(a.x / s, a.y / s, a.z / s);
|
||||
}
|
||||
inline __host__ __device__ void operator/=(int3 &a, int s)
|
||||
{
|
||||
a.x /= s; a.y /= s; a.z /= s;
|
||||
}
|
||||
|
||||
// clamp
|
||||
inline __device__ __host__ int clamp(int f, int a, int b)
|
||||
{
|
||||
return max(a, min(f, b));
|
||||
}
|
||||
|
||||
inline __device__ __host__ int3 clamp(int3 v, int a, int b)
|
||||
{
|
||||
return make_int3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
|
||||
}
|
||||
|
||||
inline __device__ __host__ int3 clamp(int3 v, int3 a, int3 b)
|
||||
{
|
||||
return make_int3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
|
||||
}
|
||||
|
||||
//validate
|
||||
inline __host__ __device__ bool validate(const int3 v0, const int3 v1)
|
||||
{
|
||||
return (v0.x == v1.x && v0.y == v1.y && v0.z == v1.z);
|
||||
}
|
||||
|
||||
// uint3 functions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// additional constructors
|
||||
inline __host__ __device__ uint3 make_uint3(uint s)
|
||||
{
|
||||
return make_uint3(s, s, s);
|
||||
}
|
||||
|
||||
inline __host__ __device__ uint4 make_uint4(uint s)
|
||||
{
|
||||
return make_uint4(s, s, s, s);
|
||||
}
|
||||
|
||||
inline __host__ __device__ uint3 make_uint3(float3 a)
|
||||
{
|
||||
return make_uint3(uint(a.x), uint(a.y), uint(a.z));
|
||||
}
|
||||
|
||||
// min
|
||||
inline __host__ __device__ uint3 min(uint3 a, uint3 b)
|
||||
{
|
||||
return make_uint3(min(a.x,b.x), min(a.y,b.y), min(a.z,b.z));
|
||||
}
|
||||
|
||||
// max
|
||||
inline __host__ __device__ uint3 max(uint3 a, uint3 b)
|
||||
{
|
||||
return make_uint3(max(a.x,b.x), max(a.y,b.y), max(a.z,b.z));
|
||||
}
|
||||
|
||||
// addition
|
||||
inline __host__ __device__ uint3 operator+(uint3 a, uint3 b)
|
||||
{
|
||||
return make_uint3(a.x + b.x, a.y + b.y, a.z + b.z);
|
||||
}
|
||||
inline __host__ __device__ void operator+=(uint3 &a, uint3 b)
|
||||
{
|
||||
a.x += b.x; a.y += b.y; a.z += b.z;
|
||||
}
|
||||
|
||||
// subtract
|
||||
inline __host__ __device__ uint3 operator-(uint3 a, uint3 b)
|
||||
{
|
||||
return make_uint3(a.x - b.x, a.y - b.y, a.z - b.z);
|
||||
}
|
||||
|
||||
inline __host__ __device__ void operator-=(uint3 &a, uint3 b)
|
||||
{
|
||||
a.x -= b.x; a.y -= b.y; a.z -= b.z;
|
||||
}
|
||||
|
||||
// multiply
|
||||
inline __host__ __device__ uint3 operator*(uint3 a, uint3 b)
|
||||
{
|
||||
return make_uint3(a.x * b.x, a.y * b.y, a.z * b.z);
|
||||
}
|
||||
inline __host__ __device__ uint3 operator*(uint3 a, uint s)
|
||||
{
|
||||
return make_uint3(a.x * s, a.y * s, a.z * s);
|
||||
}
|
||||
inline __host__ __device__ uint3 operator*(uint s, uint3 a)
|
||||
{
|
||||
return make_uint3(a.x * s, a.y * s, a.z * s);
|
||||
}
|
||||
inline __host__ __device__ void operator*=(uint3 &a, uint s)
|
||||
{
|
||||
a.x *= s; a.y *= s; a.z *= s;
|
||||
}
|
||||
|
||||
// divide
|
||||
inline __host__ __device__ uint3 operator/(uint3 a, uint3 b)
|
||||
{
|
||||
return make_uint3(a.x / b.x, a.y / b.y, a.z / b.z);
|
||||
}
|
||||
inline __host__ __device__ uint3 operator/(uint3 a, uint s)
|
||||
{
|
||||
return make_uint3(a.x / s, a.y / s, a.z / s);
|
||||
}
|
||||
inline __host__ __device__ uint3 operator/(uint s, uint3 a)
|
||||
{
|
||||
return make_uint3(a.x / s, a.y / s, a.z / s);
|
||||
}
|
||||
inline __host__ __device__ void operator/=(uint3 &a, uint s)
|
||||
{
|
||||
a.x /= s; a.y /= s; a.z /= s;
|
||||
}
|
||||
|
||||
|
||||
// clamp
|
||||
inline __device__ __host__ uint clamp(uint f, uint a, uint b)
|
||||
{
|
||||
return max(a, min(f, b));
|
||||
}
|
||||
|
||||
inline __device__ __host__ uint3 clamp(uint3 v, uint a, uint b)
|
||||
{
|
||||
return make_uint3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
|
||||
}
|
||||
|
||||
inline __device__ __host__ uint3 clamp(uint3 v, uint3 a, uint3 b)
|
||||
{
|
||||
return make_uint3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
|
||||
}
|
||||
|
||||
//validate
|
||||
inline __host__ __device__ bool validate(const uint3 v0, const uint3 v1)
|
||||
{
|
||||
return (v0.x == v1.x && v0.y == v1.y && v0.z == v1.z);
|
||||
}
|
||||
|
||||
//other
|
||||
inline __device__ __host__ ushort u32High(uint val)
|
||||
{
|
||||
return ushort(val >> 16);
|
||||
}
|
||||
|
||||
inline __device__ __host__ ushort u32Low(uint val)
|
||||
{
|
||||
return ushort(val & ((1 << 16u) - 1));
|
||||
}
|
||||
|
||||
inline __device__ __host__ uint merge(ushort hi, ushort lo)
|
||||
{
|
||||
return uint((uint(hi) << 16) | uint(lo));
|
||||
}
|
||||
|
||||
inline __device__ __host__ uchar u16High(ushort val)
|
||||
{
|
||||
return uchar(val >> 8);
|
||||
}
|
||||
|
||||
inline __device__ __host__ uchar u16Low(ushort val)
|
||||
{
|
||||
return uchar(val & ((1 << 8u) - 1));
|
||||
}
|
||||
|
||||
inline __device__ __host__ ushort merge(uchar hi, uchar lo)
|
||||
{
|
||||
return ushort((ushort(hi) << 8) | ushort(lo));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
75
engine/third_party/physx/source/gpucommon/include/mathsExtensions.h
vendored
Normal file
75
engine/third_party/physx/source/gpucommon/include/mathsExtensions.h
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
|
||||
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
|
||||
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
|
||||
|
||||
#ifndef MATHS_EXTENSIONS_H
|
||||
#define MATHS_EXTENSIONS_H
|
||||
|
||||
#include "cutil_math.h"
|
||||
#include "foundation/PxSimpleTypes.h"
|
||||
#include "foundation/PxQuat.h"
|
||||
#include "foundation/PxVec3.h"
|
||||
|
||||
namespace physx
|
||||
{
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal dot3(const float4& x, const float4& y)
|
||||
{
|
||||
return x.x * y.x + x.y * y.y + x.z * y.z;
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE float4 rotate(const PxQuat& r, const float4& v)
|
||||
{
|
||||
const PxF32 vx = 2.0f*v.x;
|
||||
const PxF32 vy = 2.0f*v.y;
|
||||
const PxF32 vz = 2.0f*v.z;
|
||||
const PxF32 w2 = r.w*r.w-0.5f;
|
||||
const PxF32 dot2 = (r.x*vx + r.y*vy +r.z*vz);
|
||||
return make_float4
|
||||
(
|
||||
(vx*w2 + (r.y * vz - r.z * vy)*r.w + r.x*dot2),
|
||||
(vy*w2 + (r.z * vx - r.x * vz)*r.w + r.y*dot2),
|
||||
(vz*w2 + (r.x * vy - r.y * vx)*r.w + r.z*dot2),
|
||||
0.f
|
||||
);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE float4 cross3(const float4& v0, const float4& v2)
|
||||
{
|
||||
return make_float4(v0.y * v2.z - v0.z * v2.y,
|
||||
v0.z * v2.x - v0.x * v2.z,
|
||||
v0.x * v2.y - v0.y * v2.x,
|
||||
0.f);
|
||||
}
|
||||
|
||||
PX_CUDA_CALLABLE PX_FORCE_INLINE float4 operator - (const float4& v)
|
||||
{
|
||||
return make_float4(-v.x, -v.y, -v.z, -v.w);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user