Main Page Class List Class Members

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

- File List
- File Members

# sdk/common/NvBlastMemory.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 NVBLASTMEMORY_H
    00030 #define NVBLASTMEMORY_H
    00031
    00032 #include <math.h>
    00033
    00034 namespace Nv
    00035 {
    00036 namespace Blast
    00037 {
    00038
    00039
    00045 template<typename T>
    00046 NV_INLINE T align16(T value)
    00047 {
    00048     return (value + 0xF)&~(T)0xF;
    00049 }
    00050
    00051
    00054 template <typename T>
    00055 NV_INLINE T pointerOffset(void* p, ptrdiff_t offset)
    00056 {
    00057     return reinterpret_cast<T>(reinterpret_cast<char*>(p)+offset);
    00058 }
    00059
    00060 template <typename T>
    00061 NV_INLINE T pointerOffset(const void* p, ptrdiff_t offset)
    00062 {
    00063     return reinterpret_cast<T>(reinterpret_cast<const char*>(p)+offset);
    00064 }
    00065
    00066 NV_INLINE const void* pointerOffset(const void* p, ptrdiff_t offset)
    00067 {
    00068     return pointerOffset<const void*>(p, offset);
    00069 }
    00070
    00071 NV_INLINE void* pointerOffset(void* p, ptrdiff_t offset)
    00072 {
    00073     return pointerOffset<void*>(p, offset);
    00074 }
    00075
    00076 } // namespace Blast
    00077 } // namespace Nv
    00078
    00079
    00081 #define NvBlastBlockData(_dataType, _name, _accessor) \
    00082 _dataType* _accessor() const \
    00083 { \
    00084     return (_dataType*)((uintptr_t)this + _name); \
    00085 } \
    00086 uint32_t _name
    00087
    00088
    00090 #define NvBlastBlockArrayData(_dataType, _name, _accessor, _sizeExpr) \
    00091 _dataType* _accessor() const \
    00092 { \
    00093     return (_dataType*)((uintptr_t)this + _name); \
    00094 } \
    00095 uint32_t _accessor##ArraySize() const \
    00096 { \
    00097     return _sizeExpr; \
    00098 } \
    00099 uint32_t _name
    00100
    00101
    00105 #define NvBlastCreateOffsetStart(_baseOffset) \
    00106 size_t _lastOffset = _baseOffset; \
    00107 size_t _lastSize = 0
    00108
    00110 #define NvBlastCreateOffsetAlign16(_name, _size) \
    00111 _name = align16(_lastOffset + _lastSize); \
    00112 _lastOffset = _name; \
    00113 _lastSize = _size
    00114
    00116 #define NvBlastCreateOffsetEndAlign16() \
    00117 align16(_lastOffset + _lastSize)
    00118
    00119
    00121 #if NV_WINDOWS_FAMILY
    00122 #include <malloc.h>
    00123 #define NvBlastAlloca(x) _alloca(x)
    00124 #elif NV_LINUX || NV_ANDROID
    00125 #include <alloca.h>
    00126 #define NvBlastAlloca(x) alloca(x)
    00127 #elif NV_APPLE_FAMILY
    00128 #include <alloca.h>
    00129 #define NvBlastAlloca(x) alloca(x)
    00130 #elif NV_PS4
    00131 #include <memory.h>
    00132 #define NvBlastAlloca(x) alloca(x)
    00133 #elif NV_XBOXONE
    00134 #include <malloc.h>
    00135 #define NvBlastAlloca(x) alloca(x)
    00136 #endif
    00137
    00138 #define NvBlastAllocaAligned16(x) (void*)(((uintptr_t)PxAlloca(x + 0xF) + 0xF) & ~(uintptr_t)0xF)
    00139
    00140
    00141 #endif // #ifndef NVBLASTMEMORY_H

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