diff options
Diffstat (limited to 'sdk/globals')
| -rwxr-xr-x[-rw-r--r--] | sdk/globals/include/NvBlastAllocator.h | 138 | ||||
| -rwxr-xr-x[-rw-r--r--] | sdk/globals/include/NvBlastDebugRender.h | 128 | ||||
| -rwxr-xr-x[-rw-r--r--] | sdk/globals/include/NvBlastGlobals.h | 554 | ||||
| -rwxr-xr-x[-rw-r--r--] | sdk/globals/include/NvBlastProfiler.h | 196 | ||||
| -rwxr-xr-x[-rw-r--r--] | sdk/globals/source/NvBlastGlobals.cpp | 380 | ||||
| -rwxr-xr-x[-rw-r--r--] | sdk/globals/source/NvBlastProfiler.cpp | 192 | ||||
| -rwxr-xr-x[-rw-r--r--] | sdk/globals/source/NvBlastProfilerInternal.h | 182 |
7 files changed, 885 insertions, 885 deletions
diff --git a/sdk/globals/include/NvBlastAllocator.h b/sdk/globals/include/NvBlastAllocator.h index 5dfed5c..e8dc38e 100644..100755 --- a/sdk/globals/include/NvBlastAllocator.h +++ b/sdk/globals/include/NvBlastAllocator.h @@ -1,69 +1,69 @@ -// 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 NVBLASTALLOCATOR_H -#define NVBLASTALLOCATOR_H - -#include "NvBlastGlobals.h" - -/** -This file contains AllocatorCallback wrappers compatible with PxShared containers. -*/ - -namespace Nv -{ -namespace Blast -{ - -/** -Allocator uses global AllocatorCallback. -*/ -class Allocator -{ -public: - Allocator(const char* = 0) - { - } - - void* allocate(size_t size, const char* filename, int line) - { - return NvBlastGlobalGetAllocatorCallback()->allocate(size, nullptr, filename, line); - } - - void deallocate(void* ptr) - { - NvBlastGlobalGetAllocatorCallback()->deallocate(ptr); - } -}; - - -} // namespace Blast -} // namespace Nv - - -#endif // #ifndef NVBLASTALLOCATOR_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 NVBLASTALLOCATOR_H
+#define NVBLASTALLOCATOR_H
+
+#include "NvBlastGlobals.h"
+
+/**
+This file contains AllocatorCallback wrappers compatible with PxShared containers.
+*/
+
+namespace Nv
+{
+namespace Blast
+{
+
+/**
+Allocator uses global AllocatorCallback.
+*/
+class Allocator
+{
+public:
+ Allocator(const char* = 0)
+ {
+ }
+
+ void* allocate(size_t size, const char* filename, int line)
+ {
+ return NvBlastGlobalGetAllocatorCallback()->allocate(size, nullptr, filename, line);
+ }
+
+ void deallocate(void* ptr)
+ {
+ NvBlastGlobalGetAllocatorCallback()->deallocate(ptr);
+ }
+};
+
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif // #ifndef NVBLASTALLOCATOR_H
diff --git a/sdk/globals/include/NvBlastDebugRender.h b/sdk/globals/include/NvBlastDebugRender.h index 635a65f..3586d31 100644..100755 --- a/sdk/globals/include/NvBlastDebugRender.h +++ b/sdk/globals/include/NvBlastDebugRender.h @@ -1,64 +1,64 @@ -// 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. - -#pragma once - -#include <NvCTypes.h> - -namespace Nv -{ -namespace Blast -{ - - -/** -Used to store a single line and colour for debug rendering. -*/ -struct DebugLine -{ - DebugLine(const NvcVec3& p0, const NvcVec3& p1, uint32_t c) - : pos0(p0), color0(c), pos1(p1), color1(c) {} - - NvcVec3 pos0; - uint32_t color0; - NvcVec3 pos1; - uint32_t color1; -}; - - -/** -Debug Buffer -*/ -struct DebugBuffer -{ - const DebugLine* lines; - uint32_t lineCount; -}; - - -} // 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.
+
+#pragma once
+
+#include <NvCTypes.h>
+
+namespace Nv
+{
+namespace Blast
+{
+
+
+/**
+Used to store a single line and colour for debug rendering.
+*/
+struct DebugLine
+{
+ DebugLine(const NvcVec3& p0, const NvcVec3& p1, uint32_t c)
+ : pos0(p0), color0(c), pos1(p1), color1(c) {}
+
+ NvcVec3 pos0;
+ uint32_t color0;
+ NvcVec3 pos1;
+ uint32_t color1;
+};
+
+
+/**
+Debug Buffer
+*/
+struct DebugBuffer
+{
+ const DebugLine* lines;
+ uint32_t lineCount;
+};
+
+
+} // namespace Blast
+} // namespace Nv
diff --git a/sdk/globals/include/NvBlastGlobals.h b/sdk/globals/include/NvBlastGlobals.h index ce21d38..c1ffd5e 100644..100755 --- a/sdk/globals/include/NvBlastGlobals.h +++ b/sdk/globals/include/NvBlastGlobals.h @@ -1,277 +1,277 @@ -// 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 NVBLASTGLOBALS_H -#define NVBLASTGLOBALS_H - -#include <new> -#include "NvBlastTypes.h" - - -namespace Nv -{ -namespace Blast -{ - - -/** -\brief Abstract base class for an application defined memory allocator that can be used by toolkit (Tk) or any extension (Ext). -*/ -class AllocatorCallback -{ -public: - /** - \brief destructor - */ - virtual ~AllocatorCallback() - { - } - - /** - \brief Allocates size bytes of memory, which must be 16-byte aligned. - - This method should never return NULL. If you run out of memory, then - you should terminate the app or take some other appropriate action. - - \param size Number of bytes to allocate. - \param typeName Name of the datatype that is being allocated - \param filename The source file which allocated the memory - \param line The source line which allocated the memory - \return The allocated block of memory. - */ - virtual void* allocate(size_t size, const char* typeName, const char* filename, int line) = 0; - - /** - \brief Frees memory previously allocated by allocate(). - - \param ptr Memory to free. - */ - virtual void deallocate(void* ptr) = 0; -}; - - -/** -\brief Error codes - -These error codes are passed to #ErrorCallback - -\note: It's actually the copy of PxErrorCallback's PxErrorCode so it can be easily casted to it. Keep that -in mind if you are going to change this enum. - -@see ErrorCallback -*/ -struct ErrorCode -{ - enum Enum - { - eNO_ERROR = 0, - - //! \brief An informational message. - eDEBUG_INFO = 1, - - //! \brief a warning message for the user to help with debugging - eDEBUG_WARNING = 2, - - //! \brief method called with invalid parameter(s) - eINVALID_PARAMETER = 4, - - //! \brief method was called at a time when an operation is not possible - eINVALID_OPERATION = 8, - - //! \brief method failed to allocate some memory - eOUT_OF_MEMORY = 16, - - /** \brief The library failed for some reason. - Possibly you have passed invalid values like NaNs, which are not checked for. - */ - eINTERNAL_ERROR = 32, - - //! \brief An unrecoverable error, execution should be halted and log output flushed - eABORT = 64, - - //! \brief The SDK has determined that an operation may result in poor performance. - ePERF_WARNING = 128, - - //! \brief A bit mask for including all errors - eMASK_ALL = -1 - }; -}; - - -/** -\brief User defined interface class. Used by the library to emit debug information. - -\note The SDK state should not be modified from within any error reporting functions. -*/ -class ErrorCallback -{ -public: - virtual ~ErrorCallback() - { - } - - /** - \brief Reports an error code. - \param code Error code, see #ErrorCode - \param message Message to display. - \param file File error occured in. - \param line Line number error occured on. - */ - virtual void reportError(ErrorCode::Enum code, const char* message, const char* file, int line) = 0; -}; - - -} // namespace Blast -} // namespace Nv - - -//////// Global API to Access Global AllocatorCallback and ErrorCallback //////// - -/** -Retrieve a pointer to the global AllocatorCallback. Default implementation with std allocator is used if user didn't provide -it's own. It always exist, 'nullptr' will never be returned. - -\return the pointer to the global AllocatorCallback. -*/ -NVBLAST_API Nv::Blast::AllocatorCallback* NvBlastGlobalGetAllocatorCallback(); - -/** -Set global AllocatorCallback. If 'nullptr' is passed the default AllocatorCallback with std allocator is set. -*/ -NVBLAST_API void NvBlastGlobalSetAllocatorCallback(Nv::Blast::AllocatorCallback* allocatorCallback); - -/** -Retrieve a pointer to the global ErrorCallback. Default implementation which writes messages to stdout is used if user didn't provide -it's own. It always exist, 'nullptr' will never be returned. - -\return the pointer to the global ErrorCallback. -*/ -NVBLAST_API Nv::Blast::ErrorCallback* NvBlastGlobalGetErrorCallback(); - -/** -Set global ErrorCallback. If 'nullptr' is passed the default ErrorCallback that writes messages to stdout is set. -*/ -NVBLAST_API void NvBlastGlobalSetErrorCallback(Nv::Blast::ErrorCallback* errorCallback); - - -//////// Helper Global Functions //////// - -namespace Nv -{ -namespace Blast -{ - - -/** -Logging wrapper compatible with NvBlastLog. @see NvBlastLog. - -Pass this function to LowLevel function calls in order to get logging into global ErrorCallback. -*/ -NV_INLINE void logLL(int type, const char* msg, const char* file, int line) -{ - ErrorCode::Enum errorCode = ErrorCode::eNO_ERROR; - switch (type) - { - case NvBlastMessage::Error: errorCode = ErrorCode::eINVALID_OPERATION; break; - case NvBlastMessage::Warning: errorCode = ErrorCode::eDEBUG_WARNING; break; - case NvBlastMessage::Info: errorCode = ErrorCode::eDEBUG_INFO; break; - case NvBlastMessage::Debug: errorCode = ErrorCode::eNO_ERROR; break; - } - - NvBlastGlobalGetErrorCallback()->reportError(errorCode, msg, file, line); -} - - -} // namespace Blast -} // namespace Nv - - - -//////// Allocator macros //////// - -/** -Alloc/Free macros that use global AllocatorCallback. Thus allocated memory is 16-byte aligned. -*/ -#define NVBLAST_ALLOC(_size) NvBlastGlobalGetAllocatorCallback()->allocate(_size, nullptr, __FILE__, __LINE__) -#define NVBLAST_ALLOC_NAMED(_size, _name) NvBlastGlobalGetAllocatorCallback()->allocate(_size, _name, __FILE__, __LINE__) -#define NVBLAST_FREE(_mem) NvBlastGlobalGetAllocatorCallback()->deallocate(_mem) - -/** -Placement new with ExtContext allocation. -Example: Foo* foo = NVBLAST_NEW(Foo, context) (params); -*/ -#define NVBLAST_NEW(T) new (NvBlastGlobalGetAllocatorCallback()->allocate(sizeof(T), #T, __FILE__, __LINE__)) T - -/** -Respective delete to NVBLAST_NEW -Example: NVBLAST_DELETE(foo, Foo, context); -*/ -#define NVBLAST_DELETE(obj, T) \ - (obj)->~T(); \ - NvBlastGlobalGetAllocatorCallback()->deallocate(obj) - - - -//////// Log macros //////// - -/** -Logging macros that use global AllocatorCallback. -*/ -#define NVBLAST_LOG(_code, _msg) NvBlastGlobalGetErrorCallback()->reportError(_code, _msg, __FILE__, __LINE__) -#define NVBLAST_LOG_ERROR(_msg) NVBLAST_LOG(Nv::Blast::ErrorCode::eINVALID_OPERATION, _msg) -#define NVBLAST_LOG_WARNING(_msg) NVBLAST_LOG(Nv::Blast::ErrorCode::eDEBUG_WARNING, _msg) -#define NVBLAST_LOG_INFO(_msg) NVBLAST_LOG(Nv::Blast::ErrorCode::eDEBUG_INFO, _msg) -#define NVBLAST_LOG_DEBUG(_msg) NVBLAST_LOG(Nv::Blast::ErrorCode::eNO_ERROR, _msg) - -/** -Check macros that use global AllocatorCallback. The idea is that you pass an expression to check, if it fails -it logs and calls '_onFail' code you passed. -*/ -#define NVBLAST_CHECK(_code, _expr, _msg, _onFail) \ - { \ - if(!(_expr)) \ - { \ - NVBLAST_LOG(_code, _msg); \ - { _onFail; }; \ - } \ - } - -#define NVBLAST_CHECK_ERROR(_expr, _msg, _onFail) NVBLAST_CHECK(Nv::Blast::ErrorCode::eINVALID_OPERATION, _expr, _msg, _onFail) -#define NVBLAST_CHECK_WARNING(_expr, _msg, _onFail) NVBLAST_CHECK(Nv::Blast::ErrorCode::eDEBUG_WARNING, _expr, _msg, _onFail) -#define NVBLAST_CHECK_INFO(_expr, _msg, _onFail) NVBLAST_CHECK(Nv::Blast::ErrorCode::eDEBUG_INFO, _expr, _msg, _onFail) -#define NVBLAST_CHECK_DEBUG(_expr, _msg, _onFail) NVBLAST_CHECK(Nv::Blast::ErrorCode::eNO_ERROR, _expr, _msg, _onFail) - - -//////// Misc //////// - - -// Macro to load a uint32_t (or larger) with four characters -#define NVBLAST_FOURCC(_a, _b, _c, _d) ( (uint32_t)(_a) | (uint32_t)(_b)<<8 | (uint32_t)(_c)<<16 | (uint32_t)(_d)<<24 ) - - -#endif // ifndef NVBLASTGLOBALS_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 NVBLASTGLOBALS_H
+#define NVBLASTGLOBALS_H
+
+#include <new>
+#include "NvBlastTypes.h"
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+
+/**
+\brief Abstract base class for an application defined memory allocator that can be used by toolkit (Tk) or any extension (Ext).
+*/
+class AllocatorCallback
+{
+public:
+ /**
+ \brief destructor
+ */
+ virtual ~AllocatorCallback()
+ {
+ }
+
+ /**
+ \brief Allocates size bytes of memory, which must be 16-byte aligned.
+
+ This method should never return NULL. If you run out of memory, then
+ you should terminate the app or take some other appropriate action.
+
+ \param size Number of bytes to allocate.
+ \param typeName Name of the datatype that is being allocated
+ \param filename The source file which allocated the memory
+ \param line The source line which allocated the memory
+ \return The allocated block of memory.
+ */
+ virtual void* allocate(size_t size, const char* typeName, const char* filename, int line) = 0;
+
+ /**
+ \brief Frees memory previously allocated by allocate().
+
+ \param ptr Memory to free.
+ */
+ virtual void deallocate(void* ptr) = 0;
+};
+
+
+/**
+\brief Error codes
+
+These error codes are passed to #ErrorCallback
+
+\note: It's actually the copy of PxErrorCallback's PxErrorCode so it can be easily casted to it. Keep that
+in mind if you are going to change this enum.
+
+@see ErrorCallback
+*/
+struct ErrorCode
+{
+ enum Enum
+ {
+ eNO_ERROR = 0,
+
+ //! \brief An informational message.
+ eDEBUG_INFO = 1,
+
+ //! \brief a warning message for the user to help with debugging
+ eDEBUG_WARNING = 2,
+
+ //! \brief method called with invalid parameter(s)
+ eINVALID_PARAMETER = 4,
+
+ //! \brief method was called at a time when an operation is not possible
+ eINVALID_OPERATION = 8,
+
+ //! \brief method failed to allocate some memory
+ eOUT_OF_MEMORY = 16,
+
+ /** \brief The library failed for some reason.
+ Possibly you have passed invalid values like NaNs, which are not checked for.
+ */
+ eINTERNAL_ERROR = 32,
+
+ //! \brief An unrecoverable error, execution should be halted and log output flushed
+ eABORT = 64,
+
+ //! \brief The SDK has determined that an operation may result in poor performance.
+ ePERF_WARNING = 128,
+
+ //! \brief A bit mask for including all errors
+ eMASK_ALL = -1
+ };
+};
+
+
+/**
+\brief User defined interface class. Used by the library to emit debug information.
+
+\note The SDK state should not be modified from within any error reporting functions.
+*/
+class ErrorCallback
+{
+public:
+ virtual ~ErrorCallback()
+ {
+ }
+
+ /**
+ \brief Reports an error code.
+ \param code Error code, see #ErrorCode
+ \param message Message to display.
+ \param file File error occured in.
+ \param line Line number error occured on.
+ */
+ virtual void reportError(ErrorCode::Enum code, const char* message, const char* file, int line) = 0;
+};
+
+
+} // namespace Blast
+} // namespace Nv
+
+
+//////// Global API to Access Global AllocatorCallback and ErrorCallback ////////
+
+/**
+Retrieve a pointer to the global AllocatorCallback. Default implementation with std allocator is used if user didn't provide
+it's own. It always exist, 'nullptr' will never be returned.
+
+\return the pointer to the global AllocatorCallback.
+*/
+NVBLAST_API Nv::Blast::AllocatorCallback* NvBlastGlobalGetAllocatorCallback();
+
+/**
+Set global AllocatorCallback. If 'nullptr' is passed the default AllocatorCallback with std allocator is set.
+*/
+NVBLAST_API void NvBlastGlobalSetAllocatorCallback(Nv::Blast::AllocatorCallback* allocatorCallback);
+
+/**
+Retrieve a pointer to the global ErrorCallback. Default implementation which writes messages to stdout is used if user didn't provide
+it's own. It always exist, 'nullptr' will never be returned.
+
+\return the pointer to the global ErrorCallback.
+*/
+NVBLAST_API Nv::Blast::ErrorCallback* NvBlastGlobalGetErrorCallback();
+
+/**
+Set global ErrorCallback. If 'nullptr' is passed the default ErrorCallback that writes messages to stdout is set.
+*/
+NVBLAST_API void NvBlastGlobalSetErrorCallback(Nv::Blast::ErrorCallback* errorCallback);
+
+
+//////// Helper Global Functions ////////
+
+namespace Nv
+{
+namespace Blast
+{
+
+
+/**
+Logging wrapper compatible with NvBlastLog. @see NvBlastLog.
+
+Pass this function to LowLevel function calls in order to get logging into global ErrorCallback.
+*/
+NV_INLINE void logLL(int type, const char* msg, const char* file, int line)
+{
+ ErrorCode::Enum errorCode = ErrorCode::eNO_ERROR;
+ switch (type)
+ {
+ case NvBlastMessage::Error: errorCode = ErrorCode::eINVALID_OPERATION; break;
+ case NvBlastMessage::Warning: errorCode = ErrorCode::eDEBUG_WARNING; break;
+ case NvBlastMessage::Info: errorCode = ErrorCode::eDEBUG_INFO; break;
+ case NvBlastMessage::Debug: errorCode = ErrorCode::eNO_ERROR; break;
+ }
+
+ NvBlastGlobalGetErrorCallback()->reportError(errorCode, msg, file, line);
+}
+
+
+} // namespace Blast
+} // namespace Nv
+
+
+
+//////// Allocator macros ////////
+
+/**
+Alloc/Free macros that use global AllocatorCallback. Thus allocated memory is 16-byte aligned.
+*/
+#define NVBLAST_ALLOC(_size) NvBlastGlobalGetAllocatorCallback()->allocate(_size, nullptr, __FILE__, __LINE__)
+#define NVBLAST_ALLOC_NAMED(_size, _name) NvBlastGlobalGetAllocatorCallback()->allocate(_size, _name, __FILE__, __LINE__)
+#define NVBLAST_FREE(_mem) NvBlastGlobalGetAllocatorCallback()->deallocate(_mem)
+
+/**
+Placement new with ExtContext allocation.
+Example: Foo* foo = NVBLAST_NEW(Foo, context) (params);
+*/
+#define NVBLAST_NEW(T) new (NvBlastGlobalGetAllocatorCallback()->allocate(sizeof(T), #T, __FILE__, __LINE__)) T
+
+/**
+Respective delete to NVBLAST_NEW
+Example: NVBLAST_DELETE(foo, Foo, context);
+*/
+#define NVBLAST_DELETE(obj, T) \
+ (obj)->~T(); \
+ NvBlastGlobalGetAllocatorCallback()->deallocate(obj)
+
+
+
+//////// Log macros ////////
+
+/**
+Logging macros that use global AllocatorCallback.
+*/
+#define NVBLAST_LOG(_code, _msg) NvBlastGlobalGetErrorCallback()->reportError(_code, _msg, __FILE__, __LINE__)
+#define NVBLAST_LOG_ERROR(_msg) NVBLAST_LOG(Nv::Blast::ErrorCode::eINVALID_OPERATION, _msg)
+#define NVBLAST_LOG_WARNING(_msg) NVBLAST_LOG(Nv::Blast::ErrorCode::eDEBUG_WARNING, _msg)
+#define NVBLAST_LOG_INFO(_msg) NVBLAST_LOG(Nv::Blast::ErrorCode::eDEBUG_INFO, _msg)
+#define NVBLAST_LOG_DEBUG(_msg) NVBLAST_LOG(Nv::Blast::ErrorCode::eNO_ERROR, _msg)
+
+/**
+Check macros that use global AllocatorCallback. The idea is that you pass an expression to check, if it fails
+it logs and calls '_onFail' code you passed.
+*/
+#define NVBLAST_CHECK(_code, _expr, _msg, _onFail) \
+ { \
+ if(!(_expr)) \
+ { \
+ NVBLAST_LOG(_code, _msg); \
+ { _onFail; }; \
+ } \
+ }
+
+#define NVBLAST_CHECK_ERROR(_expr, _msg, _onFail) NVBLAST_CHECK(Nv::Blast::ErrorCode::eINVALID_OPERATION, _expr, _msg, _onFail)
+#define NVBLAST_CHECK_WARNING(_expr, _msg, _onFail) NVBLAST_CHECK(Nv::Blast::ErrorCode::eDEBUG_WARNING, _expr, _msg, _onFail)
+#define NVBLAST_CHECK_INFO(_expr, _msg, _onFail) NVBLAST_CHECK(Nv::Blast::ErrorCode::eDEBUG_INFO, _expr, _msg, _onFail)
+#define NVBLAST_CHECK_DEBUG(_expr, _msg, _onFail) NVBLAST_CHECK(Nv::Blast::ErrorCode::eNO_ERROR, _expr, _msg, _onFail)
+
+
+//////// Misc ////////
+
+
+// Macro to load a uint32_t (or larger) with four characters
+#define NVBLAST_FOURCC(_a, _b, _c, _d) ( (uint32_t)(_a) | (uint32_t)(_b)<<8 | (uint32_t)(_c)<<16 | (uint32_t)(_d)<<24 )
+
+
+#endif // ifndef NVBLASTGLOBALS_H
diff --git a/sdk/globals/include/NvBlastProfiler.h b/sdk/globals/include/NvBlastProfiler.h index cf7b626..42f0130 100644..100755 --- a/sdk/globals/include/NvBlastProfiler.h +++ b/sdk/globals/include/NvBlastProfiler.h @@ -1,98 +1,98 @@ -// 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 NVBLASTPROFILER_H -#define NVBLASTPROFILER_H - -#include "NvBlastPreprocessor.h" - - -namespace Nv -{ -namespace Blast -{ - - -/** -Custom Blast profiler interface. -*/ -class ProfilerCallback -{ -protected: - virtual ~ProfilerCallback() {} - -public: - /** - Called when a nested profile zone starts. - */ - virtual void zoneStart(const char* name) = 0; - - /** - Called when the current profile zone ends. - */ - virtual void zoneEnd() = 0; -}; - - -/** -Profiler detail to be reported. The higher setting is used, the more details are reported. -*/ -struct ProfilerDetail -{ - enum Level - { - LOW, - MEDIUM, - HIGH - }; -}; - - -} // namespace Blast -} // namespace Nv - - -/** -Profiler features are only active in checked, debug and profile builds. -*/ - -/** -Set a custom profiler callback. May be nullptr (the default). -*/ -NVBLAST_API void NvBlastProfilerSetCallback(Nv::Blast::ProfilerCallback* pcb); - - -/** -Sets the depth of reported profile zones. -Higher levels (more nesting) of instrumentation can have a significant impact. -Defaults to Nv::Blast::ProfilerDetail::Level::LOW. -*/ -NVBLAST_API void NvBlastProfilerSetDetail(Nv::Blast::ProfilerDetail::Level); - - -#endif +// 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 NVBLASTPROFILER_H
+#define NVBLASTPROFILER_H
+
+#include "NvBlastPreprocessor.h"
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+
+/**
+Custom Blast profiler interface.
+*/
+class ProfilerCallback
+{
+protected:
+ virtual ~ProfilerCallback() {}
+
+public:
+ /**
+ Called when a nested profile zone starts.
+ */
+ virtual void zoneStart(const char* name) = 0;
+
+ /**
+ Called when the current profile zone ends.
+ */
+ virtual void zoneEnd() = 0;
+};
+
+
+/**
+Profiler detail to be reported. The higher setting is used, the more details are reported.
+*/
+struct ProfilerDetail
+{
+ enum Level
+ {
+ LOW,
+ MEDIUM,
+ HIGH
+ };
+};
+
+
+} // namespace Blast
+} // namespace Nv
+
+
+/**
+Profiler features are only active in checked, debug and profile builds.
+*/
+
+/**
+Set a custom profiler callback. May be nullptr (the default).
+*/
+NVBLAST_API void NvBlastProfilerSetCallback(Nv::Blast::ProfilerCallback* pcb);
+
+
+/**
+Sets the depth of reported profile zones.
+Higher levels (more nesting) of instrumentation can have a significant impact.
+Defaults to Nv::Blast::ProfilerDetail::Level::LOW.
+*/
+NVBLAST_API void NvBlastProfilerSetDetail(Nv::Blast::ProfilerDetail::Level);
+
+
+#endif
diff --git a/sdk/globals/source/NvBlastGlobals.cpp b/sdk/globals/source/NvBlastGlobals.cpp index 9866fce..3891f88 100644..100755 --- a/sdk/globals/source/NvBlastGlobals.cpp +++ b/sdk/globals/source/NvBlastGlobals.cpp @@ -1,190 +1,190 @@ -// 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 "NvBlastGlobals.h" -#include "NvBlastAssert.h" -#include <cstdlib> -#include <sstream> -#include <iostream> - -#if NV_WINDOWS_FAMILY -#include <windows.h> -#endif - -#if NV_WINDOWS_FAMILY || NV_LINUX_FAMILY -#include <malloc.h> -#endif - - -namespace Nv -{ -namespace Blast -{ - -#if NV_WINDOWS_FAMILY -// on win32 we only have 8-byte alignment guaranteed, but the CRT provides special aligned allocation fns -NV_FORCE_INLINE void* platformAlignedAlloc(size_t size) -{ - return _aligned_malloc(size, 16); -} - -NV_FORCE_INLINE void platformAlignedFree(void* ptr) -{ - _aligned_free(ptr); -} -#elif NV_LINUX_FAMILY -NV_FORCE_INLINE void* platformAlignedAlloc(size_t size) -{ - return ::memalign(16, size); -} - -NV_FORCE_INLINE void platformAlignedFree(void* ptr) -{ - ::free(ptr); -} -#elif NV_XBOXONE || NV_PS4 -// on these platforms we get 16-byte alignment by default -NV_FORCE_INLINE void* platformAlignedAlloc(size_t size) -{ - return ::malloc(size); -} - -NV_FORCE_INLINE void platformAlignedFree(void* ptr) -{ - ::free(ptr); -} -#else -NV_FORCE_INLINE void* platformAlignedAlloc(size_t size) -{ - const int A = 16; - unsigned char* mem = (unsigned char*)malloc(size + A); - const unsigned char offset = (unsigned char)((uintptr_t)A - (uintptr_t)mem % A - 1); - mem += offset; - *mem++ = offset; - return mem; -} - -NV_FORCE_INLINE void platformAlignedFree(void* ptr) -{ - if (ptr != nullptr) - { - unsigned char* mem = (unsigned char*)ptr; - const unsigned char offset = *--mem; - ::free(mem - offset); - } -} -#endif - -class DefaultAllocatorCallback : public AllocatorCallback -{ -public: - virtual void* allocate(size_t size, const char* typeName, const char* filename, int line) override - { - NV_UNUSED(typeName); - NV_UNUSED(filename); - NV_UNUSED(line); - return platformAlignedAlloc(size); - } - - virtual void deallocate(void* ptr) override - { - platformAlignedFree(ptr); - } -}; -DefaultAllocatorCallback g_defaultAllocatorCallback; - - -class DefaultErrorCallback : public ErrorCallback -{ - virtual void reportError(ErrorCode::Enum code, const char* msg, const char* file, int line) override - { -#if NV_DEBUG || NV_CHECKED - std::stringstream str; - str << "NvBlast "; - bool critical = false; - switch (code) - { - case ErrorCode::eNO_ERROR: str << "[Info]"; critical = false; break; - case ErrorCode::eDEBUG_INFO: str << "[Debug Info]"; critical = false; break; - case ErrorCode::eDEBUG_WARNING: str << "[Debug Warning]"; critical = false; break; - case ErrorCode::eINVALID_PARAMETER: str << "[Invalid Parameter]"; critical = true; break; - case ErrorCode::eINVALID_OPERATION: str << "[Invalid Operation]"; critical = true; break; - case ErrorCode::eOUT_OF_MEMORY: str << "[Out of] Memory"; critical = true; break; - case ErrorCode::eINTERNAL_ERROR: str << "[Internal Error]"; critical = true; break; - case ErrorCode::eABORT: str << "[Abort]"; critical = true; break; - case ErrorCode::ePERF_WARNING: str << "[Perf Warning]"; critical = false; break; - default: NVBLAST_ASSERT(false); - } - str << file << "(" << line << "): " << msg << "\n"; - - std::string message = str.str(); - std::cout << message; -#if NV_WINDOWS_FAMILY - OutputDebugStringA(message.c_str()); -#endif - NVBLAST_ASSERT_WITH_MESSAGE(!critical, message.c_str()); -#else - NV_UNUSED(code); - NV_UNUSED(msg); - NV_UNUSED(file); - NV_UNUSED(line); -#endif - } -}; -DefaultErrorCallback g_defaultErrorCallback; - - -AllocatorCallback* g_allocatorCallback = &g_defaultAllocatorCallback; -ErrorCallback* g_errorCallback = &g_defaultErrorCallback; - - -} // namespace Blast -} // namespace Nv - - -//////// Global API implementation //////// - -Nv::Blast::AllocatorCallback* NvBlastGlobalGetAllocatorCallback() -{ - return Nv::Blast::g_allocatorCallback; -} - -void NvBlastGlobalSetAllocatorCallback(Nv::Blast::AllocatorCallback* allocator) -{ - Nv::Blast::g_allocatorCallback = allocator ? allocator : &Nv::Blast::g_defaultAllocatorCallback; -} - -Nv::Blast::ErrorCallback* NvBlastGlobalGetErrorCallback() -{ - return Nv::Blast::g_errorCallback; -} - -void NvBlastGlobalSetErrorCallback(Nv::Blast::ErrorCallback* errorCallback) -{ - Nv::Blast::g_errorCallback = errorCallback ? errorCallback : &Nv::Blast::g_defaultErrorCallback; -} +// 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 "NvBlastGlobals.h"
+#include "NvBlastAssert.h"
+#include <cstdlib>
+#include <sstream>
+#include <iostream>
+
+#if NV_WINDOWS_FAMILY
+#include <windows.h>
+#endif
+
+#if NV_WINDOWS_FAMILY || NV_LINUX_FAMILY
+#include <malloc.h>
+#endif
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+#if NV_WINDOWS_FAMILY
+// on win32 we only have 8-byte alignment guaranteed, but the CRT provides special aligned allocation fns
+NV_FORCE_INLINE void* platformAlignedAlloc(size_t size)
+{
+ return _aligned_malloc(size, 16);
+}
+
+NV_FORCE_INLINE void platformAlignedFree(void* ptr)
+{
+ _aligned_free(ptr);
+}
+#elif NV_LINUX_FAMILY
+NV_FORCE_INLINE void* platformAlignedAlloc(size_t size)
+{
+ return ::memalign(16, size);
+}
+
+NV_FORCE_INLINE void platformAlignedFree(void* ptr)
+{
+ ::free(ptr);
+}
+#elif NV_XBOXONE || NV_PS4
+// on these platforms we get 16-byte alignment by default
+NV_FORCE_INLINE void* platformAlignedAlloc(size_t size)
+{
+ return ::malloc(size);
+}
+
+NV_FORCE_INLINE void platformAlignedFree(void* ptr)
+{
+ ::free(ptr);
+}
+#else
+NV_FORCE_INLINE void* platformAlignedAlloc(size_t size)
+{
+ const int A = 16;
+ unsigned char* mem = (unsigned char*)malloc(size + A);
+ const unsigned char offset = (unsigned char)((uintptr_t)A - (uintptr_t)mem % A - 1);
+ mem += offset;
+ *mem++ = offset;
+ return mem;
+}
+
+NV_FORCE_INLINE void platformAlignedFree(void* ptr)
+{
+ if (ptr != nullptr)
+ {
+ unsigned char* mem = (unsigned char*)ptr;
+ const unsigned char offset = *--mem;
+ ::free(mem - offset);
+ }
+}
+#endif
+
+class DefaultAllocatorCallback : public AllocatorCallback
+{
+public:
+ virtual void* allocate(size_t size, const char* typeName, const char* filename, int line) override
+ {
+ NV_UNUSED(typeName);
+ NV_UNUSED(filename);
+ NV_UNUSED(line);
+ return platformAlignedAlloc(size);
+ }
+
+ virtual void deallocate(void* ptr) override
+ {
+ platformAlignedFree(ptr);
+ }
+};
+DefaultAllocatorCallback g_defaultAllocatorCallback;
+
+
+class DefaultErrorCallback : public ErrorCallback
+{
+ virtual void reportError(ErrorCode::Enum code, const char* msg, const char* file, int line) override
+ {
+#if NV_DEBUG || NV_CHECKED
+ std::stringstream str;
+ str << "NvBlast ";
+ bool critical = false;
+ switch (code)
+ {
+ case ErrorCode::eNO_ERROR: str << "[Info]"; critical = false; break;
+ case ErrorCode::eDEBUG_INFO: str << "[Debug Info]"; critical = false; break;
+ case ErrorCode::eDEBUG_WARNING: str << "[Debug Warning]"; critical = false; break;
+ case ErrorCode::eINVALID_PARAMETER: str << "[Invalid Parameter]"; critical = true; break;
+ case ErrorCode::eINVALID_OPERATION: str << "[Invalid Operation]"; critical = true; break;
+ case ErrorCode::eOUT_OF_MEMORY: str << "[Out of] Memory"; critical = true; break;
+ case ErrorCode::eINTERNAL_ERROR: str << "[Internal Error]"; critical = true; break;
+ case ErrorCode::eABORT: str << "[Abort]"; critical = true; break;
+ case ErrorCode::ePERF_WARNING: str << "[Perf Warning]"; critical = false; break;
+ default: NVBLAST_ASSERT(false);
+ }
+ str << file << "(" << line << "): " << msg << "\n";
+
+ std::string message = str.str();
+ std::cout << message;
+#if NV_WINDOWS_FAMILY
+ OutputDebugStringA(message.c_str());
+#endif
+ NVBLAST_ASSERT_WITH_MESSAGE(!critical, message.c_str());
+#else
+ NV_UNUSED(code);
+ NV_UNUSED(msg);
+ NV_UNUSED(file);
+ NV_UNUSED(line);
+#endif
+ }
+};
+DefaultErrorCallback g_defaultErrorCallback;
+
+
+AllocatorCallback* g_allocatorCallback = &g_defaultAllocatorCallback;
+ErrorCallback* g_errorCallback = &g_defaultErrorCallback;
+
+
+} // namespace Blast
+} // namespace Nv
+
+
+//////// Global API implementation ////////
+
+Nv::Blast::AllocatorCallback* NvBlastGlobalGetAllocatorCallback()
+{
+ return Nv::Blast::g_allocatorCallback;
+}
+
+void NvBlastGlobalSetAllocatorCallback(Nv::Blast::AllocatorCallback* allocator)
+{
+ Nv::Blast::g_allocatorCallback = allocator ? allocator : &Nv::Blast::g_defaultAllocatorCallback;
+}
+
+Nv::Blast::ErrorCallback* NvBlastGlobalGetErrorCallback()
+{
+ return Nv::Blast::g_errorCallback;
+}
+
+void NvBlastGlobalSetErrorCallback(Nv::Blast::ErrorCallback* errorCallback)
+{
+ Nv::Blast::g_errorCallback = errorCallback ? errorCallback : &Nv::Blast::g_defaultErrorCallback;
+}
diff --git a/sdk/globals/source/NvBlastProfiler.cpp b/sdk/globals/source/NvBlastProfiler.cpp index b4d4237..ff70cee 100644..100755 --- a/sdk/globals/source/NvBlastProfiler.cpp +++ b/sdk/globals/source/NvBlastProfiler.cpp @@ -1,96 +1,96 @@ -// 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 "stdint.h" -#include "NvBlastProfilerInternal.h" - -#if NV_PROFILE || NV_CHECKED || NV_DEBUG - -namespace Nv -{ -namespace Blast -{ - -class EmptyProfilerCallback : public ProfilerCallback -{ - void zoneStart(const char*) {} - void zoneEnd() {} -}; -EmptyProfilerCallback g_EmptyCallback; - -ProfilerCallback* g_ProfilerCallback = &g_EmptyCallback; -ProfilerDetail::Level g_ProfilerDetail = ProfilerDetail::LOW; - -} // namespace Blast -} // namespace Nv - - -void NvBlastProfilerSetCallback(Nv::Blast::ProfilerCallback* pcb) -{ - Nv::Blast::g_ProfilerCallback = pcb != nullptr ? pcb : &Nv::Blast::g_EmptyCallback; -} - -Nv::Blast::ProfilerCallback* NvBlastProfilerGetCallback() -{ - return Nv::Blast::g_ProfilerCallback; -} - - -void NvBlastProfilerSetDetail(Nv::Blast::ProfilerDetail::Level level) -{ - Nv::Blast::g_ProfilerDetail = level; -} - -Nv::Blast::ProfilerDetail::Level NvBlastProfilerGetDetail() -{ - return Nv::Blast::g_ProfilerDetail; -} - - -void NvBlastProfilerBegin(const char* name, Nv::Blast::ProfilerDetail::Level level) -{ - if (level <= NvBlastProfilerGetDetail()) - { - NvBlastProfilerGetCallback()->zoneStart(name); - } -} - -void NvBlastProfilerEnd(const void* /*name*/, Nv::Blast::ProfilerDetail::Level level) -{ - if (level <= NvBlastProfilerGetDetail()) - { - NvBlastProfilerGetCallback()->zoneEnd(); - } -} - -#else - -void NvBlastProfilerSetCallback(Nv::Blast::ProfilerCallback*) {} -void NvBlastProfilerSetDetail(Nv::Blast::ProfilerDetail::Level) {} - -#endif // NV_PROFILE +// 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 "stdint.h"
+#include "NvBlastProfilerInternal.h"
+
+#if NV_PROFILE || NV_CHECKED || NV_DEBUG
+
+namespace Nv
+{
+namespace Blast
+{
+
+class EmptyProfilerCallback : public ProfilerCallback
+{
+ void zoneStart(const char*) {}
+ void zoneEnd() {}
+};
+EmptyProfilerCallback g_EmptyCallback;
+
+ProfilerCallback* g_ProfilerCallback = &g_EmptyCallback;
+ProfilerDetail::Level g_ProfilerDetail = ProfilerDetail::LOW;
+
+} // namespace Blast
+} // namespace Nv
+
+
+void NvBlastProfilerSetCallback(Nv::Blast::ProfilerCallback* pcb)
+{
+ Nv::Blast::g_ProfilerCallback = pcb != nullptr ? pcb : &Nv::Blast::g_EmptyCallback;
+}
+
+Nv::Blast::ProfilerCallback* NvBlastProfilerGetCallback()
+{
+ return Nv::Blast::g_ProfilerCallback;
+}
+
+
+void NvBlastProfilerSetDetail(Nv::Blast::ProfilerDetail::Level level)
+{
+ Nv::Blast::g_ProfilerDetail = level;
+}
+
+Nv::Blast::ProfilerDetail::Level NvBlastProfilerGetDetail()
+{
+ return Nv::Blast::g_ProfilerDetail;
+}
+
+
+void NvBlastProfilerBegin(const char* name, Nv::Blast::ProfilerDetail::Level level)
+{
+ if (level <= NvBlastProfilerGetDetail())
+ {
+ NvBlastProfilerGetCallback()->zoneStart(name);
+ }
+}
+
+void NvBlastProfilerEnd(const void* /*name*/, Nv::Blast::ProfilerDetail::Level level)
+{
+ if (level <= NvBlastProfilerGetDetail())
+ {
+ NvBlastProfilerGetCallback()->zoneEnd();
+ }
+}
+
+#else
+
+void NvBlastProfilerSetCallback(Nv::Blast::ProfilerCallback*) {}
+void NvBlastProfilerSetDetail(Nv::Blast::ProfilerDetail::Level) {}
+
+#endif // NV_PROFILE
diff --git a/sdk/globals/source/NvBlastProfilerInternal.h b/sdk/globals/source/NvBlastProfilerInternal.h index fa0bf47..d916fca 100644..100755 --- a/sdk/globals/source/NvBlastProfilerInternal.h +++ b/sdk/globals/source/NvBlastProfilerInternal.h @@ -1,91 +1,91 @@ -// 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 NVBLASTPROFILERINTERNAL_H -#define NVBLASTPROFILERINTERNAL_H - -#include "NvBlastPreprocessor.h" -#include "NvBlastProfiler.h" - -#if NV_PROFILE || NV_CHECKED || NV_DEBUG - -NVBLAST_API void NvBlastProfilerBegin(const char* name, Nv::Blast::ProfilerDetail::Level); -NVBLAST_API void NvBlastProfilerEnd(const void* name, Nv::Blast::ProfilerDetail::Level); - -Nv::Blast::ProfilerCallback* NvBlastProfilerGetCallback(); -Nv::Blast::ProfilerDetail::Level NvBlastProfilerGetDetail(); - - -namespace Nv -{ -namespace Blast -{ - - -class ProfileScope -{ -public: - ProfileScope(const char* name, ProfilerDetail::Level level) :m_name(name), m_level(level) - { - NvBlastProfilerBegin(m_name, m_level); - } - - ~ProfileScope() - { - NvBlastProfilerEnd(m_name, m_level); - } - -private: - const char* m_name; - ProfilerDetail::Level m_level; -}; - - -} // namespace Blast -} // namespace Nv - - -#define BLAST_PROFILE_PREFIX "Blast: " -#define BLAST_PROFILE_ZONE_BEGIN(name) NvBlastProfilerBegin(BLAST_PROFILE_PREFIX name, Nv::Blast::ProfilerDetail::HIGH) -#define BLAST_PROFILE_ZONE_END(name) NvBlastProfilerEnd(BLAST_PROFILE_PREFIX name, Nv::Blast::ProfilerDetail::HIGH) -#define BLAST_PROFILE_SCOPE(name, detail) Nv::Blast::ProfileScope NV_CONCAT(_scope,__LINE__) (BLAST_PROFILE_PREFIX name, detail) -#define BLAST_PROFILE_SCOPE_L(name) BLAST_PROFILE_SCOPE(name, Nv::Blast::ProfilerDetail::LOW) -#define BLAST_PROFILE_SCOPE_M(name) BLAST_PROFILE_SCOPE(name, Nv::Blast::ProfilerDetail::MEDIUM) -#define BLAST_PROFILE_SCOPE_H(name) BLAST_PROFILE_SCOPE(name, Nv::Blast::ProfilerDetail::HIGH) - -#else - -#define BLAST_PROFILE_ZONE_BEGIN(name) -#define BLAST_PROFILE_ZONE_END(name) -#define BLAST_PROFILE_SCOPE_L(name) -#define BLAST_PROFILE_SCOPE_M(name) -#define BLAST_PROFILE_SCOPE_H(name) - -#endif - -#endif +// 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 NVBLASTPROFILERINTERNAL_H
+#define NVBLASTPROFILERINTERNAL_H
+
+#include "NvBlastPreprocessor.h"
+#include "NvBlastProfiler.h"
+
+#if NV_PROFILE || NV_CHECKED || NV_DEBUG
+
+NVBLAST_API void NvBlastProfilerBegin(const char* name, Nv::Blast::ProfilerDetail::Level);
+NVBLAST_API void NvBlastProfilerEnd(const void* name, Nv::Blast::ProfilerDetail::Level);
+
+Nv::Blast::ProfilerCallback* NvBlastProfilerGetCallback();
+Nv::Blast::ProfilerDetail::Level NvBlastProfilerGetDetail();
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+
+class ProfileScope
+{
+public:
+ ProfileScope(const char* name, ProfilerDetail::Level level) :m_name(name), m_level(level)
+ {
+ NvBlastProfilerBegin(m_name, m_level);
+ }
+
+ ~ProfileScope()
+ {
+ NvBlastProfilerEnd(m_name, m_level);
+ }
+
+private:
+ const char* m_name;
+ ProfilerDetail::Level m_level;
+};
+
+
+} // namespace Blast
+} // namespace Nv
+
+
+#define BLAST_PROFILE_PREFIX "Blast: "
+#define BLAST_PROFILE_ZONE_BEGIN(name) NvBlastProfilerBegin(BLAST_PROFILE_PREFIX name, Nv::Blast::ProfilerDetail::HIGH)
+#define BLAST_PROFILE_ZONE_END(name) NvBlastProfilerEnd(BLAST_PROFILE_PREFIX name, Nv::Blast::ProfilerDetail::HIGH)
+#define BLAST_PROFILE_SCOPE(name, detail) Nv::Blast::ProfileScope NV_CONCAT(_scope,__LINE__) (BLAST_PROFILE_PREFIX name, detail)
+#define BLAST_PROFILE_SCOPE_L(name) BLAST_PROFILE_SCOPE(name, Nv::Blast::ProfilerDetail::LOW)
+#define BLAST_PROFILE_SCOPE_M(name) BLAST_PROFILE_SCOPE(name, Nv::Blast::ProfilerDetail::MEDIUM)
+#define BLAST_PROFILE_SCOPE_H(name) BLAST_PROFILE_SCOPE(name, Nv::Blast::ProfilerDetail::HIGH)
+
+#else
+
+#define BLAST_PROFILE_ZONE_BEGIN(name)
+#define BLAST_PROFILE_ZONE_END(name)
+#define BLAST_PROFILE_SCOPE_L(name)
+#define BLAST_PROFILE_SCOPE_M(name)
+#define BLAST_PROFILE_SCOPE_H(name)
+
+#endif
+
+#endif
|