Main Page Class List Class Members

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

- File List
- File Members

# sdk/lowlevel/source/NvBlastAsset.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 NVBLASTASSET_H
    00030 #define NVBLASTASSET_H
    00031
    00032
    00033 #include "NvBlastSupportGraph.h"
    00034 #include "NvBlast.h"
    00035 #include "NvBlastAssert.h"
    00036 #include "NvBlastIndexFns.h"
    00037 #include "NvBlastChunkHierarchy.h"
    00038
    00039
    00040 namespace Nv
    00041 {
    00042 namespace Blast
    00043 {
    00044
    00045 class Asset : public NvBlastAsset
    00046 {
    00047 public:
    00048
    00052     struct ChunkAnnotation
    00053     {
    00054         enum Enum
    00055         {
    00056             Parent = (1 << 0),
    00057             Support = (1 << 1),
    00058             SuperSupport = (1 << 2),
    00059
    00060             // Combinations
    00061             UpperSupport = Support | SuperSupport
    00062         };
    00063     };
    00064
    00065
    00076     static Asset*   create(void* mem, const NvBlastAssetDesc* desc, void* scratch, NvBlastLog logFn);
    00077
    00084     static size_t   getMemorySize(const NvBlastAssetDesc* desc);
    00085
    00094     static size_t   createRequiredScratch(const NvBlastAssetDesc* desc);
    00095
    00096
    00102     uint32_t        getUpperSupportChunkCount() const;
    00103
    00109     uint32_t        getLowerSupportChunkCount() const;
    00110
    00116     uint32_t        getBondCount() const;
    00117
    00123     uint32_t        getHierarchyCount() const;
    00124
    00132     uint32_t        getContiguousLowerSupportIndex(uint32_t chunkIndex) const;
    00133
    00134
    00135     // Static functions
    00136
    00156     static bool     ensureExactSupportCoverage(uint32_t& supportChunkCount, uint32_t& leafChunkCount, char* chunkAnnotation, uint32_t chunkCount, NvBlastChunkDesc* chunkDescs, bool testOnly, NvBlastLog logFn);
    00157
    00174     static bool     testForValidChunkOrder(uint32_t chunkCount, const NvBlastChunkDesc* chunkDescs, const char* chunkAnnotation, void* scratch);
    00175
    00176
    00178
    00182     NvBlastDataBlock    m_header;
    00183
    00187     NvBlastID           m_ID;
    00188
    00192     uint32_t            m_chunkCount;
    00193
    00197     SupportGraph        m_graph;
    00198
    00202     uint32_t            m_leafChunkCount;
    00203
    00207     uint32_t            m_firstSubsupportChunkIndex;
    00208
    00212     uint32_t            m_bondCount;
    00213
    00219     NvBlastBlockArrayData(NvBlastChunk, m_chunksOffset, getChunks, m_chunkCount);
    00220
    00229     NvBlastBlockArrayData(NvBlastBond, m_bondsOffset, getBonds, m_bondCount);
    00230
    00237     NvBlastBlockArrayData(uint32_t, m_subtreeLeafChunkCountsOffset, getSubtreeLeafChunkCounts, m_chunkCount);
    00238
    00244     NvBlastBlockArrayData(uint32_t, m_chunkToGraphNodeMapOffset, getChunkToGraphNodeMap, m_chunkCount);
    00245
    00246
    00248
    00253     class DepthFirstIt : public ChunkDepthFirstIt
    00254     {
    00255     public:
    00257         DepthFirstIt(const Asset& asset, uint32_t startChunkIndex, bool upperSupportOnly = false) :
    00258             ChunkDepthFirstIt(asset.getChunks(), startChunkIndex, upperSupportOnly ? asset.getUpperSupportChunkCount() : asset.m_chunkCount) {}
    00259     };
    00260 };
    00261
    00262
    00264
    00265 NV_INLINE uint32_t Asset::getUpperSupportChunkCount() const
    00266 {
    00267     return m_firstSubsupportChunkIndex;
    00268 }
    00269
    00270
    00271 NV_INLINE uint32_t Asset::getLowerSupportChunkCount() const
    00272 {
    00273     return m_graph.m_nodeCount + (m_chunkCount - m_firstSubsupportChunkIndex);
    00274 }
    00275
    00276
    00277 NV_INLINE uint32_t Asset::getBondCount() const
    00278 {
    00279     NVBLAST_ASSERT((m_graph.getAdjacencyPartition()[m_graph.m_nodeCount] & 1) == 0);    // The bidirectional graph data should have an even number of edges
    00280     return m_graph.getAdjacencyPartition()[m_graph.m_nodeCount] / 2;    // Directional bonds, divide by two
    00281 }
    00282
    00283
    00284 NV_INLINE uint32_t Asset::getHierarchyCount() const
    00285 {
    00286     const NvBlastChunk* chunks = getChunks();
    00287     for (uint32_t i = 0; i < m_chunkCount; ++i)
    00288     {
    00289         if (!isInvalidIndex(chunks[i].parentChunkIndex))
    00290         {
    00291             return i;
    00292         }
    00293     }
    00294     return m_chunkCount;
    00295 }
    00296
    00297
    00298 NV_INLINE uint32_t Asset::getContiguousLowerSupportIndex(uint32_t chunkIndex) const
    00299 {
    00300     NVBLAST_ASSERT(chunkIndex < m_chunkCount);
    00301
    00302     return chunkIndex < m_firstSubsupportChunkIndex ? getChunkToGraphNodeMap()[chunkIndex] : (chunkIndex - m_firstSubsupportChunkIndex + m_graph.m_nodeCount);
    00303 }
    00304
    00305
    00306 //JDM: Expose this so serialization layer can use it.
    00307 NVBLAST_API Asset* initializeAsset(void* mem, NvBlastID id, uint32_t chunkCount, uint32_t graphNodeCount, uint32_t leafChunkCount, uint32_t firstSubsupportChunkIndex, uint32_t bondCount, NvBlastLog logFn);
    00308
    00309 } // namespace Blast
    00310 } // namespace Nv
    00311
    00312
    00313 #endif // ifndef NVBLASTASSET_H

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