diff options
| author | Bryan Galdrikian <[email protected]> | 2017-02-21 12:07:59 -0800 |
|---|---|---|
| committer | Bryan Galdrikian <[email protected]> | 2017-02-21 12:07:59 -0800 |
| commit | 446ce137c6823ba9eff273bdafdaf266287c7c98 (patch) | |
| tree | d20aab3e2ed08d7b3ca71c2f40db6a93ea00c459 /NvBlast/sdk/lowlevel/include | |
| download | blast-1.0.0-beta.tar.xz blast-1.0.0-beta.zip | |
first commitv1.0.0-beta
Diffstat (limited to 'NvBlast/sdk/lowlevel/include')
| -rw-r--r-- | NvBlast/sdk/lowlevel/include/NvBlast.h | 807 | ||||
| -rw-r--r-- | NvBlast/sdk/lowlevel/include/NvBlastPreprocessor.h | 31 | ||||
| -rw-r--r-- | NvBlast/sdk/lowlevel/include/NvBlastProfiler.h | 52 | ||||
| -rw-r--r-- | NvBlast/sdk/lowlevel/include/NvBlastTypes.h | 632 | ||||
| -rw-r--r-- | NvBlast/sdk/lowlevel/include/NvPreprocessor.h | 540 |
5 files changed, 2062 insertions, 0 deletions
diff --git a/NvBlast/sdk/lowlevel/include/NvBlast.h b/NvBlast/sdk/lowlevel/include/NvBlast.h new file mode 100644 index 0000000..d4c91a7 --- /dev/null +++ b/NvBlast/sdk/lowlevel/include/NvBlast.h @@ -0,0 +1,807 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLAST_H +#define NVBLAST_H + + +#include "NvBlastTypes.h" + + +/////////////////////////////////////////////////////////////////////////////// +// NvBlastAsset functions +/////////////////////////////////////////////////////////////////////////////// +///@{ + +/** +Calculates the memory requirements for an asset based upon its descriptor. Use this function +when building an asset with NvBlastCreateAsset. + +\param[in] desc Asset descriptor (see NvBlastAssetDesc). +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the memory size (in bytes) required for the asset, or zero if desc is invalid. +*/ +NVBLAST_API size_t NvBlastGetAssetMemorySize(const NvBlastAssetDesc* desc, NvBlastLog logFn); + + +/** +Returns the number of bytes of scratch memory that the user must supply to NvBlastCreateAsset, +based upon the descriptor that will be passed into that function. + +\param[in] desc The asset descriptor that will be passed into NvBlastCreateAsset. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the number of bytes of scratch memory required for a call to NvBlastCreateAsset with that descriptor. +*/ +NVBLAST_API size_t NvBlastGetRequiredScratchForCreateAsset(const NvBlastAssetDesc* desc, NvBlastLog logFn); + + +/** +Asset-building function. + +Constructs an NvBlastAsset in-place at the address given by the user. The address must point to a block +of memory of at least the size given by NvBlastGetAssetMemorySize(desc, logFn), and must be 16-byte aligned. + +Support chunks (marked in the NvBlastChunkDesc struct) must provide full coverage over the asset. +This means that from any leaf chunk to the root node, exactly one chunk must be support. If this condition +is not met the function fails to create an asset. + +Any bonds described by NvBlastBondDesc descriptors that reference non-support chunks will be removed. +Duplicate bonds will be removed as well (bonds that are between the same chunk pairs). + +Chunks in the asset should be arranged such that sibling chunks (chunks with the same parent) are contiguous. +Chunks are also should be arranged such that leaf chunks (chunks with no children) are at the end of the chunk list. +If chunks aren't arranged properly the function fails to create an asset. + +\param[in] mem Pointer to block of memory of at least the size given by NvBlastGetAssetMemorySize(desc, logFn). Must be 16-byte aligned. +\param[in] desc Asset descriptor (see NvBlastAssetDesc). +\param[in] scratch User-supplied scratch memory of size NvBlastGetRequiredScratchForCreateAsset(desc) bytes. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return pointer to new NvBlastAsset (will be the same address as mem), or NULL if unsuccessful. +*/ +NVBLAST_API NvBlastAsset* NvBlastCreateAsset(void* mem, const NvBlastAssetDesc* desc, void* scratch, NvBlastLog logFn); + + +/** +Calculates the memory requirements for a family based upon an asset. Use this function +when building a family with NvBlastAssetCreateFamily. + +\param[in] asset Asset used to build the family (see NvBlastAsset). +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the memory size (in bytes) required for the family, or zero if asset is invalid. +*/ +NVBLAST_API size_t NvBlastAssetGetFamilyMemorySize(const NvBlastAsset* asset, NvBlastLog logFn); + + +/** +Family-building function. + +Constructs an NvBlastFamily in-place at the address given by the user. The address must point to a block +of memory of at least the size given by NvBlastAssetGetFamilyMemorySize(asset, logFn), and must be 16-byte aligned. + +\param[in] mem Pointer to block of memory of at least the size given by NvBlastAssetGetFamilyMemorySize(asset, logFn). Must be 16-byte aligned. +\param[in] asset Asset to instance. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the family. +*/ +NVBLAST_API NvBlastFamily* NvBlastAssetCreateFamily(void* mem, const NvBlastAsset* asset, NvBlastLog logFn); + + +/** +Retrieve the asset ID. + +\param[in] asset The given asset. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the ID of the asset. +*/ +NVBLAST_API NvBlastID NvBlastAssetGetID(const NvBlastAsset* asset, NvBlastLog logFn); + + +/** +Set an asset's ID + +\param[in] asset The given asset. +\param[in] id A pointer to the id to copy into the asset. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return true iff the id is successfully set. +*/ +NVBLAST_API bool NvBlastAssetSetID(NvBlastAsset* asset, const NvBlastID* id, NvBlastLog logFn); + + +/** +Retrieve the data format version for the given asset + +\param[in] asset The asset. Cannot be NULL. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the data format version (NvBlastAssetDataFormat). +*/ +NVBLAST_API uint32_t NvBlastAssetGetFormatVersion(const NvBlastAsset* asset, NvBlastLog logFn); + + +/** +Retrieve the memory size (in bytes) of the given data asset + +\param[in] asset The asset. Cannot be NULL. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the memory size of the asset (in bytes). +*/ +NVBLAST_API uint32_t NvBlastAssetGetSize(const NvBlastAsset* asset, NvBlastLog logFn); + + +/** +Get the number of chunks in the given asset. + +\param[in] asset The asset. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the number of chunks in the asset. +*/ +NVBLAST_API uint32_t NvBlastAssetGetChunkCount(const NvBlastAsset* asset, NvBlastLog logFn); + + +/** +Get the number of leaf chunks in the given asset. + +\param[in] asset The asset. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the number of leaf chunks in the asset. +*/ +NVBLAST_API uint32_t NvBlastAssetGetLeafChunkCount(const NvBlastAsset* asset, NvBlastLog logFn); + + +/** +Get the first subsupport chunk index in the given asset. Chunks are sorted such that subsupport chunks +come last. This is the first subsupport chunk index. Equals to total chunk count if there are no subsupport +chunks. + +\param[in] asset The asset. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the first subsupport chunk index in the asset. +*/ +NVBLAST_API uint32_t NvBlastAssetGetFirstSubsupportChunkIndex(const NvBlastAsset* asset, NvBlastLog logFn); + + +/** +Get the number of bonds in the given asset. + +\param[in] asset The asset. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the number of bonds in the asset. +*/ +NVBLAST_API uint32_t NvBlastAssetGetBondCount(const NvBlastAsset* asset, NvBlastLog logFn); + + +/** +Access the support graph for the given asset. + +\param[in] asset The asset. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return a struct of support graph for the given asset. +*/ +NVBLAST_API const NvBlastSupportGraph NvBlastAssetGetSupportGraph(const NvBlastAsset* asset, NvBlastLog logFn); + + +/** +Access a map from chunk index to graph node index. +Returned map is valid in the domain [0, NvBlastAssetGetChunkCount(asset, logFn)). +Non-support chunks are mapped to the invalid index 0xFFFFFFFF. + +\param[in] asset The asset. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return an array of uint32_t values defining the map, of size NvBlastAssetGetChunkCount(asset, logFn). +*/ +NVBLAST_API const uint32_t* NvBlastAssetGetChunkToGraphNodeMap(const NvBlastAsset* asset, NvBlastLog logFn); + + +/** +Access an array of chunks of the given asset. + +\param[in] asset The asset. +\param[in] logFn User - supplied message function(see NvBlastLog definition).May be NULL. + +\return a pointer to an array of chunks of the asset. +*/ +NVBLAST_API const NvBlastChunk* NvBlastAssetGetChunks(const NvBlastAsset* asset, NvBlastLog logFn); + + +/** +Access an array of bonds of the given asset. + +\param[in] asset The asset. +\param[in] logFn User - supplied message function(see NvBlastLog definition).May be NULL. + +\return a pointer to an array of bonds of the asset. +*/ +NVBLAST_API const NvBlastBond* NvBlastAssetGetBonds(const NvBlastAsset* asset, NvBlastLog logFn); + + +/** +A buffer size sufficient to serialize an actor instanced from a given asset. +This function is faster than NvBlastActorGetSerializationSize, and can be used to create a reusable buffer +for actor serialization. + +\param[in] asset The asset. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the required buffer size in bytes. +*/ +NVBLAST_API uint32_t NvBlastAssetGetActorSerializationSizeUpperBound(const NvBlastAsset* asset, NvBlastLog logFn); + +///@} End NvBlastAsset functions + + +/////////////////////////////////////////////////////////////////////////////// +// NvBlastAsset helper functions +/////////////////////////////////////////////////////////////////////////////// +///@{ + +/** +Function to ensure (check and update) support coverage of chunks. + +Support chunks (marked in the NvBlastChunkDesc struct) must provide full coverage over the asset. +This means that from any leaf chunk to the root node, exactly one chunk must be support. If this condition +is not met, the actual support chunks will be adjusted accordingly. + +Chunk order depends on support coverage, so this function should be called before chunk reordering. + +\param[in] chunkDescs Array of chunk descriptors of size chunkCount. It will be updated accordingly. +\param[in] chunkCount The number of chunk descriptors. +\param[in] scratch User-supplied scratch storage, must point to chunkCount valid bytes of memory. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return true iff coverage was already exact. +*/ +NVBLAST_API bool NvBlastEnsureAssetExactSupportCoverage(NvBlastChunkDesc* chunkDescs, uint32_t chunkCount, void* scratch, NvBlastLog logFn); + + +/** +Build chunk reorder map. + +NvBlastCreateAsset function requires NvBlastChunkDesc array to be in correct oder: + +1. Root chunks (chunks with invalid parent index) must be first in the asset's chunk list. +2. Chunks in the asset should be arranged such that sibling chunks (chunks with the same parent) are contiguous. +3. Chunks are also should be arranged such that upper-support chunks (support chunks and their parent chunks) should go first in +chunk list. + +This function builds chunk reorder map which can be used to order chunk descs. Reordering chunk's descriptors +according to generated map places them in correct order for NvBlastCreateAsset to succeed. + +Iff chunks are already ordered correctly, function returns 'true' and identity chunk reorder map. Otherwise 'false' is returned. + +\param[out] chunkReorderMap User-supplied map of size chunkCount to fill. For every chunk index this array will contain new chunk position (index). +\param[in] chunkDescs Array of chunk descriptors of size chunkCount. +\param[in] chunkCount The number of chunk descriptors. +\param[in] scratch User-supplied scratch storage, must point to 2 * chunkCount * sizeof(uint32_t) valid bytes of memory. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return true iff the chunks did not require reordering (chunkReorderMap is the identity map). +*/ +NVBLAST_API bool NvBlastBuildAssetDescChunkReorderMap(uint32_t* chunkReorderMap, const NvBlastChunkDesc* chunkDescs, uint32_t chunkCount, void* scratch, NvBlastLog logFn); + + +/** +Apply chunk reorder map. + +Function applies reorder map on NvBlastChunkDesc and NvBlastBondDesc arrays. It reorders chunks, replaces their 'parentChunkIndex' field +with new indices. Bonds are kept in the same order, but their 'chunkIndices' field is updated with proper indices. + +@see NvBlastBuildAssetDescChunkReorderMap + +\param[out] reorderedChunkDescs User-supplied array of size chunkCount to fill with new reordered NvBlastChunkDesc's. +\param[in] chunkDescs Array of chunk descriptors of size chunkCount. +\param[in] chunkCount The number of chunk descriptors. +\param[in] bondDescs Array of bond descriptors of size chunkCount. It will be updated accordingly. +\param[in] bondCount The number of bond descriptors. +\param[in] chunkReorderMap Chunk reorder map to use, must be of size chunkCount. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. +*/ +NVBLAST_API void NvBlastApplyAssetDescChunkReorderMap +( + NvBlastChunkDesc* reorderedChunkDescs, + const NvBlastChunkDesc* chunkDescs, + uint32_t chunkCount, + NvBlastBondDesc* bondDescs, + uint32_t bondCount, + const uint32_t* chunkReorderMap, + NvBlastLog logFn +); + + +/** +Apply chunk reorder map. + +Function applies reorder map on NvBlastChunkDesc and NvBlastBondDesc arrays. It reorders chunks, replaces their 'parentChunkIndex' field +with new indices. Bonds are kept in the same order, but their 'chunkIndices' field is updated with proper indices. + +This overload of function reorders chunks in place. + +@see NvBlastBuildAssetDescChunkReorderMap + +\param[in] chunkDescs Array of chunk descriptors of size chunkCount. It will be updated accordingly. +\param[in] chunkCount The number of chunk descriptors. +\param[in] bondDescs Array of bond descriptors of size chunkCount. It will be updated accordingly. +\param[in] bondCount The number of bond descriptors. +\param[in] chunkReorderMap Chunk reorder map to use, must be of size chunkCount. +\param[in] scratch User-supplied scratch storage, must point to chunkCount * sizeof(NvBlastChunkDesc) valid bytes of memory. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. +*/ +NVBLAST_API void NvBlastApplyAssetDescChunkReorderMapInplace(NvBlastChunkDesc* chunkDescs, uint32_t chunkCount, NvBlastBondDesc* bondDescs, uint32_t bondCount, const uint32_t* chunkReorderMap, void* scratch, NvBlastLog logFn); + + +/** +Build and apply chunk reorder map. + +Function basically calls NvBlastBuildAssetDescChunkReorderMap and NvBlastApplyAssetDescChunkReorderMap. Used for Convenience. + +\param[in] chunkDescs Array of chunk descriptors of size chunkCount. It will be updated accordingly. +\param[in] chunkCount The number of chunk descriptors. +\param[in] bondDescs Array of bond descriptors of size chunkCount. It will be updated accordingly. +\param[in] bondCount The number of bond descriptors. +\param[in] chunkReorderMap Chunk reorder map to fill, must be of size chunkCount. +\param[in] scratch User-supplied scratch storage, must point to chunkCount * sizeof(NvBlastChunkDesc) valid bytes of memory. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return true iff the chunks did not require reordering (chunkReorderMap is the identity map). +*/ +NVBLAST_API bool NvBlastReorderAssetDescChunks(NvBlastChunkDesc* chunkDescs, uint32_t chunkCount, NvBlastBondDesc* bondDescs, uint32_t bondCount, uint32_t* chunkReorderMap, void* scratch, NvBlastLog logFn); + +///@} End NvBlastAsset helper functions + + +/////////////////////////////////////////////////////////////////////////////// +// NvBlastFamily functions +/////////////////////////////////////////////////////////////////////////////// +///@{ + +/** +Retrieve the data format version for the given family. + +\param[in] family The family. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the family format version. +*/ +NVBLAST_API uint32_t NvBlastFamilyGetFormatVersion(const NvBlastFamily* family, NvBlastLog logFn); + + +/** +Set asset to the family. It should be the same asset as the one family was created from (same ID). + +\param[in] family The family. +\param[in] asset Asset to instance. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. +*/ +NVBLAST_API void NvBlastFamilySetAsset(NvBlastFamily* family, const NvBlastAsset* asset, NvBlastLog logFn); + + +/** +Retrieve the size (in bytes) of the given family. + +\param[in] family The family. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the size of the family (in bytes). +*/ +NVBLAST_API uint32_t NvBlastFamilyGetSize(const NvBlastFamily* family, NvBlastLog logFn); + + +/** +Retrieve the asset ID of the given family. + +\param[in] family The family. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the ID of the asset associated with the family. +*/ +NVBLAST_API NvBlastID NvBlastFamilyGetAssetID(const NvBlastFamily* family, NvBlastLog logFn); + + +/** +Returns the number of bytes of scratch memory that the user must supply to NvBlastFamilyCreateFirstActor. + +\param[in] family The family from which the first actor will be instanced. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the number of bytes of scratch memory required for a call to NvBlastFamilyCreateFirstActor. +*/ +NVBLAST_API size_t NvBlastFamilyGetRequiredScratchForCreateFirstActor(const NvBlastFamily* family, NvBlastLog logFn); + + +/** +Instance the family's asset into a new, unfractured actor. + +\param[in] family Family in which to create a new actor. The family must have no other actors in it. (See NvBlastAssetCreateFamily.) +\param[in] desc Actor descriptor (see NvBlastActorDesc). +\param[in] scratch User-supplied scratch memory of size NvBlastFamilyGetRequiredScratchForCreateFirstActor(asset) bytes, where 'asset' is the NvBlastAsset from which the family was created. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return pointer to new NvBlastActor if successful (the actor was successfully inserted into the family), or NULL if unsuccessful. +*/ +NVBLAST_API NvBlastActor* NvBlastFamilyCreateFirstActor(NvBlastFamily* family, const NvBlastActorDesc* desc, void* scratch, NvBlastLog logFn); + + +/** +Retrieve the number of active actors associated with the given family. + +\param[in] family The family. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the number of active actors in the family. +*/ +NVBLAST_API uint32_t NvBlastFamilyGetActorCount(const NvBlastFamily* family, NvBlastLog logFn); + + +/** +Deserialize a single Actor from a buffer into the given family. The actor will be inserted if it +is compatible with the current family state. That is, it must not share any chunks or internal +IDs with the actors already present in the family. + +\param[in] family Family in which to deserialize the actor. +\param[in] buffer User-supplied buffer containing the actor to deserialize. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the deserialized actor if successful, NULL otherwise. +*/ +NVBLAST_API NvBlastActor* NvBlastFamilyDeserializeActor(NvBlastFamily* family, const void* buffer, NvBlastLog logFn); + + +/** +Retrieve the active actors associated with the given family. + +\param[out] actors User-supplied array to be filled with the returned actor pointers. +\param[out] actorsSize The size of the actors array. To receive all actor pointers, the size must be at least that given by NvBlastFamilyGetActorCount(family). +\param[in] family The family. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the number of actor pointers written to actors. This will not exceed actorsSize. +*/ +NVBLAST_API uint32_t NvBlastFamilyGetActors(NvBlastActor** actors, uint32_t actorsSize, const NvBlastFamily* family, NvBlastLog logFn); + + +/** +Retrieve the actor associated with the given chunk. + +\param[in] family The family. +\param[in] chunkIndex The index of chunk. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return pointer to actor associated with given chunk. NULL if there is no such actor. +*/ +NVBLAST_API NvBlastActor* NvBlastFamilyGetChunkActor(const NvBlastFamily* family, uint32_t chunkIndex, NvBlastLog logFn); + + +/** +Retrieve the max active actor count family could have. + +\param[in] family The family. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the max number of active actors family could have. +*/ +NVBLAST_API uint32_t NvBlastFamilyGetMaxActorCount(const NvBlastFamily* family, NvBlastLog logFn); + +///@} End NvBlastFamily functions + + +/////////////////////////////////////////////////////////////////////////////////////// +// NvBlastActor accessor, serialization, and deactivation functions +/////////////////////////////////////////////////////////////////////////////////////// +///@{ + +/** +Get the number of visible chunks for this actor. May be used in conjunction with NvBlastActorGetVisibleChunkIndices. + +\param[in] actor The actor. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the number of visible chunk indices for the actor. +*/ +NVBLAST_API uint32_t NvBlastActorGetVisibleChunkCount(const NvBlastActor* actor, NvBlastLog logFn); + + +/** +Retrieve a list of visible chunk indices for the actor into the given array. + +\param[in] visibleChunkIndices User-supplied array to be filled in with indices of visible chunks for this actor. +\param[in] visibleChunkIndicesSize The size of the visibleChunkIndices array. To receive all visible chunk indices, the size must be at least that given by NvBlastActorGetVisibleChunkCount(actor). +\param[in] actor The actor. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the number of indices written to visibleChunkIndices. This will not exceed visibleChunkIndicesSize. +*/ +NVBLAST_API uint32_t NvBlastActorGetVisibleChunkIndices(uint32_t* visibleChunkIndices, uint32_t visibleChunkIndicesSize, const NvBlastActor* actor, NvBlastLog logFn); + + +/** +Get the number of graph nodes for this actor. May be used in conjunction with NvBlastActorGetGraphNodeIndices. + +\param[in] actor The actor. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the number of graph node indices for the actor. +*/ +NVBLAST_API uint32_t NvBlastActorGetGraphNodeCount(const NvBlastActor* actor, NvBlastLog logFn); + + +/** +Retrieve a list of graph node indices for the actor into the given array. + +\param[in] graphNodeIndices User-supplied array to be filled in with indices of graph nodes for this actor. +\param[in] graphNodeIndicesSize The size of the graphNodeIndices array. To receive all graph node indices, the size must be at least that given by NvBlastActorGetGraphNodeCount(actor). +\param[in] actor The actor. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the number of indices written to graphNodeIndices. This will not exceed graphNodeIndicesSize. +*/ +NVBLAST_API uint32_t NvBlastActorGetGraphNodeIndices(uint32_t* graphNodeIndices, uint32_t graphNodeIndicesSize, const NvBlastActor* actor, NvBlastLog logFn); + + +/** +Access the bond health data for an actor. + +This function returns a pointer to the head of an array of bond healths (floats). This array is the same for any actor that +has been created from repeated fracturing of the same original instance of an asset (in the same instance family). + +The indices obtained from NvBlastSupportGraph::adjacentBondIndices in the asset may be used to access this array. + +The size of the array returned is NvBlastAssetGetBondCount(asset, logFn), where 'asset' is the NvBlastAsset +that was used to create the actor. + +This array is valid as long as any actor in the instance family for the input actor exists. + +If the input actor is invalid, NULL will be returned. + +\param[in] actor The actor. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the array of bond healths for the actor's instance family, or NULL if the actor is invalid. +*/ +NVBLAST_API const float* NvBlastActorGetBondHealths(const NvBlastActor* actor, NvBlastLog logFn); + + +/** +The buffer size needed to serialize a single actor. This will give the exact size needed. For an upper bound +on the buffer size needed for any actor instanced from an NvBlastAsset, use NvBlastAssetGetActorSerializationSizeUpperBound. + +\param[in] actor The actor. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the required buffer size in bytes. +*/ +NVBLAST_API uint32_t NvBlastActorGetSerializationSize(const NvBlastActor* actor, NvBlastLog logFn); + + +/** +Serialize a single actor to a buffer. + +\param[out] buffer User-supplied buffer, must be at least of size given by NvBlastActorGetSerializationSize(actor). +\param[in] bufferSize The size of the user-supplied buffer. +\param[in] actor The actor. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the number of bytes written to the buffer, or 0 if there is an error (such as an under-sized buffer). +*/ +NVBLAST_API uint32_t NvBlastActorSerialize(void* buffer, uint32_t bufferSize, const NvBlastActor* actor, NvBlastLog logFn); + + +/** +Access to an actor's family. + +\param[in] actor The actor. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the family with which the actor is associated. +*/ +NVBLAST_API NvBlastFamily* NvBlastActorGetFamily(const NvBlastActor* actor, NvBlastLog logFn); + + +/** +Access to an actor's internal index. + +\param[in] actor The actor. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return actor's internal index in family. +*/ +NVBLAST_API uint32_t NvBlastActorGetIndex(const NvBlastActor* actor, NvBlastLog logFn); + + +/** +Deactivate an actor within its family. Conceptually this is "destroying" the actor, however memory will not be released until the family is released. + +\param[in] actor Points to a user-supplied actor struct. May be NULL, in which case this function no-ops. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return true iff successful (actor was active). +*/ +NVBLAST_API bool NvBlastActorDeactivate(NvBlastActor* actor, NvBlastLog logFn); + +///@} End NvBlastActor accessor, serialization, and deactivation functions + + +/////////////////////////////////////////////////////////////////////////////// +// NvBlastActor damage and fracturing functions +/////////////////////////////////////////////////////////////////////////////// +///@{ + +/** +Creates fracture commands for the actor using a damage program and program parameters (material and damage descriptions). + +\param[in,out] commandBuffers Target buffers to hold generated commands. + To avoid data loss, provide an entry for every support chunk and every bond in the original actor. +\param[in] actor The NvBlastActor to create fracture commands for. +\param[in] program A NvBlastDamageProgram containing damage shaders. +\param[in] programParams Parameters for the NvBlastDamageProgram. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. +\param[in,out] timers If non-NULL this struct will be filled out with profiling information for the step, in profile build configurations. + +Interpretation of NvBlastFractureBuffers: +As input: + Counters denote available entries for FractureData. + Chunk and Bond userdata are not used. + Health values are not used. + +As output: + Counters denote valid entires in FractureData arrays. + Chunks and Bond userdata reflect the respective userdata set during asset initialization, where implemented by the material function. + Health values denote how much damage is to be applied. +*/ +NVBLAST_API void NvBlastActorGenerateFracture +( + NvBlastFractureBuffers* commandBuffers, + const NvBlastActor* actor, + const NvBlastDamageProgram program, + const NvBlastProgramParams* programParams, + NvBlastLog logFn, + NvBlastTimers* timers +); + + +/** +Applies the direct fracture and breaks graph bonds/edges as necessary. +Chunks damaged beyond their respective health fracture their children recursively, creating a NvBlastChunkFractureData for each. + +\param[in,out] eventBuffers Target buffers to hold applied fracture events. May be NULL, in which case events are not reported. + To avoid data loss, provide an entry for every lower-support chunk and every bond in the original actor. +\param[in,out] actor The NvBlastActor to apply fracture to. +\param[in] commands The fracture commands to process. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. +\param[in,out] timers If non-NULL this struct will be filled out with profiling information for the step, in profile build configurations. + +Interpretation of NvBlastFractureBuffers: +commands: + Counters denote the number of command entries to process. + Chunk and Bond userdata are not used. + Health values denote the amount of damage to apply, as a positive value. + +eventBuffers as input: + Counters denote available entries for FractureData. + Chunk and Bond userdata are not used. + Health values are not used. + +eventBuffers as output: + Counters denote valid entires in FractureData arrays. + Chunks and Bond userdata reflect the respective userdata set during asset initialization. + Health values denote how much health is remaining for the damaged element. + Broken elements report a negative value corresponding to the superfluous health damage. + +commands and eventBuffers may point to the same memory. +*/ +NVBLAST_API void NvBlastActorApplyFracture +( + NvBlastFractureBuffers* eventBuffers, + NvBlastActor* actor, + const NvBlastFractureBuffers* commands, + NvBlastLog logFn, + NvBlastTimers* timers +); + + +/** +Releases the oldActor and creates its children newActors if necessary. + +\param[out] result The list of deleted and created NvBlastActor objects. +\param[in] actor The actor to split. +\param[in] newActorsMaxCount Number of available NvBlastActor slots. In the worst case, one NvBlastActor may be created for every chunk in the asset. +\param[in] scratch Scratch Memory used during processing. NvBlastActorGetRequiredScratchForSplit provides the necessary size. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. +\param[in,out] timers If non-NULL this struct will be filled out with profiling information for the step, in profile build configurations + +\return 1..n: new actors were created +\return 0: oldActor is unchanged +*/ +NVBLAST_API uint32_t NvBlastActorSplit +( + NvBlastActorSplitEvent* result, + NvBlastActor* actor, + uint32_t newActorsMaxCount, + void* scratch, + NvBlastLog logFn, + NvBlastTimers* timers +); + + +/** +Returns the number of bytes of scratch memory that the user must supply to NvBlastActorSplit, +based upon the actor that will be passed into that function. + +\param[in] actor The actor that will be passed into NvBlastActorSplit. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the number of bytes of scratch memory required for a call to NvBlastActorSplit with that actor. +*/ +NVBLAST_API size_t NvBlastActorGetRequiredScratchForSplit(const NvBlastActor* actor, NvBlastLog logFn); + + +/** +Returns the upper-bound number of actors which can be created by calling NvBlastActorSplit with that actor, this +value can't exceed chunk count. + +\param[in] actor The actor. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return the upper-bound number of actors which can be created by calling NvBlastActorSplit with that actor. +*/ +NVBLAST_API uint32_t NvBlastActorGetMaxActorCountForSplit(const NvBlastActor* actor, NvBlastLog logFn); + + +/** +Determines if the actor can fracture further. + +\param[in] actor The actor potentially being fractured. +\param[in] logFn User-supplied message function (see NvBlastLog definition). May be NULL. + +\return true if any result can be expected from fracturing the actor. false if no further change to the actor is possible. +*/ +NVBLAST_API bool NvBlastActorCanFracture(const NvBlastActor* actor, NvBlastLog logFn); + +///@} End NvBlastActor damage and fracturing functions + + +/////////////////////////////////////////////////////////////////////////////// +// NvBlastTimers functions and helpers +/////////////////////////////////////////////////////////////////////////////// +///@{ + +/** +Resets all values in the given NvBlastTimers struct to zero. + +\param[in] timers The NvBlastTimers to set to zero. +*/ +NVBLAST_API void NvBlastTimersReset(NvBlastTimers* timers); + + +/** +Convert a tick value from NvBlastTimers to seconds. + +\param[in] ticks The tick value. + +\return the seconds correposnding to the input tick value. +*/ +NVBLAST_API double NvBlastTicksToSeconds(int64_t ticks); + +///@} End NvBlastTimers functions and helpers + + +#endif // ifndef NVBLAST_H diff --git a/NvBlast/sdk/lowlevel/include/NvBlastPreprocessor.h b/NvBlast/sdk/lowlevel/include/NvBlastPreprocessor.h new file mode 100644 index 0000000..25a8516 --- /dev/null +++ b/NvBlast/sdk/lowlevel/include/NvBlastPreprocessor.h @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLASTPREPROCESSOR_H +#define NVBLASTPREPROCESSOR_H + + +#include "NvPreprocessor.h" + + +/** Blast API declaration */ +#define NVBLAST_API NV_C_EXPORT NV_DLL_EXPORT + + +/** +Macros for more convenient logging +*/ +#define NVBLAST_LOG_ERROR(_logFn, _msg) if (_logFn != nullptr) { _logFn(NvBlastMessage::Error, _msg, __FILE__, __LINE__); } ((void)0) +#define NVBLAST_LOG_WARNING(_logFn, _msg) if (_logFn != nullptr) { _logFn(NvBlastMessage::Warning, _msg, __FILE__, __LINE__); } ((void)0) +#define NVBLAST_LOG_INFO(_logFn, _msg) if (_logFn != nullptr) { _logFn(NvBlastMessage::Info, _msg, __FILE__, __LINE__); } ((void)0) +#define NVBLAST_LOG_DEBUG(_logFn, _msg) if (_logFn != nullptr) { _logFn(NvBlastMessage::Debug, _msg, __FILE__, __LINE__); } ((void)0) + + +#endif // ifndef NVBLASTPREPROCESSOR_H diff --git a/NvBlast/sdk/lowlevel/include/NvBlastProfiler.h b/NvBlast/sdk/lowlevel/include/NvBlastProfiler.h new file mode 100644 index 0000000..cd60b4f --- /dev/null +++ b/NvBlast/sdk/lowlevel/include/NvBlastProfiler.h @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLASTPROFILER_H +#define NVBLASTPROFILER_H + +#include "NvBlastPreprocessor.h" + +namespace physx { + class PxProfilerCallback; +} + +struct NvBlastProfilerDetail +{ + enum Level + { + LOW, + MEDIUM, + HIGH + }; +}; + +/** +Profiler features are only active in checked, debug and profile builds. +*/ + +/** +Set a callback to PVD or another PxProfilerCallback based profiler. +*/ +NVBLAST_API void NvBlastProfilerSetCallback(physx::PxProfilerCallback* pcb); + +/** +Enable events for platform specific profiler tools. Currently supported: +Nsight, PS4, Xbox One +*/ +NVBLAST_API void NvBlastProfilerEnablePlatform(bool); + +/** +Sets the depth of reported profile zones. +Higher levels (more nesting) of instrumentation can have a significant impact. +Defaults to NvBlastProfilerDetail::Level::LOW. +*/ +NVBLAST_API void NvBlastProfilerSetDetail(NvBlastProfilerDetail::Level); + +#endif diff --git a/NvBlast/sdk/lowlevel/include/NvBlastTypes.h b/NvBlast/sdk/lowlevel/include/NvBlastTypes.h new file mode 100644 index 0000000..d711842 --- /dev/null +++ b/NvBlast/sdk/lowlevel/include/NvBlastTypes.h @@ -0,0 +1,632 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLASTTYPES_H +#define NVBLASTTYPES_H + + +#include "NvBlastPreprocessor.h" +#include <stdint.h> + + +/////////////////////////////////////////////////////////////////////////////// +// NvBlast common types +/////////////////////////////////////////////////////////////////////////////// +///@{ + +/** +Types of log messages. +*/ +struct NvBlastMessage +{ + enum Type + { + Error, //!< Error messages + Warning, //!< Warning messages + Info, //!< Information messages + Debug //!< Used only in debug version of dll + }; +}; + + +/** +Function pointer type for logging. + +When a function with this signature is passed into Blast functions with an NvBlastLog argument, +Blast will use it to report errors, warnings, and other information. +*/ +typedef void(*NvBlastLog)(int type, const char* msg, const char* file, int line); + + +/** +ID used to identify assets. +*/ +struct NvBlastID +{ + char data[16]; +}; + + +/** +Time spent (in ticks) in various parts of Blast. +These values may be filled in during the execution of various API functions. +To convert to seconds, use NvBlastTicksToSeconds(ticks). + +In profile build configurations, if a pointer to an instance of this struct is passed into +Blast functions with an NvBlastTimers argument, then Blast will add to appropriate fields +the time measured in corresponding sections of code. The user must clear the timer fields +with NvBlastTimersReset to initialize or reset. +*/ +struct NvBlastTimers +{ + int64_t material; //!< Time spent in material function + int64_t fracture; //!< Time spent applying damage + int64_t island; //!< Time spent discovering islands + int64_t partition; //!< Time spent partitioning the graph + int64_t visibility; //!< Time spent updating visibility +}; + + +/** +Generic data block header for all data blocks. +*/ +struct NvBlastDataBlock +{ + /** + Enum of data block types + */ + enum Type + { + AssetDataBlock, + FamilyDataBlock, + + Count + }; + + + /** + A data type keeps value from Type enum + */ + uint32_t dataType; + + /** + A number which is incremented every time the data layout changes. Depending on dataType corresponding data + format is kept. See NvBlastAssetDataFormat, NvBlastFamilyDataFormat enum. + */ + uint32_t formatVersion; + + /** + The size of the family, including this header. + + Memory sizes are restricted to 32-bit representable values. + */ + uint32_t size; + + /** + Reserved to be possibly used in future versions + */ + uint32_t reserved; +}; + +///@} End NvBlast common types + + +/////////////////////////////////////////////////////////////////////////////// +// NvBlastAsset related types +/////////////////////////////////////////////////////////////////////////////// +///@{ + + +/** +Struct-enum which keeps track of the asset data format. +*/ +struct NvBlastAssetDataFormat +{ + enum Version + { + /** Initial version */ + Initial, + + // New formats must come before Count. They should be given descriptive names with more information in comments. + + /** The number of asset formats. */ + Count, + + /** The current version. This should always be Count-1 */ + Current = Count - 1 + }; +}; + + +/** +Represents a piece of a destructible asset which may be realized as an entity with a physical and graphical component. + +Chunks may form a hierarchical decomposition of the asset. They contain parent and child chunk index information which +defines the hierarchy. The parent and child chunk indices are their positions with the NvBlastAsset::chunks array. + +Child chunk indices are contiguous, starting at firstChildIndex and ending with childIndexStop - 1. +*/ +struct NvBlastChunk +{ + /** + Central position for the chunk's volume + */ + float centroid[3]; + + /** + Volume of the chunk + */ + float volume; + + /** + Index of parent (UINT32_MAX denotes no parent) + */ + uint32_t parentChunkIndex; + + /** + Index of first child + */ + uint32_t firstChildIndex; + + /** + Stop for child indices + */ + uint32_t childIndexStop; + + /** + Field for user to associate with external data + */ + uint32_t userData; +}; + + +/** +Represents the interface between two chunks. At most one bond is created for a chunk pair. +The convention regarding the normal direction is based upon the chunk indices, +pointing from the lower-indexed chunk to the higher-indexed chunk. +*/ +struct NvBlastBond +{ + /** + Interface average normal + */ + float normal[3]; + + /** + Area of interface + */ + float area; + + /** + Central position on the interface between chunks + */ + float centroid[3]; + + /** + Extra data associated with bond, e.g. whether or not to create a joint + */ + uint32_t userData; +}; + + +/** +Describes the connectivity between support chunks via bonds. + +Vertices in the support graph are termed "nodes," and represent particular chunks (NvBlastChunk) in an NvBlastAsset. +The indexing for nodes is not the same as that for chunks. Only some chunks are represented by nodes in the graph, +and these chunks are called "support chunks." + +Adjacent node indices and adjacent bond indices are stored for each node, and therefore each bond is represented twice in this graph, +going from node[i] -> node[j] and from node[j] -> node[i]. Therefore the size of the adjacentNodeIndices and adjacentBondIndices +arrays are twice the number of bonds stored in the corresponding NvBlastAsset. + +The graph is used as follows. Given a NvBlastSupportGraph "graph" and node index i, (0 <= i < graph.nodeCount), one may find all +adjacent bonds and nodes using: + + // adj is the lookup value in graph.adjacentNodeIndices and graph.adjacentBondIndices + for (uint32_t adj = graph.adjacencyPartition[i]; adj < graph.adjacencyPartition[i+1]; ++adj) + { + // An adjacent node: + uint32_t adjacentNodeIndex = graph.adjacentNodeIndices[adj]; + + // The corresponding bond (that connects node index i with node indexed adjacentNodeIndex: + uint32_t adjacentBondIndex = graph.adjacentBondIndices[adj]; + } + +For a graph node with index i, the corresponding asset chunk index is found using graph.chunkIndices[i]. The reverse mapping +(obtaining a graph node index from an asset chunk index) can be done using the + + NvBlastAssetGetChunkToGraphNodeMap(asset, logFn) + +function. See the documentation for its use. The returned "node index" for a non-support chunk is the invalid value 0xFFFFFFFF. +*/ +struct NvBlastSupportGraph +{ + /** + Total number of nodes in the support graph. + */ + uint32_t nodeCount; + + /** + Indices of chunks represented by the nodes, an array of size nodeCount. + */ + uint32_t* chunkIndices; + + /** + Partitions both the adjacentNodeIndices and the adjacentBondIndices arrays into subsets corresponding to each node. + The size of this array is nodeCount+1. + For 0 <= i < nodeCount, adjacencyPartition[i] is the index of the first element in adjacentNodeIndices (or adjacentBondIndices) for nodes adjacent to the node with index i. + adjacencyPartition[nodeCount] is the size of the adjacentNodeIndices and adjacentBondIndices arrays. + This allows one to easily count the number of nodes adjacent to a node with index i, using adjacencyPartition[i+1] - adjacencyPartition[i]. + */ + uint32_t* adjacencyPartition; + + /** + Array composed of subarrays holding the indices of nodes adjacent to a given node. The subarrays may be accessed through the adjacencyPartition array. + */ + uint32_t* adjacentNodeIndices; + + /** + Array composed of subarrays holding the indices of bonds (NvBlastBond) for a given node. The subarrays may be accessed through the adjacencyPartition array. + */ + uint32_t* adjacentBondIndices; +}; + + +/** +Asset (opaque) + +Static destructible data, used to create actor familes. + +Pointer to this struct can be created with NvBlastCreateAsset. + +The NvBlastAsset includes a ID which may be used to match it with physics and graphics data. +*/ +struct NvBlastAsset {}; + + +/** +Chunk descriptor used to build an asset. See NvBlastAssetDesc. +*/ +struct NvBlastChunkDesc +{ + enum Flags + { + NoFlags = 0, + + /** If this flag is set then the chunk will become a support chunk, unless an ancestor chunk is also marked as support. */ + SupportFlag = (1 << 0) + }; + + /** Central position in chunk. */ + float centroid[3]; + + /** Volume of chunk. */ + float volume; + + /** Index of this chunk's parent. If this is a root chunk, then this value must be UINT32_MAX. */ + uint32_t parentChunkIndex; + + /** See Flags enum for possible flags. */ + uint32_t flags; + + /** User-supplied data which will be accessible to the user in chunk fracture events. */ + uint32_t userData; +}; + + +/** +Chunk bond descriptor used to build an asset. See NvBlastAssetDesc. +*/ +struct NvBlastBondDesc +{ + /** The indices of the chunks linked by this bond. They must be different support chunk indices. */ + uint32_t chunkIndices[2]; + + /** Bond data (see NvBlastBond). */ + NvBlastBond bond; +}; + + +/** +Asset descriptor, used to build an asset with NvBlastCreateAsset + +A valid asset descriptor must have a non-zero chunkCount and valid chunkDescs. + +The user may create an asset with no bonds (e.g. a single-chunk asset). In this case bondCount should be +zero and bondDescs is ignored. +*/ +struct NvBlastAssetDesc +{ + /** The number of chunk descriptors. */ + uint32_t chunkCount; + + /** Array of chunk descriptors of size chunkCount. */ + const NvBlastChunkDesc* chunkDescs; + + /** The number of bond descriptors. */ + uint32_t bondCount; + + /** Array of bond descriptors of size bondCount. */ + const NvBlastBondDesc* bondDescs; +}; + +///@} End NvBlastAsset related types + + +/////////////////////////////////////////////////////////////////////////////// +// NvBlastActor related types +/////////////////////////////////////////////////////////////////////////////// +///@{ + + +/** +Struct-enum which keeps track of the family data format. +*/ +struct NvBlastFamilyDataFormat +{ + enum Version + { + /** Initial version */ + Initial, + + // New formats must come before Count. They should be given descriptive names with more information in comments. + + /** The number of family formats. */ + Count, + + /** The current version. This should always be Count-1 */ + Current = Count - 1 + }; +}; + + +/** +Family (opaque) + +a family can be created by the NvBlastAssetCreateFamily function and released +by the NvBlastFamilyRelease. Family is needed to create first actor. All the following +actors which can be created with NvBlastActorSplit function (as a result of fracture) will share the same family +block. NvBlastFamilyGetActorCount can be used to know if family can be safely released. +*/ +struct NvBlastFamily {}; + + +/** +Actor (opaque) + +Actors can be generated by the NvBlastFamilyCreateFirstActor +and NvBlastActorSplit functions. Opaque NvBlastActor pointers reference data within the family +generated during NvBlastFamilyCreateFirstActor, and represent the actor in all actor-related API +functions. +*/ +struct NvBlastActor {}; + + +/** +Actor descriptor, used to create an instance of an NvBlastAsset with NvBlastFamilyCreateFirstActor + +See NvBlastFamilyCreateFirstActor. +*/ +struct NvBlastActorDesc +{ + /** + Initial health of all bonds, if initialBondHealths is NULL (see initialBondHealths). + */ + float uniformInitialBondHealth; + + /** + Initial bond healths. If not NULL, this array must be of length NvBlastAssetGetChunkCount(asset, logFn). + If NULL, uniformInitialBondHealth must be set. + */ + const float* initialBondHealths; + + /** + Initial health of all lower-support chunks, if initialSupportChunkHealths is NULL (see initialSupportChunkHealths). + */ + float uniformInitialLowerSupportChunkHealth; + + /** + Initial health of all support chunks. If not NULL, this must be of length + NvBlastAssetGetSupportGraph(asset, logFn).nodeCount. The elements in the initialSupportChunkHealth + array will correspond to the chunk indices in the NvBlastAssetGetSupportGraph(asset, logFn).chunkIndices + array. Every descendent of a support chunk will have its health initialized to its ancestor support + chunk's health, so this initializes all lower-support chunk healths. + If NULL, uniformInitialLowerSupportChunkHealth must be set. + */ + const float* initialSupportChunkHealths; +}; + +///@} End NvBlastActor related types + + +/////////////////////////////////////////////////////////////////////////////// +// Types used for damage and fracturing +/////////////////////////////////////////////////////////////////////////////// +///@{ + + +/** +Fracture Data for Chunks + +Data interpretation varies depending on the function used. +@see NvBlastActorGenerateFracture NvBlastActorApplyFracture NvBlastFractureBuffers +*/ +struct NvBlastChunkFractureData +{ + uint32_t userdata; //!< chunk's user data + uint32_t chunkIndex; //!< asset chunk index + float health; //!< health value (damage or remains) +}; + + +/** +Fracture Data for Bonds + +Data interpretation varies depending on the function used. +@see NvBlastActorGenerateFracture NvBlastActorApplyFracture NvBlastFractureBuffers +*/ +struct NvBlastBondFractureData +{ + uint32_t userdata; //!< bond's user data + uint32_t nodeIndex0; //!< graph node index of bond + uint32_t nodeIndex1; //!< pair graph node index of bond + float health; //!< health value (damage or remains) +}; + + +/** +Memory to be used by fracture functions. + +Used as input and output target. +@see NvBlastActorGenerateFracture NvBlastActorApplyFracture +*/ +struct NvBlastFractureBuffers +{ + uint32_t bondFractureCount; //!< available elements in bondFractures + uint32_t chunkFractureCount; //!< available elements in chunkFractures + NvBlastBondFractureData* bondFractures; //!< memory to be filled by fracture functions + NvBlastChunkFractureData* chunkFractures; //!< memory to be filled by fracture functions +}; + + +/** +Description of a NvBlastActorSplit result. +This tells the user about changes in the actor, or creation of children. +*/ +struct NvBlastActorSplitEvent +{ + NvBlastActor* deletedActor; //!< deleted actor or nullptr if actor has not changed + NvBlastActor** newActors; //!< list of created actors +}; + + +/** +A single actor's representation used by NvBlastGraphShaderFunction. +*/ +struct NvBlastGraphShaderActor +{ + uint32_t firstGraphNodeIndex; //!< Entry index for graphNodeIndexLinks + const uint32_t* graphNodeIndexLinks; //!< Linked index list of connected nodes. Traversable with nextIndex = graphNodeIndexLinks[currentIndex], terminates with 0xFFFFFFFF. + const uint32_t* chunkIndices; //!< Graph's map from node index to support chunk index. + const uint32_t* adjacencyPartition; //!< See NvBlastSupportGraph::adjacencyPartition. + const uint32_t* adjacentNodeIndices; //!< See NvBlastSupportGraph::adjacentNodeIndices. + const uint32_t* adjacentBondIndices; //!< See NvBlastSupportGraph::adjacentBondIndices. + const NvBlastBond* assetBonds; //!< NvBlastBonds geometry in the NvBlastAsset. + const float* familyBondHealths; //!< Actual bond health values for broken bond detection. +}; + + +/** +Damage program params. + +Custom user params to be passed in shader functions. This structure hints recommended parameters layout, but it +doesn't required to be this way. + +The idea of this 'hint' is that damage parameters are basically 2 entities: material + damage description. +1. Material is something that describes an actor properties (e.g. mass, stiffness, fragility) which are not expected to be changed often. +2. Damage description is something that describes particular damage event (e.g. position, radius and force of explosion). + +Also this damage program hints that there could be more than one damage event happening and processed per one shader call (for efficiency reasons). +So different damage descriptions can be stacked and passed in one shader call (while material is kept the same obviously). +*/ +struct NvBlastProgramParams +{ + const void* damageDescBuffer; //!< array of damage descriptions + uint32_t damageDescCount; //!< number of damage descriptions in array + const void* material; //!< pointer to material +}; + + +/** +A single actor's representation used by NvBlastSubgraphShaderFunction. +*/ +struct NvBlastSubgraphShaderActor +{ + uint32_t chunkIndex; //!< Index of chunk represented by this actor. + const NvBlastChunk* assetChunks; //!< NvBlastChunks geometry in the NvBlastAsset. +}; + + +/** +Damage shader for actors with more then one node in support graph. + +From a an input actor data (NvBlastGraphShaderActor) and user custom data (params), +creates a list of NvBlastFractureCommand to be applied to the respective NvBlastActor. + +\param[in,out] commandBuffers The resulting health damage to apply. + Typically requires an array of size (number of support chunks) + (number of bonds) of the processed asset + but may depend on the actual implementation. +\param[in] actor The actor representation used for creating commands. +\param[in] params A set of parameters defined by the damage shader implementer. + +Interpretation of NvBlastFractureBuffers: +As input: +Counters denote available entries for FractureData. +Chunk and Bond userdata are not used. +Health values are not used. + +As output: +Counters denote valid entires in FractureData arrays. +Chunks and Bond userdata reflect the respective userdata set during asset initialization. +Health values denote how much damage is to be applied. + +@see NvBlastFractureBuffers NvBlastGraphShaderActor +*/ +typedef void(*NvBlastGraphShaderFunction)(NvBlastFractureBuffers* commandBuffers, const NvBlastGraphShaderActor* actor, const NvBlastProgramParams* params); + + +/** +Damage shader for actors with single chunk. + +From a an input actor data (NvBlastSubgraphShaderActor) and user custom data (params), +creates a list of NvBlastFractureCommand to be applied to the respective NvBlastActor. + +\param[in,out] commandBuffers The resulting health damage to apply. + Typically requires an array of size (number of support chunks) + (number of bonds) of the processed asset + but may depend on the actual implementation. +\param[in] actor The actor representation used for creating commands. +\param[in] params A set of parameters defined by the damage shader implementer. + +Interpretation of NvBlastFractureBuffers: +As input: +Counters denote available entries for FractureData. +Chunk and Bond userdata are not used. +Health values are not used. + +As output: +Counters denote valid entires in FractureData arrays. +Chunks and Bond userdata reflect the respective userdata set during asset initialization. +Health values denote how much damage is to be applied. + +@see NvBlastFractureBuffers NvBlastSubgraphShaderActor +*/ +typedef void(*NvBlastSubgraphShaderFunction)(NvBlastFractureBuffers* commandBuffers, const NvBlastSubgraphShaderActor* actor, const NvBlastProgramParams* params); + + +/** +Damage Program. + +Contains both graph and subgraph shader. When used on actor appropriate shader will be called. +Any shader can be nullptr to be skipped. + +@see NvBlastGraphShaderFunction NvBlastSubgraphShaderFunction +*/ +struct NvBlastDamageProgram +{ + NvBlastGraphShaderFunction graphShaderFunction; + NvBlastSubgraphShaderFunction subgraphShaderFunction; +}; + + +///@} End of types used for damage and fracturing + + +#endif // ifndef NVBLASTTYPES_H diff --git a/NvBlast/sdk/lowlevel/include/NvPreprocessor.h b/NvBlast/sdk/lowlevel/include/NvPreprocessor.h new file mode 100644 index 0000000..07a3ebc --- /dev/null +++ b/NvBlast/sdk/lowlevel/include/NvPreprocessor.h @@ -0,0 +1,540 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2014 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 NV_NVFOUNDATION_NVPREPROCESSOR_H +#define NV_NVFOUNDATION_NVPREPROCESSOR_H + +#include <stddef.h> + +/** \addtogroup foundation + @{ +*/ + +/* +The following preprocessor identifiers specify compiler, OS, and architecture. +All definitions have a value of 1 or 0, use '#if' instead of '#ifdef'. +*/ + +/** +Compiler defines, see http://sourceforge.net/p/predef/wiki/Compilers/ +*/ +#if defined(_MSC_VER) +#if _MSC_VER >= 1900 +#define NV_VC 14 +#elif _MSC_VER >= 1800 +#define NV_VC 12 +#elif _MSC_VER >= 1700 +#define NV_VC 11 +#elif _MSC_VER >= 1600 +#define NV_VC 10 +#elif _MSC_VER >= 1500 +#define NV_VC 9 +#else +#error "Unknown VC version" +#endif +#elif defined(__clang__) +#define NV_CLANG 1 +#elif defined(__SNC__) +#define NV_SNC 1 +#elif defined(__ghs__) +#define NV_GHS 1 +#elif defined(__GNUC__) // note: __clang__, __SNC__, or __ghs__ imply __GNUC__ +#define NV_GCC 1 +#else +#error "Unknown compiler" +#endif + +/** +Operating system defines, see http://sourceforge.net/p/predef/wiki/OperatingSystems/ +*/ +#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_PARTITION_APP +#define NV_WINRT 1 // Windows Runtime, either on Windows RT or Windows 8 +#elif defined(XBOXONE) || defined(_XBOX_ONE) +#define NV_XBOXONE 1 +#elif defined(_WIN64) // note: XBOXONE implies _WIN64 +#define NV_WIN64 1 +#elif defined(_M_PPC) +#define NV_X360 1 +#elif defined(_WIN32) // note: _M_PPC implies _WIN32 +#define NV_WIN32 1 +#elif defined(__ANDROID__) +#define NV_ANDROID 1 +#elif defined(__linux__) // note: __ANDROID__ implies __linux__ +#define NV_LINUX 1 +#elif defined(__APPLE__) && (defined(__arm__) || defined(__arm64__)) +#define NV_IOS 1 +#elif defined(__APPLE__) +#define NV_OSX 1 +#elif defined(__CELLOS_LV2__) +#define NV_PS3 1 +#elif defined(__ORBIS__) +#define NV_PS4 1 +#elif defined(__SNC__) && defined(__arm__) +#define NV_PSP2 1 +#elif defined(__ghs__) +#define NV_WIIU 1 +#else +#error "Unknown operating system" +#endif + +/** +Architecture defines, see http://sourceforge.net/p/predef/wiki/Architectures/ +*/ +#if defined(__x86_64__) || defined(_M_X64) // ps4 compiler defines _M_X64 without value +#define NV_X64 1 +#elif defined(__i386__) || defined(_M_IX86) +#define NV_X86 1 +#elif defined(__arm64__) || defined(__aarch64__) +#define NV_A64 1 +#elif defined(__arm__) || defined(_M_ARM) +#define NV_ARM 1 +#elif defined(__SPU__) +#define NV_SPU 1 +#elif defined(__ppc__) || defined(_M_PPC) || defined(__CELLOS_LV2__) +#define NV_PPC 1 +#else +#error "Unknown architecture" +#endif + +/** +SIMD defines +*/ +#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) +#define NV_SSE2 1 +#endif +#if defined(_M_ARM) || defined(__ARM_NEON__) +#define NV_NEON 1 +#endif +#if defined(_M_PPC) || defined(__CELLOS_LV2__) +#define NV_VMX 1 +#endif + +/** +define anything not defined on this platform to 0 +*/ +#ifndef NV_VC +#define NV_VC 0 +#endif +#ifndef NV_CLANG +#define NV_CLANG 0 +#endif +#ifndef NV_SNC +#define NV_SNC 0 +#endif +#ifndef NV_GHS +#define NV_GHS 0 +#endif +#ifndef NV_GCC +#define NV_GCC 0 +#endif +#ifndef NV_WINRT +#define NV_WINRT 0 +#endif +#ifndef NV_XBOXONE +#define NV_XBOXONE 0 +#endif +#ifndef NV_WIN64 +#define NV_WIN64 0 +#endif +#ifndef NV_X360 +#define NV_X360 0 +#endif +#ifndef NV_WIN32 +#define NV_WIN32 0 +#endif +#ifndef NV_ANDROID +#define NV_ANDROID 0 +#endif +#ifndef NV_LINUX +#define NV_LINUX 0 +#endif +#ifndef NV_IOS +#define NV_IOS 0 +#endif +#ifndef NV_OSX +#define NV_OSX 0 +#endif +#ifndef NV_PS3 +#define NV_PS3 0 +#endif +#ifndef NV_PS4 +#define NV_PS4 0 +#endif +#ifndef NV_PSP2 +#define NV_PSP2 0 +#endif +#ifndef NV_WIIU +#define NV_WIIU 0 +#endif +#ifndef NV_X64 +#define NV_X64 0 +#endif +#ifndef NV_X86 +#define NV_X86 0 +#endif +#ifndef NV_A64 +#define NV_A64 0 +#endif +#ifndef NV_ARM +#define NV_ARM 0 +#endif +#ifndef NV_SPU +#define NV_SPU 0 +#endif +#ifndef NV_PPC +#define NV_PPC 0 +#endif +#ifndef NV_SSE2 +#define NV_SSE2 0 +#endif +#ifndef NV_NEON +#define NV_NEON 0 +#endif +#ifndef NV_VMX +#define NV_VMX 0 +#endif + +/* +define anything not defined through the command line to 0 +*/ +#ifndef NV_DEBUG +#define NV_DEBUG 0 +#endif +#ifndef NV_CHECKED +#define NV_CHECKED 0 +#endif +#ifndef NV_PROFILE +#define NV_PROFILE 0 +#endif +#ifndef NV_NVTX +#define NV_NVTX 0 +#endif +#ifndef NV_DOXYGEN +#define NV_DOXYGEN 0 +#endif + +/** +family shortcuts +*/ +// compiler +#define NV_GCC_FAMILY (NV_CLANG || NV_SNC || NV_GHS || NV_GCC) +// os +#define NV_WINDOWS_FAMILY (NV_WINRT || NV_WIN32 || NV_WIN64) +#define NV_MICROSOFT_FAMILY (NV_XBOXONE || NV_X360 || NV_WINDOWS_FAMILY) +#define NV_LINUX_FAMILY (NV_LINUX || NV_ANDROID) +#define NV_APPLE_FAMILY (NV_IOS || NV_OSX) // equivalent to #if __APPLE__ +#define NV_UNIX_FAMILY (NV_LINUX_FAMILY || NV_APPLE_FAMILY) // shortcut for unix/posix platforms +// architecture +#define NV_INTEL_FAMILY (NV_X64 || NV_X86) +#define NV_ARM_FAMILY (NV_ARM || NV_A64) +#define NV_P64_FAMILY (NV_X64 || NV_A64) // shortcut for 64-bit architectures + +// shortcut for PS3 PPU +#define NV_PPU (NV_PS3&& NV_PPC) + +/** +Assert macro +*/ +#ifndef NV_ENABLE_ASSERTS +#if NV_DEBUG && !defined(__CUDACC__) +#define NV_ENABLE_ASSERTS 1 +#else +#define NV_ENABLE_ASSERTS 0 +#endif +#endif + +/** +DLL export macros +*/ +#ifndef NV_C_EXPORT +#if NV_WINDOWS_FAMILY || NV_LINUX || NV_PS4 || NV_XBOXONE +#define NV_C_EXPORT extern "C" +#else +#define NV_C_EXPORT +#endif +#endif + +#if NV_UNIX_FAMILY && __GNUC__ >= 4 +#define NV_UNIX_EXPORT __attribute__((visibility("default"))) +#else +#define NV_UNIX_EXPORT +#endif + +#if NV_WINDOWS_FAMILY +#define NV_DLL_EXPORT __declspec(dllexport) +#define NV_DLL_IMPORT __declspec(dllimport) +#else +#define NV_DLL_EXPORT NV_UNIX_EXPORT +#define NV_DLL_IMPORT +#endif + +/** +Define API function declaration + +NV_FOUNDATION_DLL=1 - used by the DLL library (PhysXCommon) to export the API +NV_FOUNDATION_DLL=0 - for windows configurations where the NV_FOUNDATION_API is linked through standard static linking +no definition - this will allow DLLs and libraries to use the exported API from PhysXCommon + +*/ + +#if NV_WINDOWS_FAMILY && !NV_ARM_FAMILY || NV_WINRT +#ifndef NV_FOUNDATION_DLL +#define NV_FOUNDATION_API NV_DLL_IMPORT +#elif NV_FOUNDATION_DLL +#define NV_FOUNDATION_API NV_DLL_EXPORT +#endif +#elif NV_UNIX_FAMILY +#ifdef NV_FOUNDATION_DLL +#define NV_FOUNDATION_API NV_UNIX_EXPORT +#endif +#endif + +#ifndef NV_FOUNDATION_API +#define NV_FOUNDATION_API +#endif + +/** +Calling convention +*/ +#ifndef NV_CALL_CONV +#if NV_MICROSOFT_FAMILY +#define NV_CALL_CONV __cdecl +#else +#define NV_CALL_CONV +#endif +#endif + +/** +Pack macros - disabled on SPU because they are not supported +*/ +#if NV_VC +#define NV_PUSH_PACK_DEFAULT __pragma(pack(push, 8)) +#define NV_POP_PACK __pragma(pack(pop)) +#elif NV_GCC_FAMILY && !NV_SPU +#define NV_PUSH_PACK_DEFAULT _Pragma("pack(push, 8)") +#define NV_POP_PACK _Pragma("pack(pop)") +#else +#define NV_PUSH_PACK_DEFAULT +#define NV_POP_PACK +#endif + +/** +Inline macro +*/ +#define NV_INLINE inline +#if NV_MICROSOFT_FAMILY +#pragma inline_depth(255) +#endif + +/** +Force inline macro +*/ +#if NV_VC +#define NV_FORCE_INLINE __forceinline +#elif NV_LINUX // Workaround; Fedora Core 3 do not agree with force inline and NvcPool +#define NV_FORCE_INLINE inline +#elif NV_GCC_FAMILY +#define NV_FORCE_INLINE inline __attribute__((always_inline)) +#else +#define NV_FORCE_INLINE inline +#endif + +/** +Noinline macro +*/ +#if NV_MICROSOFT_FAMILY +#define NV_NOINLINE __declspec(noinline) +#elif NV_GCC_FAMILY +#define NV_NOINLINE __attribute__((noinline)) +#else +#define NV_NOINLINE +#endif + +/** +Restrict macro +*/ +#if defined(__CUDACC__) +#define NV_RESTRICT __restrict__ +#else +#define NV_RESTRICT __restrict +#endif + +/** +Noalias macro +*/ +#if NV_MICROSOFT_FAMILY +#define NV_NOALIAS __declspec(noalias) +#else +#define NV_NOALIAS +#endif + +/** +Alignment macros + +NV_ALIGN_PREFIX and NV_ALIGN_SUFFIX can be used for type alignment instead of aligning individual variables as follows: +NV_ALIGN_PREFIX(16) +struct A { +... +} NV_ALIGN_SUFFIX(16); +This declaration style is parsed correctly by Visual Assist. + +*/ +#ifndef NV_ALIGN +#if NV_MICROSOFT_FAMILY +#define NV_ALIGN(alignment, decl) __declspec(align(alignment)) decl +#define NV_ALIGN_PREFIX(alignment) __declspec(align(alignment)) +#define NV_ALIGN_SUFFIX(alignment) +#elif NV_GCC_FAMILY +#define NV_ALIGN(alignment, decl) decl __attribute__((aligned(alignment))) +#define NV_ALIGN_PREFIX(alignment) +#define NV_ALIGN_SUFFIX(alignment) __attribute__((aligned(alignment))) +#else +#define NV_ALIGN(alignment, decl) +#define NV_ALIGN_PREFIX(alignment) +#define NV_ALIGN_SUFFIX(alignment) +#endif +#endif + +/** +Deprecated macro +- To deprecate a function: Place NV_DEPRECATED at the start of the function header (leftmost word). +- To deprecate a 'typedef', a 'struct' or a 'class': Place NV_DEPRECATED directly after the keywords ('typdef', +'struct', 'class'). + +Use these macro definitions to create warnings for deprecated functions +#define NV_DEPRECATED __declspec(deprecated) // Microsoft +#define NV_DEPRECATED __attribute__((deprecated())) // GCC +*/ +#define NV_DEPRECATED + +/** +General defines +*/ + +// static assert +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) || defined(__ORBIS__) +#define NV_COMPILE_TIME_ASSERT(exp) typedef char NvCompileTimeAssert_Dummy[(exp) ? 1 : -1] __attribute__((unused)) +#else +#define NV_COMPILE_TIME_ASSERT(exp) typedef char NvCompileTimeAssert_Dummy[(exp) ? 1 : -1] +#endif + +#if NV_GCC_FAMILY && !NV_SNC && !NV_GHS +#define NV_OFFSET_OF(X, Y) __builtin_offsetof(X, Y) +#else +#define NV_OFFSET_OF(X, Y) offsetof(X, Y) +#endif + +#define NV_OFFSETOF_BASE 0x100 // casting the null ptr takes a special-case code path, which we don't want +#define NV_OFFSET_OF_RT(Class, Member) \ + (reinterpret_cast<size_t>(&reinterpret_cast<Class*>(NV_OFFSETOF_BASE)->Member) - size_t(NV_OFFSETOF_BASE)) + +// check that exactly one of NDEBUG and _DEBUG is defined +#if !defined(NDEBUG) ^ defined(_DEBUG) +#error Exactly one of NDEBUG and _DEBUG needs to be defined! +#endif + +// make sure NV_CHECKED is defined in all _DEBUG configurations as well +#if !defined(NV_CHECKED) && defined(NV_DEBUG) +#error NV_CHECKED must be defined when NV_DEBUG is defined +#endif + +#ifdef __CUDACC__ +#define NV_CUDA_CALLABLE __host__ __device__ +#else +#define NV_CUDA_CALLABLE +#endif + +// avoid unreferenced parameter warning +// preferred solution: omit the parameter's name from the declaration +template <class T> +NV_CUDA_CALLABLE NV_INLINE void NV_UNUSED(T const&) +{ +} + +// Ensure that the application hasn't tweaked the pack value to less than 8, which would break +// matching between the API headers and the binaries +// This assert works on win32/win64/360/ps3, but may need further specialization on other platforms. +// Some GCC compilers need the compiler flag -malign-double to be set. +// Apparently the apple-clang-llvm compiler doesn't support malign-double. +#if NV_PS4 || NV_APPLE_FAMILY +struct NvPackValidation +{ + char _; + long a; +}; +#elif NV_ANDROID +struct NvPackValidation +{ + char _; + double a; +}; +#else +struct NvPackValidation +{ + char _; + long long a; +}; +#endif +#if !NV_APPLE_FAMILY +NV_COMPILE_TIME_ASSERT(NV_OFFSET_OF(NvPackValidation, a) == 8); +#endif + +// use in a cpp file to suppress LNK4221 +#if NV_VC +#define NV_DUMMY_SYMBOL \ + namespace \ + { \ + char NvDummySymbol; \ + } +#else +#define NV_DUMMY_SYMBOL +#endif + +#if NV_GCC_FAMILY && !NV_GHS +#define NV_WEAK_SYMBOL __attribute__((weak)) // this is to support SIMD constant merging in template specialization +#else +#define NV_WEAK_SYMBOL +#endif + +// Macro for avoiding default assignment and copy, because doing this by inheritance can increase class size on some +// platforms. +#define NV_NOCOPY(Class) \ + \ +protected: \ + Class(const Class&); \ + Class& operator=(const Class&); + +#define NV_STRINGIZE_HELPER(X) #X +#define NV_STRINGIZE(X) NV_STRINGIZE_HELPER(X) + +#define NV_CONCAT_HELPER(X, Y) X##Y +#define NV_CONCAT(X, Y) NV_CONCAT_HELPER(X, Y) + +/** @} */ +#endif // #ifndef NV_NVFOUNDATION_NVPREPROCESSOR_H |