RavEngine
Loading...
Searching...
No Matches
PxPvdCommStreamTypes.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26
27#ifndef PX_PVD_COMM_STREAM_TYPES_H
28#define PX_PVD_COMM_STREAM_TYPES_H
29
30#include "foundation/PxErrorCallback.h"
31#include "common/PxRenderBuffer.h"
32#include "pvd/PxPvdTransport.h"
33
34#include "PxPvdObjectModelBaseTypes.h"
35#include "PxPvdCommStreamEvents.h"
36#include "PxPvdDataStream.h"
37#include "foundation/PxMutex.h"
38
39namespace physx
40{
41namespace profile
42{
43class PxProfileZone;
44class PxProfileMemoryEventBuffer;
45}
46namespace pvdsdk
47{
48struct PvdErrorMessage;
49class PvdObjectModelMetaData;
50
51DEFINE_PVD_TYPE_NAME_MAP(profile::PxProfileZone, "_debugger_", "PxProfileZone")
52DEFINE_PVD_TYPE_NAME_MAP(profile::PxProfileMemoryEventBuffer, "_debugger_", "PxProfileMemoryEventBuffer")
53DEFINE_PVD_TYPE_NAME_MAP(PvdErrorMessage, "_debugger_", "PvdErrorMessage")
54// All event streams are on the 'events' property of objects of these types
55static inline NamespacedName getMemoryEventTotalsClassName()
56{
57 return NamespacedName("_debugger", "MemoryEventTotals");
58}
59
61{
62 protected:
64 {
65 }
66
67 public:
68 virtual void addRef() = 0;
69 virtual void release() = 0;
70 virtual PvdObjectModelMetaData& lock() = 0;
71 virtual void unlock() = 0;
72 virtual bool createInstance(const NamespacedName& clsName, const void* instance) = 0;
73 virtual bool isInstanceValid(const void* instance) = 0;
74 virtual void destroyInstance(const void* instance) = 0;
75 virtual int32_t getInstanceClassType(const void* instance) = 0;
76};
77
79{
80 public:
81 static const char* getProfileEventStreamSemantic()
82 {
83 return "profile event stream";
84 }
85 static const char* getMemoryEventStreamSemantic()
86 {
87 return "memory event stream";
88 }
89 static const char* getRendererEventStreamSemantic()
90 {
91 return "render event stream";
92 }
93};
94
95class PvdCommStreamEventBufferClient;
96
97template <typename TStreamType>
99{
100 TStreamType& mBuffer;
101 EventStreamifier(TStreamType& buf) : mBuffer(buf)
102 {
103 }
104
105 template <typename TDataType>
106 void write(const TDataType& type)
107 {
108 mBuffer.write(reinterpret_cast<const uint8_t*>(&type), sizeof(TDataType));
109 }
110 template <typename TDataType>
111 void write(const TDataType* type, uint32_t count)
112 {
113 mBuffer.write(reinterpret_cast<const uint8_t*>(type), count * sizeof(TDataType));
114 }
115
116 void writeRef(DataRef<const uint8_t> data)
117 {
118 uint32_t amount = static_cast<uint32_t>(data.size());
119 write(amount);
120 write(data.begin(), amount);
121 }
122 void writeRef(DataRef<StringHandle> data)
123 {
124 uint32_t amount = static_cast<uint32_t>(data.size());
125 write(amount);
126 write(data.begin(), amount);
127 }
128 template <typename TDataType>
129 void writeRef(DataRef<TDataType> data)
130 {
131 uint32_t amount = static_cast<uint32_t>(data.size());
132 write(amount);
133 for(uint32_t idx = 0; idx < amount; ++idx)
134 {
135 TDataType& dtype(const_cast<TDataType&>(data[idx]));
136 dtype.serialize(*this);
137 }
138 }
139
140 virtual void streamify(uint16_t& val)
141 {
142 write(val);
143 }
144 virtual void streamify(uint8_t& val)
145 {
146 write(val);
147 }
148 virtual void streamify(uint32_t& val)
149 {
150 write(val);
151 }
152 virtual void streamify(float& val)
153 {
154 write(val);
155 }
156 virtual void streamify(uint64_t& val)
157 {
158 write(val);
159 }
160 virtual void streamify(PxDebugText& val)
161 {
162 write(val.color);
163 write(val.position);
164 write(val.size);
165 streamify(val.string);
166 }
167
168 virtual void streamify(String& val)
169 {
170 uint32_t len = 0;
171 String temp = nonNull(val);
172 if(*temp)
173 len = static_cast<uint32_t>(strlen(temp) + 1);
174 write(len);
175 write(val, len);
176 }
177 virtual void streamify(DataRef<const uint8_t>& val)
178 {
179 writeRef(val);
180 }
181 virtual void streamify(DataRef<NameHandleValue>& val)
182 {
183 writeRef(val);
184 }
185 virtual void streamify(DataRef<StreamPropMessageArg>& val)
186 {
187 writeRef(val);
188 }
189 virtual void streamify(DataRef<StringHandle>& val)
190 {
191 writeRef(val);
192 }
193
194 private:
195 EventStreamifier& operator=(const EventStreamifier&);
196};
197
199{
200 uint32_t mSize;
201 MeasureStream() : mSize(0)
202 {
203 }
204 template <typename TDataType>
205 void write(const TDataType& val)
206 {
207 mSize += sizeof(val);
208 }
209 template <typename TDataType>
210 void write(const TDataType*, uint32_t count)
211 {
212 mSize += sizeof(TDataType) * count;
213 }
214};
215
217{
218 enum Enum
219 {
220 Open,
222 PropertyMessageGroup
223 };
224};
225
226} // pvdsdk
227} // physx
228#endif
229
Definition PxPvdObjectModelBaseTypes.h:345
Definition PxPvdCommStreamTypes.h:79
Definition PxPvdCommStreamEvents.h:205
Definition PxPvdCommStreamTypes.h:61
Definition PxPvdObjectModelMetaData.h:374
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Used to store a text for debug rendering. Doesn't own 'string' array.
Definition PxRenderBuffer.h:115
Definition PxPvdCommStreamTypes.h:217
Definition PxPvdCommStreamTypes.h:99
Definition PxPvdCommStreamTypes.h:199
Definition PxPvdObjectModelBaseTypes.h:188
Definition PxPvdCommStreamEvents.h:533