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_HANDLER_H
12#define PX_PROFILE_EVENT_HANDLER_H
13
14#include "physxprofilesdk/PxProfileBase.h"
15#include "physxprofilesdk/PxProfileEventId.h"
16#include "physxprofilesdk/PxProfileEvents.h"
17
18namespace physx {
19
20 //A client of the event system can expect to find these events in the event buffer.
21 class PxProfileEventHandler
22 {
23 protected:
24 virtual ~PxProfileEventHandler(){}
25 public:
26 virtual void onStartEvent( const PxProfileEventId& inId, PxU32 threadId, PxU64 contextId, PxU8 cpuId, PxU8 threadPriority, PxU64 timestamp ) = 0;
27 virtual void onStopEvent( const PxProfileEventId& inId, PxU32 threadId, PxU64 contextId, PxU8 cpuId, PxU8 threadPriority, PxU64 timestamp ) = 0;
28 virtual void onEventValue( const PxProfileEventId& inId, PxU32 threadId, PxU64 contextId, PxI64 inValue ) = 0;
29 virtual void onCUDAProfileBuffer( PxU64 submitTimestamp, PxF32 timeSpanInMilliseconds, const PxU8* cudaData, PxU32 bufLenInBytes, PxU32 bufferVersion ) = 0;
30 static void parseEventBuffer( const PxU8* inBuffer, PxU32 inBufferSize, PxProfileEventHandler& inHandler, bool inSwapBytes );
31
32 /**
33 \brief Translates event duration in timestamp (cycles) into nanoseconds.
34
35 \param[in] duration Timestamp duration of the event.
36
37 \return event duration in nanoseconds.
38 */
39 static PxU64 durationToNanoseconds(PxU64 duration);
40 };
41
42 class PxProfileBulkEventHandler
43 {
44 protected:
45 virtual ~PxProfileBulkEventHandler(){}
46 public:
47 virtual void handleEvents( const physx::profile::Event* inEvents, PxU32 inBufferSize ) = 0;
48 static void parseEventBuffer( const PxU8* inBuffer, PxU32 inBufferSize, PxProfileBulkEventHandler& inHandler, bool inSwapBytes );
49 };
50}
51
52#endif // PX_PROFILE_EVENT_HANDLER_H
53