1 #ifndef DALI_INTERNAL_GL_IMPLEMENTATION_H
2 #define DALI_INTERNAL_GL_IMPLEMENTATION_H
5 * Copyright (c) 2024 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 <GLES2/gl2.h>
23 #include <GLES2/gl2ext.h>
24 #include <dali/devel-api/threading/conditional-wait.h>
25 #include <dali/integration-api/gl-abstraction.h>
26 #include <dali/internal/graphics/common/egl-include.h>
27 #include <dali/public-api/common/vector-wrapper.h>
33 #include <dali/devel-api/adaptor-framework/environment-variable.h>
34 #include <dali/internal/graphics/gles/gl-extensions-support.h>
35 #include <dali/internal/graphics/gles/gles-abstraction.h>
36 #include <dali/internal/graphics/gles/gles2-implementation.h>
37 #include <dali/internal/graphics/gles/gles3-implementation.h>
38 #include <dali/internal/system/common/time-service.h>
48 #ifndef START_DURATION_CHECK
49 #define START_DURATION_CHECK() \
50 uint64_t startTimeNanoSeconds = 0ull; \
51 uint64_t endTimeNanoSeconds = 0ull; \
54 TimeService::GetNanoseconds(startTimeNanoSeconds); \
58 #ifndef FINISH_DURATION_CHECK
59 #define FINISH_DURATION_CHECK(functionName) \
62 TimeService::GetNanoseconds(endTimeNanoSeconds); \
63 if(static_cast<uint32_t>((endTimeNanoSeconds - startTimeNanoSeconds) / 1000000ull) >= mLogThreshold) \
65 DALI_LOG_RELEASE_INFO("%s takes long time! [%.6lf ms]\n", functionName, static_cast<double>(endTimeNanoSeconds - startTimeNanoSeconds) / 1000000.0); \
70 #ifndef FINISH_DURATION_CHECK_WITH_FORMAT
71 #define FINISH_DURATION_CHECK_WITH_FORMAT(functionName, format, ...) \
74 TimeService::GetNanoseconds(endTimeNanoSeconds); \
75 if(static_cast<uint32_t>((endTimeNanoSeconds - startTimeNanoSeconds) / 1000000ull) >= mLogThreshold) \
77 DALI_LOG_RELEASE_INFO("%s takes long time! [%.6lf ms] " format "\n", functionName, static_cast<double>(endTimeNanoSeconds - startTimeNanoSeconds) / 1000000.0, ##__VA_ARGS__); \
83 * GlImplementation is a concrete implementation for GlAbstraction.
84 * The class provides an OpenGL-ES 2.0 or 3.0 implementation.
85 * The class is provided when creating the Integration::Core object.
87 class GlImplementation : public Dali::Integration::GlAbstraction
92 virtual ~GlImplementation()
96 void PreRender() override
98 /* Do nothing in main implementation */
101 void PostRender() override
103 /* Do nothing in main implementation */
106 void ContextCreated();
108 void SetGlesVersion(const int32_t glesVersion)
110 if(mGlesVersion / 10 != glesVersion / 10)
112 mGlesVersion = glesVersion;
113 if(mGlesVersion >= 30)
115 mImpl.reset(new Gles3Implementation());
119 mImpl.reset(new Gles2Implementation());
124 void SetIsSurfacelessContextSupported(const bool isSupported)
126 mIsSurfacelessContextSupported = isSupported;
129 bool IsSurfacelessContextSupported() const override
131 return mIsSurfacelessContextSupported;
134 void SetIsAdvancedBlendEquationSupported(const bool isSupported)
136 mGlExtensionSupportedCacheList.MarkSupported(GlExtensionCache::GlExtensionCheckerType::BLEND_EQUATION_ADVANCED, isSupported);
139 bool IsAdvancedBlendEquationSupported() override
141 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
143 const auto type = GlExtensionCache::GlExtensionCheckerType::BLEND_EQUATION_ADVANCED;
144 if(!mIsContextCreated && !mGlExtensionSupportedCacheList.IsCached(type))
146 mContextCreatedWaitCondition.Wait(lock);
148 return mGlExtensionSupportedCacheList.IsSupported(type);
151 void SetIsMultisampledRenderToTextureSupported(const bool isSupported)
153 mGlExtensionSupportedCacheList.MarkSupported(GlExtensionCache::GlExtensionCheckerType::MULTISAMPLED_RENDER_TO_TEXTURE, isSupported);
156 bool IsMultisampledRenderToTextureSupported() override
158 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
160 const auto type = GlExtensionCache::GlExtensionCheckerType::MULTISAMPLED_RENDER_TO_TEXTURE;
161 if(!mIsContextCreated && !mGlExtensionSupportedCacheList.IsCached(type))
163 mContextCreatedWaitCondition.Wait(lock);
165 return mGlExtensionSupportedCacheList.IsSupported(type);
168 bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation) override
170 switch(blendEquation)
172 case DevelBlendEquation::ADD:
173 case DevelBlendEquation::SUBTRACT:
174 case DevelBlendEquation::REVERSE_SUBTRACT:
178 case DevelBlendEquation::MIN:
179 case DevelBlendEquation::MAX:
181 return (GetGlesVersion() >= 30);
183 case DevelBlendEquation::MULTIPLY:
184 case DevelBlendEquation::SCREEN:
185 case DevelBlendEquation::OVERLAY:
186 case DevelBlendEquation::DARKEN:
187 case DevelBlendEquation::LIGHTEN:
188 case DevelBlendEquation::COLOR_DODGE:
189 case DevelBlendEquation::COLOR_BURN:
190 case DevelBlendEquation::HARD_LIGHT:
191 case DevelBlendEquation::SOFT_LIGHT:
192 case DevelBlendEquation::DIFFERENCE:
193 case DevelBlendEquation::EXCLUSION:
194 case DevelBlendEquation::HUE:
195 case DevelBlendEquation::SATURATION:
196 case DevelBlendEquation::COLOR:
197 case DevelBlendEquation::LUMINOSITY:
199 return IsAdvancedBlendEquationSupported();
211 uint32_t GetShaderLanguageVersion() override
213 return static_cast<uint32_t>(GetShadingLanguageVersion());
216 std::string GetShaderVersionPrefix() override
218 if(mShaderVersionPrefix == "")
220 mShaderVersionPrefix = "#version " + std::to_string(GetShadingLanguageVersion());
221 if(GetShadingLanguageVersion() < 300)
223 mShaderVersionPrefix += "\n";
227 mShaderVersionPrefix += " es\n";
230 return mShaderVersionPrefix;
233 std::string GetVertexShaderPrefix() override
235 if(mVertexShaderPrefix == "")
237 mVertexShaderPrefix = GetShaderVersionPrefix();
239 if(GetShadingLanguageVersion() < 300)
241 mVertexShaderPrefix += "#define INPUT attribute\n";
242 mVertexShaderPrefix += "#define OUTPUT varying\n";
246 mVertexShaderPrefix += "#define INPUT in\n";
247 mVertexShaderPrefix += "#define OUTPUT out\n";
250 return mVertexShaderPrefix;
253 std::string GetFragmentShaderPrefix() override;
255 bool TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const override
257 bool convert = ((imageGlFormat == GL_RGB) && (textureGlFormat == GL_RGBA));
258 if(mGlesVersion >= 30)
260 // Don't convert manually from RGB to RGBA if GLES >= 3.0 and a sub-image is uploaded.
261 convert = (convert && !isSubImage);
266 int GetMaxTextureSize()
268 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
269 if(!mIsContextCreated)
271 mContextCreatedWaitCondition.Wait(lock);
273 return mMaxTextureSize;
276 int GetMaxCombinedTextureUnits()
278 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
279 if(!mIsContextCreated)
281 mContextCreatedWaitCondition.Wait(lock);
283 return mMaxCombinedTextureUnits;
286 int GetMaxTextureSamples()
288 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
289 if(!mIsContextCreated)
291 mContextCreatedWaitCondition.Wait(lock);
293 return mMaxTextureSamples;
296 int32_t GetGlesVersion()
298 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
299 if(!mIsContextCreated)
301 mContextCreatedWaitCondition.Wait(lock);
306 void SetShadingLanguageVersion(int shadingLanguageVersion)
308 mShadingLanguageVersion = shadingLanguageVersion;
309 mShadingLanguageVersionCached = true;
312 int GetShadingLanguageVersion()
314 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
315 if(!mIsContextCreated && !mShadingLanguageVersionCached)
317 mContextCreatedWaitCondition.Wait(lock);
319 return mShadingLanguageVersion;
322 bool ApplyNativeFragmentShader(std::string& shader, const char* customSamplerType);
326 void ActiveTexture(GLenum texture) override
328 glActiveTexture(texture);
331 void AttachShader(GLuint program, GLuint shader) override
333 glAttachShader(program, shader);
336 void BindAttribLocation(GLuint program, GLuint index, const char* name) override
338 glBindAttribLocation(program, index, name);
341 void BindBuffer(GLenum target, GLuint buffer) override
343 glBindBuffer(target, buffer);
346 void BindFramebuffer(GLenum target, GLuint framebuffer) override
348 glBindFramebuffer(target, framebuffer);
351 void BindRenderbuffer(GLenum target, GLuint renderbuffer) override
353 glBindRenderbuffer(target, renderbuffer);
356 void BindTexture(GLenum target, GLuint texture) override
358 glBindTexture(target, texture);
361 void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) override
363 glBlendColor(red, green, blue, alpha);
366 void BlendEquation(GLenum mode) override
368 glBlendEquation(mode);
371 void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) override
373 glBlendEquationSeparate(modeRGB, modeAlpha);
376 void BlendFunc(GLenum sfactor, GLenum dfactor) override
378 glBlendFunc(sfactor, dfactor);
381 void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) override
383 glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
386 void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) override
388 glBufferData(target, size, data, usage);
391 void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) override
393 glBufferSubData(target, offset, size, data);
396 GLenum CheckFramebufferStatus(GLenum target) override
398 return glCheckFramebufferStatus(target);
401 void Clear(GLbitfield mask) override
403 START_DURATION_CHECK();
407 FINISH_DURATION_CHECK("glClear");
410 void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) override
412 glClearColor(red, green, blue, alpha);
415 void ClearDepthf(GLclampf depth) override
417 glClearDepthf(depth);
420 void ClearStencil(GLint s) override
425 void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) override
427 glColorMask(red, green, blue, alpha);
430 void CompileShader(GLuint shader) override
432 START_DURATION_CHECK();
434 glCompileShader(shader);
436 FINISH_DURATION_CHECK_WITH_FORMAT("glCompileShader", "shader id : %u", shader);
439 void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) override
441 START_DURATION_CHECK();
443 glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
445 FINISH_DURATION_CHECK_WITH_FORMAT("glCompressedTexImage2D", "size : %u x %u", width, height);
448 void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) override
450 START_DURATION_CHECK();
452 glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
454 FINISH_DURATION_CHECK_WITH_FORMAT("glCompressedTexSubImage2D", "size : %u x %u", width, height);
457 void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) override
459 glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
462 void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) override
464 glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
467 GLuint CreateProgram(void) override
469 return glCreateProgram();
472 GLuint CreateShader(GLenum type) override
474 return glCreateShader(type);
477 void CullFace(GLenum mode) override
482 void DeleteBuffers(GLsizei n, const GLuint* buffers) override
484 glDeleteBuffers(n, buffers);
487 void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) override
489 glDeleteFramebuffers(n, framebuffers);
492 void DeleteProgram(GLuint program) override
494 glDeleteProgram(program);
497 void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) override
499 glDeleteRenderbuffers(n, renderbuffers);
502 void DeleteShader(GLuint shader) override
504 glDeleteShader(shader);
507 void DeleteTextures(GLsizei n, const GLuint* textures) override
509 glDeleteTextures(n, textures);
512 void DepthFunc(GLenum func) override
517 void DepthMask(GLboolean flag) override
522 void DepthRangef(GLclampf zNear, GLclampf zFar) override
524 glDepthRangef(zNear, zFar);
527 void DetachShader(GLuint program, GLuint shader) override
529 glDetachShader(program, shader);
532 void Disable(GLenum cap) override
537 void DisableVertexAttribArray(GLuint index) override
539 glDisableVertexAttribArray(index);
542 void DrawArrays(GLenum mode, GLint first, GLsizei count) override
544 glDrawArrays(mode, first, count);
547 void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) override
549 glDrawElements(mode, count, type, indices);
552 void Enable(GLenum cap) override
557 void EnableVertexAttribArray(GLuint index) override
559 glEnableVertexAttribArray(index);
562 void Finish(void) override
564 START_DURATION_CHECK();
568 FINISH_DURATION_CHECK("glFinish");
571 void Flush(void) override
573 START_DURATION_CHECK();
577 FINISH_DURATION_CHECK("glFlush");
580 void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) override
582 glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
585 void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) override
587 glFramebufferTexture2D(target, attachment, textarget, texture, level);
590 void FrontFace(GLenum mode) override
595 void GenBuffers(GLsizei n, GLuint* buffers) override
597 glGenBuffers(n, buffers);
600 void GenerateMipmap(GLenum target) override
602 glGenerateMipmap(target);
605 void GenFramebuffers(GLsizei n, GLuint* framebuffers) override
607 glGenFramebuffers(n, framebuffers);
610 void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) override
612 glGenRenderbuffers(n, renderbuffers);
615 void GenTextures(GLsizei n, GLuint* textures) override
617 glGenTextures(n, textures);
620 void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) override
622 glGetActiveAttrib(program, index, bufsize, length, size, type, name);
625 void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) override
627 glGetActiveUniform(program, index, bufsize, length, size, type, name);
630 void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) override
632 glGetAttachedShaders(program, maxcount, count, shaders);
635 int GetAttribLocation(GLuint program, const char* name) override
637 return glGetAttribLocation(program, name);
640 void GetBooleanv(GLenum pname, GLboolean* params) override
642 glGetBooleanv(pname, params);
645 void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) override
647 glGetBufferParameteriv(target, pname, params);
650 GLenum GetError(void) override
655 void GetFloatv(GLenum pname, GLfloat* params) override
657 glGetFloatv(pname, params);
660 void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) override
662 glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
665 void GetIntegerv(GLenum pname, GLint* params) override
667 glGetIntegerv(pname, params);
670 void GetProgramiv(GLuint program, GLenum pname, GLint* params) override
672 glGetProgramiv(program, pname, params);
675 void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) override
677 glGetProgramInfoLog(program, bufsize, length, infolog);
680 void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) override
682 glGetRenderbufferParameteriv(target, pname, params);
685 void GetShaderiv(GLuint shader, GLenum pname, GLint* params) override
687 glGetShaderiv(shader, pname, params);
690 void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) override
692 glGetShaderInfoLog(shader, bufsize, length, infolog);
695 void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) override
697 glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
700 void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) override
702 glGetShaderSource(shader, bufsize, length, source);
705 const GLubyte* GetString(GLenum name) override
707 return glGetString(name);
710 void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) override
712 glGetTexParameterfv(target, pname, params);
715 void GetTexParameteriv(GLenum target, GLenum pname, GLint* params) override
717 glGetTexParameteriv(target, pname, params);
720 void GetUniformfv(GLuint program, GLint location, GLfloat* params) override
722 glGetUniformfv(program, location, params);
725 void GetUniformiv(GLuint program, GLint location, GLint* params) override
727 glGetUniformiv(program, location, params);
730 int GetUniformLocation(GLuint program, const char* name) override
732 return glGetUniformLocation(program, name);
735 void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) override
737 glGetVertexAttribfv(index, pname, params);
740 void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) override
742 glGetVertexAttribiv(index, pname, params);
745 void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) override
747 glGetVertexAttribPointerv(index, pname, pointer);
750 void Hint(GLenum target, GLenum mode) override
752 glHint(target, mode);
755 GLboolean IsBuffer(GLuint buffer) override
757 return glIsBuffer(buffer);
760 GLboolean IsEnabled(GLenum cap) override
762 return glIsEnabled(cap);
765 GLboolean IsFramebuffer(GLuint framebuffer) override
767 return glIsFramebuffer(framebuffer);
770 GLboolean IsProgram(GLuint program) override
772 return glIsProgram(program);
775 GLboolean IsRenderbuffer(GLuint renderbuffer) override
777 return glIsRenderbuffer(renderbuffer);
780 GLboolean IsShader(GLuint shader) override
782 return glIsShader(shader);
785 GLboolean IsTexture(GLuint texture) override
787 return glIsTexture(texture);
790 void LineWidth(GLfloat width) override
795 void LinkProgram(GLuint program) override
797 START_DURATION_CHECK();
799 glLinkProgram(program);
801 FINISH_DURATION_CHECK_WITH_FORMAT("glLinkProgram", "program id : %u", program);
804 void PixelStorei(GLenum pname, GLint param) override
806 glPixelStorei(pname, param);
809 void PolygonOffset(GLfloat factor, GLfloat units) override
811 glPolygonOffset(factor, units);
814 void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) override
816 glReadPixels(x, y, width, height, format, type, pixels);
819 void ReleaseShaderCompiler(void) override
821 glReleaseShaderCompiler();
824 void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) override
826 glRenderbufferStorage(target, internalformat, width, height);
829 void SampleCoverage(GLclampf value, GLboolean invert) override
831 glSampleCoverage(value, invert);
834 void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) override
836 glScissor(x, y, width, height);
839 void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) override
841 glShaderBinary(n, shaders, binaryformat, binary, length);
844 void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) override
846 glShaderSource(shader, count, string, length);
849 void StencilFunc(GLenum func, GLint ref, GLuint mask) override
851 glStencilFunc(func, ref, mask);
854 void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) override
856 glStencilFuncSeparate(face, func, ref, mask);
859 void StencilMask(GLuint mask) override
864 void StencilMaskSeparate(GLenum face, GLuint mask) override
866 glStencilMaskSeparate(face, mask);
869 void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) override
871 glStencilOp(fail, zfail, zpass);
874 void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) override
876 glStencilOpSeparate(face, fail, zfail, zpass);
879 void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) override
881 START_DURATION_CHECK();
883 glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
885 FINISH_DURATION_CHECK_WITH_FORMAT("glTexImage2D", "size : %u x %u, format : %d, type : %d", width, height, static_cast<int>(format), static_cast<int>(type));
888 void TexParameterf(GLenum target, GLenum pname, GLfloat param) override
890 glTexParameterf(target, pname, param);
893 void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params) override
895 glTexParameterfv(target, pname, params);
898 void TexParameteri(GLenum target, GLenum pname, GLint param) override
900 glTexParameteri(target, pname, param);
903 void TexParameteriv(GLenum target, GLenum pname, const GLint* params) override
905 glTexParameteriv(target, pname, params);
908 void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) override
910 START_DURATION_CHECK();
912 glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
914 FINISH_DURATION_CHECK_WITH_FORMAT("glTexSubImage2D", "size : %u x %u, format : %d, type : %d", width, height, static_cast<int>(format), static_cast<int>(type));
917 void Uniform1f(GLint location, GLfloat x) override
919 glUniform1f(location, x);
922 void Uniform1fv(GLint location, GLsizei count, const GLfloat* v) override
924 glUniform1fv(location, count, v);
927 void Uniform1i(GLint location, GLint x) override
929 glUniform1i(location, x);
932 void Uniform1iv(GLint location, GLsizei count, const GLint* v) override
934 glUniform1iv(location, count, v);
937 void Uniform2f(GLint location, GLfloat x, GLfloat y) override
939 glUniform2f(location, x, y);
942 void Uniform2fv(GLint location, GLsizei count, const GLfloat* v) override
944 glUniform2fv(location, count, v);
947 void Uniform2i(GLint location, GLint x, GLint y) override
949 glUniform2i(location, x, y);
952 void Uniform2iv(GLint location, GLsizei count, const GLint* v) override
954 glUniform2iv(location, count, v);
957 void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) override
959 glUniform3f(location, x, y, z);
962 void Uniform3fv(GLint location, GLsizei count, const GLfloat* v) override
964 glUniform3fv(location, count, v);
967 void Uniform3i(GLint location, GLint x, GLint y, GLint z) override
969 glUniform3i(location, x, y, z);
972 void Uniform3iv(GLint location, GLsizei count, const GLint* v) override
974 glUniform3iv(location, count, v);
977 void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) override
979 glUniform4f(location, x, y, z, w);
982 void Uniform4fv(GLint location, GLsizei count, const GLfloat* v) override
984 glUniform4fv(location, count, v);
987 void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) override
989 glUniform4i(location, x, y, z, w);
992 void Uniform4iv(GLint location, GLsizei count, const GLint* v) override
994 glUniform4iv(location, count, v);
997 void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
999 glUniformMatrix2fv(location, count, transpose, value);
1002 void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1004 glUniformMatrix3fv(location, count, transpose, value);
1007 void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1009 glUniformMatrix4fv(location, count, transpose, value);
1012 void UseProgram(GLuint program) override
1014 glUseProgram(program);
1017 void ValidateProgram(GLuint program) override
1019 glValidateProgram(program);
1022 void VertexAttrib1f(GLuint indx, GLfloat x) override
1024 glVertexAttrib1f(indx, x);
1027 void VertexAttrib1fv(GLuint indx, const GLfloat* values) override
1029 glVertexAttrib1fv(indx, values);
1032 void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) override
1034 glVertexAttrib2f(indx, x, y);
1037 void VertexAttrib2fv(GLuint indx, const GLfloat* values) override
1039 glVertexAttrib2fv(indx, values);
1042 void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) override
1044 glVertexAttrib3f(indx, x, y, z);
1047 void VertexAttrib3fv(GLuint indx, const GLfloat* values) override
1049 glVertexAttrib3fv(indx, values);
1052 void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) override
1054 glVertexAttrib4f(indx, x, y, z, w);
1057 void VertexAttrib4fv(GLuint indx, const GLfloat* values) override
1059 glVertexAttrib4fv(indx, values);
1062 void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) override
1064 glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
1067 void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) override
1069 glViewport(x, y, width, height);
1074 void ReadBuffer(GLenum mode) override
1076 mImpl->ReadBuffer(mode);
1079 void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) override
1081 mImpl->DrawRangeElements(mode, start, end, count, type, indices);
1084 void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) override
1086 mImpl->TexImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels);
1089 void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) override
1091 mImpl->TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
1094 void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) override
1096 mImpl->CopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height);
1099 void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) override
1101 mImpl->CompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data);
1104 void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) override
1106 mImpl->CompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
1109 void GenQueries(GLsizei n, GLuint* ids) override
1111 mImpl->GenQueries(n, ids);
1114 void DeleteQueries(GLsizei n, const GLuint* ids) override
1116 mImpl->DeleteQueries(n, ids);
1119 GLboolean IsQuery(GLuint id) override
1121 return mImpl->IsQuery(id);
1124 void BeginQuery(GLenum target, GLuint id) override
1126 mImpl->BeginQuery(target, id);
1129 void EndQuery(GLenum target) override
1131 mImpl->EndQuery(target);
1134 void GetQueryiv(GLenum target, GLenum pname, GLint* params) override
1136 mImpl->GetQueryiv(target, pname, params);
1139 void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) override
1141 mImpl->GetQueryObjectuiv(id, pname, params);
1144 GLboolean UnmapBuffer(GLenum target) override
1146 return mImpl->UnmapBuffer(target);
1149 void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) override
1151 mImpl->GetBufferPointerv(target, pname, params);
1154 void DrawBuffers(GLsizei n, const GLenum* bufs) override
1156 mImpl->DrawBuffers(n, bufs);
1159 void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1161 mImpl->UniformMatrix2x3fv(location, count, transpose, value);
1164 void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1166 mImpl->UniformMatrix3x2fv(location, count, transpose, value);
1169 void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1171 mImpl->UniformMatrix2x4fv(location, count, transpose, value);
1174 void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1176 mImpl->UniformMatrix4x2fv(location, count, transpose, value);
1179 void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1181 mImpl->UniformMatrix3x4fv(location, count, transpose, value);
1184 void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1186 mImpl->UniformMatrix4x3fv(location, count, transpose, value);
1189 void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) override
1191 mImpl->BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
1194 void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) override
1196 mImpl->RenderbufferStorageMultisample(target, samples, internalformat, width, height);
1199 void FramebufferTexture2DMultisample(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) override
1201 mImpl->FramebufferTexture2DMultisample(target, attachment, textarget, texture, level, samples);
1204 void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) override
1206 mImpl->FramebufferTextureLayer(target, attachment, texture, level, layer);
1209 GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) override
1211 return mImpl->MapBufferRange(target, offset, length, access);
1214 void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) override
1216 mImpl->FlushMappedBufferRange(target, offset, length);
1219 void BindVertexArray(GLuint array) override
1221 mImpl->BindVertexArray(array);
1224 void DeleteVertexArrays(GLsizei n, const GLuint* arrays) override
1226 mImpl->DeleteVertexArrays(n, arrays);
1229 void GenVertexArrays(GLsizei n, GLuint* arrays) override
1231 mImpl->GenVertexArrays(n, arrays);
1234 GLboolean IsVertexArray(GLuint array) override
1236 return mImpl->IsVertexArray(array);
1239 void GetIntegeri_v(GLenum target, GLuint index, GLint* data) override
1241 mImpl->GetIntegeri_v(target, index, data);
1244 void BeginTransformFeedback(GLenum primitiveMode) override
1246 mImpl->BeginTransformFeedback(primitiveMode);
1249 void EndTransformFeedback(void) override
1251 mImpl->EndTransformFeedback();
1254 void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) override
1256 mImpl->BindBufferRange(target, index, buffer, offset, size);
1259 void BindBufferBase(GLenum target, GLuint index, GLuint buffer) override
1261 mImpl->BindBufferBase(target, index, buffer);
1264 void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) override
1266 mImpl->TransformFeedbackVaryings(program, count, varyings, bufferMode);
1269 void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) override
1271 mImpl->GetTransformFeedbackVarying(program, index, bufSize, length, size, type, name);
1274 void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) override
1276 mImpl->VertexAttribIPointer(index, size, type, stride, pointer);
1279 void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) override
1281 mImpl->GetVertexAttribIiv(index, pname, params);
1284 void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) override
1286 mImpl->GetVertexAttribIuiv(index, pname, params);
1289 void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) override
1291 mImpl->VertexAttribI4i(index, x, y, z, w);
1294 void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) override
1296 mImpl->VertexAttribI4ui(index, x, y, z, w);
1299 void VertexAttribI4iv(GLuint index, const GLint* v) override
1301 mImpl->VertexAttribI4iv(index, v);
1304 void VertexAttribI4uiv(GLuint index, const GLuint* v) override
1306 mImpl->VertexAttribI4uiv(index, v);
1309 void GetUniformuiv(GLuint program, GLint location, GLuint* params) override
1311 mImpl->GetUniformuiv(program, location, params);
1314 GLint GetFragDataLocation(GLuint program, const GLchar* name) override
1316 return mImpl->GetFragDataLocation(program, name);
1319 void Uniform1ui(GLint location, GLuint v0) override
1321 mImpl->Uniform1ui(location, v0);
1324 void Uniform2ui(GLint location, GLuint v0, GLuint v1) override
1326 mImpl->Uniform2ui(location, v0, v1);
1329 void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) override
1331 mImpl->Uniform3ui(location, v0, v1, v2);
1334 void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) override
1336 mImpl->Uniform4ui(location, v0, v1, v2, v3);
1339 void Uniform1uiv(GLint location, GLsizei count, const GLuint* value) override
1341 mImpl->Uniform1uiv(location, count, value);
1344 void Uniform2uiv(GLint location, GLsizei count, const GLuint* value) override
1346 mImpl->Uniform2uiv(location, count, value);
1349 void Uniform3uiv(GLint location, GLsizei count, const GLuint* value) override
1351 mImpl->Uniform3uiv(location, count, value);
1354 void Uniform4uiv(GLint location, GLsizei count, const GLuint* value) override
1356 mImpl->Uniform4uiv(location, count, value);
1359 void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) override
1361 mImpl->ClearBufferiv(buffer, drawbuffer, value);
1364 void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) override
1366 mImpl->ClearBufferuiv(buffer, drawbuffer, value);
1369 void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) override
1371 mImpl->ClearBufferfv(buffer, drawbuffer, value);
1374 void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) override
1376 mImpl->ClearBufferfi(buffer, drawbuffer, depth, stencil);
1379 const GLubyte* GetStringi(GLenum name, GLuint index) override
1381 return mImpl->GetStringi(name, index);
1384 void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) override
1386 mImpl->CopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
1389 void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) override
1391 mImpl->GetUniformIndices(program, uniformCount, uniformNames, uniformIndices);
1394 void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) override
1396 mImpl->GetActiveUniformsiv(program, uniformCount, uniformIndices, pname, params);
1399 GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) override
1401 return mImpl->GetUniformBlockIndex(program, uniformBlockName);
1404 void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) override
1406 mImpl->GetActiveUniformBlockiv(program, uniformBlockIndex, pname, params);
1409 void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) override
1411 mImpl->GetActiveUniformBlockName(program, uniformBlockIndex, bufSize, length, uniformBlockName);
1414 void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) override
1416 mImpl->UniformBlockBinding(program, uniformBlockIndex, uniformBlockBinding);
1419 void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) override
1421 mImpl->DrawArraysInstanced(mode, first, count, instanceCount);
1424 void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) override
1426 mImpl->DrawElementsInstanced(mode, count, type, indices, instanceCount);
1429 GLsync FenceSync(GLenum condition, GLbitfield flags) override
1431 return mImpl->FenceSync(condition, flags);
1434 GLboolean IsSync(GLsync sync) override
1436 return mImpl->IsSync(sync);
1439 void DeleteSync(GLsync sync) override
1441 mImpl->DeleteSync(sync);
1444 GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) override
1446 return mImpl->ClientWaitSync(sync, flags, timeout);
1449 void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) override
1451 mImpl->WaitSync(sync, flags, timeout);
1454 void GetInteger64v(GLenum pname, GLint64* params) override
1456 mImpl->GetInteger64v(pname, params);
1459 void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) override
1461 mImpl->GetSynciv(sync, pname, bufSize, length, values);
1464 void GetInteger64i_v(GLenum target, GLuint index, GLint64* data) override
1466 mImpl->GetInteger64i_v(target, index, data);
1469 void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) override
1471 mImpl->GetBufferParameteri64v(target, pname, params);
1474 void GenSamplers(GLsizei count, GLuint* samplers) override
1476 mImpl->GenSamplers(count, samplers);
1479 void DeleteSamplers(GLsizei count, const GLuint* samplers) override
1481 mImpl->DeleteSamplers(count, samplers);
1484 GLboolean IsSampler(GLuint sampler) override
1486 return mImpl->IsSampler(sampler);
1489 void BindSampler(GLuint unit, GLuint sampler) override
1491 mImpl->BindSampler(unit, sampler);
1494 void SamplerParameteri(GLuint sampler, GLenum pname, GLint param) override
1496 mImpl->SamplerParameteri(sampler, pname, param);
1499 void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) override
1501 mImpl->SamplerParameteriv(sampler, pname, param);
1504 void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) override
1506 mImpl->SamplerParameterf(sampler, pname, param);
1509 void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) override
1511 mImpl->SamplerParameterfv(sampler, pname, param);
1514 void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) override
1516 mImpl->GetSamplerParameteriv(sampler, pname, params);
1519 void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) override
1521 mImpl->GetSamplerParameterfv(sampler, pname, params);
1524 void VertexAttribDivisor(GLuint index, GLuint divisor) override
1526 mImpl->VertexAttribDivisor(index, divisor);
1529 void BindTransformFeedback(GLenum target, GLuint id) override
1531 mImpl->BindTransformFeedback(target, id);
1534 void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids) override
1536 mImpl->DeleteTransformFeedbacks(n, ids);
1539 void GenTransformFeedbacks(GLsizei n, GLuint* ids) override
1541 mImpl->GenTransformFeedbacks(n, ids);
1544 GLboolean IsTransformFeedback(GLuint id) override
1546 return mImpl->IsTransformFeedback(id);
1549 void PauseTransformFeedback(void) override
1551 mImpl->PauseTransformFeedback();
1554 void ResumeTransformFeedback(void) override
1556 mImpl->ResumeTransformFeedback();
1559 void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) override
1561 mImpl->GetProgramBinary(program, bufSize, length, binaryFormat, binary);
1564 void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) override
1566 mImpl->ProgramBinary(program, binaryFormat, binary, length);
1569 void ProgramParameteri(GLuint program, GLenum pname, GLint value) override
1571 mImpl->ProgramParameteri(program, pname, value);
1574 void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) override
1576 mImpl->InvalidateFramebuffer(target, numAttachments, attachments);
1579 void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) override
1581 mImpl->InvalidateSubFramebuffer(target, numAttachments, attachments, x, y, width, height);
1584 void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) override
1586 mImpl->TexStorage2D(target, levels, internalformat, width, height);
1589 void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) override
1591 mImpl->TexStorage3D(target, levels, internalformat, width, height, depth);
1594 void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) override
1596 mImpl->GetInternalformativ(target, internalformat, pname, bufSize, params);
1599 void BlendBarrier(void)
1601 if(mGlExtensionSupportedCacheList.IsSupported(GlExtensionCache::GlExtensionCheckerType::BLEND_EQUATION_ADVANCED))
1603 mImpl->BlendBarrier();
1608 std::unique_ptr<GlesAbstraction> mImpl;
1610 GlExtensionCache::GlExtensionSupportedCacheList mGlExtensionSupportedCacheList;
1612 ConditionalWait mContextCreatedWaitCondition;
1613 GLint mMaxTextureSize;
1614 GLint mMaxCombinedTextureUnits;
1615 GLint mMaxTextureSamples;
1616 std::string mShaderVersionPrefix;
1617 std::string mVertexShaderPrefix;
1618 std::string mFragmentShaderPrefix;
1619 int32_t mGlesVersion;
1620 int32_t mShadingLanguageVersion;
1621 uint32_t mLogThreshold{0};
1622 bool mShadingLanguageVersionCached;
1623 bool mIsSurfacelessContextSupported;
1624 bool mIsContextCreated;
1625 bool mLogEnabled{false};
1627 #ifdef START_DURATION_CHECK
1628 #undef START_DURATION_CHECK
1631 #ifdef FINISH_DURATION_CHECK
1632 #undef FINISH_DURATION_CHECK
1635 #ifdef FINISH_DURATION_CHECK_WITH_FORMAT
1636 #undef FINISH_DURATION_CHECK_WITH_FORMAT
1639 } // namespace Adaptor
1641 } // namespace Internal
1645 #endif // DALI_INTERNAL_GL_IMPLEMENTATION_H