diff options
| author | Marijn Tamis <[email protected]> | 2017-10-20 14:30:56 +0200 |
|---|---|---|
| committer | Marijn Tamis <[email protected]> | 2017-10-20 14:36:12 +0200 |
| commit | fabb251458f4a2d6d4f87dd36038fac2774b378c (patch) | |
| tree | 68a4a0ecd940dc949e0477d521d8c159968cfcd5 /NvCloth/src/cuda | |
| parent | NvCloth 1.1.2 Release. (22576033) (diff) | |
| download | nvcloth-1.1.3.tar.xz nvcloth-1.1.3.zip | |
NvCloth 1.1.3 Release. (23014067)v1.1.3
Diffstat (limited to 'NvCloth/src/cuda')
| -rw-r--r-- | NvCloth/src/cuda/CuCloth.cpp | 2 | ||||
| -rw-r--r-- | NvCloth/src/cuda/CuClothData.h | 2 | ||||
| -rw-r--r-- | NvCloth/src/cuda/CuFabric.cpp | 1 | ||||
| -rw-r--r-- | NvCloth/src/cuda/CuPinnedAllocator.h | 18 | ||||
| -rw-r--r-- | NvCloth/src/cuda/CuSolver.cpp | 52 | ||||
| -rw-r--r-- | NvCloth/src/cuda/CuSolver.h | 5 |
6 files changed, 52 insertions, 28 deletions
diff --git a/NvCloth/src/cuda/CuCloth.cpp b/NvCloth/src/cuda/CuCloth.cpp index 3e6175b..4131b04 100644 --- a/NvCloth/src/cuda/CuCloth.cpp +++ b/NvCloth/src/cuda/CuCloth.cpp @@ -423,7 +423,7 @@ void CuCloth::clearParticleAccelerations() { CuContextLock contextLock(mFactory); CuDeviceVector<PxVec4>(mFactory.mContext).swap(mParticleAccelerations); - CuHostVector<PxVec4, CU_MEMHOSTALLOC_DEVICEMAP>::Type().swap(mParticleAccelerationsHostCopy); + CuHostVector<PxVec4, CU_MEMHOSTALLOC_DEVICEMAP>::Type(mFactory.mContext).swap(mParticleAccelerationsHostCopy); wakeUp(); } diff --git a/NvCloth/src/cuda/CuClothData.h b/NvCloth/src/cuda/CuClothData.h index dd836fd..5f2d7c6 100644 --- a/NvCloth/src/cuda/CuClothData.h +++ b/NvCloth/src/cuda/CuClothData.h @@ -32,7 +32,7 @@ #include <foundation/Px.h> #ifndef __CUDACC__ -#include "simd.h" +#include "Simd.h" #endif namespace nv diff --git a/NvCloth/src/cuda/CuFabric.cpp b/NvCloth/src/cuda/CuFabric.cpp index 9bc20db..957f912 100644 --- a/NvCloth/src/cuda/CuFabric.cpp +++ b/NvCloth/src/cuda/CuFabric.cpp @@ -31,6 +31,7 @@ #include "CuContextLock.h" #include "CuFactory.h" #include <PsUtilities.h> +#include <limits.h> using namespace physx; diff --git a/NvCloth/src/cuda/CuPinnedAllocator.h b/NvCloth/src/cuda/CuPinnedAllocator.h index 8b1787b..9939324 100644 --- a/NvCloth/src/cuda/CuPinnedAllocator.h +++ b/NvCloth/src/cuda/CuPinnedAllocator.h @@ -29,6 +29,8 @@ #pragma once +#include <utility> + #include "CuCheckSuccess.h" #include "NvCloth/Allocator.h" @@ -102,7 +104,7 @@ public: void destroy(T* ptr) { - core::unused(ptr); + PX_UNUSED(ptr); ptr->~T(); } @@ -122,13 +124,13 @@ bool operator!=(const CuHostAllocator<T1, Flag1>&, const CuHostAllocator<T2, Fla return false; } -//Use CuHostVectorImpl instead of physx::shdfnd::Array<T, typename CuHostAllocator<T, Flags>> +//Use CuHostVectorImpl instead of physx::shdfnd::Array<T, CuHostAllocator<T, Flags>> //This entire class is just to make sure that the mDevicePtr from the CuHostAllocator is properly swapped together with mData template <typename T, unsigned Flags = 0> -class CuHostVectorImpl : public physx::shdfnd::Array<T, typename CuHostAllocator<T, Flags>> +class CuHostVectorImpl : public physx::shdfnd::Array<T, CuHostAllocator<T, Flags>> { - typedef physx::shdfnd::Array<T, typename CuHostAllocator<T, Flags>> Super; - typedef typename CuHostAllocator<T, Flags> Alloc; + typedef physx::shdfnd::Array<T, CuHostAllocator<T, Flags>> Super; + typedef CuHostAllocator<T, Flags> Alloc; public: explicit CuHostVectorImpl(const physx::PxEMPTY v):Super(v){} PX_INLINE explicit CuHostVectorImpl(const Alloc& alloc = Alloc()):Super(alloc){} @@ -142,10 +144,10 @@ public: PX_INLINE explicit CuHostVectorImpl(const T* first, const T* last, const Alloc& alloc = Alloc()):Super(first,last,alloc){} - void swap(physx::shdfnd::Array<T, typename CuHostAllocator<T, Flags>>& other) + void swap(CuHostVectorImpl<T, Flags>& other) { - PX_ASSERT(mContext == other.mContext); - physx::shdfnd::swap(mDevicePtr, other.mDevicePtr); + NV_CLOTH_ASSERT(this->mContext == other.mContext); + physx::shdfnd::swap(this->mDevicePtr, other.mDevicePtr); Super::swap(other); } }; diff --git a/NvCloth/src/cuda/CuSolver.cpp b/NvCloth/src/cuda/CuSolver.cpp index f0e328f..7ef1d32 100644 --- a/NvCloth/src/cuda/CuSolver.cpp +++ b/NvCloth/src/cuda/CuSolver.cpp @@ -302,6 +302,28 @@ cloth::CuSolver::~CuSolver() mFactory.mSolverCount--; } +void cloth::CuSolver::addClothAppend(Cloth* cloth) +{ + CuCloth& cuCloth = *static_cast<CuCloth*>(cloth); + + NV_CLOTH_ASSERT(mCloths.find(&cuCloth) == mCloths.end()); + + mCloths.pushBack(&cuCloth); + // trigger update of mClothData array + cuCloth.notifyChanged(); +} + +void cloth::CuSolver::addClothUpdateData() +{ + CuContextLock contextLock(mFactory); + + // resize containers and update kernel data + mClothDataHostCopy.resize(mCloths.size()); + mClothData.resize(mCloths.size()); + mFrameData.resize(mCloths.size()); + updateKernelData(); +} + void cloth::CuSolver::updateKernelData() { mKernelDataHost.mClothIndex = mClothIndex.get(); @@ -326,24 +348,17 @@ struct ClothSimCostGreater void cloth::CuSolver::addCloth(Cloth* cloth) { - CuCloth& cuCloth = *static_cast<CuCloth*>(cloth); - - NV_CLOTH_ASSERT(mCloths.find(&cuCloth) == mCloths.end()); - - mCloths.pushBack(&cuCloth); - // trigger update of mClothData array - cuCloth.notifyChanged(); - - // sort cloth instances by size - shdfnd::sort(mCloths.begin(), mCloths.size(), ClothSimCostGreater(), NonTrackingAllocator()); - - CuContextLock contextLock(mFactory); + addClothAppend(cloth); + addClothUpdateData(); +} - // resize containers and update kernel data - mClothDataHostCopy.resize(mCloths.size()); - mClothData.resize(mCloths.size()); - mFrameData.resize(mCloths.size()); - updateKernelData(); +void cloth::CuSolver::addCloths(Range<Cloth*> cloths) +{ + for (uint32_t i = 0; i < cloths.size(); ++i) + { + addClothAppend(*(cloths.begin() + i)); + } + addClothUpdateData(); } void cloth::CuSolver::removeCloth(Cloth* cloth) @@ -401,7 +416,8 @@ void cloth::CuSolver::endSimulation() int cloth::CuSolver::getSimulationChunkCount() const { - return 1; + // 0 chunks when no cloth present in the solver, 1 otherwise + return getNumCloths() != 0; } void cloth::CuSolver::beginFrame() diff --git a/NvCloth/src/cuda/CuSolver.h b/NvCloth/src/cuda/CuSolver.h index 0406e00..b4c6d6b 100644 --- a/NvCloth/src/cuda/CuSolver.h +++ b/NvCloth/src/cuda/CuSolver.h @@ -58,6 +58,7 @@ public: ~CuSolver(); virtual void addCloth(Cloth*) override; + virtual void addCloths(Range<Cloth*> cloths) override; virtual void removeCloth(Cloth*) override; virtual int getNumCloths() const override; virtual Cloth * const * getClothList() const override; @@ -103,6 +104,10 @@ public: } private: + // add cloth helper functions + void addClothAppend(Cloth* cloth); + void addClothUpdateData(); + void updateKernelData(); // context needs to be acquired // simulate helper functions |