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_ZONE_MANAGER_H
12#define PX_PROFILE_ZONE_MANAGER_H
13
14#include "physxprofilesdk/PxProfileEventSender.h"
15#include "physxprofilesdk/PxProfileEventNames.h"
16
17namespace physx {
18 class PxProfileZone;
19 class PxProfileNameProvider;
20
21 class PxProfileZoneHandler
22 {
23 protected:
24 virtual ~PxProfileZoneHandler(){}
25 public:
26 /*
27 * Not a threadsafe call; handlers are expected to be able to handle
28 * this from any thread.
29 */
30 virtual void onZoneAdded( PxProfileZone& inSDK ) = 0;
31 virtual void onZoneRemoved( PxProfileZone& inSDK ) = 0;
32 };
33
34 class PxUserCustomProfiler
35 {
36 public:
37 virtual void onStartEvent( const char* eventName, PxU64 contextId, PxU32 threadId) = 0;
38 virtual void onStopEvent( const char* eventName, PxU64 contextId, PxU32 threadId) = 0;
39 virtual void onEventValue(const char* eventValue, PxI64 inValue) = 0;
40
41 protected:
42 virtual ~PxUserCustomProfiler(void) {}
43 };
44
45 /**
46 * The profiling system was setup in the expectation that there would be several
47 * systems that each had its own island of profile information. PhysX, client code,
48 * and APEX would be the first examples of these. Each one of these islands is represented
49 * by a profile zone.
50 *
51 * The Manager is a singleton-like object where all these different systems can be registered
52 * so that clients of the profiling system can have one point to capture *all* profiling events.
53 *
54 * Flushing the manager implies that you want to loop through all the profile zones and flush
55 * each one.
56 */
57 class PxProfileZoneManager
58 : public PxProfileEventFlusher //Tell all SDK's to flush their queue of profile events.
59 {
60 protected:
61 virtual ~PxProfileZoneManager(){}
62 public:
63 /**
64 * Threadsafe call, can be done from any thread. Handlers that are already connected
65 * will get a new callback on the current thread.
66 */
67 virtual void addProfileZone( PxProfileZone& inSDK ) = 0;
68 virtual void removeProfileZone( PxProfileZone& inSDK ) = 0;
69
70 /**
71 * Threadsafe call. The new handler will immediately be notified about all
72 * known SDKs.
73 */
74 virtual void addProfileZoneHandler( PxProfileZoneHandler& inHandler ) = 0;
75 virtual void removeProfileZoneHandler( PxProfileZoneHandler& inHandler ) = 0;
76
77
78 /**
79 * Create a new profile zone. This means you don't need access to a PxFoundation to
80 * create your profile zone object, and your object is automatically registered with
81 * the profile zone manager.
82 *
83 * You still need to release your object when you are finished with it.
84 * \param inSDKName Name of the SDK object.
85 * \param inProvider Option set of event id to name mappings.
86 * \param inEventBufferByteSize rough maximum size of the event buffer. May exceed this size
87 * by sizeof one event. When full an immediate call to all listeners is made.
88 */
89 virtual PxProfileZone& createProfileZone( const char* inSDKName, PxProfileNames inNames = PxProfileNames(), PxU32 inEventBufferByteSize = 0x4000 /*16k*/ ) = 0;
90
91 /**
92 * Deprecated form of the above function.
93 */
94 virtual PxProfileZone& createProfileZone( const char* inSDKName, PxProfileNameProvider* inProvider = NULL, PxU32 inEventBufferByteSize = 0x4000 /*16k*/ ) = 0;
95
96 virtual void setUserCustomProfiler(PxUserCustomProfiler* callback) = 0;
97
98 virtual void release() = 0;
99
100 static PxProfileZoneManager& createProfileZoneManager(PxFoundation* inFoundation );
101 };
102
103}
104
105#endif // PX_PROFILE_ZONE_MANAGER_H
106