sdk/globals/include/NvBlastGlobals.h File Reference

#include <new>
#include "NvBlastTypes.h"

Go to the source code of this file.

Classes

class  Nv::Blast::AllocatorCallback
 Abstract base class for an application defined memory allocator that can be used by toolkit (Tk) or any extension (Ext). More...
class  Nv::Blast::ErrorCallback
 User defined interface class. Used by the library to emit debug information. More...
struct  Nv::Blast::ErrorCode
 Error codes. More...

Namespaces

namespace  Nv
namespace  Nv::Blast

Defines

#define NVBLAST_ALLOC(_size)   NvBlastGlobalGetAllocatorCallback()->allocate(_size, nullptr, __FILE__, __LINE__)
#define NVBLAST_ALLOC_NAMED(_size, _name)   NvBlastGlobalGetAllocatorCallback()->allocate(_size, _name, __FILE__, __LINE__)
#define NVBLAST_CHECK(_code, _expr, _msg, _onFail)
#define NVBLAST_CHECK_DEBUG(_expr, _msg, _onFail)   NVBLAST_CHECK(Nv::Blast::ErrorCode::eNO_ERROR, _expr, _msg, _onFail)
#define NVBLAST_CHECK_ERROR(_expr, _msg, _onFail)   NVBLAST_CHECK(Nv::Blast::ErrorCode::eINVALID_OPERATION, _expr, _msg, _onFail)
#define NVBLAST_CHECK_INFO(_expr, _msg, _onFail)   NVBLAST_CHECK(Nv::Blast::ErrorCode::eDEBUG_INFO, _expr, _msg, _onFail)
#define NVBLAST_CHECK_WARNING(_expr, _msg, _onFail)   NVBLAST_CHECK(Nv::Blast::ErrorCode::eDEBUG_WARNING, _expr, _msg, _onFail)
#define NVBLAST_DELETE(obj, T)
#define NVBLAST_FOURCC(_a, _b, _c, _d)   ( (uint32_t)(_a) | (uint32_t)(_b)<<8 | (uint32_t)(_c)<<16 | (uint32_t)(_d)<<24 )
#define NVBLAST_FREE(_mem)   NvBlastGlobalGetAllocatorCallback()->deallocate(_mem)
#define NVBLAST_LOG(_code, _msg)   NvBlastGlobalGetErrorCallback()->reportError(_code, _msg, __FILE__, __LINE__)
#define NVBLAST_LOG_DEBUG(_msg)   NVBLAST_LOG(Nv::Blast::ErrorCode::eNO_ERROR, _msg)
#define NVBLAST_LOG_ERROR(_msg)   NVBLAST_LOG(Nv::Blast::ErrorCode::eINVALID_OPERATION, _msg)
#define NVBLAST_LOG_INFO(_msg)   NVBLAST_LOG(Nv::Blast::ErrorCode::eDEBUG_INFO, _msg)
#define NVBLAST_LOG_WARNING(_msg)   NVBLAST_LOG(Nv::Blast::ErrorCode::eDEBUG_WARNING, _msg)
#define NVBLAST_NEW(T)   new (NvBlastGlobalGetAllocatorCallback()->allocate(sizeof(T), #T, __FILE__, __LINE__)) T

Functions

NV_INLINE void Nv::Blast::logLL (int type, const char *msg, const char *file, int line)
NVBLAST_API
Nv::Blast::AllocatorCallback
NvBlastGlobalGetAllocatorCallback ()
NVBLAST_API
Nv::Blast::ErrorCallback
NvBlastGlobalGetErrorCallback ()
NVBLAST_API void NvBlastGlobalSetAllocatorCallback (Nv::Blast::AllocatorCallback *allocatorCallback)
NVBLAST_API void NvBlastGlobalSetErrorCallback (Nv::Blast::ErrorCallback *errorCallback)


Define Documentation

#define NVBLAST_ALLOC ( _size   )     NvBlastGlobalGetAllocatorCallback()->allocate(_size, nullptr, __FILE__, __LINE__)

Alloc/Free macros that use global AllocatorCallback. Thus allocated memory is 16-byte aligned.

#define NVBLAST_ALLOC_NAMED ( _size,
_name   )     NvBlastGlobalGetAllocatorCallback()->allocate(_size, _name, __FILE__, __LINE__)

#define NVBLAST_CHECK ( _code,
_expr,
_msg,
_onFail   ) 

Value:

{                                                                                                                   \
        if(!(_expr))                                                                                                    \
        {                                                                                                               \
            NVBLAST_LOG(_code, _msg);                                                                                   \
            { _onFail; };                                                                                               \
        }                                                                                                               \
    }
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_DEBUG ( _expr,
_msg,
_onFail   )     NVBLAST_CHECK(Nv::Blast::ErrorCode::eNO_ERROR, _expr, _msg, _onFail)

#define NVBLAST_CHECK_ERROR ( _expr,
_msg,
_onFail   )     NVBLAST_CHECK(Nv::Blast::ErrorCode::eINVALID_OPERATION, _expr, _msg, _onFail)

#define NVBLAST_CHECK_INFO ( _expr,
_msg,
_onFail   )     NVBLAST_CHECK(Nv::Blast::ErrorCode::eDEBUG_INFO, _expr, _msg, _onFail)

#define NVBLAST_CHECK_WARNING ( _expr,
_msg,
_onFail   )     NVBLAST_CHECK(Nv::Blast::ErrorCode::eDEBUG_WARNING, _expr, _msg, _onFail)

#define NVBLAST_DELETE ( obj,
 ) 

Value:

Respective delete to NVBLAST_NEW Example: NVBLAST_DELETE(foo, Foo, context);

#define NVBLAST_FOURCC ( _a,
_b,
_c,
_d   )     ( (uint32_t)(_a) | (uint32_t)(_b)<<8 | (uint32_t)(_c)<<16 | (uint32_t)(_d)<<24 )

#define NVBLAST_FREE ( _mem   )     NvBlastGlobalGetAllocatorCallback()->deallocate(_mem)

#define NVBLAST_LOG ( _code,
_msg   )     NvBlastGlobalGetErrorCallback()->reportError(_code, _msg, __FILE__, __LINE__)

Logging macros that use global AllocatorCallback.

#define NVBLAST_LOG_DEBUG ( _msg   )     NVBLAST_LOG(Nv::Blast::ErrorCode::eNO_ERROR, _msg)

#define NVBLAST_LOG_ERROR ( _msg   )     NVBLAST_LOG(Nv::Blast::ErrorCode::eINVALID_OPERATION, _msg)

#define NVBLAST_LOG_INFO ( _msg   )     NVBLAST_LOG(Nv::Blast::ErrorCode::eDEBUG_INFO, _msg)

#define NVBLAST_LOG_WARNING ( _msg   )     NVBLAST_LOG(Nv::Blast::ErrorCode::eDEBUG_WARNING, _msg)

#define NVBLAST_NEW (  )     new (NvBlastGlobalGetAllocatorCallback()->allocate(sizeof(T), #T, __FILE__, __LINE__)) T

Placement new with ExtContext allocation. Example: Foo* foo = NVBLAST_NEW(Foo, context) (params);


Function Documentation

NVBLAST_API Nv::Blast::AllocatorCallback* NvBlastGlobalGetAllocatorCallback (  ) 

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.

Returns:
the pointer to the global AllocatorCallback.

NVBLAST_API Nv::Blast::ErrorCallback* NvBlastGlobalGetErrorCallback (  ) 

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.

Returns:
the pointer to the global ErrorCallback.

NVBLAST_API void NvBlastGlobalSetAllocatorCallback ( Nv::Blast::AllocatorCallback allocatorCallback  ) 

Set global AllocatorCallback. If 'nullptr' is passed the default AllocatorCallback with std allocator is set.

NVBLAST_API void NvBlastGlobalSetErrorCallback ( Nv::Blast::ErrorCallback errorCallback  ) 

Set global ErrorCallback. If 'nullptr' is passed the default ErrorCallback that writes messages to stdout is set.