Main Page Class List Class Members

- Main Page
- User's Guide
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# sdk/toolkit/source/NvBlastTkGroupImpl.h

Go to the documentation of this file.

    00001 // This code contains NVIDIA Confidential Information and is disclosed to you
    00002 // under a form of NVIDIA software license agreement provided separately to you.
    00003 //
    00004 // Notice
    00005 // NVIDIA Corporation and its licensors retain all intellectual property and
    00006 // proprietary rights in and to this software and related documentation and
    00007 // any modifications thereto. Any use, reproduction, disclosure, or
    00008 // distribution of this software and related documentation without an express
    00009 // license agreement from NVIDIA Corporation is strictly prohibited.
    00010 //
    00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
    00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
    00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
    00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
    00015 //
    00016 // Information and code furnished is believed to be accurate and reliable.
    00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
    00018 // information or for any infringement of patents or other rights of third parties that may
    00019 // result from its use. No license is granted by implication or otherwise under any patent
    00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
    00021 // This code supersedes and replaces all information previously supplied.
    00022 // NVIDIA Corporation products are not authorized for use as critical
    00023 // components in life support devices or systems without express written approval of
    00024 // NVIDIA Corporation.
    00025 //
    00026 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
    00027
    00028
    00029 #ifndef NVBLASTTKGROUPIMPL_H
    00030 #define NVBLASTTKGROUPIMPL_H
    00031
    00032
    00033 #include "NvBlastTkTaskImpl.h"
    00034 #include "NvBlastTkGroup.h"
    00035 #include "NvBlastTkTypeImpl.h"
    00036
    00037
    00038 namespace Nv
    00039 {
    00040 namespace Blast
    00041 {
    00042
    00043 class TkActorImpl;
    00044 class TkFamilyImpl;
    00045
    00046 NVBLASTTK_IMPL_DECLARE(Group)
    00047 {
    00048     ~TkGroupImpl();
    00049
    00050 public:
    00051     TkGroupImpl();
    00052
    00053     NVBLASTTK_IMPL_DEFINE_IDENTIFIABLE('G', 'R', 'P', '\0');
    00054
    00055     static TkGroupImpl*     create(const TkGroupDesc& desc);
    00056
    00057     // Begin TkGroup
    00058     virtual bool            addActor(TkActor& actor) override;
    00059
    00060     virtual uint32_t        getActorCount() const override;
    00061
    00062     virtual uint32_t        getActors(TkActor** buffer, uint32_t bufferSize, uint32_t indexStart = 0) const override;
    00063
    00064     virtual uint32_t        startProcess() override;
    00065     virtual bool            endProcess() override;
    00066
    00067     virtual void            getStats(TkGroupStats& stats) const override;
    00068
    00069     virtual void            setWorkerCount(uint32_t workerCount) override;
    00070     virtual uint32_t        getWorkerCount() const override;
    00071
    00072     virtual TkGroupWorker*  acquireWorker() override;
    00073     virtual void            returnWorker(TkGroupWorker*) override;
    00074     // End TkGroup
    00075
    00076     // TkGroupImpl API
    00077
    00085     bool                    removeActor(TkActor& actor);
    00086
    00091     void                    enqueue(TkActorImpl* tkActor);
    00092
    00098     bool                    isProcessing() const;
    00099
    00100 private:
    00109     bool                    setProcessing(bool value);
    00110
    00114     SharedMemory*           getSharedMemory(TkFamilyImpl* family);
    00115     void                    releaseSharedMemory(TkFamilyImpl* fam, SharedMemory* mem);
    00116
    00117     // functions to add/remove actors _without_ group-family memory management
    00118     void                    addActorInternal(TkActorImpl& tkActor);
    00119     void                    addActorsInternal(TkActorImpl** actors, uint32_t numActors);
    00120     void                    removeActorInternal(TkActorImpl& tkActor);
    00121
    00122
    00123     uint32_t                                        m_actorCount;
    00124
    00125     HashMap<TkFamilyImpl*, SharedMemory*>::type     m_sharedMemory;
    00126
    00127     // it is assumed no more than the asset's number of bond and chunks fracture commands are produced
    00128     SharedBlock<NvBlastChunkFractureData>           m_chunkTempDataBlock;
    00129     SharedBlock<NvBlastBondFractureData>            m_bondTempDataBlock;
    00130     SharedBlock<NvBlastChunkFractureData>           m_chunkEventDataBlock;
    00131     SharedBlock<NvBlastBondFractureData>            m_bondEventDataBlock;
    00132     SharedBlock<char>                               m_splitScratchBlock;
    00133
    00134     std::atomic<bool>                               m_isProcessing;
    00135
    00136     Array<TkWorker>::type                           m_workers;
    00137
    00138     Array<TkWorkerJob>::type                        m_jobs;
    00139
    00140 //#if NV_PROFILE
    00141     TkGroupStats                                    m_stats;
    00142 //#endif
    00143
    00144     std::mutex  m_workerMtx;
    00145
    00146     friend class TkWorker;
    00147 };
    00148
    00149
    00150 NV_INLINE bool TkGroupImpl::isProcessing() const
    00151 {
    00152     return m_isProcessing.load();
    00153 }
    00154
    00155
    00156 NV_INLINE void TkGroupImpl::getStats(TkGroupStats& stats) const
    00157 {
    00158 #if NV_PROFILE
    00159     memcpy(&stats, &m_stats, sizeof(TkGroupStats));
    00160 #else
    00161     NV_UNUSED(stats);
    00162 #endif
    00163 }
    00164
    00165
    00166 NV_INLINE uint32_t TkGroupImpl::getActorCount() const
    00167 {
    00168     return m_actorCount;
    00169 }
    00170
    00171
    00172 NV_INLINE SharedMemory* TkGroupImpl::getSharedMemory(TkFamilyImpl* family)
    00173 {
    00174     SharedMemory* mem = m_sharedMemory[family];
    00175     NVBLAST_ASSERT(mem != nullptr);
    00176     return mem;
    00177 }
    00178
    00179
    00180 NV_FORCE_INLINE void operator +=(NvBlastTimers& lhs, const NvBlastTimers& rhs)
    00181 {
    00182     lhs.material += rhs.material;
    00183     lhs.fracture += rhs.fracture;
    00184     lhs.island += rhs.fracture;
    00185     lhs.partition += rhs.partition;
    00186     lhs.visibility += rhs.visibility;
    00187 }
    00188
    00189
    00190 } // namespace Blast
    00191 } // namespace Nv
    00192
    00193
    00194 #endif // ifndef NVBLASTTKGROUPIMPL_H

Copyright © 2015-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com