1//
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions
4// are met:
5// * Redistributions of source code must retain the above copyright
6// notice, this list of conditions and the following disclaimer.
7// * Redistributions in binary form must reproduce the above copyright
8// notice, this list of conditions and the following disclaimer in the
9// documentation and/or other materials provided with the distribution.
10// * Neither the name of NVIDIA CORPORATION nor the names of its
11// contributors may be used to endorse or promote products derived
12// from this software without specific prior written permission.
13//
14// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
15// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25//
26// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
27// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29
30#ifndef PXPVDSDK_PXPVD_H
31#define PXPVDSDK_PXPVD_H
32
33/** \addtogroup pvd
34@{
35*/
36#include "foundation/PxFlags.h"
37#include "foundation/PxProfiler.h"
38
39#if !PX_DOXYGEN
40namespace physx
41{
42#endif
43
44class PxFoundation;
45class PxPvdTransport;
46
47/**
48\brief types of instrumentation that PVD can do.
49*/
50struct PxPvdInstrumentationFlag
51{
52 enum Enum
53 {
54 /**
55 \brief Send debugging information to PVD.
56
57 This information is the actual object data of the rigid statics, shapes,
58 articulations, etc. Sending this information has a noticeable impact on
59 performance and thus this flag should not be set if you want an accurate
60 performance profile.
61 */
62 eDEBUG = 1 << 0,
63
64 /**
65 \brief Send profile information to PVD.
66
67 This information populates PVD's profile view. It has (at this time) negligible
68 cost compared to Debug information and makes PVD *much* more useful so it is quite
69 highly recommended.
70
71 This flag works together with a PxCreatePhysics parameter.
72 Using it allows the SDK to send profile events to PVD.
73 */
74 ePROFILE = 1 << 1,
75
76 /**
77 \brief Send memory information to PVD.
78
79 The PVD sdk side hooks into the Foundation memory controller and listens to
80 allocation/deallocation events. This has a noticable hit on the first frame,
81 however, this data is somewhat compressed and the PhysX SDK doesn't allocate much
82 once it hits a steady state. This information also has a fairly negligible
83 impact and thus is also highly recommended.
84
85 This flag works together with a PxCreatePhysics parameter,
86 trackOutstandingAllocations. Using both of them together allows users to have
87 an accurate view of the overall memory usage of the simulation at the cost of
88 a hashtable lookup per allocation/deallocation. Again, PhysX makes a best effort
89 attempt not to allocate or deallocate during simulation so this hashtable lookup
90 tends to have no effect past the first frame.
91
92 Sending memory information without tracking outstanding allocations means that
93 PVD will accurate information about the state of the memory system before the
94 actual connection happened.
95 */
96 eMEMORY = 1 << 2,
97
98 eALL = (eDEBUG | ePROFILE | eMEMORY)
99 };
100};
101
102/**
103\brief Bitfield that contains a set of raised flags defined in PxPvdInstrumentationFlag.
104
105@see PxPvdInstrumentationFlag
106*/
107typedef PxFlags<PxPvdInstrumentationFlag::Enum, uint8_t> PxPvdInstrumentationFlags;
108PX_FLAGS_OPERATORS(PxPvdInstrumentationFlag::Enum, uint8_t)
109
110/**
111\brief PxPvd is the top-level class for the PVD framework, and the main customer interface for PVD
112configuration.It is a singleton class, instantiated and owned by the application.
113*/
114class PxPvd : public physx::PxProfilerCallback
115{
116 public:
117 /**
118 Connects the SDK to the PhysX Visual Debugger application.
119 \param transport transport for pvd captured data.
120 \param flags Flags to set.
121 return True if success
122 */
123 virtual bool connect(PxPvdTransport& transport, PxPvdInstrumentationFlags flags) = 0;
124
125 /**
126 Disconnects the SDK from the PhysX Visual Debugger application.
127 If we are still connected, this will kill the entire debugger connection.
128 */
129 virtual void disconnect() = 0;
130
131 /**
132 * Return if connection to PVD is created.
133 \param useCachedStatus
134 1> When useCachedStaus is false, isConnected() checks the lowlevel network status.
135 This can be slow because it needs to lock the lowlevel network stream. If isConnected() is
136 called frequently, the expense of locking can be significant.
137 2> When useCachedStatus is true, isConnected() checks the highlevel cached status with atomic access.
138 It is faster than locking, but the status may be different from the lowlevel network with latency of up to
139 one frame.
140 The reason for this is that the cached status is changed inside socket listener, which is not
141 called immediately when the lowlevel connection status changes.
142 */
143 virtual bool isConnected(bool useCachedStatus = true) = 0;
144
145 /**
146 returns the PVD data transport
147 returns NULL if no transport is present.
148 */
149 virtual PxPvdTransport* getTransport() = 0;
150
151 /**
152 Retrieves the PVD flags. See PxPvdInstrumentationFlags.
153 */
154 virtual PxPvdInstrumentationFlags getInstrumentationFlags() = 0;
155
156 /**
157 \brief Releases the pvd instance.
158 */
159 virtual void release() = 0;
160
161 protected:
162 virtual ~PxPvd()
163 {
164 }
165};
166
167/**
168 \brief Create a pvd instance.
169 \param foundation is the foundation instance that stores the allocator and error callbacks.
170*/
171PX_C_EXPORT PxPvd* PX_CALL_CONV PxCreatePvd(PxFoundation& foundation);
172
173#if !PX_DOXYGEN
174} // namespace physx
175#endif
176
177/** @} */
178#endif // PXPVDSDK_PXPVD_H
179

source code of qtquick3dphysics/src/3rdparty/PhysX/include/pvd/PxPvd.h