Dali 3D User Interface Engine
gl-proxy-implementation.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 // CLASS HEADER
20 
21 // EXTERNAL INCLUDES
22 #include <math.h>
23 
25 
26 // INTERNAL INCLUDES
28 
29 namespace
30 {
31 const int NUM_FRAMES_PER_SECOND(60);
32 }
33 
34 
35 namespace Dali
36 {
37 namespace Internal
38 {
39 namespace Adaptor
40 {
41 
42 Sampler::Sampler( const char* description )
43 : mDescription( description ),
44  mAccumulated(0.0f),
45  mAccumulatedSquare(0.0f),
46  mMin(0.0f),
47  mMax(0.0f),
48  mNumSamples(0),
49  mCurrentFrameCount(0)
50 {
51 }
52 
54 {
56 }
57 
59 {
60  mAccumulated = 0.0f;
61  mAccumulatedSquare= 0.0f;
62  mMin = 0.0f;
63  mMax = 0.0f;
64  mNumSamples = 0;
66 }
67 
69 {
70  if( mNumSamples == 0 )
71  {
74  }
75  else
76  {
78  {
80  }
82  {
84  }
85  }
86 
87  mNumSamples++;
88 
92 }
93 const char* Sampler::GetDescription() const
94 {
95  return mDescription;
96 }
97 
98 float Sampler::GetMeanValue() const
99 {
100  float meanValue = 0;
101  if( mNumSamples > 0 )
102  {
103  meanValue = mAccumulated / (float)mNumSamples;
104  }
105  return meanValue;
106 }
107 
109 {
110  float standardDeviation=0.0f;
111  if( mNumSamples > 0 )
112  {
113  standardDeviation = sqrtf( mNumSamples * mAccumulatedSquare - (mAccumulated*mAccumulated)) / mNumSamples;
114  }
115  return standardDeviation;
116 }
117 
118 float Sampler::GetMin() const
119 {
120  return mMin;
121 }
122 
123 float Sampler::GetMax() const
124 {
125  return mMax;
126 }
127 
128 ObjectCounter::ObjectCounter( const char* description )
129 :mDescription(description),
130  mCount(0),
131  mPeak(0)
132 {}
133 
135 {
136  ++mCount;
137  if( mCount > mPeak )
138  {
139  mPeak = mCount;
140  }
141 }
142 
144 {
145  --mCount;
146 }
147 
148 unsigned int ObjectCounter::GetCount() const
149 {
150  return mCount;
151 }
152 unsigned int ObjectCounter::GetPeak() const
153 {
154  return mPeak;
155 }
156 
157 const char* ObjectCounter::GetDescription() const
158 {
159  return mDescription;
160 }
161 
163 : mEnvironmentOptions(environmentOptions),
164  mActiveTextureSampler( "ActiveTexture calls"),
165  mClearSampler("Clear calls"),
166  mBindBufferSampler( "Bind buffers"),
167  mBindTextureSampler( "Bind textures"),
168  mDrawSampler("Draw calls"),
169  mUniformSampler("Uniform sets"),
170  mUseProgramSampler("Used programs"),
171  mBufferCount( "Buffer Count"),
172  mTextureCount("Texture Count"),
173  mProgramCount("Program Count"),
174  mFrameCount(0)
175 {
176 }
177 
179 {
180 }
181 
183 {
184 }
185 
187 {
188  // Accumulate counts in each sampler
190 
191  // When we reach the desired frame count, output the averages from the samples
192  mFrameCount++;
194  {
195  LogResults();
196  ResetSamplers();
197  }
198 }
199 
201 {
204 }
205 
207 {
209  GlImplementation::GenBuffers( n, buffers );
210 }
211 
213 {
215  GlImplementation::DeleteBuffers( n, buffers );
216 }
217 
219 {
221  GlImplementation::BindBuffer(target,buffer);
222 }
223 
225 {
227  GlImplementation::GenTextures( n, textures );
228 }
229 
231 {
233  GlImplementation::DeleteTextures( n, textures );
234 }
235 
237 {
240 }
241 
243 {
245  GlImplementation::BindTexture(target,texture);
246 }
247 
249 {
251  GlImplementation::DrawArrays(mode,first,count);
252 }
253 
254 void GlProxyImplementation::DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices )
255 {
257  GlImplementation::DrawElements(mode,count,type,indices);
258 }
259 
261 {
263  GlImplementation::Uniform1f(location,x);
264 }
265 
266 void GlProxyImplementation::Uniform1fv( GLint location, GLsizei count, const GLfloat* v )
267 {
269  GlImplementation::Uniform1fv(location,count,v);
270 }
271 
273 {
275  GlImplementation::Uniform1i(location,x);
276 }
277 
278 void GlProxyImplementation::Uniform1iv( GLint location, GLsizei count, const GLint* v )
279 {
281  GlImplementation::Uniform1iv(location,count,v);
282 }
283 
285 {
287  GlImplementation::Uniform2f(location,x,y);
288 }
289 
290 void GlProxyImplementation::Uniform2fv( GLint location, GLsizei count, const GLfloat* v )
291 {
293  GlImplementation::Uniform2fv(location,count,v);
294 }
295 
297 {
299  GlImplementation::Uniform2i(location,x,y);
300 }
301 
302 void GlProxyImplementation::Uniform2iv( GLint location, GLsizei count, const GLint* v )
303 {
305  GlImplementation::Uniform2iv(location,count,v);
306 }
307 
309 {
311  GlImplementation::Uniform3f(location,x,y,z);
312 }
313 
314 void GlProxyImplementation::Uniform3fv( GLint location, GLsizei count, const GLfloat* v )
315 {
317  GlImplementation::Uniform3fv(location,count,v);
318 }
319 
321 {
323  GlImplementation::Uniform3i(location,x,y,z);
324 }
325 
326 void GlProxyImplementation::Uniform3iv( GLint location, GLsizei count, const GLint* v )
327 {
329  GlImplementation::Uniform3iv(location,count,v);
330 }
331 
333 {
335  GlImplementation::Uniform4f(location,x,y,z,w);
336 }
337 
338 void GlProxyImplementation::Uniform4fv( GLint location, GLsizei count, const GLfloat* v )
339 {
341  GlImplementation::Uniform4fv(location,count,v);
342 }
343 
345 {
347  GlImplementation::Uniform4i(location,x,y,z,w);
348 }
349 
350 void GlProxyImplementation::Uniform4iv( GLint location, GLsizei count, const GLint* v )
351 {
353  GlImplementation::Uniform4iv(location,count,v);
354 }
355 
356 void GlProxyImplementation::UniformMatrix2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
357 {
359  GlImplementation::UniformMatrix2fv(location,count,transpose,value);
360 }
361 
362 void GlProxyImplementation::UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
363 {
365  GlImplementation::UniformMatrix3fv(location,count,transpose,value);
366 }
367 
368 void GlProxyImplementation::UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
369 {
371  GlImplementation::UniformMatrix4fv(location,count,transpose,value);
372 }
373 
375 {
378 }
379 
381 {
384 }
385 
387 {
390 }
391 
393 {
394  // Accumulate counts in each sampler
402 }
403 
405 {
406  Debug::LogMessage( Debug::DebugInfo, "OpenGL ES statistics sampled over %d frames) operations per frame:\n", mFrameCount );
414  Debug::LogMessage( Debug::DebugInfo, "OpenGL ES Object Count:\n", mFrameCount );
418 }
419 
421 {
422  Debug::LogMessage( Debug::DebugInfo, " %s : Mean %5.2f (Min:%5.2f, Max:%5.2f, StdDev:%5.2f)\n",
423  sampler.GetDescription(),
424  sampler.GetMeanValue(), sampler.GetMin(), sampler.GetMax(),
425  sampler.GetStandardDeviation() );
426 }
427 
429 {
430  Debug::LogMessage( Debug::DebugInfo, " %s : %u (Peak:%u)\n",
431  sampler.GetDescription(),
432  sampler.GetCount(),
433  sampler.GetPeak() );
434 }
435 
437 {
445  mFrameCount = 0;
446 }
447 
448 } // namespace Adaptor
449 
450 } // namespace Internal
451 
452 } // namespace Dali
Dali Docs Home
Read more about Dali