Main Page Class List Class Members

NvBlastPxCallbacks.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed to you
2 // under a form of NVIDIA software license agreement provided separately to you.
3 //
4 // Notice
5 // NVIDIA Corporation and its licensors retain all intellectual property and
6 // proprietary rights in and to this software and related documentation and
7 // any modifications thereto. Any use, reproduction, disclosure, or
8 // distribution of this software and related documentation without an express
9 // license agreement from NVIDIA Corporation is strictly prohibited.
10 //
11 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
12 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
13 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
14 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // Information and code furnished is believed to be accurate and reliable.
17 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
18 // information or for any infringement of patents or other rights of third parties that may
19 // result from its use. No license is granted by implication or otherwise under any patent
20 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
21 // This code supersedes and replaces all information previously supplied.
22 // NVIDIA Corporation products are not authorized for use as critical
23 // components in life support devices or systems without express written approval of
24 // NVIDIA Corporation.
25 //
26 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
27
28
29 #ifndef NVBLASTPXCALLBACKS_H
30 #define NVBLASTPXCALLBACKS_H
31
32 #include "NvBlastGlobals.h"
33 #include "PxErrorCallback.h"
34 #include "PxAllocatorCallback.h"
35
41 NV_INLINE physx::PxErrorCallback& NvBlastGetPxErrorCallback()
42 {
43 class PxErrorCallbackWrapper : public physx::PxErrorCallback
44 {
45 virtual void reportError(physx::PxErrorCode::Enum code, const char* message, const char* file, int line) override
46 {
47 NvBlastGlobalGetErrorCallback()->reportError((Nv::Blast::ErrorCode::Enum)code, message, file, line);
48 }
49 };
50 static PxErrorCallbackWrapper wrapper;
51 return wrapper;
52 }
53
54 NV_INLINE physx::PxAllocatorCallback& NvBlastGetPxAllocatorCallback()
55 {
56 class PxAllocatorCallbackWrapper : public physx::PxAllocatorCallback
57 {
58 virtual void* allocate(size_t size, const char* typeName, const char* filename, int line) override
59 {
60 return NvBlastGlobalGetAllocatorCallback()->allocate(size, typeName, filename, line);
61 }
62
63 virtual void deallocate(void* ptr) override
64 {
65 NvBlastGlobalGetAllocatorCallback()->deallocate(ptr);
66 }
67 };
68 static PxAllocatorCallbackWrapper wrapper;
69 return wrapper;
70 }
71
72
73 #endif // #ifndef NVBLASTPXCALLBACKS_H
Nv::Blast::AllocatorCallback::deallocate
virtual void deallocate(void *ptr)=0
Frees memory previously allocated by allocate().
Nv::Blast::AllocatorCallback::allocate
virtual void * allocate(size_t size, const char *typeName, const char *filename, int line)=0
Allocates size bytes of memory, which must be 16-byte aligned.
Nv::Blast::ErrorCallback::reportError
virtual void reportError(ErrorCode::Enum code, const char *message, const char *file, int line)=0
Reports an error code.
NvBlastGlobals.h
NvBlastGlobalGetAllocatorCallback
NVBLAST_API Nv::Blast::AllocatorCallback * NvBlastGlobalGetAllocatorCallback()
NvBlastGetPxAllocatorCallback
NV_INLINE physx::PxAllocatorCallback & NvBlastGetPxAllocatorCallback()
Definition: NvBlastPxCallbacks.h:54
NvBlastGlobalGetErrorCallback
NVBLAST_API Nv::Blast::ErrorCallback * NvBlastGlobalGetErrorCallback()
NV_INLINE
#define NV_INLINE
Definition: NvPreprocessor.h:350
NvBlastGetPxErrorCallback
NV_INLINE physx::PxErrorCallback & NvBlastGetPxErrorCallback()
Definition: NvBlastPxCallbacks.h:41
Nv::Blast::ErrorCode::Enum
Enum
Definition: NvBlastGlobals.h:90