Main Page   Class List   Class Members  

  • Main Page
  • Modules
  • Classes
  • Files
  • File List

Callbacks.h

Go to the documentation of this file.
00001 // This code contains NVIDIA Confidential Information and is disclosed to you
00002 // under a form of NVIDIA software license agreement provided separately to you.
00003 //
00004 // Notice
00005 // NVIDIA Corporation and its licensors retain all intellectual property and
00006 // proprietary rights in and to this software and related documentation and
00007 // any modifications thereto. Any use, reproduction, disclosure, or
00008 // distribution of this software and related documentation without an express
00009 // license agreement from NVIDIA Corporation is strictly prohibited.
00010 //
00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
00015 //
00016 // Information and code furnished is believed to be accurate and reliable.
00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
00018 // information or for any infringement of patents or other rights of third parties that may
00019 // result from its use. No license is granted by implication or otherwise under any patent
00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
00021 // This code supersedes and replaces all information previously supplied.
00022 // NVIDIA Corporation products are not authorized for use as critical
00023 // components in life support devices or systems without express written approval of
00024 // NVIDIA Corporation.
00025 //
00026 // Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
00027 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
00028 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
00029 
00036 #pragma once
00037 #include <foundation/PxPreprocessor.h>
00038 #include <foundation/PxProfiler.h>
00039 #include <foundation/PxAssert.h>
00040 #ifndef NV_CLOTH_IMPORT
00041 #define NV_CLOTH_IMPORT PX_DLL_IMPORT
00042 #endif
00043 
00044 #define NV_CLOTH_DLL_ID 0x2
00045 
00046 #define NV_CLOTH_LINKAGE PX_C_EXPORT NV_CLOTH_IMPORT
00047 #define NV_CLOTH_CALL_CONV PX_CALL_CONV
00048 #define NV_CLOTH_API(ret_type) NV_CLOTH_LINKAGE ret_type NV_CLOTH_CALL_CONV
00049 
00050 namespace physx
00051 {
00052     class PxAllocatorCallback;
00053     class PxErrorCallback;
00054     class PxProfilerCallback;
00055     class PxAssertHandler;
00056 }
00057 
00059 namespace nv
00060 {
00062 namespace cloth
00063 {
00072 NV_CLOTH_API(void)
00073     InitializeNvCloth(physx::PxAllocatorCallback* allocatorCallback, physx::PxErrorCallback* errorCallback, 
00074                         physx::PxAssertHandler* assertHandler, physx::PxProfilerCallback* profilerCallback,
00075                         int autoDllIDCheck = NV_CLOTH_DLL_ID);
00076 }
00077 }
00078 
00079 //Allocator
00080 NV_CLOTH_API(physx::PxAllocatorCallback*) GetNvClothAllocator(); //Only use internally
00081 
00082 namespace nv
00083 {
00084 namespace cloth
00085 {
00086 //Logging
00087 void LogErrorFn  (const char* fileName, int lineNumber, const char* msg, ...);
00088 void LogInvalidParameterFn  (const char* fileName, int lineNumber, const char* msg, ...);
00089 void LogWarningFn(const char* fileName, int lineNumber, const char* msg, ...);
00090 void LogInfoFn   (const char* fileName, int lineNumber, const char* msg, ...);
00092 #define NV_CLOTH_LOG_ERROR(...) nv::cloth::LogErrorFn(__FILE__,__LINE__,__VA_ARGS__)
00093 #define NV_CLOTH_LOG_INVALID_PARAMETER(...) nv::cloth::LogInvalidParameterFn(__FILE__,__LINE__,__VA_ARGS__)
00094 #define NV_CLOTH_LOG_WARNING(...) nv::cloth::LogWarningFn(__FILE__,__LINE__,__VA_ARGS__)
00095 #define NV_CLOTH_LOG_INFO(...) nv::cloth::LogInfoFn(__FILE__,__LINE__,__VA_ARGS__)
00096 
00097 //ASSERT
00098 NV_CLOTH_API(physx::PxAssertHandler*) GetNvClothAssertHandler(); //This function needs to be exposed to properly inline asserts outside this dll
00099 #if !PX_ENABLE_ASSERTS
00100 #if PX_VC
00101 #define NV_CLOTH_ASSERT(exp) __noop
00102 #define NV_CLOTH_ASSERT_WITH_MESSAGE(message, exp) __noop
00103 #else
00104 #define NV_CLOTH_ASSERT(exp) ((void)0)
00105 #define NV_CLOTH_ASSERT_WITH_MESSAGE(message, exp) ((void)0)
00106 #endif
00107 #else
00108 #if PX_VC
00109 #define PX_CODE_ANALYSIS_ASSUME(exp)                                                                                   \
00110     __analysis_assume(!!(exp)) // This macro will be used to get rid of analysis warning messages if a PX_ASSERT is used
00111                                                                  // to "guard" illegal mem access, for example.
00112 #else
00113 #define PX_CODE_ANALYSIS_ASSUME(exp)
00114 #endif
00115 #define NV_CLOTH_ASSERT(exp)                                                                                           \
00116     {                                                                                                                  \
00117         static bool _ignore = false;                                                                                   \
00118         ((void)((!!(exp)) || (!_ignore && ((*nv::cloth::GetNvClothAssertHandler())(#exp, __FILE__, __LINE__, _ignore), false))));    \
00119         PX_CODE_ANALYSIS_ASSUME(exp);                                                                                  \
00120     }
00121 #define NV_CLOTH_ASSERT_WITH_MESSAGE(message, exp)                                                                             \
00122     {                                                                                                                    \
00123         static bool _ignore = false;                                                                                     \
00124         ((void)((!!(exp)) || (!_ignore && (physx::PxGetAssertHandler()(message, __FILE__, __LINE__, _ignore), false)))); \
00125         PX_CODE_ANALYSIS_ASSUME(exp);                                                                                    \
00126     }
00127 #endif
00128 
00129 //Profiler
00130 physx::PxProfilerCallback* GetNvClothProfiler(); //Only use internally
00131 #if PX_DEBUG || PX_CHECKED || PX_PROFILE || 1
00132 class NvClothProfileScoped
00133 {
00134   public:
00135     PX_FORCE_INLINE NvClothProfileScoped(const char* eventName, bool detached, uint64_t contextId,
00136                                     const char* fileName, int lineno, physx::PxProfilerCallback* callback)
00137     : mCallback(callback)
00138     {
00139         PX_UNUSED(fileName);
00140         PX_UNUSED(lineno);
00141         mProfilerData = NULL; //nullptr doesn't work here on mac
00142         if (mCallback)
00143         {
00144             mEventName = eventName;
00145             mDetached = detached;
00146             mContextId = contextId;
00147             mProfilerData = mCallback->zoneStart(mEventName, mDetached, mContextId);
00148         }
00149     }
00150     ~NvClothProfileScoped(void)
00151     {
00152         if (mCallback)
00153         {
00154             mCallback->zoneEnd(mProfilerData, mEventName, mDetached, mContextId);
00155         }
00156     }
00157     physx::PxProfilerCallback* mCallback;
00158     const char* mEventName;
00159     bool mDetached;
00160     uint64_t mContextId;
00161     void* mProfilerData;
00162 };
00163 
00164 #define NV_CLOTH_PROFILE_ZONE(x, y)                                                                                          \
00165     nv::cloth::NvClothProfileScoped PX_CONCAT(_scoped, __LINE__)(x, false, y, __FILE__, __LINE__, nv::cloth::GetNvClothProfiler())
00166 #define NV_CLOTH_PROFILE_START_CROSSTHREAD(x, y)                                                                             \
00167     (GetNvClothProfiler()!=nullptr?                                                                                        \
00168     GetNvClothProfiler()->zoneStart(x, true, y):nullptr)
00169 #define NV_CLOTH_PROFILE_STOP_CROSSTHREAD(profilerData, x, y)                                                                              \
00170     if (GetNvClothProfiler())                                                                                           \
00171     GetNvClothProfiler()->zoneEnd(profilerData, x, true, y)
00172 #else
00173 
00174 #define NV_CLOTH_PROFILE_ZONE(x, y)
00175 #define NV_CLOTH_PROFILE_START_CROSSTHREAD(x, y) nullptr
00176 #define NV_CLOTH_PROFILE_STOP_CROSSTHREAD(profilerData, x, y)
00177 
00178 #endif
00179 
00180 }
00181 }
Copyright © 2016-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com