summaryrefslogtreecommitdiff
path: root/Runtime/Profiler/MemoryProfilerStats.h
blob: a1484847ab5210863e90f8c523c6a2d2a685e804 (plain)
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
#ifndef _MEMORY_PROFILER_STATS_H_
#define _MEMORY_PROFILER_STATS_H_

#include "Configuration/UnityConfigure.h"
#include "Runtime/Utilities/dynamic_array.h"


#if ENABLE_PROFILER


class Object;

class MemoryProfilerStats
{
public:
	MemoryProfilerStats();
	~MemoryProfilerStats();

	void RegisterObject ( Object* obj );
	void UnregisterObject ( Object* obj );
	void ChangePersistancyflag (int instanceID, bool oldvalue, bool newvalue);

	typedef dynamic_array<Object*> ObjectVector;
	const ObjectVector& GetTextures() const {return textures;}
	const ObjectVector& GetMeshes() const {return meshes;}
	const ObjectVector& GetMaterials() const {return materials;}
	const ObjectVector& GetAnimationClips() const {return animations;}
	const ObjectVector& GetAudioClips() const {return audioclips;}

	const dynamic_array<int>& GetClassCount() const {return classCount;}

	int GetAssetCount() const {return assetCount;}
	int GetSceneObjectCount() const {return sceneObjectCount;}
	int GetGameObjectCount() const {return gameObjectCount;}
private:

	ObjectVector textures;
	ObjectVector meshes;
	ObjectVector materials;
	ObjectVector animations;
	ObjectVector audioclips;

	volatile int assetCount;
	volatile int sceneObjectCount;
	volatile int gameObjectCount;

	dynamic_array<int> classCount; 

	void AddDynamicObjectCount(Object* obj, int classID);
	void RemoveDynamicObjectCount(Object* obj, int classID);

};

MemoryProfilerStats& GetMemoryProfilerStats();
void InitializeMemoryProfilerStats();
void CleanupMemoryProfilerStats();

void profiler_register_object(Object* obj);
void profiler_unregister_object(Object* obj);
void profiler_change_persistancy(int instanceID, bool oldvalue, bool newvalue);

#define PROFILER_REGISTER_OBJECT(obj) profiler_register_object(obj);
#define PROFILER_UNREGISTER_OBJECT(obj) profiler_unregister_object(obj);
#define PROFILER_CHANGE_PERSISTANCY(id,oldvalue,newvalue) profiler_change_persistancy(id,oldvalue,newvalue);

#else

#define PROFILER_REGISTER_OBJECT(obj) 
#define PROFILER_UNREGISTER_OBJECT(obj) 
#define PROFILER_CHANGE_PERSISTANCY(id,oldvalue,newvalue)

#endif


#endif