1 /**
2 Exposes performance-related data.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.performance;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 /**
24 Exposes performance-related data.
25 
26 This class provides access to a number of different monitors related to performance, such as memory usage, draw calls, and FPS. These are the same as the values displayed in the $(B Monitor) tab in the editor's $(B Debugger) panel. By using the $(D getMonitor) method of this class, you can access this data from your code.
27 $(B Note:) A few of these monitors are only available in debug mode and will always return 0 when used in a release build.
28 $(B Note:) Many of these monitors are not updated in real-time, so there may be a short delay between changes.
29 */
30 @GodotBaseClass struct PerformanceSingleton
31 {
32 	package(godot) enum string _GODOT_internal_name = "Performance";
33 public:
34 @nogc nothrow:
35 	union { /** */ godot_object _godot_object; /** */ GodotObject _GODOT_base; }
36 	alias _GODOT_base this;
37 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
38 	package(godot) __gshared bool _classBindingInitialized = false;
39 	package(godot) static struct GDNativeClassBinding
40 	{
41 		__gshared:
42 		godot_object _singleton;
43 		immutable char* _singletonName = "Performance";
44 		@GodotName("get_monitor") GodotMethod!(double, long) getMonitor;
45 	}
46 	/// 
47 	pragma(inline, true) bool opEquals(in PerformanceSingleton other) const
48 	{ return _godot_object.ptr is other._godot_object.ptr; }
49 	/// 
50 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
51 	{ _godot_object.ptr = n; return null; }
52 	/// 
53 	pragma(inline, true) bool opEquals(typeof(null) n) const
54 	{ return _godot_object.ptr is n; }
55 	/// 
56 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
57 	mixin baseCasts;
58 	/// Construct a new instance of PerformanceSingleton.
59 	/// Note: use `memnew!PerformanceSingleton` instead.
60 	static PerformanceSingleton _new()
61 	{
62 		static godot_class_constructor constructor;
63 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Performance");
64 		if(constructor is null) return typeof(this).init;
65 		return cast(PerformanceSingleton)(constructor());
66 	}
67 	@disable new(size_t s);
68 	/// 
69 	enum Monitor : int
70 	{
71 		/**
72 		Number of frames per second.
73 		*/
74 		timeFps = 0,
75 		/**
76 		Time it took to complete one frame, in seconds.
77 		*/
78 		timeProcess = 1,
79 		/**
80 		Time it took to complete one physics frame, in seconds.
81 		*/
82 		timePhysicsProcess = 2,
83 		/**
84 		Static memory currently used, in bytes. Not available in release builds.
85 		*/
86 		memoryStatic = 3,
87 		/**
88 		Dynamic memory currently used, in bytes. Not available in release builds.
89 		*/
90 		memoryDynamic = 4,
91 		/**
92 		Available static memory. Not available in release builds.
93 		*/
94 		memoryStaticMax = 5,
95 		/**
96 		Available dynamic memory. Not available in release builds.
97 		*/
98 		memoryDynamicMax = 6,
99 		/**
100 		Largest amount of memory the message queue buffer has used, in bytes. The message queue is used for deferred functions calls and notifications.
101 		*/
102 		memoryMessageBufferMax = 7,
103 		/**
104 		Number of objects currently instanced (including nodes).
105 		*/
106 		objectCount = 8,
107 		/**
108 		Number of resources currently used.
109 		*/
110 		objectResourceCount = 9,
111 		/**
112 		Number of nodes currently instanced in the scene tree. This also includes the root node.
113 		*/
114 		objectNodeCount = 10,
115 		/**
116 		Number of orphan nodes, i.e. nodes which are not parented to a node of the scene tree.
117 		*/
118 		objectOrphanNodeCount = 11,
119 		/**
120 		3D objects drawn per frame.
121 		*/
122 		renderObjectsInFrame = 12,
123 		/**
124 		Vertices drawn per frame. 3D only.
125 		*/
126 		renderVerticesInFrame = 13,
127 		/**
128 		Material changes per frame. 3D only.
129 		*/
130 		renderMaterialChangesInFrame = 14,
131 		/**
132 		Shader changes per frame. 3D only.
133 		*/
134 		renderShaderChangesInFrame = 15,
135 		/**
136 		Render surface changes per frame. 3D only.
137 		*/
138 		renderSurfaceChangesInFrame = 16,
139 		/**
140 		Draw calls per frame. 3D only.
141 		*/
142 		renderDrawCallsInFrame = 17,
143 		/**
144 		Items or joined items drawn per frame.
145 		*/
146 		render2dItemsInFrame = 18,
147 		/**
148 		Draw calls per frame.
149 		*/
150 		render2dDrawCallsInFrame = 19,
151 		/**
152 		The amount of video memory used, i.e. texture and vertex memory combined.
153 		*/
154 		renderVideoMemUsed = 20,
155 		/**
156 		The amount of texture memory used.
157 		*/
158 		renderTextureMemUsed = 21,
159 		/**
160 		The amount of vertex memory used.
161 		*/
162 		renderVertexMemUsed = 22,
163 		/**
164 		Unimplemented in the GLES2 and GLES3 rendering backends, always returns 0.
165 		*/
166 		renderUsageVideoMemTotal = 23,
167 		/**
168 		Number of active $(D RigidBody2D) nodes in the game.
169 		*/
170 		physics2dActiveObjects = 24,
171 		/**
172 		Number of collision pairs in the 2D physics engine.
173 		*/
174 		physics2dCollisionPairs = 25,
175 		/**
176 		Number of islands in the 2D physics engine.
177 		*/
178 		physics2dIslandCount = 26,
179 		/**
180 		Number of active $(D RigidBody) and $(D VehicleBody) nodes in the game.
181 		*/
182 		physics3dActiveObjects = 27,
183 		/**
184 		Number of collision pairs in the 3D physics engine.
185 		*/
186 		physics3dCollisionPairs = 28,
187 		/**
188 		Number of islands in the 3D physics engine.
189 		*/
190 		physics3dIslandCount = 29,
191 		/**
192 		Output latency of the $(D AudioServer).
193 		*/
194 		audioOutputLatency = 30,
195 		/**
196 		Represents the size of the $(D monitor) enum.
197 		*/
198 		monitorMax = 31,
199 	}
200 	/// 
201 	enum Constants : int
202 	{
203 		timeFps = 0,
204 		timeProcess = 1,
205 		timePhysicsProcess = 2,
206 		memoryStatic = 3,
207 		memoryDynamic = 4,
208 		memoryStaticMax = 5,
209 		memoryDynamicMax = 6,
210 		memoryMessageBufferMax = 7,
211 		objectCount = 8,
212 		objectResourceCount = 9,
213 		objectNodeCount = 10,
214 		objectOrphanNodeCount = 11,
215 		renderObjectsInFrame = 12,
216 		renderVerticesInFrame = 13,
217 		renderMaterialChangesInFrame = 14,
218 		renderShaderChangesInFrame = 15,
219 		renderSurfaceChangesInFrame = 16,
220 		renderDrawCallsInFrame = 17,
221 		render2dItemsInFrame = 18,
222 		render2dDrawCallsInFrame = 19,
223 		renderVideoMemUsed = 20,
224 		renderTextureMemUsed = 21,
225 		renderVertexMemUsed = 22,
226 		renderUsageVideoMemTotal = 23,
227 		physics2dActiveObjects = 24,
228 		physics2dCollisionPairs = 25,
229 		physics2dIslandCount = 26,
230 		physics3dActiveObjects = 27,
231 		physics3dCollisionPairs = 28,
232 		physics3dIslandCount = 29,
233 		audioOutputLatency = 30,
234 		monitorMax = 31,
235 	}
236 	/**
237 	Returns the value of one of the available monitors. You should provide one of the $(D monitor) constants as the argument, like this:
238 	
239 	
240 	print(Performance.get_monitor(Performance.TIME_FPS)) # Prints the FPS to the console
241 	
242 	
243 	*/
244 	double getMonitor(in long monitor) const
245 	{
246 		checkClassBinding!(typeof(this))();
247 		return ptrcall!(double)(GDNativeClassBinding.getMonitor, _godot_object, monitor);
248 	}
249 }
250 /// Returns: the PerformanceSingleton
251 @property @nogc nothrow pragma(inline, true)
252 PerformanceSingleton Performance()
253 {
254 	checkClassBinding!PerformanceSingleton();
255 	return PerformanceSingleton(PerformanceSingleton.GDNativeClassBinding._singleton);
256 }