1 #ifndef DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H
2 #define DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/internal/graphics/gles/gl-implementation.h>
30 class EnvironmentOptions;
33 * Helper class to calculate the statistics for Open GLES calls
40 * @param description to write to the log
42 Sampler(const char* description);
45 * Increment the counter for this frame
55 * Accumulate the count onto statistics
60 * @return the description of the sampler
62 const char* GetDescription() const;
65 * @return the mean value
67 float GetMeanValue() const;
70 * @return the standard deviation
72 float GetStandardDeviation() const;
75 * @return the minimum value
80 * @return the maximum value
85 * @return the current count
87 uint64_t GetCount() const;
90 const char* mDescription;
92 uint64_t mAccumulatedSquare;
93 uint64_t mAccumulated;
97 unsigned int mCurrentFrameCount;
101 * Helper class to calculate number of OpenGL objects
106 ObjectCounter(const char* description);
109 * Increment the counter
114 * Decrement the counter
119 * @return The current number of objects
121 unsigned int GetCount() const;
124 * @return The maximum number of objects created
126 unsigned int GetPeak() const;
129 * @return the description of the sampler
131 const char* GetDescription() const;
134 const char* mDescription;
140 * GlProxyImplementation is a wrapper for the concrete implementation
141 * of GlAbstraction that also gathers statistical information.
143 class GlProxyImplementation : public GlImplementation
148 * @param environmentOptions to check how often to log results
150 GlProxyImplementation(const EnvironmentOptions& environmentOptions);
155 virtual ~GlProxyImplementation();
158 * @copydoc GlAbstraction::PreRender();
160 void PreRender() override;
163 * @copydoc GlAbstraction::PostRender();
165 void PostRender() override;
167 /* OpenGL ES 2.0 API */
168 void Clear(GLbitfield mask) override;
170 void GenBuffers(GLsizei n, GLuint* buffers) override;
171 void DeleteBuffers(GLsizei n, const GLuint* buffers) override;
172 void BindBuffer(GLenum target, GLuint buffer) override;
174 void GenTextures(GLsizei n, GLuint* textures) override;
175 void DeleteTextures(GLsizei n, const GLuint* textures) override;
176 void ActiveTexture(GLenum texture) override;
177 void BindTexture(GLenum target, GLuint texture) override;
179 void DrawArrays(GLenum mode, GLint first, GLsizei count) override;
180 void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) override;
182 void Uniform1f(GLint location, GLfloat x) override;
183 void Uniform1fv(GLint location, GLsizei count, const GLfloat* v) override;
184 void Uniform1i(GLint location, GLint x) override;
185 void Uniform1iv(GLint location, GLsizei count, const GLint* v) override;
186 void Uniform2f(GLint location, GLfloat x, GLfloat y) override;
187 void Uniform2fv(GLint location, GLsizei count, const GLfloat* v) override;
188 void Uniform2i(GLint location, GLint x, GLint y) override;
189 void Uniform2iv(GLint location, GLsizei count, const GLint* v) override;
190 void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) override;
191 void Uniform3fv(GLint location, GLsizei count, const GLfloat* v) override;
192 void Uniform3i(GLint location, GLint x, GLint y, GLint z) override;
193 void Uniform3iv(GLint location, GLsizei count, const GLint* v) override;
194 void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) override;
195 void Uniform4fv(GLint location, GLsizei count, const GLfloat* v) override;
196 void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) override;
197 void Uniform4iv(GLint location, GLsizei count, const GLint* v) override;
198 void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override;
199 void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override;
200 void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override;
202 GLuint CreateProgram(void) override;
203 void DeleteProgram(GLuint program) override;
204 void UseProgram(GLuint program) override;
207 void AccumulateSamples();
209 void LogCalls(const Sampler& sampler);
210 void LogObjectCounter(const ObjectCounter& sampler);
211 void ResetSamplers();
214 const EnvironmentOptions& mEnvironmentOptions;
215 Sampler mActiveTextureSampler;
216 Sampler mClearSampler;
217 Sampler mBindBufferSampler;
218 Sampler mBindTextureSampler;
219 Sampler mDrawSampler;
220 Sampler mUniformSampler;
221 Sampler mUseProgramSampler;
222 ObjectCounter mBufferCount;
223 ObjectCounter mTextureCount;
224 ObjectCounter mProgramCount;
226 int mCurrentFrameCount;
227 int mTotalFrameCount;
230 } // namespace Adaptor
232 } // namespace Internal
236 #endif // DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H