1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
|
#include "UnityPrefix.h"
#include "ProfilerStats.h"
#include "Runtime/BaseClasses/BaseObject.h"
#include "MemoryProfiler.h"
#include "SerializationUtility.h"
#if ENABLE_PROFILER
using namespace std;
struct ProfilerSample;
void InitializeStatisticsProperties (dynamic_array<StatisticsProperty>& statisticProperties)
{
AllProfilerStats* proxy = NULL;
#define ADD_STAT(_area,_graph,_name,_val,_format) { \
StatisticsProperty& prop = statisticProperties.push_back(); \
new (&prop) StatisticsProperty(); \
prop.name = _name; \
prop.offset = reinterpret_cast<UInt8*>(&proxy->_val) - reinterpret_cast<UInt8*>(proxy); \
prop.format = _format; \
prop.showGraph = _graph; \
prop.area = _area; \
}
// Any int stats value can be added by specifying the name, variable and display format into the macro
#define ADD_STAT_CHART(_area,_name,_val) \
ADD_STAT(_area, true, _name, chartSample._val, kFormatTime); \
ADD_STAT(_area, false, "Selected" _name, chartSampleSelected._val, kFormatTime)
// CPU overview
ADD_STAT_CHART(kProfilerAreaCPU, "Rendering", rendering);
ADD_STAT_CHART(kProfilerAreaCPU, "Scripts", scripts);
ADD_STAT_CHART(kProfilerAreaCPU, "Physics", physics);
ADD_STAT_CHART(kProfilerAreaCPU, "GarbageCollector", gc);
ADD_STAT_CHART(kProfilerAreaCPU, "VSync", vsync);
ADD_STAT_CHART(kProfilerAreaCPU, "Others", others);
// GPU overview
ADD_STAT_CHART(kProfilerAreaGPU, "Opaque", gpuOpaque);
ADD_STAT_CHART(kProfilerAreaGPU, "Transparent", gpuTransparent);
ADD_STAT_CHART(kProfilerAreaGPU, "Shadows/Depth", gpuShadows);
ADD_STAT_CHART(kProfilerAreaGPU, "Deferred PrePass", gpuDeferredPrePass);
ADD_STAT_CHART(kProfilerAreaGPU, "Deferred Lighting", gpuDeferredLighting);
ADD_STAT_CHART(kProfilerAreaGPU, "PostProcess", gpuPostProcess);
ADD_STAT_CHART(kProfilerAreaGPU, "Other", gpuOther);
// Graphics
ADD_STAT(kProfilerAreaRendering, true, "Draw Calls", drawStats.drawCalls, kFormatCount);
ADD_STAT(kProfilerAreaRendering, true, "Triangles", drawStats.triangles, kFormatCount);
ADD_STAT(kProfilerAreaRendering, true, "Vertices", drawStats.vertices, kFormatCount);
// Memory
ADD_STAT(kProfilerAreaMemory, true, "Total Allocated", memoryStats.bytesUsedTotal, kFormatBytes);
ADD_STAT(kProfilerAreaMemory, true, "Texture Memory", drawStats.usedTextureBytes, kFormatBytes);
ADD_STAT(kProfilerAreaMemory, false, "Texture Count", memoryStats.textureCount, kFormatCount);
ADD_STAT(kProfilerAreaMemory, true, "Mesh Count", memoryStats.meshCount, kFormatCount);
ADD_STAT(kProfilerAreaMemory, true, "Material Count", memoryStats.materialCount, kFormatCount);
ADD_STAT(kProfilerAreaMemory, true, "Object Count", memoryStats.totalObjectsCount, kFormatCount);
// Audio
ADD_STAT(kProfilerAreaAudio, true, "Playing Sources", audioStats.playingSources, kFormatCount);
ADD_STAT(kProfilerAreaAudio, true, "Paused Sources", audioStats.pausedSources, kFormatCount);
ADD_STAT(kProfilerAreaAudio, true, "Audio Voices", audioStats.audioVoices, kFormatCount);
ADD_STAT(kProfilerAreaAudio, false, "Audio CPU Usage", audioStats.audioCPUusage, kFormatPercentage);
ADD_STAT(kProfilerAreaAudio, true, "Audio Memory", audioStats.audioMemUsage, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Max Audio Memory Usage", audioStats.audioMaxMemUsage, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, true, "Audio Clip Count", audioStats.audioClipCount, kFormatCount);
ADD_STAT(kProfilerAreaAudio, true, "Audio Source Count", audioStats.audioSourceCount, kFormatCount);
ADD_STAT(kProfilerAreaAudio, false, "Detailed Audio Memory Usage", audioStats.audioMemDetailsUsage, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Memory not accounted for by other types", audioStats.audioMemDetails.other, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "String data", audioStats.audioMemDetails.string, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "System object and various internals", audioStats.audioMemDetails.system, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Plugin objects and internals", audioStats.audioMemDetails.plugins, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Output module object and internals", audioStats.audioMemDetails.output, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Channel related memory", audioStats.audioMemDetails.channel, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "ChannelGroup objects and internals", audioStats.audioMemDetails.channelgroup, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Codecs allocated for streaming", audioStats.audioMemDetails.codec, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "File buffers and structures", audioStats.audioMemDetails.file, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Sound objects and internals", audioStats.audioMemDetails.sound, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Sound data stored in secondary RAM", audioStats.audioMemDetails.secondaryram, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "SoundGroup objects and internals", audioStats.audioMemDetails.soundgroup, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Stream buffer memory", audioStats.audioMemDetails.streambuffer, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "DSPConnection objects and internals", audioStats.audioMemDetails.dspconnection, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "DSP implementation objects", audioStats.audioMemDetails.dsp, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Realtime file format decoding DSP objects", audioStats.audioMemDetails.dspcodec, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Profiler memory footprint", audioStats.audioMemDetails.profile, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Buffer used to store recorded data from microphone", audioStats.audioMemDetails.recordbuffer, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Reverb implementation objects", audioStats.audioMemDetails.reverb, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Reverb channel properties structs", audioStats.audioMemDetails.reverbchannelprops, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Geometry objects and internals", audioStats.audioMemDetails.geometry, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Sync point memory", audioStats.audioMemDetails.syncpoint, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "EventSystem and various internals", audioStats.audioMemDetails.eventsystem, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "MusicSystem and various internals", audioStats.audioMemDetails.musicsystem, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Definition of objects contained in all loaded projects e.g. events, groups, categories", audioStats.audioMemDetails.fev, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Data loaded with preloadFSB", audioStats.audioMemDetails.memoryfsb, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "EventProject objects and internals", audioStats.audioMemDetails.eventproject, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "EventGroup objects and internals", audioStats.audioMemDetails.eventgroupi, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Objects used to manage wave banks", audioStats.audioMemDetails.soundbankclass, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Data used to manage lists of wave bank usage", audioStats.audioMemDetails.soundbanklist, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Stream objects and internals", audioStats.audioMemDetails.streaminstance, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Sound definition objects", audioStats.audioMemDetails.sounddefclass, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Sound definition static data objects", audioStats.audioMemDetails.sounddefdefclass, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Sound definition pool data", audioStats.audioMemDetails.sounddefpool, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Reverb definition objects", audioStats.audioMemDetails.reverbdef, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Reverb objects", audioStats.audioMemDetails.eventreverb, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "User property objects", audioStats.audioMemDetails.userproperty, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Event instance base objects", audioStats.audioMemDetails.eventinstance, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Complex event instance objects", audioStats.audioMemDetails.eventinstance_complex, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Simple event instance objects", audioStats.audioMemDetails.eventinstance_simple, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Event layer instance objects", audioStats.audioMemDetails.eventinstance_layer, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Event sound instance objects", audioStats.audioMemDetails.eventinstance_sound, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Event envelope objects", audioStats.audioMemDetails.eventenvelope, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Event envelope definition objects", audioStats.audioMemDetails.eventenvelopedef, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Event parameter objects", audioStats.audioMemDetails.eventparameter, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Event category objects", audioStats.audioMemDetails.eventcategory, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Event envelope point objects", audioStats.audioMemDetails.eventenvelopepoint, kFormatBytes);
ADD_STAT(kProfilerAreaAudio, false, "Event instance pool memory", audioStats.audioMemDetails.eventinstancepool, kFormatBytes);
// Physics
////@TODO: Add some kind of warning when moving static colliders because that has a very high performance impact!
ADD_STAT(kProfilerAreaPhysics, true, "Active Rigidbodies", physicsStats.activeRigidbodies, kFormatCount);
ADD_STAT(kProfilerAreaPhysics, false, "Sleeping Rigidbodies", physicsStats.sleepingRigidbodies, kFormatCount);
ADD_STAT(kProfilerAreaPhysics, true, "Number of Contacts", physicsStats.numberOfShapePairs, kFormatCount);
ADD_STAT(kProfilerAreaPhysics, false, "Static Colliders", physicsStats.numberOfStaticColliders, kFormatCount);
ADD_STAT(kProfilerAreaPhysics, false, "Dynamic Colliders", physicsStats.numberOfDynamicColliders, kFormatCount);
// Physics (2D).
ADD_STAT(kProfilerAreaPhysics2D, false, "Total Bodies", physics2DStats.m_TotalBodyCount, kFormatCount);
ADD_STAT(kProfilerAreaPhysics2D, true, "Active Bodies", physics2DStats.m_ActiveBodyCount, kFormatCount);
ADD_STAT(kProfilerAreaPhysics2D, true, "Sleeping Bodies", physics2DStats.m_SleepingBodyCount, kFormatCount);
ADD_STAT(kProfilerAreaPhysics2D, true, "Dynamic Bodies", physics2DStats.m_DynamicBodyCount, kFormatCount);
ADD_STAT(kProfilerAreaPhysics2D, true, "Kinematic Bodies", physics2DStats.m_KinematicBodyCount, kFormatCount);
ADD_STAT(kProfilerAreaPhysics2D, true, "Discrete Bodies", physics2DStats.m_DiscreteBodyCount, kFormatCount);
ADD_STAT(kProfilerAreaPhysics2D, true, "Continuous Bodies", physics2DStats.m_ContinuousBodyCount, kFormatCount);
ADD_STAT(kProfilerAreaPhysics2D, true, "Joints", physics2DStats.m_JointCount, kFormatCount);
ADD_STAT(kProfilerAreaPhysics2D, true, "Contacts", physics2DStats.m_ContactCount, kFormatCount);
ADD_STAT(kProfilerAreaPhysics2D, false, "Active Collider Shapes", physics2DStats.m_ActiveColliderShapesCount, kFormatCount);
ADD_STAT(kProfilerAreaPhysics2D, false, "Sleeping Collider Shapes", physics2DStats.m_SleepingColliderShapesCount, kFormatCount);
ADD_STAT(kProfilerAreaPhysics2D, false, "Step Time", physics2DStats.m_StepTime, kFormatTime);
ADD_STAT(kProfilerAreaPhysics2D, false, "Contact Time", physics2DStats.m_CollideTime, kFormatTime);
ADD_STAT(kProfilerAreaPhysics2D, false, "Solve Time", physics2DStats.m_SolveTime, kFormatTime);
ADD_STAT(kProfilerAreaPhysics2D, false, "Solve Initialization Time", physics2DStats.m_SolveInitialization, kFormatTime);
ADD_STAT(kProfilerAreaPhysics2D, false, "Solve Velocity Time", physics2DStats.m_SolveVelocity, kFormatTime);
ADD_STAT(kProfilerAreaPhysics2D, false, "Solve Position Time", physics2DStats.m_SolvePosition, kFormatTime);
ADD_STAT(kProfilerAreaPhysics2D, false, "Solve Broadphase Time", physics2DStats.m_SolveBroadphase, kFormatTime);
ADD_STAT(kProfilerAreaPhysics2D, false, "Solve TOI Time", physics2DStats.m_SolveTimeOfImpact, kFormatTime);
}
static inline ProfilerString FormatNumber (int num)
{
if (num < 1000)
return FormatString<ProfilerString>("%d", num);
else if (num < 1000000)
return FormatString<ProfilerString>("%1.1fk", (num*0.001F));
else
return FormatString<ProfilerString>("%1.1fM", num*0.000001F);
}
ProfilerString DrawStats::ToString () const
{
int vramUsageMin = screenBytes + renderTextureBytes;
int vramUsageMax = screenBytes + usedTextureBytes + renderTextureBytes + vboTotalBytes;
return
FormatString<ProfilerString>("Draw Calls: %d \tTris: %s \t Verts: %s", drawCalls, FormatNumber(triangles).c_str(), FormatNumber(vertices).c_str()) +
FormatString<ProfilerString>("\nBatched Draw Calls: %d \tBatched Tris: %s \t Batched Verts: %s", batchedDrawCalls, FormatNumber(batchedTriangles).c_str(), FormatNumber(batchedVertices).c_str()) +
FormatString<ProfilerString>("\nUsed Textures: %d / %s", usedTextureCount, FormatBytes(usedTextureBytes).c_str()) +
FormatString<ProfilerString>("\nRenderTextures: %d / %s", renderTextureCount, FormatBytes(renderTextureBytes).c_str()) +
FormatString<ProfilerString>("\nRenderTexture Switches: %d", renderTextureStateChanges) +
FormatString<ProfilerString>("\nScreen: %s / %s", GetScreenResString().c_str(), FormatBytes(screenBytes).c_str()) +
FormatString<ProfilerString>("\nVRAM usage: %s to %s (of %s)", FormatBytes(vramUsageMin).c_str(), FormatBytes(vramUsageMax).c_str(), FormatBytes(totalAvailableVRamMBytes * 1024 * 1024).c_str()) +
FormatString<ProfilerString>("\nVBO Total: %d - %s", vboTotal, FormatBytes(vboTotalBytes).c_str()) +
FormatString<ProfilerString>("\nVB Uploads: %d - %s", vboUploads, FormatBytes(vboUploadBytes).c_str()) +
FormatString<ProfilerString>("\nIB Uploads: %d - %s", ibUploads, FormatBytes(ibUploadBytes).c_str()) +
FormatString<ProfilerString>("\nShadow Casters: %d\t ", shadowCasters);
}
ProfilerString GetFormattedSmallTime(ProfileTimeFormat time)
{
if (time < 100000)
return FormatString<ProfilerString>("%d nano", (int)time);
time /= 100;
ProfilerString value = FormatString<ProfilerString>("%u", (unsigned)time);
int length = value.length();
if (length > 4)
{
value.insert(length - 4, 1, '.');
}
else
{
ProfilerString tmp;
tmp.assign(4, '0');
value.copy((char*) tmp.c_str() + (4 - length), length);
return "0." + tmp;
}
return value;
}
ProfilerString DebugStats::ToString () const
{
return
FormatString<ProfilerString>("Profiler Memory: %s\n", FormatBytes(m_ProfilerMemoryUsage).c_str()) +
FormatString<ProfilerString>("Profiler Memory Misc: %s\n", FormatBytes(m_ProfilerMemoryUsageOthers).c_str())
#if DEBUGMODE
+ FormatString<ProfilerString>("Profiler Sample Count: %d\n", m_AllocatedProfileSamples)
#endif
;
}
ProfilerString MemoryStats::ToString () const
{
ProfilerString str =
FormatString<ProfilerString>("Used Total: %s ", FormatBytes(bytesUsedTotal).c_str()) +
FormatString<ProfilerString>("Unity: %s ", FormatBytes(bytesUsedUnity).c_str()) +
FormatString<ProfilerString>("Mono: %s ", FormatBytes(bytesUsedMono).c_str()) +
FormatString<ProfilerString>("GfxDriver: %s ", FormatBytes(bytesUsedGFX).c_str()) +
FormatString<ProfilerString>("FMOD: %s ", FormatBytes(bytesUsedFMOD).c_str()) +
FormatString<ProfilerString>("Profiler: %s ", FormatBytes(bytesUsedProfiler).c_str()) +
FormatString<ProfilerString>("\nReserved Total: %s ", FormatBytes(bytesReservedTotal).c_str()) +
FormatString<ProfilerString>("Unity: %s ", FormatBytes(bytesReservedUnity).c_str()) +
FormatString<ProfilerString>("Mono: %s ", FormatBytes(bytesReservedMono).c_str()) +
FormatString<ProfilerString>("GfxDriver: %s ", FormatBytes(bytesReservedGFX).c_str()) +
FormatString<ProfilerString>("FMOD: %s ", FormatBytes(bytesReservedFMOD).c_str()) +
FormatString<ProfilerString>("Profiler: %s ", FormatBytes(bytesReservedProfiler).c_str()) +
FormatString<ProfilerString>("\nTotal System Memory Usage: %s ", FormatBytes(bytesVirtual).c_str()) +
FormatString<ProfilerString>("\n(WP8) Commited Limit: %s ", FormatBytes(bytesCommitedLimit).c_str()) +
FormatString<ProfilerString>("Commited Total: %s ", FormatBytes(bytesCommitedTotal).c_str()) +
FormatString<ProfilerString>("\n\nTextures: %d / %s", textureCount, FormatBytes(textureBytes).c_str()) +
FormatString<ProfilerString>("\nMeshes: %d / %s", meshCount, FormatBytes(meshBytes).c_str()) +
FormatString<ProfilerString>("\nMaterials: %d / %s", materialCount, FormatBytes(materialBytes).c_str()) +
FormatString<ProfilerString>("\nAnimationClips: %d / %s", animationClipCount, FormatBytes(animationClipBytes).c_str()) +
FormatString<ProfilerString>("\nAudioClips: %d / %s", audioCount, FormatBytes(audioBytes).c_str()) +
FormatString<ProfilerString>("\nAssets: %d ", assetCount) +
FormatString<ProfilerString>("\nGameObjects in Scene: %d ", gameObjectCount) +
FormatString<ProfilerString>("\nTotal Objects in Scene: %d ", sceneObjectCount) +
FormatString<ProfilerString>("\nTotal Object Count: %d", totalObjectsCount);// +
/* Format("\nMost Occurring Objects:");
std::vector<int> sorted;
sorted.resize(classCount.size());
for(int i = 0; i < classCount.size(); i++)
sorted[i] = (classCount[i]<<12)+i;
std::sort(sorted.begin(), sorted.end());
for(int i = sorted.size()-1; i >= 0 ; i--)
{
int count = sorted[i] >> 12;
int index = sorted[i] & 0xFFF;
if(count != 0)
str += Format("\n\t%s: %d",Object::ClassIDToString(index).c_str(), count);
}*/
/*str += "\n\n";
for(int i = 0; i < memoryAllocatorInformation.size(); i++)
{
str += FormatString<ProfilerString>("\n%s: used %s (reserved %s)",memoryAllocatorInformation[i].name.c_str(), FormatBytes(memoryAllocatorInformation[i].used).c_str(), FormatBytes(memoryAllocatorInformation[i].reserved).c_str());
}
str += "\n\n";
str += memoryOverview;
*/
return str;
}
ProfilerString DrawStats::GetScreenResString () const
{
if (screenFSAA > 1)
return FormatString<ProfilerString>("%ix%i %ixAA", screenWidth, screenHeight, screenFSAA);
else
return FormatString<ProfilerString>("%ix%i", screenWidth, screenHeight);
}
#if ENABLE_PLAYERCONNECTION
void AllProfilerStats::Serialize( dynamic_array<int>& bitstream )
{
memoryStats.Serialize(bitstream);
WriteIntArray (bitstream, drawStats);
WriteIntArray (bitstream, physicsStats);
WriteIntArray (bitstream, physics2DStats);
debugStats.Serialize(bitstream); // not all ints
WriteIntArray (bitstream, audioStats);
WriteIntArray (bitstream, chartSample);
WriteIntArray (bitstream, chartSampleSelected);
}
void DebugStats::Serialize( dynamic_array<int>& bitstream )
{
bitstream.push_back (m_ProfilerMemoryUsage);
bitstream.push_back (m_ProfilerMemoryUsageOthers);
bitstream.push_back (m_AllocatedProfileSamples);
}
void MemoryStats::Serialize( dynamic_array<int>& bitstream )
{
bitstream.push_back (bytesUsedTotal/1024);
bitstream.push_back (bytesUsedUnity/1024);
bitstream.push_back (bytesUsedMono/1024);
bitstream.push_back (bytesUsedGFX/1024);
bitstream.push_back (bytesUsedFMOD/1024);
bitstream.push_back (bytesUsedProfiler/1024);
bitstream.push_back (bytesReservedTotal/1024);
bitstream.push_back (bytesReservedUnity/1024);
bitstream.push_back (bytesReservedMono/1024);
bitstream.push_back (bytesReservedGFX/1024);
bitstream.push_back (bytesReservedFMOD/1024);
bitstream.push_back (bytesReservedProfiler/1024);
bitstream.push_back (bytesVirtual/1024);
bitstream.push_back (bytesCommitedLimit/1024);
bitstream.push_back (bytesCommitedTotal/1024);
bitstream.push_back (textureCount);
bitstream.push_back (textureBytes);
bitstream.push_back (meshCount);
bitstream.push_back (meshBytes);
bitstream.push_back (materialCount);
bitstream.push_back (materialBytes);
bitstream.push_back (animationClipCount);
bitstream.push_back (animationClipBytes);
bitstream.push_back (audioCount);
bitstream.push_back (audioBytes);
bitstream.push_back (assetCount);
bitstream.push_back (sceneObjectCount);
bitstream.push_back (gameObjectCount);
bitstream.push_back (totalObjectsCount);
// write size, and index,entry for all non 0 entries
bitstream.push_back (classCount.size());
for(int i = 0; i < classCount.size(); i++)
{
if(classCount[i] != 0)
{
bitstream.push_back (i);
bitstream.push_back (classCount[i]);
}
}
bitstream.push_back (-1);
/// TODO
// WriteString(bitstream, memoryOverview.c_str());
}
void AllProfilerStats::Deserialize( int** bitstream, bool swapdata )
{
memoryStats.Deserialize(bitstream, swapdata);
ReadIntArray (bitstream, drawStats);
ReadIntArray (bitstream, physicsStats);
ReadIntArray (bitstream, physics2DStats);
debugStats.Deserialize(bitstream); // not all ints
ReadIntArray (bitstream, audioStats);
ReadIntArray (bitstream, chartSample);
ReadIntArray (bitstream, chartSampleSelected);
}
void DebugStats::Deserialize( int** bitstream )
{
m_ProfilerMemoryUsage = *((*bitstream)++);
m_ProfilerMemoryUsageOthers = *((*bitstream)++);
m_AllocatedProfileSamples = *((*bitstream)++);
}
void MemoryStats::Deserialize( int** bitstream, bool swapdata )
{
bytesUsedTotal = *((*bitstream)++)*1024;
bytesUsedUnity = *((*bitstream)++)*1024;
bytesUsedMono = *((*bitstream)++)*1024;
bytesUsedGFX = *((*bitstream)++)*1024;
bytesUsedFMOD = *((*bitstream)++)*1024;
bytesUsedProfiler = *((*bitstream)++)*1024;
bytesReservedTotal = *((*bitstream)++)*1024;
bytesReservedUnity = *((*bitstream)++)*1024;
bytesReservedMono = *((*bitstream)++)*1024;
bytesReservedGFX = *((*bitstream)++)*1024;
bytesReservedFMOD = *((*bitstream)++)*1024;
bytesReservedProfiler = *((*bitstream)++)*1024;
bytesVirtual = *((*bitstream)++)*1024;
bytesCommitedLimit = *((*bitstream)++)*1024;
bytesCommitedTotal = *((*bitstream)++)*1024;
textureCount = *((*bitstream)++);
textureBytes = *((*bitstream)++);
meshCount = *((*bitstream)++);
meshBytes = *((*bitstream)++);
materialCount = *((*bitstream)++);
materialBytes = *((*bitstream)++);
animationClipCount = *((*bitstream)++);
animationClipBytes = *((*bitstream)++);
audioCount = *((*bitstream)++);
audioBytes = *((*bitstream)++);
assetCount = *((*bitstream)++);
sceneObjectCount = *((*bitstream)++);
gameObjectCount = *((*bitstream)++);
totalObjectsCount = *((*bitstream)++);
int count;
count = *((*bitstream)++);
classCount.resize_initialized(count,0);
int index = *((*bitstream)++);
while(index != -1)
{
classCount[index] = *((*bitstream)++);
index = *((*bitstream)++);
}
// ReadString(bitstream, memoryOverview, swapdata);
}
#endif
#endif
|