From 7115f60b91b5717d90f643fd692010905c7004db Mon Sep 17 00:00:00 2001 From: Bryan Galdrikian Date: Thu, 31 May 2018 11:36:08 -0700 Subject: Blast 1.1.3. See docs/release_notes.txt. --- sdk/common/NvBlastArray.h | 134 +++---- sdk/common/NvBlastAssert.cpp | 134 +++---- sdk/common/NvBlastAssert.h | 162 ++++----- sdk/common/NvBlastAtomic.cpp | 180 ++++----- sdk/common/NvBlastAtomic.h | 100 ++--- sdk/common/NvBlastDLink.h | 606 +++++++++++++++---------------- sdk/common/NvBlastFixedArray.h | 292 +++++++-------- sdk/common/NvBlastFixedBitmap.h | 272 +++++++------- sdk/common/NvBlastFixedBoolArray.h | 248 ++++++------- sdk/common/NvBlastFixedPriorityQueue.h | 420 ++++++++++----------- sdk/common/NvBlastFixedQueue.h | 282 +++++++------- sdk/common/NvBlastGeometry.h | 474 ++++++++++++------------ sdk/common/NvBlastHashMap.h | 110 +++--- sdk/common/NvBlastHashSet.h | 108 +++--- sdk/common/NvBlastIncludeWindows.h | 206 +++++------ sdk/common/NvBlastIndexFns.h | 290 +++++++-------- sdk/common/NvBlastIteratorBase.h | 306 ++++++++-------- sdk/common/NvBlastMath.h | 218 +++++------ sdk/common/NvBlastMemory.h | 282 +++++++------- sdk/common/NvBlastPreprocessorInternal.h | 126 +++---- sdk/common/NvBlastTime.cpp | 82 ++--- sdk/common/NvBlastTime.h | 242 ++++++------ sdk/common/NvBlastTimers.cpp | 94 ++--- 23 files changed, 2684 insertions(+), 2684 deletions(-) mode change 100644 => 100755 sdk/common/NvBlastArray.h mode change 100644 => 100755 sdk/common/NvBlastAssert.cpp mode change 100644 => 100755 sdk/common/NvBlastAssert.h mode change 100644 => 100755 sdk/common/NvBlastAtomic.cpp mode change 100644 => 100755 sdk/common/NvBlastAtomic.h mode change 100644 => 100755 sdk/common/NvBlastDLink.h mode change 100644 => 100755 sdk/common/NvBlastFixedArray.h mode change 100644 => 100755 sdk/common/NvBlastFixedBitmap.h mode change 100644 => 100755 sdk/common/NvBlastFixedBoolArray.h mode change 100644 => 100755 sdk/common/NvBlastFixedPriorityQueue.h mode change 100644 => 100755 sdk/common/NvBlastFixedQueue.h mode change 100644 => 100755 sdk/common/NvBlastGeometry.h mode change 100644 => 100755 sdk/common/NvBlastHashMap.h mode change 100644 => 100755 sdk/common/NvBlastHashSet.h mode change 100644 => 100755 sdk/common/NvBlastIncludeWindows.h mode change 100644 => 100755 sdk/common/NvBlastIndexFns.h mode change 100644 => 100755 sdk/common/NvBlastIteratorBase.h mode change 100644 => 100755 sdk/common/NvBlastMath.h mode change 100644 => 100755 sdk/common/NvBlastMemory.h mode change 100644 => 100755 sdk/common/NvBlastPreprocessorInternal.h mode change 100644 => 100755 sdk/common/NvBlastTime.cpp mode change 100644 => 100755 sdk/common/NvBlastTime.h mode change 100644 => 100755 sdk/common/NvBlastTimers.cpp (limited to 'sdk/common') diff --git a/sdk/common/NvBlastArray.h b/sdk/common/NvBlastArray.h old mode 100644 new mode 100755 index 9e9308a..8efe21d --- a/sdk/common/NvBlastArray.h +++ b/sdk/common/NvBlastArray.h @@ -1,67 +1,67 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTARRAY_H -#define NVBLASTARRAY_H - - -#include "NvBlastAllocator.h" -#include "PsInlineArray.h" - - -namespace Nv -{ -namespace Blast -{ - -/** -Wrapped PxShared Array that uses NvBlastGlobals AllocatorCalllback. -*/ -template -struct Array -{ - typedef physx::shdfnd::Array type; -}; - - -/** -Wrapped PxShared InlineArray that uses NvBlastGlobals AllocatorCalllback. - -InlineArraya is array that pre-allocates for N elements. -*/ -template -struct InlineArray -{ - typedef physx::shdfnd::InlineArray type; -}; - -} // namespace Blast -} // namespace Nv - - -#endif // #ifndef NVBLASTARRAY_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTARRAY_H +#define NVBLASTARRAY_H + + +#include "NvBlastAllocator.h" +#include "PsInlineArray.h" + + +namespace Nv +{ +namespace Blast +{ + +/** +Wrapped PxShared Array that uses NvBlastGlobals AllocatorCalllback. +*/ +template +struct Array +{ + typedef physx::shdfnd::Array type; +}; + + +/** +Wrapped PxShared InlineArray that uses NvBlastGlobals AllocatorCalllback. + +InlineArraya is array that pre-allocates for N elements. +*/ +template +struct InlineArray +{ + typedef physx::shdfnd::InlineArray type; +}; + +} // namespace Blast +} // namespace Nv + + +#endif // #ifndef NVBLASTARRAY_H diff --git a/sdk/common/NvBlastAssert.cpp b/sdk/common/NvBlastAssert.cpp old mode 100644 new mode 100755 index 05a88cc..86d92f9 --- a/sdk/common/NvBlastAssert.cpp +++ b/sdk/common/NvBlastAssert.cpp @@ -1,67 +1,67 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastAssert.h" - -#include -#include - -#if NV_WINDOWS_FAMILY -#include -#endif - -extern "C" -{ - -void NvBlastAssertHandler(const char* expr, const char* file, int line, bool& ignore) -{ - NV_UNUSED(ignore); // is used only in debug windows config - char buffer[1024]; -#if NV_WINDOWS_FAMILY - sprintf_s(buffer, 1024, "%s(%d) : Assertion failed: %s\n", file, line, expr); -#else - sprintf(buffer, "%s(%d) : Assertion failed: %s\n", file, line, expr); -#endif - puts(buffer); -#if NV_WINDOWS_FAMILY && NV_DEBUG - // _CrtDbgReport returns -1 on error, 1 on 'retry', 0 otherwise including 'ignore'. - // Hitting 'abort' will terminate the process immediately. - int result = _CrtDbgReport(_CRT_ASSERT, file, line, NULL, "%s", buffer); - int mode = _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_REPORT_MODE); - ignore = _CRTDBG_MODE_WNDW == mode && result == 0; - if (ignore) - return; - __debugbreak(); -#elif (NV_WINDOWS_FAMILY && NV_CHECKED) - __debugbreak(); -#else - abort(); -#endif -} - -} // extern "C" +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastAssert.h" + +#include +#include + +#if NV_WINDOWS_FAMILY +#include +#endif + +extern "C" +{ + +void NvBlastAssertHandler(const char* expr, const char* file, int line, bool& ignore) +{ + NV_UNUSED(ignore); // is used only in debug windows config + char buffer[1024]; +#if NV_WINDOWS_FAMILY + sprintf_s(buffer, 1024, "%s(%d) : Assertion failed: %s\n", file, line, expr); +#else + sprintf(buffer, "%s(%d) : Assertion failed: %s\n", file, line, expr); +#endif + puts(buffer); +#if NV_WINDOWS_FAMILY && NV_DEBUG + // _CrtDbgReport returns -1 on error, 1 on 'retry', 0 otherwise including 'ignore'. + // Hitting 'abort' will terminate the process immediately. + int result = _CrtDbgReport(_CRT_ASSERT, file, line, NULL, "%s", buffer); + int mode = _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_REPORT_MODE); + ignore = _CRTDBG_MODE_WNDW == mode && result == 0; + if (ignore) + return; + __debugbreak(); +#elif (NV_WINDOWS_FAMILY && NV_CHECKED) + __debugbreak(); +#else + abort(); +#endif +} + +} // extern "C" diff --git a/sdk/common/NvBlastAssert.h b/sdk/common/NvBlastAssert.h old mode 100644 new mode 100755 index 8978297..09f2b8a --- a/sdk/common/NvBlastAssert.h +++ b/sdk/common/NvBlastAssert.h @@ -1,81 +1,81 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTASSERT_H -#define NVBLASTASSERT_H - - -#include "NvBlastPreprocessor.h" - - -#if !NV_ENABLE_ASSERTS -#define NVBLAST_ASSERT(exp) ((void)0) -#define NVBLAST_ALWAYS_ASSERT_MESSAGE(message) ((void)0) -#define NVBLAST_ASSERT_WITH_MESSAGE(condition, message) ((void)0) -#else -#if NV_VC -#define NVBLAST_CODE_ANALYSIS_ASSUME(exp) \ - __analysis_assume(!!(exp)) // This macro will be used to get rid of analysis warning messages if a NVBLAST_ASSERT is used -// to "guard" illegal mem access, for example. -#else -#define NVBLAST_CODE_ANALYSIS_ASSUME(exp) -#endif -#define NVBLAST_ASSERT(exp) \ -{ \ - static bool _ignore = false; \ - if (!(exp) && !_ignore) NvBlastAssertHandler(#exp, __FILE__, __LINE__, _ignore); \ - NVBLAST_CODE_ANALYSIS_ASSUME(exp); \ -} ((void)0) -#define NVBLAST_ALWAYS_ASSERT_MESSAGE(message) \ -{ \ - static bool _ignore = false; \ - if(!_ignore) \ - { \ - NvBlastAssertHandler(message, __FILE__, __LINE__, _ignore); \ - } \ -} ((void)0) -#define NVBLAST_ASSERT_WITH_MESSAGE(exp, message) \ -{ \ - static bool _ignore = false; \ - if (!(exp) && !_ignore) NvBlastAssertHandler(message, __FILE__, __LINE__, _ignore); \ - NVBLAST_CODE_ANALYSIS_ASSUME(exp); \ -} ((void)0) -#endif - -#define NVBLAST_ALWAYS_ASSERT() NVBLAST_ASSERT(0) - - -extern "C" -{ - -NVBLAST_API void NvBlastAssertHandler(const char* expr, const char* file, int line, bool& ignore); - -} // extern "C" - - -#endif // #ifndef NVBLASTASSERT_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTASSERT_H +#define NVBLASTASSERT_H + + +#include "NvBlastPreprocessor.h" + + +#if !NV_ENABLE_ASSERTS +#define NVBLAST_ASSERT(exp) ((void)0) +#define NVBLAST_ALWAYS_ASSERT_MESSAGE(message) ((void)0) +#define NVBLAST_ASSERT_WITH_MESSAGE(condition, message) ((void)0) +#else +#if NV_VC +#define NVBLAST_CODE_ANALYSIS_ASSUME(exp) \ + __analysis_assume(!!(exp)) // This macro will be used to get rid of analysis warning messages if a NVBLAST_ASSERT is used +// to "guard" illegal mem access, for example. +#else +#define NVBLAST_CODE_ANALYSIS_ASSUME(exp) +#endif +#define NVBLAST_ASSERT(exp) \ +{ \ + static bool _ignore = false; \ + if (!(exp) && !_ignore) NvBlastAssertHandler(#exp, __FILE__, __LINE__, _ignore); \ + NVBLAST_CODE_ANALYSIS_ASSUME(exp); \ +} ((void)0) +#define NVBLAST_ALWAYS_ASSERT_MESSAGE(message) \ +{ \ + static bool _ignore = false; \ + if(!_ignore) \ + { \ + NvBlastAssertHandler(message, __FILE__, __LINE__, _ignore); \ + } \ +} ((void)0) +#define NVBLAST_ASSERT_WITH_MESSAGE(exp, message) \ +{ \ + static bool _ignore = false; \ + if (!(exp) && !_ignore) NvBlastAssertHandler(message, __FILE__, __LINE__, _ignore); \ + NVBLAST_CODE_ANALYSIS_ASSUME(exp); \ +} ((void)0) +#endif + +#define NVBLAST_ALWAYS_ASSERT() NVBLAST_ASSERT(0) + + +extern "C" +{ + +NVBLAST_API void NvBlastAssertHandler(const char* expr, const char* file, int line, bool& ignore); + +} // extern "C" + + +#endif // #ifndef NVBLASTASSERT_H diff --git a/sdk/common/NvBlastAtomic.cpp b/sdk/common/NvBlastAtomic.cpp old mode 100644 new mode 100755 index 96c1ea9..789dfa2 --- a/sdk/common/NvBlastAtomic.cpp +++ b/sdk/common/NvBlastAtomic.cpp @@ -1,90 +1,90 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastAtomic.h" - -#include -#include - - -namespace Nv -{ -namespace Blast -{ - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Windows/XBOXONE Implementation -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#if NV_WINDOWS_FAMILY || NV_XBOXONE - -#include "NvBlastIncludeWindows.h" - -int32_t atomicIncrement(volatile int32_t* val) -{ - return (int32_t)InterlockedIncrement((volatile LONG*)val); -} - -int32_t atomicDecrement(volatile int32_t* val) -{ - return (int32_t)InterlockedDecrement((volatile LONG*)val); -} - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Unix/PS4 Implementation -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#elif(NV_UNIX_FAMILY || NV_PS4) - -int32_t atomicIncrement(volatile int32_t* val) -{ - return __sync_add_and_fetch(val, 1); -} - -int32_t atomicDecrement(volatile int32_t* val) -{ - return __sync_sub_and_fetch(val, 1); -} - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Unsupported Platforms -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#else - -#error "Platform not supported!" - -#endif - - -} // namespace Blast -} // namespace Nv - +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastAtomic.h" + +#include +#include + + +namespace Nv +{ +namespace Blast +{ + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Windows/XBOXONE Implementation +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +#if NV_WINDOWS_FAMILY || NV_XBOXONE + +#include "NvBlastIncludeWindows.h" + +int32_t atomicIncrement(volatile int32_t* val) +{ + return (int32_t)InterlockedIncrement((volatile LONG*)val); +} + +int32_t atomicDecrement(volatile int32_t* val) +{ + return (int32_t)InterlockedDecrement((volatile LONG*)val); +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Unix/PS4 Implementation +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +#elif(NV_UNIX_FAMILY || NV_PS4) + +int32_t atomicIncrement(volatile int32_t* val) +{ + return __sync_add_and_fetch(val, 1); +} + +int32_t atomicDecrement(volatile int32_t* val) +{ + return __sync_sub_and_fetch(val, 1); +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Unsupported Platforms +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +#else + +#error "Platform not supported!" + +#endif + + +} // namespace Blast +} // namespace Nv + diff --git a/sdk/common/NvBlastAtomic.h b/sdk/common/NvBlastAtomic.h old mode 100644 new mode 100755 index 8957ba9..5bff61d --- a/sdk/common/NvBlastAtomic.h +++ b/sdk/common/NvBlastAtomic.h @@ -1,50 +1,50 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTATOMIC_H -#define NVBLASTATOMIC_H - -#include "NvBlastTypes.h" - - -namespace Nv -{ -namespace Blast -{ - -/* increment the specified location. Return the incremented value */ -int32_t atomicIncrement(volatile int32_t* val); - - -/* decrement the specified location. Return the decremented value */ -int32_t atomicDecrement(volatile int32_t* val); - -} // namespace Blast -} // namespace Nv - -#endif // #ifndef NVBLASTATOMIC_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTATOMIC_H +#define NVBLASTATOMIC_H + +#include "NvBlastTypes.h" + + +namespace Nv +{ +namespace Blast +{ + +/* increment the specified location. Return the incremented value */ +int32_t atomicIncrement(volatile int32_t* val); + + +/* decrement the specified location. Return the decremented value */ +int32_t atomicDecrement(volatile int32_t* val); + +} // namespace Blast +} // namespace Nv + +#endif // #ifndef NVBLASTATOMIC_H diff --git a/sdk/common/NvBlastDLink.h b/sdk/common/NvBlastDLink.h old mode 100644 new mode 100755 index 61f4862..6b76616 --- a/sdk/common/NvBlastDLink.h +++ b/sdk/common/NvBlastDLink.h @@ -1,303 +1,303 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTDLINK_H -#define NVBLASTDLINK_H - - -#include "NvBlastAssert.h" -#include "NvBlastIndexFns.h" - - -namespace Nv -{ -namespace Blast -{ - -template -struct IndexDLink -{ - IndexType m_adj[2]; -}; - - -template -class IndexDList -{ -public: - void initLinksSolitary(IndexDLink* links, IndexType linkCount) - { - for (IndexType i = 0; i < linkCount; ++i) - { - links[i].m_adj[0] = invalidIndex(); - links[i].m_adj[1] = invalidIndex(); - } - } - - void initLinksChain(IndexDLink* links, IndexType linkCount) - { - if (linkCount > 0) - { - links[0].m_adj[0] = invalidIndex(); - for (IndexType i = 1; i < linkCount; ++i) - { - links[i - 1].m_adj[1] = i; - links[i].m_adj[0] = i - 1; - } - links[linkCount - 1].m_adj[1] = invalidIndex(); - } - } - - IndexType getAdj(IndexDLink* links, IndexType linkIndex, int which) - { - return links[linkIndex].m_adj[which & 1]; - } - - void remove(IndexDLink* links, IndexType linkIndex) - { - IndexDLink& link = links[linkIndex]; - const IndexType adj0 = link.m_adj[0]; - const IndexType adj1 = link.m_adj[1]; - if (!isInvalidIndex(adj1)) - { - links[adj1].m_adj[0] = adj0; - link.m_adj[1] = invalidIndex(); - } - if (!isInvalidIndex(adj0)) - { - links[adj0].m_adj[1] = adj1; - link.m_adj[0] = invalidIndex(); - } - } - - bool isSolitary(IndexDLink* links, IndexType linkIndex) - { - const IndexDLink& link = links[linkIndex]; - return isInvalidIndex(link.m_adj[0]) && isInvalidIndex(link.m_adj[1]); - } - - void insertListHead(IndexType& listHead, IndexDLink* links, IndexType linkIndex) - { - NVBLAST_ASSERT(!isInvalidIndex(linkIndex)); - if (!isInvalidIndex(listHead)) - { - links[listHead].m_adj[0] = linkIndex; - } - links[linkIndex].m_adj[1] = listHead; - listHead = linkIndex; - } - - IndexType removeListHead(IndexType& listHead, IndexDLink* links) - { - const IndexType linkIndex = listHead; - if (!isInvalidIndex(linkIndex)) - { - listHead = links[linkIndex].m_adj[1]; - if (!isInvalidIndex(listHead)) - { - links[listHead].m_adj[0] = invalidIndex(); - } - links[linkIndex].m_adj[1] = invalidIndex(); - } - return linkIndex; - } - - void removeFromList(IndexType& listHead, IndexDLink* links, IndexType linkIndex) - { - NVBLAST_ASSERT(!isInvalidIndex(linkIndex)); - if (listHead == linkIndex) - { - listHead = links[linkIndex].m_adj[1]; - } - remove(links, linkIndex); - } -}; - - -struct DLink -{ - DLink() : m_prev(nullptr), m_next(nullptr) {} - - DLink* getPrev() const - { - return m_prev; - } - - DLink* getNext() const - { - return m_next; - } - -private: - DLink* m_prev; - DLink* m_next; - - friend class DList; -}; - - -class DList -{ -public: - DList() : m_head(nullptr), m_tail(nullptr) {} - - bool isEmpty() const - { - NVBLAST_ASSERT((m_head == nullptr) == (m_tail == nullptr)); - return m_head == nullptr; - } - - bool isSolitary(const DLink& link) const - { - return link.m_prev == nullptr && link.m_next == nullptr && m_head != &link; - } - - DLink* getHead() const - { - return m_head; - } - - DLink* getTail() const - { - return m_tail; - } - - bool insertHead(DLink& link) - { - NVBLAST_ASSERT(isSolitary(link)); - if (!isSolitary(link)) - { - return false; - } - - link.m_next = m_head; - if (m_head != nullptr) - { - m_head->m_prev = &link; - } - m_head = &link; - if (m_tail == nullptr) - { - m_tail = &link; - } - - return true; - } - - bool insertTail(DLink& link) - { - NVBLAST_ASSERT(isSolitary(link)); - if (!isSolitary(link)) - { - return false; - } - - link.m_prev = m_tail; - if (m_tail != nullptr) - { - m_tail->m_next = &link; - } - m_tail = &link; - if (m_head == nullptr) - { - m_head = &link; - } - - return true; - } - - void remove(DLink& link) - { - if (link.m_prev != nullptr) - { - link.m_prev->m_next = link.m_next; - } - else - if (m_head == &link) - { - m_head = link.m_next; - } - - if (link.m_next != nullptr) - { - link.m_next->m_prev = link.m_prev; - } - else - if (m_tail == &link) - { - m_tail = link.m_prev; - } - - link.m_next = link.m_prev = nullptr; - } - - class It - { - public: - enum Direction { Reverse, Forward }; - - It(const DList& list, Direction dir = Forward) : m_curr(dir == Forward ? list.getHead() : list.getTail()) {} - - /** Validity of current value. */ - operator bool() const - { - return m_curr != nullptr; - } - - /** Current value. */ - operator const DLink*() const - { - return m_curr; - } - - /** Pre-increment. */ - const DLink* operator ++ () - { - return m_curr = m_curr->getNext(); - } - - /** Pre-deccrement. */ - const DLink* operator -- () - { - return m_curr = m_curr->getPrev(); - } - - private: - const DLink* m_curr; - }; - -private: - DLink* m_head; - DLink* m_tail; -}; - -} // end namespace Blast -} // end namespace Nv - - -#endif // #ifndef NVBLASTDLINK_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTDLINK_H +#define NVBLASTDLINK_H + + +#include "NvBlastAssert.h" +#include "NvBlastIndexFns.h" + + +namespace Nv +{ +namespace Blast +{ + +template +struct IndexDLink +{ + IndexType m_adj[2]; +}; + + +template +class IndexDList +{ +public: + void initLinksSolitary(IndexDLink* links, IndexType linkCount) + { + for (IndexType i = 0; i < linkCount; ++i) + { + links[i].m_adj[0] = invalidIndex(); + links[i].m_adj[1] = invalidIndex(); + } + } + + void initLinksChain(IndexDLink* links, IndexType linkCount) + { + if (linkCount > 0) + { + links[0].m_adj[0] = invalidIndex(); + for (IndexType i = 1; i < linkCount; ++i) + { + links[i - 1].m_adj[1] = i; + links[i].m_adj[0] = i - 1; + } + links[linkCount - 1].m_adj[1] = invalidIndex(); + } + } + + IndexType getAdj(IndexDLink* links, IndexType linkIndex, int which) + { + return links[linkIndex].m_adj[which & 1]; + } + + void remove(IndexDLink* links, IndexType linkIndex) + { + IndexDLink& link = links[linkIndex]; + const IndexType adj0 = link.m_adj[0]; + const IndexType adj1 = link.m_adj[1]; + if (!isInvalidIndex(adj1)) + { + links[adj1].m_adj[0] = adj0; + link.m_adj[1] = invalidIndex(); + } + if (!isInvalidIndex(adj0)) + { + links[adj0].m_adj[1] = adj1; + link.m_adj[0] = invalidIndex(); + } + } + + bool isSolitary(IndexDLink* links, IndexType linkIndex) + { + const IndexDLink& link = links[linkIndex]; + return isInvalidIndex(link.m_adj[0]) && isInvalidIndex(link.m_adj[1]); + } + + void insertListHead(IndexType& listHead, IndexDLink* links, IndexType linkIndex) + { + NVBLAST_ASSERT(!isInvalidIndex(linkIndex)); + if (!isInvalidIndex(listHead)) + { + links[listHead].m_adj[0] = linkIndex; + } + links[linkIndex].m_adj[1] = listHead; + listHead = linkIndex; + } + + IndexType removeListHead(IndexType& listHead, IndexDLink* links) + { + const IndexType linkIndex = listHead; + if (!isInvalidIndex(linkIndex)) + { + listHead = links[linkIndex].m_adj[1]; + if (!isInvalidIndex(listHead)) + { + links[listHead].m_adj[0] = invalidIndex(); + } + links[linkIndex].m_adj[1] = invalidIndex(); + } + return linkIndex; + } + + void removeFromList(IndexType& listHead, IndexDLink* links, IndexType linkIndex) + { + NVBLAST_ASSERT(!isInvalidIndex(linkIndex)); + if (listHead == linkIndex) + { + listHead = links[linkIndex].m_adj[1]; + } + remove(links, linkIndex); + } +}; + + +struct DLink +{ + DLink() : m_prev(nullptr), m_next(nullptr) {} + + DLink* getPrev() const + { + return m_prev; + } + + DLink* getNext() const + { + return m_next; + } + +private: + DLink* m_prev; + DLink* m_next; + + friend class DList; +}; + + +class DList +{ +public: + DList() : m_head(nullptr), m_tail(nullptr) {} + + bool isEmpty() const + { + NVBLAST_ASSERT((m_head == nullptr) == (m_tail == nullptr)); + return m_head == nullptr; + } + + bool isSolitary(const DLink& link) const + { + return link.m_prev == nullptr && link.m_next == nullptr && m_head != &link; + } + + DLink* getHead() const + { + return m_head; + } + + DLink* getTail() const + { + return m_tail; + } + + bool insertHead(DLink& link) + { + NVBLAST_ASSERT(isSolitary(link)); + if (!isSolitary(link)) + { + return false; + } + + link.m_next = m_head; + if (m_head != nullptr) + { + m_head->m_prev = &link; + } + m_head = &link; + if (m_tail == nullptr) + { + m_tail = &link; + } + + return true; + } + + bool insertTail(DLink& link) + { + NVBLAST_ASSERT(isSolitary(link)); + if (!isSolitary(link)) + { + return false; + } + + link.m_prev = m_tail; + if (m_tail != nullptr) + { + m_tail->m_next = &link; + } + m_tail = &link; + if (m_head == nullptr) + { + m_head = &link; + } + + return true; + } + + void remove(DLink& link) + { + if (link.m_prev != nullptr) + { + link.m_prev->m_next = link.m_next; + } + else + if (m_head == &link) + { + m_head = link.m_next; + } + + if (link.m_next != nullptr) + { + link.m_next->m_prev = link.m_prev; + } + else + if (m_tail == &link) + { + m_tail = link.m_prev; + } + + link.m_next = link.m_prev = nullptr; + } + + class It + { + public: + enum Direction { Reverse, Forward }; + + It(const DList& list, Direction dir = Forward) : m_curr(dir == Forward ? list.getHead() : list.getTail()) {} + + /** Validity of current value. */ + operator bool() const + { + return m_curr != nullptr; + } + + /** Current value. */ + operator const DLink*() const + { + return m_curr; + } + + /** Pre-increment. */ + const DLink* operator ++ () + { + return m_curr = m_curr->getNext(); + } + + /** Pre-deccrement. */ + const DLink* operator -- () + { + return m_curr = m_curr->getPrev(); + } + + private: + const DLink* m_curr; + }; + +private: + DLink* m_head; + DLink* m_tail; +}; + +} // end namespace Blast +} // end namespace Nv + + +#endif // #ifndef NVBLASTDLINK_H diff --git a/sdk/common/NvBlastFixedArray.h b/sdk/common/NvBlastFixedArray.h old mode 100644 new mode 100755 index cfe5ebe..c23ce5a --- a/sdk/common/NvBlastFixedArray.h +++ b/sdk/common/NvBlastFixedArray.h @@ -1,146 +1,146 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTFIXEDARRAY_H -#define NVBLASTFIXEDARRAY_H - -#include "NvBlastAssert.h" -#include "NvBlastMemory.h" - -namespace Nv -{ -namespace Blast -{ - -/*! -FixedArray is a sequential container which is intended to be used with placement new on chunk of memory. -It'll use following memory for data layout. As follows: - -// some memory -char ​*buf = new char[64 *​ 1024]; - -// placement new on this memory -FixedArray* arr = new (buf) FixedArray(); - -// you can get max requiredMemorySize by an array of 'capacity' elements count to use memory left -buf = buf + FixedArray::requiredMemorySize(capacity); - -buf: - -+------------------------------------------------------------+ -| uint32_t | T[0] | T[1] | T[2] | ... | -+------------------------------------------------------------+ - - -!!!TODO: -- check ctor/dtor of elements calls -*/ -template -class FixedArray -{ -public: - explicit FixedArray() : m_size(0) - { - } - - static size_t requiredMemorySize(uint32_t capacity) - { - return align16(sizeof(FixedArray)) + align16(capacity * sizeof(T)); - } - - NV_FORCE_INLINE T& pushBack(T& t) - { - new (data() + m_size) T(t); - return data()[m_size++]; - } - - T popBack() - { - NVBLAST_ASSERT(m_size); - T t = data()[m_size - 1]; - data()[--m_size].~T(); - return t; - } - - void clear() - { - for(T* first = data(); first < data() + m_size; ++first) - first->~T(); - m_size = 0; - } - - NV_FORCE_INLINE void forceSize_Unsafe(uint32_t s) - { - m_size = s; - } - - NV_FORCE_INLINE T& operator[](uint32_t idx) - { - NVBLAST_ASSERT(idx < m_size); - return data()[idx]; - } - - NV_FORCE_INLINE const T& operator[](uint32_t idx) const - { - NVBLAST_ASSERT(idx < m_size); - return data()[idx]; - } - - NV_FORCE_INLINE T& at(uint32_t idx) - { - NVBLAST_ASSERT(idx < m_size); - return data()[idx]; - } - - NV_FORCE_INLINE const T& at(uint32_t idx) const - { - NVBLAST_ASSERT(idx < m_size); - return data()[idx]; - } - - NV_FORCE_INLINE uint32_t size() const - { - return m_size; - } - -private: - uint32_t m_size; - - NV_FORCE_INLINE T* data() - { - return (T*)((char*)this + sizeof(FixedArray)); - } - -private: - FixedArray(const FixedArray& that); -}; - -} // namespace Blast -} // namespace Nv - -#endif // ifndef NVBLASTFIXEDARRAY_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTFIXEDARRAY_H +#define NVBLASTFIXEDARRAY_H + +#include "NvBlastAssert.h" +#include "NvBlastMemory.h" + +namespace Nv +{ +namespace Blast +{ + +/*! +FixedArray is a sequential container which is intended to be used with placement new on chunk of memory. +It'll use following memory for data layout. As follows: + +// some memory +char ​*buf = new char[64 *​ 1024]; + +// placement new on this memory +FixedArray* arr = new (buf) FixedArray(); + +// you can get max requiredMemorySize by an array of 'capacity' elements count to use memory left +buf = buf + FixedArray::requiredMemorySize(capacity); + +buf: + ++------------------------------------------------------------+ +| uint32_t | T[0] | T[1] | T[2] | ... | ++------------------------------------------------------------+ + + +!!!TODO: +- check ctor/dtor of elements calls +*/ +template +class FixedArray +{ +public: + explicit FixedArray() : m_size(0) + { + } + + static size_t requiredMemorySize(uint32_t capacity) + { + return align16(sizeof(FixedArray)) + align16(capacity * sizeof(T)); + } + + NV_FORCE_INLINE T& pushBack(T& t) + { + new (data() + m_size) T(t); + return data()[m_size++]; + } + + T popBack() + { + NVBLAST_ASSERT(m_size); + T t = data()[m_size - 1]; + data()[--m_size].~T(); + return t; + } + + void clear() + { + for(T* first = data(); first < data() + m_size; ++first) + first->~T(); + m_size = 0; + } + + NV_FORCE_INLINE void forceSize_Unsafe(uint32_t s) + { + m_size = s; + } + + NV_FORCE_INLINE T& operator[](uint32_t idx) + { + NVBLAST_ASSERT(idx < m_size); + return data()[idx]; + } + + NV_FORCE_INLINE const T& operator[](uint32_t idx) const + { + NVBLAST_ASSERT(idx < m_size); + return data()[idx]; + } + + NV_FORCE_INLINE T& at(uint32_t idx) + { + NVBLAST_ASSERT(idx < m_size); + return data()[idx]; + } + + NV_FORCE_INLINE const T& at(uint32_t idx) const + { + NVBLAST_ASSERT(idx < m_size); + return data()[idx]; + } + + NV_FORCE_INLINE uint32_t size() const + { + return m_size; + } + +private: + uint32_t m_size; + + NV_FORCE_INLINE T* data() + { + return (T*)((char*)this + sizeof(FixedArray)); + } + +private: + FixedArray(const FixedArray& that); +}; + +} // namespace Blast +} // namespace Nv + +#endif // ifndef NVBLASTFIXEDARRAY_H diff --git a/sdk/common/NvBlastFixedBitmap.h b/sdk/common/NvBlastFixedBitmap.h old mode 100644 new mode 100755 index b6c00f8..122c467 --- a/sdk/common/NvBlastFixedBitmap.h +++ b/sdk/common/NvBlastFixedBitmap.h @@ -1,136 +1,136 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTFIXEDBITMAP_H -#define NVBLASTFIXEDBITMAP_H - -#include "NvBlastAssert.h" -#include "NvBlastMemory.h" -#include - -namespace Nv -{ -namespace Blast -{ - -/*! -FixedBitmap is a bitset (bitmap) of fixed side, it's intended to be used with placement new on chunk of memory. -It'll use following memory for data layout. As follows: - -// some memory -char ​*buf = new char[64 *​ 1024]; - -const uint32_t bitsCount = 100; - -// placement new on this memory -FixedBitmap* arr = new (buf) FixedBitmap(bitsCount); - -// you can get max requiredMemorySize by an bitMap to use memory left -buf = buf + FixedBitmap::requiredMemorySize(bitsCount); - -buf: - -+------------------------------------------------------------+ -| uint32_t | word0 | word1 | word2 | ... | -+------------------------------------------------------------+ - -*/ -class FixedBitmap -{ -public: - explicit FixedBitmap(uint32_t bitsCount) - { - m_bitsCount = bitsCount; - } - - static uint32_t getWordsCount(uint32_t bitsCount) - { - return (bitsCount + 31) >> 5; - } - - static size_t requiredMemorySize(uint32_t bitsCount) - { - return align16(sizeof(FixedBitmap)) + align16(getWordsCount(bitsCount) * sizeof(uint32_t)); - } - - void clear() - { - memset(data(), 0, getWordsCount(m_bitsCount) * sizeof(uint32_t)); - } - - void fill() - { - const uint32_t wordCount = getWordsCount(m_bitsCount); - uint32_t* mem = data(); - memset(mem, 0xFF, wordCount * sizeof(uint32_t)); - const uint32_t bitsRemainder = m_bitsCount & 31; - if (bitsRemainder > 0) - { - mem[wordCount - 1] &= ~(0xFFFFFFFF << bitsRemainder); - } - } - - int test(uint32_t index) const - { - NVBLAST_ASSERT(index < m_bitsCount); - return data()[index >> 5] & (1 << (index & 31)); - } - - void set(uint32_t index) - { - NVBLAST_ASSERT(index < m_bitsCount); - data()[index >> 5] |= 1 << (index & 31); - } - - void reset(uint32_t index) - { - NVBLAST_ASSERT(index < m_bitsCount); - data()[index >> 5] &= ~(1 << (index & 31)); - } - -private: - uint32_t m_bitsCount; - - NV_FORCE_INLINE uint32_t* data() - { - return (uint32_t*)((char*)this + sizeof(FixedBitmap)); - } - - NV_FORCE_INLINE const uint32_t* data() const - { - return (uint32_t*)((char*)this + sizeof(FixedBitmap)); - } - -private: - FixedBitmap(const FixedBitmap& that); -}; - -} // namespace Blast -} // namespace Nv - -#endif // ifndef NVBLASTFIXEDBITMAP_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTFIXEDBITMAP_H +#define NVBLASTFIXEDBITMAP_H + +#include "NvBlastAssert.h" +#include "NvBlastMemory.h" +#include + +namespace Nv +{ +namespace Blast +{ + +/*! +FixedBitmap is a bitset (bitmap) of fixed side, it's intended to be used with placement new on chunk of memory. +It'll use following memory for data layout. As follows: + +// some memory +char ​*buf = new char[64 *​ 1024]; + +const uint32_t bitsCount = 100; + +// placement new on this memory +FixedBitmap* arr = new (buf) FixedBitmap(bitsCount); + +// you can get max requiredMemorySize by an bitMap to use memory left +buf = buf + FixedBitmap::requiredMemorySize(bitsCount); + +buf: + ++------------------------------------------------------------+ +| uint32_t | word0 | word1 | word2 | ... | ++------------------------------------------------------------+ + +*/ +class FixedBitmap +{ +public: + explicit FixedBitmap(uint32_t bitsCount) + { + m_bitsCount = bitsCount; + } + + static uint32_t getWordsCount(uint32_t bitsCount) + { + return (bitsCount + 31) >> 5; + } + + static size_t requiredMemorySize(uint32_t bitsCount) + { + return align16(sizeof(FixedBitmap)) + align16(getWordsCount(bitsCount) * sizeof(uint32_t)); + } + + void clear() + { + memset(data(), 0, getWordsCount(m_bitsCount) * sizeof(uint32_t)); + } + + void fill() + { + const uint32_t wordCount = getWordsCount(m_bitsCount); + uint32_t* mem = data(); + memset(mem, 0xFF, wordCount * sizeof(uint32_t)); + const uint32_t bitsRemainder = m_bitsCount & 31; + if (bitsRemainder > 0) + { + mem[wordCount - 1] &= ~(0xFFFFFFFF << bitsRemainder); + } + } + + int test(uint32_t index) const + { + NVBLAST_ASSERT(index < m_bitsCount); + return data()[index >> 5] & (1 << (index & 31)); + } + + void set(uint32_t index) + { + NVBLAST_ASSERT(index < m_bitsCount); + data()[index >> 5] |= 1 << (index & 31); + } + + void reset(uint32_t index) + { + NVBLAST_ASSERT(index < m_bitsCount); + data()[index >> 5] &= ~(1 << (index & 31)); + } + +private: + uint32_t m_bitsCount; + + NV_FORCE_INLINE uint32_t* data() + { + return (uint32_t*)((char*)this + sizeof(FixedBitmap)); + } + + NV_FORCE_INLINE const uint32_t* data() const + { + return (uint32_t*)((char*)this + sizeof(FixedBitmap)); + } + +private: + FixedBitmap(const FixedBitmap& that); +}; + +} // namespace Blast +} // namespace Nv + +#endif // ifndef NVBLASTFIXEDBITMAP_H diff --git a/sdk/common/NvBlastFixedBoolArray.h b/sdk/common/NvBlastFixedBoolArray.h old mode 100644 new mode 100755 index aa5332f..d934537 --- a/sdk/common/NvBlastFixedBoolArray.h +++ b/sdk/common/NvBlastFixedBoolArray.h @@ -1,124 +1,124 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTFIXEDBOOLARRAY_H -#define NVBLASTFIXEDBOOLARRAY_H - -#include "NvBlastAssert.h" -#include "NvBlastMemory.h" -#include - -namespace Nv -{ -namespace Blast -{ - -/*! -FixedBoolArray is an array of bools of fixed size, it's intended to be used with placement new on chunk of memory. -It'll use following memory for data layout. As follows: - -// some memory -char ​*buf = new char[64 *​ 1024]; - -const uint32_t size = 100; - -// placement new on this memory -FixedBoolArray* arr = new (buf) FixedBoolArray(size); - -// you can get max requiredMemorySize by an bitMap to use memory left -buf = buf + FixedBoolArray::requiredMemorySize(size); - -buf: - -+------------------------------------------------------------+ -| uint32_t | bool0 | bool1 | bool2 | ... | -+------------------------------------------------------------+ - -*/ -class FixedBoolArray -{ -public: - explicit FixedBoolArray(uint32_t size) - { - m_size = size; - } - - static size_t requiredMemorySize(uint32_t size) - { - return align16(sizeof(FixedBoolArray)) + align16(size); - } - - void clear() - { - memset(data(), 0, m_size); - } - - void fill() - { - memset(data(), 1, m_size); - } - - int test(uint32_t index) const - { - NVBLAST_ASSERT(index < m_size); - return data()[index]; - } - - void set(uint32_t index) - { - NVBLAST_ASSERT(index < m_size); - data()[index] = 1; - } - - void reset(uint32_t index) - { - NVBLAST_ASSERT(index < m_size); - data()[index] = 0; - } - -private: - uint32_t m_size; - - NV_FORCE_INLINE char* data() - { - return ((char*)this + sizeof(FixedBoolArray)); - } - - NV_FORCE_INLINE const char* data() const - { - return ((char*)this + sizeof(FixedBoolArray)); - } - -private: - FixedBoolArray(const FixedBoolArray& that); -}; - -} // namespace Blast -} // namespace Nv - -#endif // ifndef NVBLASTFIXEDBOOLARRAY_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTFIXEDBOOLARRAY_H +#define NVBLASTFIXEDBOOLARRAY_H + +#include "NvBlastAssert.h" +#include "NvBlastMemory.h" +#include + +namespace Nv +{ +namespace Blast +{ + +/*! +FixedBoolArray is an array of bools of fixed size, it's intended to be used with placement new on chunk of memory. +It'll use following memory for data layout. As follows: + +// some memory +char ​*buf = new char[64 *​ 1024]; + +const uint32_t size = 100; + +// placement new on this memory +FixedBoolArray* arr = new (buf) FixedBoolArray(size); + +// you can get max requiredMemorySize by an bitMap to use memory left +buf = buf + FixedBoolArray::requiredMemorySize(size); + +buf: + ++------------------------------------------------------------+ +| uint32_t | bool0 | bool1 | bool2 | ... | ++------------------------------------------------------------+ + +*/ +class FixedBoolArray +{ +public: + explicit FixedBoolArray(uint32_t size) + { + m_size = size; + } + + static size_t requiredMemorySize(uint32_t size) + { + return align16(sizeof(FixedBoolArray)) + align16(size); + } + + void clear() + { + memset(data(), 0, m_size); + } + + void fill() + { + memset(data(), 1, m_size); + } + + int test(uint32_t index) const + { + NVBLAST_ASSERT(index < m_size); + return data()[index]; + } + + void set(uint32_t index) + { + NVBLAST_ASSERT(index < m_size); + data()[index] = 1; + } + + void reset(uint32_t index) + { + NVBLAST_ASSERT(index < m_size); + data()[index] = 0; + } + +private: + uint32_t m_size; + + NV_FORCE_INLINE char* data() + { + return ((char*)this + sizeof(FixedBoolArray)); + } + + NV_FORCE_INLINE const char* data() const + { + return ((char*)this + sizeof(FixedBoolArray)); + } + +private: + FixedBoolArray(const FixedBoolArray& that); +}; + +} // namespace Blast +} // namespace Nv + +#endif // ifndef NVBLASTFIXEDBOOLARRAY_H diff --git a/sdk/common/NvBlastFixedPriorityQueue.h b/sdk/common/NvBlastFixedPriorityQueue.h old mode 100644 new mode 100755 index 393790a..f9216ee --- a/sdk/common/NvBlastFixedPriorityQueue.h +++ b/sdk/common/NvBlastFixedPriorityQueue.h @@ -1,210 +1,210 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTFIXEDPRIORITYQUEUE_H -#define NVBLASTFIXEDPRIORITYQUEUE_H - -#include "NvBlastAssert.h" -#include "NvBlastMemory.h" - -namespace Nv -{ - -namespace Blast -{ - -/*! -FixedPriorityQueue is a priority queue container which is intended to be used with placement new on chunk of memory. -It'll use following memory for data layout. As follows: - -// some memory -char ​*buf = new char[64 *​ 1024]; - -// placement new on this memory -FixedPriorityQueue* arr = new (buf) FixedPriorityQueue(); - -// you can get max requiredMemorySize by an array of 'capacity' elements count to use memory left -buf = buf + FixedPriorityQueue::requiredMemorySize(capacity); - -buf: - -+------------------------------------------------------------+ -| uint32_t | T[0] | T[1] | T[2] | ... | -+------------------------------------------------------------+ - -*/ - -template -struct Less -{ - bool operator()(const A& a, const A& b) const - { - return a < b; - } -}; - - -template > -class FixedPriorityQueue : protected Comparator // inherit so that stateless comparators take no space -{ -public: - FixedPriorityQueue(const Comparator& less = Comparator()) : Comparator(less), mHeapSize(0) - { - } - - ~FixedPriorityQueue() - { - } - - static size_t requiredMemorySize(uint32_t capacity) - { - return align16(sizeof(FixedPriorityQueue)) + align16(capacity * sizeof(Element)); - } - - //! Get the element with the highest priority - const Element top() const - { - return data()[0]; - } - - //! Get the element with the highest priority - Element top() - { - return data()[0]; - } - - //! Check to whether the priority queue is empty - bool empty() const - { - return (mHeapSize == 0); - } - - //! Empty the priority queue - void clear() - { - mHeapSize = 0; - } - - //! Insert a new element into the priority queue. Only valid when size() is less than Capacity - void push(const Element& value) - { - uint32_t newIndex; - uint32_t parentIndex = parent(mHeapSize); - - for (newIndex = mHeapSize; newIndex > 0 && compare(value, data()[parentIndex]); newIndex = parentIndex, parentIndex= parent(newIndex)) - { - data()[ newIndex ] = data()[parentIndex]; - } - data()[newIndex] = value; - mHeapSize++; - NVBLAST_ASSERT(valid()); - } - - //! Delete the highest priority element. Only valid when non-empty. - Element pop() - { - NVBLAST_ASSERT(mHeapSize > 0); - uint32_t i, child; - //try to avoid LHS - uint32_t tempHs = mHeapSize-1; - mHeapSize = tempHs; - Element min = data()[0]; - Element last = data()[tempHs]; - - for (i = 0; (child = left(i)) < tempHs; i = child) - { - /* Find highest priority child */ - const uint32_t rightChild = child + 1; - - child += ((rightChild < tempHs) & compare((data()[rightChild]), (data()[child]))) ? 1 : 0; - - if(compare(last, data()[child])) - break; - - data()[i] = data()[child]; - } - data()[ i ] = last; - - NVBLAST_ASSERT(valid()); - return min; - } - - //! Make sure the priority queue sort all elements correctly - bool valid() const - { - const Element& min = data()[0]; - for(uint32_t i=1; i)); - } - - NV_FORCE_INLINE Element* data() const - { - return (Element*)((char*)this + sizeof(FixedPriorityQueue)); - } - - bool compare(const Element& a, const Element& b) const - { - return Comparator::operator()(a,b); - } - - static uint32_t left(uint32_t nodeIndex) - { - return (nodeIndex << 1) + 1; - } - - static uint32_t parent(uint32_t nodeIndex) - { - return (nodeIndex - 1) >> 1; - } - - FixedPriorityQueue& operator = (const FixedPriorityQueue); -}; - -} // namespace Blast -} // namespace Nv - -#endif // ifndef NVBLASTFIXEDPRIORITYQUEUE_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTFIXEDPRIORITYQUEUE_H +#define NVBLASTFIXEDPRIORITYQUEUE_H + +#include "NvBlastAssert.h" +#include "NvBlastMemory.h" + +namespace Nv +{ + +namespace Blast +{ + +/*! +FixedPriorityQueue is a priority queue container which is intended to be used with placement new on chunk of memory. +It'll use following memory for data layout. As follows: + +// some memory +char ​*buf = new char[64 *​ 1024]; + +// placement new on this memory +FixedPriorityQueue* arr = new (buf) FixedPriorityQueue(); + +// you can get max requiredMemorySize by an array of 'capacity' elements count to use memory left +buf = buf + FixedPriorityQueue::requiredMemorySize(capacity); + +buf: + ++------------------------------------------------------------+ +| uint32_t | T[0] | T[1] | T[2] | ... | ++------------------------------------------------------------+ + +*/ + +template +struct Less +{ + bool operator()(const A& a, const A& b) const + { + return a < b; + } +}; + + +template > +class FixedPriorityQueue : protected Comparator // inherit so that stateless comparators take no space +{ +public: + FixedPriorityQueue(const Comparator& less = Comparator()) : Comparator(less), mHeapSize(0) + { + } + + ~FixedPriorityQueue() + { + } + + static size_t requiredMemorySize(uint32_t capacity) + { + return align16(sizeof(FixedPriorityQueue)) + align16(capacity * sizeof(Element)); + } + + //! Get the element with the highest priority + const Element top() const + { + return data()[0]; + } + + //! Get the element with the highest priority + Element top() + { + return data()[0]; + } + + //! Check to whether the priority queue is empty + bool empty() const + { + return (mHeapSize == 0); + } + + //! Empty the priority queue + void clear() + { + mHeapSize = 0; + } + + //! Insert a new element into the priority queue. Only valid when size() is less than Capacity + void push(const Element& value) + { + uint32_t newIndex; + uint32_t parentIndex = parent(mHeapSize); + + for (newIndex = mHeapSize; newIndex > 0 && compare(value, data()[parentIndex]); newIndex = parentIndex, parentIndex= parent(newIndex)) + { + data()[ newIndex ] = data()[parentIndex]; + } + data()[newIndex] = value; + mHeapSize++; + NVBLAST_ASSERT(valid()); + } + + //! Delete the highest priority element. Only valid when non-empty. + Element pop() + { + NVBLAST_ASSERT(mHeapSize > 0); + uint32_t i, child; + //try to avoid LHS + uint32_t tempHs = mHeapSize-1; + mHeapSize = tempHs; + Element min = data()[0]; + Element last = data()[tempHs]; + + for (i = 0; (child = left(i)) < tempHs; i = child) + { + /* Find highest priority child */ + const uint32_t rightChild = child + 1; + + child += ((rightChild < tempHs) & compare((data()[rightChild]), (data()[child]))) ? 1 : 0; + + if(compare(last, data()[child])) + break; + + data()[i] = data()[child]; + } + data()[ i ] = last; + + NVBLAST_ASSERT(valid()); + return min; + } + + //! Make sure the priority queue sort all elements correctly + bool valid() const + { + const Element& min = data()[0]; + for(uint32_t i=1; i)); + } + + NV_FORCE_INLINE Element* data() const + { + return (Element*)((char*)this + sizeof(FixedPriorityQueue)); + } + + bool compare(const Element& a, const Element& b) const + { + return Comparator::operator()(a,b); + } + + static uint32_t left(uint32_t nodeIndex) + { + return (nodeIndex << 1) + 1; + } + + static uint32_t parent(uint32_t nodeIndex) + { + return (nodeIndex - 1) >> 1; + } + + FixedPriorityQueue& operator = (const FixedPriorityQueue); +}; + +} // namespace Blast +} // namespace Nv + +#endif // ifndef NVBLASTFIXEDPRIORITYQUEUE_H diff --git a/sdk/common/NvBlastFixedQueue.h b/sdk/common/NvBlastFixedQueue.h old mode 100644 new mode 100755 index 99bbdc0..8038e28 --- a/sdk/common/NvBlastFixedQueue.h +++ b/sdk/common/NvBlastFixedQueue.h @@ -1,141 +1,141 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTFIXEDQUEUE_H -#define NVBLASTFIXEDQUEUE_H - -#include "NvBlastAssert.h" -#include "NvBlastMemory.h" - -namespace Nv -{ -namespace Blast -{ - -/*! -FixedQueue is a queue container which is intended to be used with placement new on chunk of memory. -It'll use following memory for data layout. As follows: - -// some memory -char ​*buf = new char[64 *​ 1024]; - -// placement new on this memory -FixedQueue* arr = new (buf) FixedQueue(); - -// you can get max requiredMemorySize by an array of 'capacity' elements count to use memory left -buf = buf + FixedQueue::requiredMemorySize(capacity); - -*/ -template -class FixedQueue -{ -public: - explicit FixedQueue(uint32_t maxEntries) : m_num(0), m_head(0), m_tail(0), m_maxEntries(maxEntries) - { - } - - static size_t requiredMemorySize(uint32_t capacity) - { - return align16(sizeof(FixedQueue)) + align16(capacity * sizeof(T)); - } - - T popFront() - { - NVBLAST_ASSERT(m_num>0); - - m_num--; - T& element = data()[m_tail]; - m_tail = (m_tail+1) % (m_maxEntries); - return element; - } - - T front() - { - NVBLAST_ASSERT(m_num>0); - - return data()[m_tail]; - } - - T popBack() - { - NVBLAST_ASSERT(m_num>0); - - m_num--; - m_head = (m_head-1) % (m_maxEntries); - return data()[m_head]; - } - - T back() - { - NVBLAST_ASSERT(m_num>0); - - uint32_t headAccess = (m_head-1) % (m_maxEntries); - return data()[headAccess]; - } - - bool pushBack(const T& element) - { - if (m_num == m_maxEntries) return false; - data()[m_head] = element; - - m_num++; - m_head = (m_head+1) % (m_maxEntries); - - return true; - } - - bool empty() const - { - return m_num == 0; - } - - uint32_t size() const - { - return m_num; - } - - -private: - uint32_t m_num; - uint32_t m_head; - uint32_t m_tail; - uint32_t m_maxEntries; - - T* data() - { - return (T*)((char*)this + sizeof(FixedQueue)); - } - -private: - FixedQueue(const FixedQueue& that); -}; - -} // namespace Blast -} // namespace Nv - -#endif // ifndef NVBLASTFIXEDQUEUE_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTFIXEDQUEUE_H +#define NVBLASTFIXEDQUEUE_H + +#include "NvBlastAssert.h" +#include "NvBlastMemory.h" + +namespace Nv +{ +namespace Blast +{ + +/*! +FixedQueue is a queue container which is intended to be used with placement new on chunk of memory. +It'll use following memory for data layout. As follows: + +// some memory +char ​*buf = new char[64 *​ 1024]; + +// placement new on this memory +FixedQueue* arr = new (buf) FixedQueue(); + +// you can get max requiredMemorySize by an array of 'capacity' elements count to use memory left +buf = buf + FixedQueue::requiredMemorySize(capacity); + +*/ +template +class FixedQueue +{ +public: + explicit FixedQueue(uint32_t maxEntries) : m_num(0), m_head(0), m_tail(0), m_maxEntries(maxEntries) + { + } + + static size_t requiredMemorySize(uint32_t capacity) + { + return align16(sizeof(FixedQueue)) + align16(capacity * sizeof(T)); + } + + T popFront() + { + NVBLAST_ASSERT(m_num>0); + + m_num--; + T& element = data()[m_tail]; + m_tail = (m_tail+1) % (m_maxEntries); + return element; + } + + T front() + { + NVBLAST_ASSERT(m_num>0); + + return data()[m_tail]; + } + + T popBack() + { + NVBLAST_ASSERT(m_num>0); + + m_num--; + m_head = (m_head-1) % (m_maxEntries); + return data()[m_head]; + } + + T back() + { + NVBLAST_ASSERT(m_num>0); + + uint32_t headAccess = (m_head-1) % (m_maxEntries); + return data()[headAccess]; + } + + bool pushBack(const T& element) + { + if (m_num == m_maxEntries) return false; + data()[m_head] = element; + + m_num++; + m_head = (m_head+1) % (m_maxEntries); + + return true; + } + + bool empty() const + { + return m_num == 0; + } + + uint32_t size() const + { + return m_num; + } + + +private: + uint32_t m_num; + uint32_t m_head; + uint32_t m_tail; + uint32_t m_maxEntries; + + T* data() + { + return (T*)((char*)this + sizeof(FixedQueue)); + } + +private: + FixedQueue(const FixedQueue& that); +}; + +} // namespace Blast +} // namespace Nv + +#endif // ifndef NVBLASTFIXEDQUEUE_H diff --git a/sdk/common/NvBlastGeometry.h b/sdk/common/NvBlastGeometry.h old mode 100644 new mode 100755 index 15fbf57..8fa220a --- a/sdk/common/NvBlastGeometry.h +++ b/sdk/common/NvBlastGeometry.h @@ -1,237 +1,237 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTGEOMETRY_H -#define NVBLASTGEOMETRY_H - -#include "NvBlastTypes.h" -#include "NvBlastMath.h" -#include "NvBlastAssert.h" - -#include - - -namespace Nv { -namespace Blast{ - - -/** -Find the closest node to point in the graph. Uses primarily distance to chunk centroids. -Bond normals are expected to be directed from the lower to higher node index. -Cannot be used for graph actors with only the world chunk in the graph. - -\param[in] point the point to test against -\param[in] firstGraphNodeIndex the entry point for familyGraphNodeIndexLinks -\param[in] familyGraphNodeIndexLinks the list index links of the actor's graph -\param[in] adjacencyPartition the actor's SupportGraph adjacency partition -\param[in] adjacentNodeIndices the actor's SupportGraph adjacent node indices -\param[in] adjacentBondIndices the actor's SupportGraph adjacent bond indices -\param[in] assetBonds the actor's asset bonds -\param[in] bondHealths the actor's bond healths -\param[in] assetChunks the actor's asset chunks -\param[in] supportChunkHealths the actor's graph chunks healths -\param[in] chunkIndices maps node index to chunk index in SupportGraph - -\return the index of the node closest to point -*/ -NV_FORCE_INLINE uint32_t findClosestNode(const float point[4], - const uint32_t firstGraphNodeIndex, const uint32_t* familyGraphNodeIndexLinks, - const uint32_t* adjacencyPartition, const uint32_t* adjacentNodeIndices, const uint32_t* adjacentBondIndices, - const NvBlastBond* assetBonds, const float* bondHealths, - const NvBlastChunk* assetChunks, const float* supportChunkHealths, const uint32_t* chunkIndices) -{ - // firstGraphNodeIndex could still be the world chunk, however - // there should be no way a single-node actor that is just the world chunk exists. - uint32_t nodeIndex = firstGraphNodeIndex; - // Since there should always be a regular chunk in the graph, it is possible to initialize closestNode - // as world chunk index but it would always evaluate to some meaningful node index eventually. - uint32_t closestNode = nodeIndex; - float minDist = std::numeric_limits().max(); - - // find the closest healthy chunk in the graph by its centroid to point distance - while (!Nv::Blast::isInvalidIndex(nodeIndex)) - { - if (supportChunkHealths[nodeIndex] > 0.0f) - { - uint32_t chunkIndex = chunkIndices[nodeIndex]; - if (!isInvalidIndex(chunkIndex)) // Invalid if this is the world chunk - { - const NvBlastChunk& chunk = assetChunks[chunkIndex]; - const float* centroid = chunk.centroid; - - float d[3]; VecMath::sub(point, centroid, d); - float dist = VecMath::dot(d, d); - - if (dist < minDist) - { - minDist = dist; - closestNode = nodeIndex; - } - } - } - nodeIndex = familyGraphNodeIndexLinks[nodeIndex]; - } - - // as long as the world chunk is not input as a single-node graph actor - NVBLAST_ASSERT(!isInvalidIndex(chunkIndices[closestNode])); - - bool iterateOnBonds = true; - if (iterateOnBonds) - { - // improve geometric accuracy by looking on which side of the closest bond the point lies - // expects bond normals to point from the smaller to the larger node index - - nodeIndex = closestNode; - minDist = std::numeric_limits().max(); - - const uint32_t startIndex = adjacencyPartition[nodeIndex]; - const uint32_t stopIndex = adjacencyPartition[nodeIndex + 1]; - - for (uint32_t adjacentIndex = startIndex; adjacentIndex < stopIndex; adjacentIndex++) - { - const uint32_t neighbourIndex = adjacentNodeIndices[adjacentIndex]; - const uint32_t neighbourChunk = chunkIndices[neighbourIndex]; - if (!isInvalidIndex(neighbourChunk)) // Invalid if neighbor is the world chunk - { - const uint32_t bondIndex = adjacentBondIndices[adjacentIndex]; - // do not follow broken bonds, since it means that neighbor is not actually connected in the graph - if (bondHealths[bondIndex] > 0.0f && supportChunkHealths[neighbourIndex] > 0.0f) - { - const NvBlastBond& bond = assetBonds[bondIndex]; - - const float* centroid = bond.centroid; - float d[3]; VecMath::sub(point, centroid, d); - float dist = VecMath::dot(d, d); - - if (dist < minDist) - { - minDist = dist; - float s = VecMath::dot(d, bond.normal); - if (nodeIndex < neighbourIndex) - { - closestNode = s < 0.0f ? nodeIndex : neighbourIndex; - } - else - { - closestNode = s < 0.0f ? neighbourIndex : nodeIndex; - } - } - } - } - } - } - - return closestNode; -} - - -/** -Find the closest node to point in the graph. Uses primarily distance to bond centroids. -Slower compared to chunk based lookup but may yield better accuracy in some cases. -Bond normals are expected to be directed from the lower to higher node index. -Cannot be used for graph actors with only the world chunk in the graph. - -\param[in] point the point to test against -\param[in] firstGraphNodeIndex the entry point for familyGraphNodeIndexLinks -\param[in] familyGraphNodeIndexLinks the list index links of the actor's graph -\param[in] adjacencyPartition the actor's SupportGraph adjacency partition -\param[in] adjacentNodeIndices the actor's SupportGraph adjacent node indices -\param[in] adjacentBondIndices the actor's SupportGraph adjacent bond indices -\param[in] assetBonds the actor's asset bonds -\param[in] bondHealths the actor's bond healths -\param[in] chunkIndices maps node index to chunk index in SupportGraph - -\return the index of the node closest to point -*/ -NV_FORCE_INLINE uint32_t findClosestNode(const float point[4], - const uint32_t firstGraphNodeIndex, const uint32_t* familyGraphNodeIndexLinks, - const uint32_t* adjacencyPartition, const uint32_t* adjacentNodeIndices, const uint32_t* adjacentBondIndices, - const NvBlastBond* bonds, const float* bondHealths, const uint32_t* chunkIndices) -{ - // firstGraphNodeIndex could still be the world chunk, however - // there should be no way a single-node actor that is just the world chunk exists. - uint32_t nodeIndex = firstGraphNodeIndex; - // Since there should always be a regular chunk in the graph, it is possible to initialize closestNode - // as world chunk index but it would always evaluate to some meaningful node index eventually. - uint32_t closestNode = nodeIndex; - float minDist = std::numeric_limits().max(); - - while (!Nv::Blast::isInvalidIndex(nodeIndex)) - { - const uint32_t startIndex = adjacencyPartition[nodeIndex]; - const uint32_t stopIndex = adjacencyPartition[nodeIndex + 1]; - - for (uint32_t adjacentIndex = startIndex; adjacentIndex < stopIndex; adjacentIndex++) - { - const uint32_t neighbourIndex = adjacentNodeIndices[adjacentIndex]; - if (nodeIndex < neighbourIndex) - { - const uint32_t bondIndex = adjacentBondIndices[adjacentIndex]; - if (bondHealths[bondIndex] > 0.0f) - { - const NvBlastBond& bond = bonds[bondIndex]; - - const float* centroid = bond.centroid; - float d[3]; VecMath::sub(point, centroid, d); - float dist = VecMath::dot(d, d); - - if (dist < minDist) - { - minDist = dist; - // if any of the nodes is the world chunk, use the valid one instead - if (isInvalidIndex(chunkIndices[neighbourIndex])) - { - closestNode = nodeIndex; - } - else if (isInvalidIndex(chunkIndices[nodeIndex])) - { - closestNode = neighbourIndex; - } - else - { - float s = VecMath::dot(d, bond.normal); - closestNode = s < 0 ? nodeIndex : neighbourIndex; - } - } - } - } - } - nodeIndex = familyGraphNodeIndexLinks[nodeIndex]; - } - - // as long as the world chunk is not input as a single-node graph actor - NVBLAST_ASSERT(!isInvalidIndex(chunkIndices[closestNode])); - return closestNode; -} - - -} // namespace Blast -} // namespace Nv - - -#endif // NVBLASTGEOMETRY_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTGEOMETRY_H +#define NVBLASTGEOMETRY_H + +#include "NvBlastTypes.h" +#include "NvBlastMath.h" +#include "NvBlastAssert.h" + +#include + + +namespace Nv { +namespace Blast{ + + +/** +Find the closest node to point in the graph. Uses primarily distance to chunk centroids. +Bond normals are expected to be directed from the lower to higher node index. +Cannot be used for graph actors with only the world chunk in the graph. + +\param[in] point the point to test against +\param[in] firstGraphNodeIndex the entry point for familyGraphNodeIndexLinks +\param[in] familyGraphNodeIndexLinks the list index links of the actor's graph +\param[in] adjacencyPartition the actor's SupportGraph adjacency partition +\param[in] adjacentNodeIndices the actor's SupportGraph adjacent node indices +\param[in] adjacentBondIndices the actor's SupportGraph adjacent bond indices +\param[in] assetBonds the actor's asset bonds +\param[in] bondHealths the actor's bond healths +\param[in] assetChunks the actor's asset chunks +\param[in] supportChunkHealths the actor's graph chunks healths +\param[in] chunkIndices maps node index to chunk index in SupportGraph + +\return the index of the node closest to point +*/ +NV_FORCE_INLINE uint32_t findClosestNode(const float point[4], + const uint32_t firstGraphNodeIndex, const uint32_t* familyGraphNodeIndexLinks, + const uint32_t* adjacencyPartition, const uint32_t* adjacentNodeIndices, const uint32_t* adjacentBondIndices, + const NvBlastBond* assetBonds, const float* bondHealths, + const NvBlastChunk* assetChunks, const float* supportChunkHealths, const uint32_t* chunkIndices) +{ + // firstGraphNodeIndex could still be the world chunk, however + // there should be no way a single-node actor that is just the world chunk exists. + uint32_t nodeIndex = firstGraphNodeIndex; + // Since there should always be a regular chunk in the graph, it is possible to initialize closestNode + // as world chunk index but it would always evaluate to some meaningful node index eventually. + uint32_t closestNode = nodeIndex; + float minDist = std::numeric_limits().max(); + + // find the closest healthy chunk in the graph by its centroid to point distance + while (!Nv::Blast::isInvalidIndex(nodeIndex)) + { + if (supportChunkHealths[nodeIndex] > 0.0f) + { + uint32_t chunkIndex = chunkIndices[nodeIndex]; + if (!isInvalidIndex(chunkIndex)) // Invalid if this is the world chunk + { + const NvBlastChunk& chunk = assetChunks[chunkIndex]; + const float* centroid = chunk.centroid; + + float d[3]; VecMath::sub(point, centroid, d); + float dist = VecMath::dot(d, d); + + if (dist < minDist) + { + minDist = dist; + closestNode = nodeIndex; + } + } + } + nodeIndex = familyGraphNodeIndexLinks[nodeIndex]; + } + + // as long as the world chunk is not input as a single-node graph actor + NVBLAST_ASSERT(!isInvalidIndex(chunkIndices[closestNode])); + + bool iterateOnBonds = true; + if (iterateOnBonds) + { + // improve geometric accuracy by looking on which side of the closest bond the point lies + // expects bond normals to point from the smaller to the larger node index + + nodeIndex = closestNode; + minDist = std::numeric_limits().max(); + + const uint32_t startIndex = adjacencyPartition[nodeIndex]; + const uint32_t stopIndex = adjacencyPartition[nodeIndex + 1]; + + for (uint32_t adjacentIndex = startIndex; adjacentIndex < stopIndex; adjacentIndex++) + { + const uint32_t neighbourIndex = adjacentNodeIndices[adjacentIndex]; + const uint32_t neighbourChunk = chunkIndices[neighbourIndex]; + if (!isInvalidIndex(neighbourChunk)) // Invalid if neighbor is the world chunk + { + const uint32_t bondIndex = adjacentBondIndices[adjacentIndex]; + // do not follow broken bonds, since it means that neighbor is not actually connected in the graph + if (bondHealths[bondIndex] > 0.0f && supportChunkHealths[neighbourIndex] > 0.0f) + { + const NvBlastBond& bond = assetBonds[bondIndex]; + + const float* centroid = bond.centroid; + float d[3]; VecMath::sub(point, centroid, d); + float dist = VecMath::dot(d, d); + + if (dist < minDist) + { + minDist = dist; + float s = VecMath::dot(d, bond.normal); + if (nodeIndex < neighbourIndex) + { + closestNode = s < 0.0f ? nodeIndex : neighbourIndex; + } + else + { + closestNode = s < 0.0f ? neighbourIndex : nodeIndex; + } + } + } + } + } + } + + return closestNode; +} + + +/** +Find the closest node to point in the graph. Uses primarily distance to bond centroids. +Slower compared to chunk based lookup but may yield better accuracy in some cases. +Bond normals are expected to be directed from the lower to higher node index. +Cannot be used for graph actors with only the world chunk in the graph. + +\param[in] point the point to test against +\param[in] firstGraphNodeIndex the entry point for familyGraphNodeIndexLinks +\param[in] familyGraphNodeIndexLinks the list index links of the actor's graph +\param[in] adjacencyPartition the actor's SupportGraph adjacency partition +\param[in] adjacentNodeIndices the actor's SupportGraph adjacent node indices +\param[in] adjacentBondIndices the actor's SupportGraph adjacent bond indices +\param[in] assetBonds the actor's asset bonds +\param[in] bondHealths the actor's bond healths +\param[in] chunkIndices maps node index to chunk index in SupportGraph + +\return the index of the node closest to point +*/ +NV_FORCE_INLINE uint32_t findClosestNode(const float point[4], + const uint32_t firstGraphNodeIndex, const uint32_t* familyGraphNodeIndexLinks, + const uint32_t* adjacencyPartition, const uint32_t* adjacentNodeIndices, const uint32_t* adjacentBondIndices, + const NvBlastBond* bonds, const float* bondHealths, const uint32_t* chunkIndices) +{ + // firstGraphNodeIndex could still be the world chunk, however + // there should be no way a single-node actor that is just the world chunk exists. + uint32_t nodeIndex = firstGraphNodeIndex; + // Since there should always be a regular chunk in the graph, it is possible to initialize closestNode + // as world chunk index but it would always evaluate to some meaningful node index eventually. + uint32_t closestNode = nodeIndex; + float minDist = std::numeric_limits().max(); + + while (!Nv::Blast::isInvalidIndex(nodeIndex)) + { + const uint32_t startIndex = adjacencyPartition[nodeIndex]; + const uint32_t stopIndex = adjacencyPartition[nodeIndex + 1]; + + for (uint32_t adjacentIndex = startIndex; adjacentIndex < stopIndex; adjacentIndex++) + { + const uint32_t neighbourIndex = adjacentNodeIndices[adjacentIndex]; + if (nodeIndex < neighbourIndex) + { + const uint32_t bondIndex = adjacentBondIndices[adjacentIndex]; + if (bondHealths[bondIndex] > 0.0f) + { + const NvBlastBond& bond = bonds[bondIndex]; + + const float* centroid = bond.centroid; + float d[3]; VecMath::sub(point, centroid, d); + float dist = VecMath::dot(d, d); + + if (dist < minDist) + { + minDist = dist; + // if any of the nodes is the world chunk, use the valid one instead + if (isInvalidIndex(chunkIndices[neighbourIndex])) + { + closestNode = nodeIndex; + } + else if (isInvalidIndex(chunkIndices[nodeIndex])) + { + closestNode = neighbourIndex; + } + else + { + float s = VecMath::dot(d, bond.normal); + closestNode = s < 0 ? nodeIndex : neighbourIndex; + } + } + } + } + } + nodeIndex = familyGraphNodeIndexLinks[nodeIndex]; + } + + // as long as the world chunk is not input as a single-node graph actor + NVBLAST_ASSERT(!isInvalidIndex(chunkIndices[closestNode])); + return closestNode; +} + + +} // namespace Blast +} // namespace Nv + + +#endif // NVBLASTGEOMETRY_H diff --git a/sdk/common/NvBlastHashMap.h b/sdk/common/NvBlastHashMap.h old mode 100644 new mode 100755 index 49d4b5c..94e28be --- a/sdk/common/NvBlastHashMap.h +++ b/sdk/common/NvBlastHashMap.h @@ -1,55 +1,55 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTHASHMAP_H -#define NVBLASTHASHMAP_H - - -#include "NvBlastAllocator.h" -#include "PsHashMap.h" - - -namespace Nv -{ -namespace Blast -{ - -/** -Wrapped PxShared HashMap that uses NvBlastGlobals AllocatorCalllback. -*/ -template > -struct HashMap -{ - typedef physx::shdfnd::HashMap type; -}; - -} // namespace Blast -} // namespace Nv - - -#endif // #ifndef NVBLASTHASHMAP_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTHASHMAP_H +#define NVBLASTHASHMAP_H + + +#include "NvBlastAllocator.h" +#include "PsHashMap.h" + + +namespace Nv +{ +namespace Blast +{ + +/** +Wrapped PxShared HashMap that uses NvBlastGlobals AllocatorCalllback. +*/ +template > +struct HashMap +{ + typedef physx::shdfnd::HashMap type; +}; + +} // namespace Blast +} // namespace Nv + + +#endif // #ifndef NVBLASTHASHMAP_H diff --git a/sdk/common/NvBlastHashSet.h b/sdk/common/NvBlastHashSet.h old mode 100644 new mode 100755 index 58fa5e1..6bd8eed --- a/sdk/common/NvBlastHashSet.h +++ b/sdk/common/NvBlastHashSet.h @@ -1,54 +1,54 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTHASHSET_H -#define NVBLASTHASHSET_H - - -#include "NvBlastAllocator.h" -#include "PsHashSet.h" - -namespace Nv -{ -namespace Blast -{ - -/** -Wrapped PxShared HashSet that uses NvBlastGlobals AllocatorCalllback. -*/ -template > -struct HashSet -{ - typedef physx::shdfnd::HashSet type; -}; - -} // namespace Blast -} // namespace Nv - - -#endif // #ifndef NVBLASTHASHSET_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTHASHSET_H +#define NVBLASTHASHSET_H + + +#include "NvBlastAllocator.h" +#include "PsHashSet.h" + +namespace Nv +{ +namespace Blast +{ + +/** +Wrapped PxShared HashSet that uses NvBlastGlobals AllocatorCalllback. +*/ +template > +struct HashSet +{ + typedef physx::shdfnd::HashSet type; +}; + +} // namespace Blast +} // namespace Nv + + +#endif // #ifndef NVBLASTHASHSET_H diff --git a/sdk/common/NvBlastIncludeWindows.h b/sdk/common/NvBlastIncludeWindows.h old mode 100644 new mode 100755 index 04d6dd4..0fabfd4 --- a/sdk/common/NvBlastIncludeWindows.h +++ b/sdk/common/NvBlastIncludeWindows.h @@ -1,103 +1,103 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTINCLUDEWINDOWS_H -#define NVBLASTINCLUDEWINDOWS_H - -#ifndef _WINDOWS_ // windows already included if this is defined - -#include "NvBlastPreprocessor.h" - -#ifndef _WIN32 -#error "This file should only be included by Windows builds!!" -#endif - -// We only support >= Windows XP, and we need this for critical section and -#if !NV_WINRT -#define _WIN32_WINNT 0x0501 -#else -#define _WIN32_WINNT 0x0602 -#endif - -// turn off as much as we can for windows. All we really need is the thread functions(critical sections/Interlocked* -// etc) -#define NOGDICAPMASKS -#define NOVIRTUALKEYCODES -#define NOWINMESSAGES -#define NOWINSTYLES -#define NOSYSMETRICS -#define NOMENUS -#define NOICONS -#define NOKEYSTATES -#define NOSYSCOMMANDS -#define NORASTEROPS -#define NOSHOWWINDOW -#define NOATOM -#define NOCLIPBOARD -#define NOCOLOR -#define NOCTLMGR -#define NODRAWTEXT -#define NOGDI -#define NOMB -#define NOMEMMGR -#define NOMETAFILE -#define NOMINMAX -#define NOOPENFILE -#define NOSCROLL -#define NOSERVICE -#define NOSOUND -#define NOTEXTMETRIC -#define NOWH -#define NOWINOFFSETS -#define NOCOMM -#define NOKANJI -#define NOHELP -#define NOPROFILER -#define NODEFERWINDOWPOS -#define NOMCX -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#if !NV_WINRT -#define NOUSER -#define NONLS -#define NOMSG -#endif - -#pragma warning(push) -#pragma warning(disable : 4668) //'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives' -#include -#pragma warning(pop) - -#if NV_SSE2 -#include -#endif - -#endif // #ifndef _WINDOWS_ - -#endif // #ifndef NVBLASTINCLUDEWINDOWS_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTINCLUDEWINDOWS_H +#define NVBLASTINCLUDEWINDOWS_H + +#ifndef _WINDOWS_ // windows already included if this is defined + +#include "NvBlastPreprocessor.h" + +#ifndef _WIN32 +#error "This file should only be included by Windows builds!!" +#endif + +// We only support >= Windows XP, and we need this for critical section and +#if !NV_WINRT +#define _WIN32_WINNT 0x0501 +#else +#define _WIN32_WINNT 0x0602 +#endif + +// turn off as much as we can for windows. All we really need is the thread functions(critical sections/Interlocked* +// etc) +#define NOGDICAPMASKS +#define NOVIRTUALKEYCODES +#define NOWINMESSAGES +#define NOWINSTYLES +#define NOSYSMETRICS +#define NOMENUS +#define NOICONS +#define NOKEYSTATES +#define NOSYSCOMMANDS +#define NORASTEROPS +#define NOSHOWWINDOW +#define NOATOM +#define NOCLIPBOARD +#define NOCOLOR +#define NOCTLMGR +#define NODRAWTEXT +#define NOGDI +#define NOMB +#define NOMEMMGR +#define NOMETAFILE +#define NOMINMAX +#define NOOPENFILE +#define NOSCROLL +#define NOSERVICE +#define NOSOUND +#define NOTEXTMETRIC +#define NOWH +#define NOWINOFFSETS +#define NOCOMM +#define NOKANJI +#define NOHELP +#define NOPROFILER +#define NODEFERWINDOWPOS +#define NOMCX +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#if !NV_WINRT +#define NOUSER +#define NONLS +#define NOMSG +#endif + +#pragma warning(push) +#pragma warning(disable : 4668) //'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives' +#include +#pragma warning(pop) + +#if NV_SSE2 +#include +#endif + +#endif // #ifndef _WINDOWS_ + +#endif // #ifndef NVBLASTINCLUDEWINDOWS_H diff --git a/sdk/common/NvBlastIndexFns.h b/sdk/common/NvBlastIndexFns.h old mode 100644 new mode 100755 index b83c84d..98070f4 --- a/sdk/common/NvBlastIndexFns.h +++ b/sdk/common/NvBlastIndexFns.h @@ -1,145 +1,145 @@ -// 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-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTINDEXFNS_H -#define NVBLASTINDEXFNS_H - - -#include "NvBlastTypes.h" - -#include - - -namespace Nv -{ -namespace Blast -{ - -/** -Set to invalid index. -*/ -template -NV_INLINE T invalidIndex() -{ - return ~(T)0; -} - - -/** -Test for invalid index (max representable integer). -*/ -template -NV_INLINE bool isInvalidIndex(T index) -{ - return index == invalidIndex(); -} - - -/** - Create a lookup table for data sorted by a templated index type. - - Note: when using this function with unsigned integer index types invalidIndex() is treated as a value less than zero. - - On input: - - The indices must lie in the interval [indexBase, indexBase+indexRange]. - - indexSource must point to the first index in the data. - - indexCount must be set to the number of indices in the data. - - indexByteStride must be set to the distance, in bytes, between subequent indices. - - lookup must point to a T array of size indexRange+2. - - On return: - - lookup will be filled such that: - - lookup[i] = the position of first data element with index (i + indexBase) - - lookup[indexRange+1] = indexCount - - The last (indexRange+1) element is used so that one may always determine the number of data elements with the given index using: - - count = lookup[i+1] - lookup[i] - - Note, if an index (i + indexBase) is not present in the data then, lookup[i+1] = lookup[i], so the count (above) will correctly be zero. - In this case, the actual value of lookup[i] is irrelevant. -*/ -template -void createIndexStartLookup(T* lookup, T indexBase, T indexRange, T* indexSource, T indexCount, T indexByteStride) -{ - ++indexBase; // Ordering invalidIndex() as lowest value - T indexPos = 0; - for (T i = 0; i <= indexRange; ++i) - { - for (; indexPos < indexCount; ++indexPos, indexSource = (T*)((uintptr_t)indexSource + indexByteStride)) - { - if (*indexSource + 1 >= i + indexBase) // +1 to order invalidIndex() as lowest value - { - lookup[i] = indexPos; - break; - } - } - if (indexPos == indexCount) - { - lookup[i] = indexPos; - } - } - lookup[indexRange + 1] = indexCount; -} - - -/** -Creates the inverse of a map, such that inverseMap[map[i]] = i. -Unmapped indices are set to invalidIndex. - -\param[out] inverseMap inverse map space of given size -\param[in] map original map of given size, unmapped entries must contain invalidIndex -\param[in] size size of the involved maps -*/ -template -void invertMap(T* inverseMap, const T* map, const T size) -{ - memset(inverseMap, invalidIndex(), size*sizeof(T)); - - for (T i = 0; i < size; i++) - { - if (!isInvalidIndex(map[i])) - { - inverseMap[map[i]] = i; - } - } -} - -} // end namespace Blast -} // end namespace Nv - - -#endif // #ifndef NVBLASTINDEXFNS_H +// 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-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTINDEXFNS_H +#define NVBLASTINDEXFNS_H + + +#include "NvBlastTypes.h" + +#include + + +namespace Nv +{ +namespace Blast +{ + +/** +Set to invalid index. +*/ +template +NV_INLINE T invalidIndex() +{ + return ~(T)0; +} + + +/** +Test for invalid index (max representable integer). +*/ +template +NV_INLINE bool isInvalidIndex(T index) +{ + return index == invalidIndex(); +} + + +/** + Create a lookup table for data sorted by a templated index type. + + Note: when using this function with unsigned integer index types invalidIndex() is treated as a value less than zero. + + On input: + + The indices must lie in the interval [indexBase, indexBase+indexRange]. + + indexSource must point to the first index in the data. + + indexCount must be set to the number of indices in the data. + + indexByteStride must be set to the distance, in bytes, between subequent indices. + + lookup must point to a T array of size indexRange+2. + + On return: + + lookup will be filled such that: + + lookup[i] = the position of first data element with index (i + indexBase) + + lookup[indexRange+1] = indexCount + + The last (indexRange+1) element is used so that one may always determine the number of data elements with the given index using: + + count = lookup[i+1] - lookup[i] + + Note, if an index (i + indexBase) is not present in the data then, lookup[i+1] = lookup[i], so the count (above) will correctly be zero. + In this case, the actual value of lookup[i] is irrelevant. +*/ +template +void createIndexStartLookup(T* lookup, T indexBase, T indexRange, T* indexSource, T indexCount, T indexByteStride) +{ + ++indexBase; // Ordering invalidIndex() as lowest value + T indexPos = 0; + for (T i = 0; i <= indexRange; ++i) + { + for (; indexPos < indexCount; ++indexPos, indexSource = (T*)((uintptr_t)indexSource + indexByteStride)) + { + if (*indexSource + 1 >= i + indexBase) // +1 to order invalidIndex() as lowest value + { + lookup[i] = indexPos; + break; + } + } + if (indexPos == indexCount) + { + lookup[i] = indexPos; + } + } + lookup[indexRange + 1] = indexCount; +} + + +/** +Creates the inverse of a map, such that inverseMap[map[i]] = i. +Unmapped indices are set to invalidIndex. + +\param[out] inverseMap inverse map space of given size +\param[in] map original map of given size, unmapped entries must contain invalidIndex +\param[in] size size of the involved maps +*/ +template +void invertMap(T* inverseMap, const T* map, const T size) +{ + memset(inverseMap, invalidIndex(), size*sizeof(T)); + + for (T i = 0; i < size; i++) + { + if (!isInvalidIndex(map[i])) + { + inverseMap[map[i]] = i; + } + } +} + +} // end namespace Blast +} // end namespace Nv + + +#endif // #ifndef NVBLASTINDEXFNS_H diff --git a/sdk/common/NvBlastIteratorBase.h b/sdk/common/NvBlastIteratorBase.h old mode 100644 new mode 100755 index be30197..d3edbbd --- a/sdk/common/NvBlastIteratorBase.h +++ b/sdk/common/NvBlastIteratorBase.h @@ -1,153 +1,153 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTITERATORBASE_H -#define NVBLASTITERATORBASE_H - - -#include "NvBlastIndexFns.h" - -namespace Nv -{ -namespace Blast -{ - -/** -Common functionality and implementation for iterators over an index, using invalidIndex() to indicate termination. -Derived class needs to implement increment operators. -*/ -template -class IteratorBase -{ -public: - /** Constructor sets m_curr value */ - IteratorBase(T curr); - - /** Validity of current value. */ - operator bool() const; - - /** Current value. */ - operator T() const; - -protected: - T m_curr; -}; - - -//////// IteratorBase inline methods //////// - -template -NV_INLINE IteratorBase::IteratorBase(T curr) : m_curr(curr) -{ -} - - -template -NV_INLINE IteratorBase::operator bool() const -{ - return !isInvalidIndex(m_curr); -} - - -template -NV_INLINE IteratorBase::operator T() const -{ - return m_curr; -} - - -/** -Common functionality and implementation for an indexed linked list iterator -*/ -template -class LListIt : public IteratorBase -{ -public: - LListIt(IndexType curr, IndexType* links); - - /** Pre-increment. Only use if valid() == true. */ - uint32_t operator ++ (); - -protected: - IndexType* m_links; -}; - - -//////// LListIt inline methods //////// - -template -NV_INLINE LListIt::LListIt(IndexType curr, IndexType* links) : IteratorBase(curr), m_links(links) -{ -} - - -template -NV_INLINE uint32_t LListIt::operator ++ () -{ - NVBLAST_ASSERT((bool)(*this)); - return (this->m_curr = m_links[this->m_curr]); -} - - -/** -Common functionality and implementation for an IndexDList iterator -*/ -template -class DListIt : public IteratorBase -{ -public: - DListIt(IndexType curr, IndexDLink* links); - - /** Pre-increment. Only use if valid() == true. */ - uint32_t operator ++ (); - -protected: - IndexDLink* m_links; -}; - - -//////// DListIt inline methods //////// - -template -NV_INLINE DListIt::DListIt(IndexType curr, IndexDLink* links) : IteratorBase(curr), m_links(links) -{ -} - - -template -NV_INLINE uint32_t DListIt::operator ++ () -{ - NVBLAST_ASSERT((bool)(*this)); - return (this->m_curr = m_links[this->m_curr].m_adj[1]); -} - -} // end namespace Blast -} // end namespace Nv - - -#endif // #ifndef NVBLASTITERATORBASE_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTITERATORBASE_H +#define NVBLASTITERATORBASE_H + + +#include "NvBlastIndexFns.h" + +namespace Nv +{ +namespace Blast +{ + +/** +Common functionality and implementation for iterators over an index, using invalidIndex() to indicate termination. +Derived class needs to implement increment operators. +*/ +template +class IteratorBase +{ +public: + /** Constructor sets m_curr value */ + IteratorBase(T curr); + + /** Validity of current value. */ + operator bool() const; + + /** Current value. */ + operator T() const; + +protected: + T m_curr; +}; + + +//////// IteratorBase inline methods //////// + +template +NV_INLINE IteratorBase::IteratorBase(T curr) : m_curr(curr) +{ +} + + +template +NV_INLINE IteratorBase::operator bool() const +{ + return !isInvalidIndex(m_curr); +} + + +template +NV_INLINE IteratorBase::operator T() const +{ + return m_curr; +} + + +/** +Common functionality and implementation for an indexed linked list iterator +*/ +template +class LListIt : public IteratorBase +{ +public: + LListIt(IndexType curr, IndexType* links); + + /** Pre-increment. Only use if valid() == true. */ + uint32_t operator ++ (); + +protected: + IndexType* m_links; +}; + + +//////// LListIt inline methods //////// + +template +NV_INLINE LListIt::LListIt(IndexType curr, IndexType* links) : IteratorBase(curr), m_links(links) +{ +} + + +template +NV_INLINE uint32_t LListIt::operator ++ () +{ + NVBLAST_ASSERT((bool)(*this)); + return (this->m_curr = m_links[this->m_curr]); +} + + +/** +Common functionality and implementation for an IndexDList iterator +*/ +template +class DListIt : public IteratorBase +{ +public: + DListIt(IndexType curr, IndexDLink* links); + + /** Pre-increment. Only use if valid() == true. */ + uint32_t operator ++ (); + +protected: + IndexDLink* m_links; +}; + + +//////// DListIt inline methods //////// + +template +NV_INLINE DListIt::DListIt(IndexType curr, IndexDLink* links) : IteratorBase(curr), m_links(links) +{ +} + + +template +NV_INLINE uint32_t DListIt::operator ++ () +{ + NVBLAST_ASSERT((bool)(*this)); + return (this->m_curr = m_links[this->m_curr].m_adj[1]); +} + +} // end namespace Blast +} // end namespace Nv + + +#endif // #ifndef NVBLASTITERATORBASE_H diff --git a/sdk/common/NvBlastMath.h b/sdk/common/NvBlastMath.h old mode 100644 new mode 100755 index bea2828..b7334c9 --- a/sdk/common/NvBlastMath.h +++ b/sdk/common/NvBlastMath.h @@ -1,109 +1,109 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTMATH_H -#define NVBLASTMATH_H - -#include - -namespace Nv -{ -namespace Blast -{ - -namespace VecMath -{ - - -NV_INLINE void div(float a[3], float divisor) -{ - for (int i = 0; i < 3; i++) - a[i] /= divisor; -} - -NV_INLINE void mul(float a[3], float multiplier) -{ - for (int i = 0; i < 3; i++) - a[i] *= multiplier; -} - -NV_INLINE void add(const float a[3], float b[3]) -{ - for (int i = 0; i < 3; i++) - b[i] = a[i] + b[i]; -} - -NV_INLINE void add(const float a[3], const float b[3], float r[3]) -{ - for (int i = 0; i < 3; i++) - r[i] = a[i] + b[i]; -} - -NV_INLINE void sub(const float a[3], const float b[3], float r[3]) -{ - for (int i = 0; i < 3; i++) - r[i] = a[i] - b[i]; -} - -NV_INLINE float dot(const float a[3], const float b[3]) -{ - float r = 0; - for (int i = 0; i < 3; i++) - r += a[i] * b[i]; - return r; -} - -NV_INLINE float length(const float a[3]) -{ - return sqrtf(dot(a, a)); -} - -NV_INLINE float dist(const float a[3], const float b[3]) -{ - float v[3]; - sub(a, b, v); - return length(v); -} - -NV_INLINE float normal(const float a[3], float r[3]) -{ - float d = length(a); - for (int i = 0; i < 3; i++) - r[i] = a[i] / d; - - return d; -} - - -} // namespace VecMath - -} // namespace Blast -} // namespace Nv - - -#endif // #ifndef NVBLASTMATH_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTMATH_H +#define NVBLASTMATH_H + +#include + +namespace Nv +{ +namespace Blast +{ + +namespace VecMath +{ + + +NV_INLINE void div(float a[3], float divisor) +{ + for (int i = 0; i < 3; i++) + a[i] /= divisor; +} + +NV_INLINE void mul(float a[3], float multiplier) +{ + for (int i = 0; i < 3; i++) + a[i] *= multiplier; +} + +NV_INLINE void add(const float a[3], float b[3]) +{ + for (int i = 0; i < 3; i++) + b[i] = a[i] + b[i]; +} + +NV_INLINE void add(const float a[3], const float b[3], float r[3]) +{ + for (int i = 0; i < 3; i++) + r[i] = a[i] + b[i]; +} + +NV_INLINE void sub(const float a[3], const float b[3], float r[3]) +{ + for (int i = 0; i < 3; i++) + r[i] = a[i] - b[i]; +} + +NV_INLINE float dot(const float a[3], const float b[3]) +{ + float r = 0; + for (int i = 0; i < 3; i++) + r += a[i] * b[i]; + return r; +} + +NV_INLINE float length(const float a[3]) +{ + return sqrtf(dot(a, a)); +} + +NV_INLINE float dist(const float a[3], const float b[3]) +{ + float v[3]; + sub(a, b, v); + return length(v); +} + +NV_INLINE float normal(const float a[3], float r[3]) +{ + float d = length(a); + for (int i = 0; i < 3; i++) + r[i] = a[i] / d; + + return d; +} + + +} // namespace VecMath + +} // namespace Blast +} // namespace Nv + + +#endif // #ifndef NVBLASTMATH_H diff --git a/sdk/common/NvBlastMemory.h b/sdk/common/NvBlastMemory.h old mode 100644 new mode 100755 index cd394e4..6e91623 --- a/sdk/common/NvBlastMemory.h +++ b/sdk/common/NvBlastMemory.h @@ -1,141 +1,141 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTMEMORY_H -#define NVBLASTMEMORY_H - -#include - -namespace Nv -{ -namespace Blast -{ - - -/** -Utility function to align the given value to the next 16-byte boundary. - -Returns the aligned value. -*/ -template -NV_INLINE T align16(T value) -{ - return (value + 0xF)&~(T)0xF; -} - - -/** Offset void* pointer by 'offset' bytes helper-functions */ - -template -NV_INLINE T pointerOffset(void* p, ptrdiff_t offset) -{ - return reinterpret_cast(reinterpret_cast(p)+offset); -} - -template -NV_INLINE T pointerOffset(const void* p, ptrdiff_t offset) -{ - return reinterpret_cast(reinterpret_cast(p)+offset); -} - -NV_INLINE const void* pointerOffset(const void* p, ptrdiff_t offset) -{ - return pointerOffset(p, offset); -} - -NV_INLINE void* pointerOffset(void* p, ptrdiff_t offset) -{ - return pointerOffset(p, offset); -} - -} // namespace Blast -} // namespace Nv - - -/** Block data offset and accessor macro. */ -#define NvBlastBlockData(_dataType, _name, _accessor) \ -_dataType* _accessor() const \ -{ \ - return (_dataType*)((uintptr_t)this + _name); \ -} \ -uint32_t _name - - -/** Block data offset and accessor macro for an array (includes an _accessor##ArraySize() function which returns the last expression). */ -#define NvBlastBlockArrayData(_dataType, _name, _accessor, _sizeExpr) \ -_dataType* _accessor() const \ -{ \ - return (_dataType*)((uintptr_t)this + _name); \ -} \ -uint32_t _accessor##ArraySize() const \ -{ \ - return _sizeExpr; \ -} \ -uint32_t _name - - -/** Block data offset generation macros. */ - -/** Start offset generation with this. */ -#define NvBlastCreateOffsetStart(_baseOffset) \ -size_t _lastOffset = _baseOffset; \ -size_t _lastSize = 0 - -/** Create the next offset generation with this. The value will be aligned to a 16-byte boundary. */ -#define NvBlastCreateOffsetAlign16(_name, _size) \ -_name = align16(_lastOffset + _lastSize); \ -_lastOffset = _name; \ -_lastSize = _size - -/** End offset generation with this. It evaluates to the (16-byte aligned) total size of the data block. */ -#define NvBlastCreateOffsetEndAlign16() \ -align16(_lastOffset + _lastSize) - - -/** Stack allocation */ -#if NV_WINDOWS_FAMILY -#include -#define NvBlastAlloca(x) _alloca(x) -#elif NV_LINUX || NV_ANDROID -#include -#define NvBlastAlloca(x) alloca(x) -#elif NV_APPLE_FAMILY -#include -#define NvBlastAlloca(x) alloca(x) -#elif NV_PS4 -#include -#define NvBlastAlloca(x) alloca(x) -#elif NV_XBOXONE -#include -#define NvBlastAlloca(x) alloca(x) -#endif - -#define NvBlastAllocaAligned16(x) (void*)(((uintptr_t)PxAlloca(x + 0xF) + 0xF) & ~(uintptr_t)0xF) - - -#endif // #ifndef NVBLASTMEMORY_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTMEMORY_H +#define NVBLASTMEMORY_H + +#include + +namespace Nv +{ +namespace Blast +{ + + +/** +Utility function to align the given value to the next 16-byte boundary. + +Returns the aligned value. +*/ +template +NV_INLINE T align16(T value) +{ + return (value + 0xF)&~(T)0xF; +} + + +/** Offset void* pointer by 'offset' bytes helper-functions */ + +template +NV_INLINE T pointerOffset(void* p, ptrdiff_t offset) +{ + return reinterpret_cast(reinterpret_cast(p)+offset); +} + +template +NV_INLINE T pointerOffset(const void* p, ptrdiff_t offset) +{ + return reinterpret_cast(reinterpret_cast(p)+offset); +} + +NV_INLINE const void* pointerOffset(const void* p, ptrdiff_t offset) +{ + return pointerOffset(p, offset); +} + +NV_INLINE void* pointerOffset(void* p, ptrdiff_t offset) +{ + return pointerOffset(p, offset); +} + +} // namespace Blast +} // namespace Nv + + +/** Block data offset and accessor macro. */ +#define NvBlastBlockData(_dataType, _name, _accessor) \ +_dataType* _accessor() const \ +{ \ + return (_dataType*)((uintptr_t)this + _name); \ +} \ +uint32_t _name + + +/** Block data offset and accessor macro for an array (includes an _accessor##ArraySize() function which returns the last expression). */ +#define NvBlastBlockArrayData(_dataType, _name, _accessor, _sizeExpr) \ +_dataType* _accessor() const \ +{ \ + return (_dataType*)((uintptr_t)this + _name); \ +} \ +uint32_t _accessor##ArraySize() const \ +{ \ + return _sizeExpr; \ +} \ +uint32_t _name + + +/** Block data offset generation macros. */ + +/** Start offset generation with this. */ +#define NvBlastCreateOffsetStart(_baseOffset) \ +size_t _lastOffset = _baseOffset; \ +size_t _lastSize = 0 + +/** Create the next offset generation with this. The value will be aligned to a 16-byte boundary. */ +#define NvBlastCreateOffsetAlign16(_name, _size) \ +_name = align16(_lastOffset + _lastSize); \ +_lastOffset = _name; \ +_lastSize = _size + +/** End offset generation with this. It evaluates to the (16-byte aligned) total size of the data block. */ +#define NvBlastCreateOffsetEndAlign16() \ +align16(_lastOffset + _lastSize) + + +/** Stack allocation */ +#if NV_WINDOWS_FAMILY +#include +#define NvBlastAlloca(x) _alloca(x) +#elif NV_LINUX || NV_ANDROID +#include +#define NvBlastAlloca(x) alloca(x) +#elif NV_APPLE_FAMILY +#include +#define NvBlastAlloca(x) alloca(x) +#elif NV_PS4 +#include +#define NvBlastAlloca(x) alloca(x) +#elif NV_XBOXONE +#include +#define NvBlastAlloca(x) alloca(x) +#endif + +#define NvBlastAllocaAligned16(x) (void*)(((uintptr_t)PxAlloca(x + 0xF) + 0xF) & ~(uintptr_t)0xF) + + +#endif // #ifndef NVBLASTMEMORY_H diff --git a/sdk/common/NvBlastPreprocessorInternal.h b/sdk/common/NvBlastPreprocessorInternal.h old mode 100644 new mode 100755 index b7dfe1e..793e542 --- a/sdk/common/NvBlastPreprocessorInternal.h +++ b/sdk/common/NvBlastPreprocessorInternal.h @@ -1,63 +1,63 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTPREPROCESSORINTERNAL_H -#define NVBLASTPREPROCESSORINTERNAL_H - - -#include "NvPreprocessor.h" - - -/** -Macros for more convenient logging -*/ -#define NVBLASTLL_LOG_ERROR(_logFn, _msg) if (_logFn != nullptr) { _logFn(NvBlastMessage::Error, _msg, __FILE__, __LINE__); } ((void)0) -#define NVBLASTLL_LOG_WARNING(_logFn, _msg) if (_logFn != nullptr) { _logFn(NvBlastMessage::Warning, _msg, __FILE__, __LINE__); } ((void)0) -#define NVBLASTLL_LOG_INFO(_logFn, _msg) if (_logFn != nullptr) { _logFn(NvBlastMessage::Info, _msg, __FILE__, __LINE__); } ((void)0) -#define NVBLASTLL_LOG_DEBUG(_logFn, _msg) if (_logFn != nullptr) { _logFn(NvBlastMessage::Debug, _msg, __FILE__, __LINE__); } ((void)0) - - -/** Blast will check function parameters for debug and checked builds. */ -#define NVBLASTLL_CHECK_PARAMS (NV_DEBUG || NV_CHECKED) - - -#if NVBLASTLL_CHECK_PARAMS -#define NVBLASTLL_CHECK(_expr, _logFn, _msg, _onFail) \ - { \ - if(!(_expr)) \ - { \ - if (_logFn) { _logFn(NvBlastMessage::Error, _msg, __FILE__, __LINE__); } \ - { _onFail; }; \ - } \ - } -#else -#define NVBLASTLL_CHECK(_expr, _logFn, _msg, _onFail) NV_UNUSED(_logFn) -#endif - - -#endif // ifndef NVBLASTPREPROCESSORINTERNAL_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTPREPROCESSORINTERNAL_H +#define NVBLASTPREPROCESSORINTERNAL_H + + +#include "NvPreprocessor.h" + + +/** +Macros for more convenient logging +*/ +#define NVBLASTLL_LOG_ERROR(_logFn, _msg) if (_logFn != nullptr) { _logFn(NvBlastMessage::Error, _msg, __FILE__, __LINE__); } ((void)0) +#define NVBLASTLL_LOG_WARNING(_logFn, _msg) if (_logFn != nullptr) { _logFn(NvBlastMessage::Warning, _msg, __FILE__, __LINE__); } ((void)0) +#define NVBLASTLL_LOG_INFO(_logFn, _msg) if (_logFn != nullptr) { _logFn(NvBlastMessage::Info, _msg, __FILE__, __LINE__); } ((void)0) +#define NVBLASTLL_LOG_DEBUG(_logFn, _msg) if (_logFn != nullptr) { _logFn(NvBlastMessage::Debug, _msg, __FILE__, __LINE__); } ((void)0) + + +/** Blast will check function parameters for debug and checked builds. */ +#define NVBLASTLL_CHECK_PARAMS (NV_DEBUG || NV_CHECKED) + + +#if NVBLASTLL_CHECK_PARAMS +#define NVBLASTLL_CHECK(_expr, _logFn, _msg, _onFail) \ + { \ + if(!(_expr)) \ + { \ + if (_logFn) { _logFn(NvBlastMessage::Error, _msg, __FILE__, __LINE__); } \ + { _onFail; }; \ + } \ + } +#else +#define NVBLASTLL_CHECK(_expr, _logFn, _msg, _onFail) NV_UNUSED(_logFn) +#endif + + +#endif // ifndef NVBLASTPREPROCESSORINTERNAL_H diff --git a/sdk/common/NvBlastTime.cpp b/sdk/common/NvBlastTime.cpp old mode 100644 new mode 100755 index b11aeba..3b3e01a --- a/sdk/common/NvBlastTime.cpp +++ b/sdk/common/NvBlastTime.cpp @@ -1,41 +1,41 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastTime.h" -#include "NvBlast.h" -#include - -namespace Nv -{ -namespace Blast -{ - -const double Time::s_secondsPerTick = Time::getTickDuration(); - -} // namespace Blast -} // namespace Nv +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastTime.h" +#include "NvBlast.h" +#include + +namespace Nv +{ +namespace Blast +{ + +const double Time::s_secondsPerTick = Time::getTickDuration(); + +} // namespace Blast +} // namespace Nv diff --git a/sdk/common/NvBlastTime.h b/sdk/common/NvBlastTime.h old mode 100644 new mode 100755 index 7c7a6ab..e3facf1 --- a/sdk/common/NvBlastTime.h +++ b/sdk/common/NvBlastTime.h @@ -1,121 +1,121 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#ifndef NVBLASTTIME_H -#define NVBLASTTIME_H - -#include "NvBlastTypes.h" - - -namespace Nv -{ -namespace Blast -{ - -class Time -{ -public: - Time() : m_lastTickCount(getTimeTicks()) {} - - int64_t getElapsedTicks() - { - const int64_t lastTickCount = m_lastTickCount; - m_lastTickCount = getTimeTicks(); - return m_lastTickCount - lastTickCount; - } - - int64_t peekElapsedTicks() const - { - return getTimeTicks() - m_lastTickCount; - } - - int64_t getLastTickCount() const - { - return m_lastTickCount; - } - - static double seconds(int64_t ticks) - { - return s_secondsPerTick * ticks; - } - -private: - int64_t getTimeTicks() const; - static double getTickDuration(); - - int64_t m_lastTickCount; - static const double s_secondsPerTick; -}; - -} // namespace Blast -} // namespace Nv - - -//////// Time inline functions for various platforms //////// - -#if NV_MICROSOFT_FAMILY - -#include "NvBlastIncludeWindows.h" - -NV_INLINE int64_t Nv::Blast::Time::getTimeTicks() const -{ - LARGE_INTEGER a; - QueryPerformanceCounter(&a); - return a.QuadPart; -} - -NV_INLINE double Nv::Blast::Time::getTickDuration() -{ - LARGE_INTEGER a; - QueryPerformanceFrequency(&a); - return 1.0 / (double)a.QuadPart; -} - -#elif NV_UNIX_FAMILY - -#include - -NV_INLINE int64_t Nv::Blast::Time::getTimeTicks() const -{ - struct timespec mCurrTimeInt; - clock_gettime(CLOCK_REALTIME, &mCurrTimeInt); - return (static_cast(mCurrTimeInt.tv_sec) * 1000000000) + (static_cast(mCurrTimeInt.tv_nsec)); -} - -NV_INLINE double Nv::Blast::Time::getTickDuration() -{ - return 1.e-9; -} - -#elif NV_PS4 - -#include "ps4/NvBlastTimePS4.h" - -#endif - -#endif // #ifndef NVBLASTTIME_H +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#ifndef NVBLASTTIME_H +#define NVBLASTTIME_H + +#include "NvBlastTypes.h" + + +namespace Nv +{ +namespace Blast +{ + +class Time +{ +public: + Time() : m_lastTickCount(getTimeTicks()) {} + + int64_t getElapsedTicks() + { + const int64_t lastTickCount = m_lastTickCount; + m_lastTickCount = getTimeTicks(); + return m_lastTickCount - lastTickCount; + } + + int64_t peekElapsedTicks() const + { + return getTimeTicks() - m_lastTickCount; + } + + int64_t getLastTickCount() const + { + return m_lastTickCount; + } + + static double seconds(int64_t ticks) + { + return s_secondsPerTick * ticks; + } + +private: + int64_t getTimeTicks() const; + static double getTickDuration(); + + int64_t m_lastTickCount; + static const double s_secondsPerTick; +}; + +} // namespace Blast +} // namespace Nv + + +//////// Time inline functions for various platforms //////// + +#if NV_MICROSOFT_FAMILY + +#include "NvBlastIncludeWindows.h" + +NV_INLINE int64_t Nv::Blast::Time::getTimeTicks() const +{ + LARGE_INTEGER a; + QueryPerformanceCounter(&a); + return a.QuadPart; +} + +NV_INLINE double Nv::Blast::Time::getTickDuration() +{ + LARGE_INTEGER a; + QueryPerformanceFrequency(&a); + return 1.0 / (double)a.QuadPart; +} + +#elif NV_UNIX_FAMILY + +#include + +NV_INLINE int64_t Nv::Blast::Time::getTimeTicks() const +{ + struct timespec mCurrTimeInt; + clock_gettime(CLOCK_REALTIME, &mCurrTimeInt); + return (static_cast(mCurrTimeInt.tv_sec) * 1000000000) + (static_cast(mCurrTimeInt.tv_nsec)); +} + +NV_INLINE double Nv::Blast::Time::getTickDuration() +{ + return 1.e-9; +} + +#elif NV_PS4 + +#include "ps4/NvBlastTimePS4.h" + +#endif + +#endif // #ifndef NVBLASTTIME_H diff --git a/sdk/common/NvBlastTimers.cpp b/sdk/common/NvBlastTimers.cpp old mode 100644 new mode 100755 index f12fe78..41359d4 --- a/sdk/common/NvBlastTimers.cpp +++ b/sdk/common/NvBlastTimers.cpp @@ -1,47 +1,47 @@ -// 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) 2016-2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlast.h" -#include "NvBlastTime.h" -#include - - -extern "C" -{ - -void NvBlastTimersReset(NvBlastTimers* timers) -{ - memset(timers, 0, sizeof(NvBlastTimers)); -} - -double NvBlastTicksToSeconds(int64_t ticks) -{ - return Nv::Blast::Time::seconds(ticks); -} - -} // extern "C" +// 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) 2016-2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlast.h" +#include "NvBlastTime.h" +#include + + +extern "C" +{ + +void NvBlastTimersReset(NvBlastTimers* timers) +{ + memset(timers, 0, sizeof(NvBlastTimers)); +} + +double NvBlastTicksToSeconds(int64_t ticks) +{ + return Nv::Blast::Time::seconds(ticks); +} + +} // extern "C" -- cgit v1.2.3