| 1 | /* |
| 2 | * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. |
| 3 | * |
| 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property |
| 5 | * and proprietary rights in and to this software, related documentation |
| 6 | * and any modifications thereto. Any use, reproduction, disclosure or |
| 7 | * distribution of this software and related documentation without an express |
| 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. |
| 9 | */ |
| 10 | |
| 11 | #ifndef PX_PROFILE_EVENT_SENDER_H |
| 12 | #define PX_PROFILE_EVENT_SENDER_H |
| 13 | |
| 14 | #include "physxprofilesdk/PxProfileBase.h" |
| 15 | #include "physxprofilesdk/PxProfileContextProvider.h" |
| 16 | #include "physxprofilesdk/PxProfileEventId.h" |
| 17 | |
| 18 | namespace physx { |
| 19 | |
| 20 | /** |
| 21 | * Tagging interface to indicate an object that is capable of flushing a profile |
| 22 | * event stream at a certain point. |
| 23 | */ |
| 24 | class PxProfileEventFlusher |
| 25 | { |
| 26 | protected: |
| 27 | virtual ~PxProfileEventFlusher(){} |
| 28 | public: |
| 29 | virtual void flushProfileEvents() = 0; |
| 30 | }; |
| 31 | |
| 32 | /** |
| 33 | * Sends the full events where the caller must provide the context and thread id. |
| 34 | */ |
| 35 | class PxProfileEventSender |
| 36 | { |
| 37 | protected: |
| 38 | virtual ~PxProfileEventSender(){} |
| 39 | public: |
| 40 | |
| 41 | // use this as a thread id for events that start on one thread and end on another |
| 42 | static const PxU32 CrossThreadId = 99999789; |
| 43 | |
| 44 | //Send a profile event, optionally with a context. Events are sorted by thread |
| 45 | //and context in the client side. |
| 46 | virtual void startEvent( PxU16 inId, PxU64 contextId) = 0; |
| 47 | virtual void stopEvent( PxU16 inId, PxU64 contextId) = 0; |
| 48 | |
| 49 | virtual void startEvent( PxU16 inId, PxU64 contextId, PxU32 threadId) = 0; |
| 50 | virtual void stopEvent( PxU16 inId, PxU64 contextId, PxU32 threadId ) = 0; |
| 51 | |
| 52 | /** |
| 53 | * Set an specific events value. This is different than the profiling value |
| 54 | * for the event; it is a value recorded and kept around without a timestamp associated |
| 55 | * with it. This value is displayed when the event itself is processed. |
| 56 | */ |
| 57 | virtual void eventValue( PxU16 inId, PxU64 contextId, PxI64 inValue ) = 0; |
| 58 | |
| 59 | //GPUProfile.h .. |
| 60 | /* |
| 61 | typedef struct CUDA_ALIGN_16 |
| 62 | { |
| 63 | PxU16 block; |
| 64 | PxU8 warp; |
| 65 | PxU8 mpId; |
| 66 | PxU8 hwWarpId; |
| 67 | PxU8 userDataCfg; |
| 68 | PxU16 eventId; |
| 69 | PxU32 startTime; |
| 70 | PxU32 endTime; |
| 71 | } warpProfileEvent; |
| 72 | */ |
| 73 | static const PxU32 CurrentCUDABufferFormat = 1; |
| 74 | |
| 75 | /** |
| 76 | * Send a CUDA profile buffer. We assume the submit time is almost exactly the end time of the batch. |
| 77 | * We then work backwards, using the batchRuntimeInMilliseconds in order to get the original time |
| 78 | * of the batch. The buffer format is described in GPUProfile.h. |
| 79 | * |
| 80 | * \param batchRuntimeInMilliseconds The batch runtime in milliseconds, see cuEventElapsedTime. |
| 81 | * \param cudaData An opaque pointer to the buffer of cuda data. |
| 82 | * \param bufLenInBytes length of the cuda data buffer in bytes |
| 83 | * \param bufferVersion Version of the format of the cuda data. |
| 84 | */ |
| 85 | virtual void CUDAProfileBuffer( PxF32 batchRuntimeInMilliseconds, const PxU8* cudaData, PxU32 bufLenInBytes, PxU32 bufferVersion = CurrentCUDABufferFormat ) = 0; |
| 86 | }; |
| 87 | |
| 88 | /** |
| 89 | Tagging interface to indicate an object that may or may not return |
| 90 | an object capable of adding profile events to a buffer. |
| 91 | */ |
| 92 | class PxProfileEventSenderProvider |
| 93 | { |
| 94 | protected: |
| 95 | virtual ~PxProfileEventSenderProvider(){} |
| 96 | public: |
| 97 | /** |
| 98 | This method can *always* return NULL. |
| 99 | Thus need to always check that what you are getting is what |
| 100 | you think it is. |
| 101 | |
| 102 | \return Perhaps a profile event sender. |
| 103 | */ |
| 104 | virtual PxProfileEventSender* getProfileEventSender() = 0; |
| 105 | }; |
| 106 | } |
| 107 | |
| 108 | #endif // PX_PROFILE_EVENT_SENDER_H |
| 109 | |