1 #ifndef DALI_INTERNAL_GL_IMPLEMENTATION_H
2 #define DALI_INTERNAL_GL_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 <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>
31 #include <dali/internal/graphics/gles/gles-abstraction.h>
32 #include <dali/internal/graphics/gles/gles2-implementation.h>
33 #include <dali/internal/graphics/gles/gles3-implementation.h>
43 static constexpr int32_t INITIAL_GLES_VERSION = 30;
44 static constexpr int32_t GLES_VERSION_SUPPORT_BLEND_EQUATION_ADVANCED = 32;
45 static constexpr const char* KHR_BLEND_EQUATION_ADVANCED = "GL_KHR_blend_equation_advanced";
47 static constexpr const char* FRAGMENT_SHADER_ADVANCED_BLEND_EQUATION_PREFIX =
48 "#extension GL_KHR_blend_equation_advanced : enable\n"
50 "#if GL_KHR_blend_equation_advanced==1 || __VERSION__>=320\n"
51 " layout(blend_support_all_equations) out;\n"
54 static constexpr const char* FRAGMENT_SHADER_OUTPUT_COLOR_STRING =
55 "out mediump vec4 fragColor;\n";
57 static constexpr const char* OES_EGL_IMAGE_EXTERNAL_STRING = "#extension GL_OES_EGL_image_external:require\n";
59 static constexpr const char* OES_EGL_IMAGE_EXTERNAL_STRING_ESSL3 = "#extension GL_OES_EGL_image_external_essl3:require\n";
63 * GlImplementation is a concrete implementation for GlAbstraction.
64 * The class provides an OpenGL-ES 2.0 or 3.0 implementation.
65 * The class is provided when creating the Integration::Core object.
67 class GlImplementation : public Dali::Integration::GlAbstraction
71 : mContextCreatedWaitCondition(),
73 mVertexShaderPrefix(""),
74 mGlesVersion(INITIAL_GLES_VERSION),
75 mShadingLanguageVersion(100),
76 mShadingLanguageVersionCached(false),
77 mIsSurfacelessContextSupported(false),
78 mIsAdvancedBlendEquationSupportedCached(false),
79 mIsAdvancedBlendEquationSupported(false),
80 mIsContextCreated(false)
82 mImpl.reset(new Gles3Implementation());
85 virtual ~GlImplementation()
89 void PreRender() override
91 /* Do nothing in main implementation */
94 void PostRender() override
96 /* Do nothing in main implementation */
101 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
103 // Only change gles version for the device that support above gles 3.0.
104 if(mGlesVersion >= INITIAL_GLES_VERSION)
106 GLint majorVersion, minorVersion;
107 glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
108 glGetIntegerv(GL_MINOR_VERSION, &minorVersion);
109 mGlesVersion = majorVersion * 10 + minorVersion;
112 if(mGlesVersion >= GLES_VERSION_SUPPORT_BLEND_EQUATION_ADVANCED)
114 mIsAdvancedBlendEquationSupported = true;
118 // when mIsAdvancedBlendEquationSupported is cached, we don't need to check all the extensions.
119 if(!mIsAdvancedBlendEquationSupportedCached)
121 const char* const extensionStr = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
122 std::istringstream stream(extensionStr);
123 std::string currentExtension;
124 while(std::getline(stream, currentExtension, ' '))
126 if(currentExtension == KHR_BLEND_EQUATION_ADVANCED)
128 mIsAdvancedBlendEquationSupported = true;
135 if(!mShadingLanguageVersionCached)
137 std::istringstream shadingLanguageVersionStream(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
139 uint32_t tokenCount = 0;
140 while(std::getline(shadingLanguageVersionStream, token, ' '))
142 if(tokenCount == 3 && token == "ES")
144 std::getline(shadingLanguageVersionStream, token, '.');
145 mShadingLanguageVersion = std::atoi(token.c_str());
146 mShadingLanguageVersion *= 100;
147 std::getline(shadingLanguageVersionStream, token, '.');
148 mShadingLanguageVersion += std::atoi(token.c_str());
156 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
157 mIsContextCreated = true;
158 mContextCreatedWaitCondition.Notify(lock);
162 void SetGlesVersion(const int32_t glesVersion)
164 if(mGlesVersion / 10 != glesVersion / 10)
166 mGlesVersion = glesVersion;
167 if(mGlesVersion >= 30)
169 mImpl.reset(new Gles3Implementation());
173 mImpl.reset(new Gles2Implementation());
178 void SetIsSurfacelessContextSupported(const bool isSupported)
180 mIsSurfacelessContextSupported = isSupported;
183 bool IsSurfacelessContextSupported() const override
185 return mIsSurfacelessContextSupported;
188 void SetIsAdvancedBlendEquationSupported(const bool isSupported)
190 mIsAdvancedBlendEquationSupported = isSupported;
191 mIsAdvancedBlendEquationSupportedCached = true;
194 bool IsAdvancedBlendEquationSupported()
196 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
197 if(!mIsContextCreated && !mIsAdvancedBlendEquationSupportedCached)
199 mContextCreatedWaitCondition.Wait(lock);
201 return mIsAdvancedBlendEquationSupported;
204 bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation)
206 switch(blendEquation)
208 case DevelBlendEquation::ADD:
209 case DevelBlendEquation::SUBTRACT:
210 case DevelBlendEquation::REVERSE_SUBTRACT:
214 case DevelBlendEquation::MIN:
215 case DevelBlendEquation::MAX:
217 return (GetGlesVersion() >= 30);
219 case DevelBlendEquation::MULTIPLY:
220 case DevelBlendEquation::SCREEN:
221 case DevelBlendEquation::OVERLAY:
222 case DevelBlendEquation::DARKEN:
223 case DevelBlendEquation::LIGHTEN:
224 case DevelBlendEquation::COLOR_DODGE:
225 case DevelBlendEquation::COLOR_BURN:
226 case DevelBlendEquation::HARD_LIGHT:
227 case DevelBlendEquation::SOFT_LIGHT:
228 case DevelBlendEquation::DIFFERENCE:
229 case DevelBlendEquation::EXCLUSION:
230 case DevelBlendEquation::HUE:
231 case DevelBlendEquation::SATURATION:
232 case DevelBlendEquation::COLOR:
233 case DevelBlendEquation::LUMINOSITY:
235 return IsAdvancedBlendEquationSupported();
247 std::string GetShaderVersionPrefix()
249 if(mShaderVersionPrefix == "")
251 mShaderVersionPrefix = "#version " + std::to_string(GetShadingLanguageVersion());
252 if(GetShadingLanguageVersion() < 300)
254 mShaderVersionPrefix += "\n";
258 mShaderVersionPrefix += " es\n";
261 return mShaderVersionPrefix;
264 std::string GetVertexShaderPrefix()
266 if(mVertexShaderPrefix == "")
268 mVertexShaderPrefix = GetShaderVersionPrefix();
270 if(GetShadingLanguageVersion() < 300)
272 mVertexShaderPrefix += "#define INPUT attribute\n";
273 mVertexShaderPrefix += "#define OUTPUT varying\n";
277 mVertexShaderPrefix += "#define INPUT in\n";
278 mVertexShaderPrefix += "#define OUTPUT out\n";
281 return mVertexShaderPrefix;
284 std::string GetFragmentShaderPrefix()
286 if(mFragmentShaderPrefix == "")
288 mFragmentShaderPrefix = GetShaderVersionPrefix();
290 if(GetShadingLanguageVersion() < 300)
292 mFragmentShaderPrefix += "#define INPUT varying\n";
293 mFragmentShaderPrefix += "#define OUT_COLOR gl_FragColor\n";
294 mFragmentShaderPrefix += "#define TEXTURE texture2D\n";
298 mFragmentShaderPrefix += "#define INPUT in\n";
299 mFragmentShaderPrefix += "#define OUT_COLOR fragColor\n";
300 mFragmentShaderPrefix += "#define TEXTURE texture\n";
302 if(IsAdvancedBlendEquationSupported())
304 mFragmentShaderPrefix += FRAGMENT_SHADER_ADVANCED_BLEND_EQUATION_PREFIX;
307 mFragmentShaderPrefix += FRAGMENT_SHADER_OUTPUT_COLOR_STRING;
310 return mFragmentShaderPrefix;
313 bool TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const override
315 bool convert = ((imageGlFormat == GL_RGB) && (textureGlFormat == GL_RGBA));
316 if(mGlesVersion >= 30)
318 // Don't convert manually from RGB to RGBA if GLES >= 3.0 and a sub-image is uploaded.
319 convert = (convert && !isSubImage);
324 int GetMaxTextureSize()
326 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
327 if(!mIsContextCreated)
329 mContextCreatedWaitCondition.Wait(lock);
331 return mMaxTextureSize;
336 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
337 if(!mIsContextCreated)
339 mContextCreatedWaitCondition.Wait(lock);
344 void SetShadingLanguageVersion(int shadingLanguageVersion)
346 mShadingLanguageVersion = shadingLanguageVersion;
347 mShadingLanguageVersionCached = true;
350 int GetShadingLanguageVersion()
352 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
353 if(!mIsContextCreated && !mShadingLanguageVersionCached)
355 mContextCreatedWaitCondition.Wait(lock);
357 return mShadingLanguageVersion;
360 const char* GetEglImageExtensionString()
362 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
363 if(!mIsContextCreated)
365 mContextCreatedWaitCondition.Wait(lock);
367 if(mShadingLanguageVersion < 300)
369 return OES_EGL_IMAGE_EXTERNAL_STRING;
373 return OES_EGL_IMAGE_EXTERNAL_STRING_ESSL3;
379 void ActiveTexture(GLenum texture) override
381 glActiveTexture(texture);
384 void AttachShader(GLuint program, GLuint shader) override
386 glAttachShader(program, shader);
389 void BindAttribLocation(GLuint program, GLuint index, const char* name) override
391 glBindAttribLocation(program, index, name);
394 void BindBuffer(GLenum target, GLuint buffer) override
396 glBindBuffer(target, buffer);
399 void BindFramebuffer(GLenum target, GLuint framebuffer) override
401 glBindFramebuffer(target, framebuffer);
404 void BindRenderbuffer(GLenum target, GLuint renderbuffer) override
406 glBindRenderbuffer(target, renderbuffer);
409 void BindTexture(GLenum target, GLuint texture) override
411 glBindTexture(target, texture);
414 void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) override
416 glBlendColor(red, green, blue, alpha);
419 void BlendEquation(GLenum mode) override
421 glBlendEquation(mode);
424 void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) override
426 glBlendEquationSeparate(modeRGB, modeAlpha);
429 void BlendFunc(GLenum sfactor, GLenum dfactor) override
431 glBlendFunc(sfactor, dfactor);
434 void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) override
436 glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
439 void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) override
441 glBufferData(target, size, data, usage);
444 void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) override
446 glBufferSubData(target, offset, size, data);
449 GLenum CheckFramebufferStatus(GLenum target) override
451 return glCheckFramebufferStatus(target);
454 void Clear(GLbitfield mask) override
459 void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) override
461 glClearColor(red, green, blue, alpha);
464 void ClearDepthf(GLclampf depth) override
466 glClearDepthf(depth);
469 void ClearStencil(GLint s) override
474 void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) override
476 glColorMask(red, green, blue, alpha);
479 void CompileShader(GLuint shader) override
481 glCompileShader(shader);
484 void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) override
486 glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
489 void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) override
491 glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
494 void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) override
496 glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
499 void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) override
501 glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
504 GLuint CreateProgram(void) override
506 return glCreateProgram();
509 GLuint CreateShader(GLenum type) override
511 return glCreateShader(type);
514 void CullFace(GLenum mode) override
519 void DeleteBuffers(GLsizei n, const GLuint* buffers) override
521 glDeleteBuffers(n, buffers);
524 void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) override
526 glDeleteFramebuffers(n, framebuffers);
529 void DeleteProgram(GLuint program) override
531 glDeleteProgram(program);
534 void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) override
536 glDeleteRenderbuffers(n, renderbuffers);
539 void DeleteShader(GLuint shader) override
541 glDeleteShader(shader);
544 void DeleteTextures(GLsizei n, const GLuint* textures) override
546 glDeleteTextures(n, textures);
549 void DepthFunc(GLenum func) override
554 void DepthMask(GLboolean flag) override
559 void DepthRangef(GLclampf zNear, GLclampf zFar) override
561 glDepthRangef(zNear, zFar);
564 void DetachShader(GLuint program, GLuint shader) override
566 glDetachShader(program, shader);
569 void Disable(GLenum cap) override
574 void DisableVertexAttribArray(GLuint index) override
576 glDisableVertexAttribArray(index);
579 void DrawArrays(GLenum mode, GLint first, GLsizei count) override
581 glDrawArrays(mode, first, count);
584 void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) override
586 glDrawElements(mode, count, type, indices);
589 void Enable(GLenum cap) override
594 void EnableVertexAttribArray(GLuint index) override
596 glEnableVertexAttribArray(index);
599 void Finish(void) override
604 void Flush(void) override
609 void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) override
611 glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
614 void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) override
616 glFramebufferTexture2D(target, attachment, textarget, texture, level);
619 void FrontFace(GLenum mode) override
624 void GenBuffers(GLsizei n, GLuint* buffers) override
626 glGenBuffers(n, buffers);
629 void GenerateMipmap(GLenum target) override
631 glGenerateMipmap(target);
634 void GenFramebuffers(GLsizei n, GLuint* framebuffers) override
636 glGenFramebuffers(n, framebuffers);
639 void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) override
641 glGenRenderbuffers(n, renderbuffers);
644 void GenTextures(GLsizei n, GLuint* textures) override
646 glGenTextures(n, textures);
649 void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) override
651 glGetActiveAttrib(program, index, bufsize, length, size, type, name);
654 void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) override
656 glGetActiveUniform(program, index, bufsize, length, size, type, name);
659 void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) override
661 glGetAttachedShaders(program, maxcount, count, shaders);
664 int GetAttribLocation(GLuint program, const char* name) override
666 return glGetAttribLocation(program, name);
669 void GetBooleanv(GLenum pname, GLboolean* params) override
671 glGetBooleanv(pname, params);
674 void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) override
676 glGetBufferParameteriv(target, pname, params);
679 GLenum GetError(void) override
684 void GetFloatv(GLenum pname, GLfloat* params) override
686 glGetFloatv(pname, params);
689 void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) override
691 glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
694 void GetIntegerv(GLenum pname, GLint* params) override
696 glGetIntegerv(pname, params);
699 void GetProgramiv(GLuint program, GLenum pname, GLint* params) override
701 glGetProgramiv(program, pname, params);
704 void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) override
706 glGetProgramInfoLog(program, bufsize, length, infolog);
709 void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) override
711 glGetRenderbufferParameteriv(target, pname, params);
714 void GetShaderiv(GLuint shader, GLenum pname, GLint* params) override
716 glGetShaderiv(shader, pname, params);
719 void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) override
721 glGetShaderInfoLog(shader, bufsize, length, infolog);
724 void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) override
726 glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
729 void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) override
731 glGetShaderSource(shader, bufsize, length, source);
734 const GLubyte* GetString(GLenum name) override
736 return glGetString(name);
739 void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) override
741 glGetTexParameterfv(target, pname, params);
744 void GetTexParameteriv(GLenum target, GLenum pname, GLint* params) override
746 glGetTexParameteriv(target, pname, params);
749 void GetUniformfv(GLuint program, GLint location, GLfloat* params) override
751 glGetUniformfv(program, location, params);
754 void GetUniformiv(GLuint program, GLint location, GLint* params) override
756 glGetUniformiv(program, location, params);
759 int GetUniformLocation(GLuint program, const char* name) override
761 return glGetUniformLocation(program, name);
764 void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) override
766 glGetVertexAttribfv(index, pname, params);
769 void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) override
771 glGetVertexAttribiv(index, pname, params);
774 void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) override
776 glGetVertexAttribPointerv(index, pname, pointer);
779 void Hint(GLenum target, GLenum mode) override
781 glHint(target, mode);
784 GLboolean IsBuffer(GLuint buffer) override
786 return glIsBuffer(buffer);
789 GLboolean IsEnabled(GLenum cap) override
791 return glIsEnabled(cap);
794 GLboolean IsFramebuffer(GLuint framebuffer) override
796 return glIsFramebuffer(framebuffer);
799 GLboolean IsProgram(GLuint program) override
801 return glIsProgram(program);
804 GLboolean IsRenderbuffer(GLuint renderbuffer) override
806 return glIsRenderbuffer(renderbuffer);
809 GLboolean IsShader(GLuint shader) override
811 return glIsShader(shader);
814 GLboolean IsTexture(GLuint texture) override
816 return glIsTexture(texture);
819 void LineWidth(GLfloat width) override
824 void LinkProgram(GLuint program) override
826 glLinkProgram(program);
829 void PixelStorei(GLenum pname, GLint param) override
831 glPixelStorei(pname, param);
834 void PolygonOffset(GLfloat factor, GLfloat units) override
836 glPolygonOffset(factor, units);
839 void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) override
841 glReadPixels(x, y, width, height, format, type, pixels);
844 void ReleaseShaderCompiler(void) override
846 glReleaseShaderCompiler();
849 void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) override
851 glRenderbufferStorage(target, internalformat, width, height);
854 void SampleCoverage(GLclampf value, GLboolean invert) override
856 glSampleCoverage(value, invert);
859 void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) override
861 glScissor(x, y, width, height);
864 void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) override
866 glShaderBinary(n, shaders, binaryformat, binary, length);
869 void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) override
871 glShaderSource(shader, count, string, length);
874 void StencilFunc(GLenum func, GLint ref, GLuint mask) override
876 glStencilFunc(func, ref, mask);
879 void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) override
881 glStencilFuncSeparate(face, func, ref, mask);
884 void StencilMask(GLuint mask) override
889 void StencilMaskSeparate(GLenum face, GLuint mask) override
891 glStencilMaskSeparate(face, mask);
894 void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) override
896 glStencilOp(fail, zfail, zpass);
899 void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) override
901 glStencilOpSeparate(face, fail, zfail, zpass);
904 void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) override
906 glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
909 void TexParameterf(GLenum target, GLenum pname, GLfloat param) override
911 glTexParameterf(target, pname, param);
914 void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params) override
916 glTexParameterfv(target, pname, params);
919 void TexParameteri(GLenum target, GLenum pname, GLint param) override
921 glTexParameteri(target, pname, param);
924 void TexParameteriv(GLenum target, GLenum pname, const GLint* params) override
926 glTexParameteriv(target, pname, params);
929 void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) override
931 glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
934 void Uniform1f(GLint location, GLfloat x) override
936 glUniform1f(location, x);
939 void Uniform1fv(GLint location, GLsizei count, const GLfloat* v) override
941 glUniform1fv(location, count, v);
944 void Uniform1i(GLint location, GLint x) override
946 glUniform1i(location, x);
949 void Uniform1iv(GLint location, GLsizei count, const GLint* v) override
951 glUniform1iv(location, count, v);
954 void Uniform2f(GLint location, GLfloat x, GLfloat y) override
956 glUniform2f(location, x, y);
959 void Uniform2fv(GLint location, GLsizei count, const GLfloat* v) override
961 glUniform2fv(location, count, v);
964 void Uniform2i(GLint location, GLint x, GLint y) override
966 glUniform2i(location, x, y);
969 void Uniform2iv(GLint location, GLsizei count, const GLint* v) override
971 glUniform2iv(location, count, v);
974 void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) override
976 glUniform3f(location, x, y, z);
979 void Uniform3fv(GLint location, GLsizei count, const GLfloat* v) override
981 glUniform3fv(location, count, v);
984 void Uniform3i(GLint location, GLint x, GLint y, GLint z) override
986 glUniform3i(location, x, y, z);
989 void Uniform3iv(GLint location, GLsizei count, const GLint* v) override
991 glUniform3iv(location, count, v);
994 void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) override
996 glUniform4f(location, x, y, z, w);
999 void Uniform4fv(GLint location, GLsizei count, const GLfloat* v) override
1001 glUniform4fv(location, count, v);
1004 void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) override
1006 glUniform4i(location, x, y, z, w);
1009 void Uniform4iv(GLint location, GLsizei count, const GLint* v) override
1011 glUniform4iv(location, count, v);
1014 void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1016 glUniformMatrix2fv(location, count, transpose, value);
1019 void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1021 glUniformMatrix3fv(location, count, transpose, value);
1024 void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1026 glUniformMatrix4fv(location, count, transpose, value);
1029 void UseProgram(GLuint program) override
1031 glUseProgram(program);
1034 void ValidateProgram(GLuint program) override
1036 glValidateProgram(program);
1039 void VertexAttrib1f(GLuint indx, GLfloat x) override
1041 glVertexAttrib1f(indx, x);
1044 void VertexAttrib1fv(GLuint indx, const GLfloat* values) override
1046 glVertexAttrib1fv(indx, values);
1049 void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) override
1051 glVertexAttrib2f(indx, x, y);
1054 void VertexAttrib2fv(GLuint indx, const GLfloat* values) override
1056 glVertexAttrib2fv(indx, values);
1059 void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) override
1061 glVertexAttrib3f(indx, x, y, z);
1064 void VertexAttrib3fv(GLuint indx, const GLfloat* values) override
1066 glVertexAttrib3fv(indx, values);
1069 void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) override
1071 glVertexAttrib4f(indx, x, y, z, w);
1074 void VertexAttrib4fv(GLuint indx, const GLfloat* values) override
1076 glVertexAttrib4fv(indx, values);
1079 void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) override
1081 glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
1084 void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) override
1086 glViewport(x, y, width, height);
1091 void ReadBuffer(GLenum mode) override
1093 mImpl->ReadBuffer(mode);
1096 void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) override
1098 mImpl->DrawRangeElements(mode, start, end, count, type, indices);
1101 void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) override
1103 mImpl->TexImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels);
1106 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
1108 mImpl->TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
1111 void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) override
1113 mImpl->CopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height);
1116 void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) override
1118 mImpl->CompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data);
1121 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
1123 mImpl->CompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
1126 void GenQueries(GLsizei n, GLuint* ids) override
1128 mImpl->GenQueries(n, ids);
1131 void DeleteQueries(GLsizei n, const GLuint* ids) override
1133 mImpl->DeleteQueries(n, ids);
1136 GLboolean IsQuery(GLuint id) override
1138 return mImpl->IsQuery(id);
1141 void BeginQuery(GLenum target, GLuint id) override
1143 mImpl->BeginQuery(target, id);
1146 void EndQuery(GLenum target) override
1148 mImpl->EndQuery(target);
1151 void GetQueryiv(GLenum target, GLenum pname, GLint* params) override
1153 mImpl->GetQueryiv(target, pname, params);
1156 void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) override
1158 mImpl->GetQueryObjectuiv(id, pname, params);
1161 GLboolean UnmapBuffer(GLenum target) override
1163 return mImpl->UnmapBuffer(target);
1166 void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) override
1168 mImpl->GetBufferPointerv(target, pname, params);
1171 void DrawBuffers(GLsizei n, const GLenum* bufs) override
1173 mImpl->DrawBuffers(n, bufs);
1176 void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1178 mImpl->UniformMatrix2x3fv(location, count, transpose, value);
1181 void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1183 mImpl->UniformMatrix3x2fv(location, count, transpose, value);
1186 void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1188 mImpl->UniformMatrix2x4fv(location, count, transpose, value);
1191 void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1193 mImpl->UniformMatrix4x2fv(location, count, transpose, value);
1196 void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1198 mImpl->UniformMatrix3x4fv(location, count, transpose, value);
1201 void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1203 mImpl->UniformMatrix4x3fv(location, count, transpose, value);
1206 void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) override
1208 mImpl->BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
1211 void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) override
1213 mImpl->RenderbufferStorageMultisample(target, samples, internalformat, width, height);
1216 void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) override
1218 mImpl->FramebufferTextureLayer(target, attachment, texture, level, layer);
1221 GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) override
1223 return mImpl->MapBufferRange(target, offset, length, access);
1226 void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) override
1228 mImpl->FlushMappedBufferRange(target, offset, length);
1231 void BindVertexArray(GLuint array) override
1233 mImpl->BindVertexArray(array);
1236 void DeleteVertexArrays(GLsizei n, const GLuint* arrays) override
1238 mImpl->DeleteVertexArrays(n, arrays);
1241 void GenVertexArrays(GLsizei n, GLuint* arrays) override
1243 mImpl->GenVertexArrays(n, arrays);
1246 GLboolean IsVertexArray(GLuint array) override
1248 return mImpl->IsVertexArray(array);
1251 void GetIntegeri_v(GLenum target, GLuint index, GLint* data) override
1253 mImpl->GetIntegeri_v(target, index, data);
1256 void BeginTransformFeedback(GLenum primitiveMode) override
1258 mImpl->BeginTransformFeedback(primitiveMode);
1261 void EndTransformFeedback(void) override
1263 mImpl->EndTransformFeedback();
1266 void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) override
1268 mImpl->BindBufferRange(target, index, buffer, offset, size);
1271 void BindBufferBase(GLenum target, GLuint index, GLuint buffer) override
1273 mImpl->BindBufferBase(target, index, buffer);
1276 void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) override
1278 mImpl->TransformFeedbackVaryings(program, count, varyings, bufferMode);
1281 void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) override
1283 mImpl->GetTransformFeedbackVarying(program, index, bufSize, length, size, type, name);
1286 void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) override
1288 mImpl->VertexAttribIPointer(index, size, type, stride, pointer);
1291 void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) override
1293 mImpl->GetVertexAttribIiv(index, pname, params);
1296 void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) override
1298 mImpl->GetVertexAttribIuiv(index, pname, params);
1301 void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) override
1303 mImpl->VertexAttribI4i(index, x, y, z, w);
1306 void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) override
1308 mImpl->VertexAttribI4ui(index, x, y, z, w);
1311 void VertexAttribI4iv(GLuint index, const GLint* v) override
1313 mImpl->VertexAttribI4iv(index, v);
1316 void VertexAttribI4uiv(GLuint index, const GLuint* v) override
1318 mImpl->VertexAttribI4uiv(index, v);
1321 void GetUniformuiv(GLuint program, GLint location, GLuint* params) override
1323 mImpl->GetUniformuiv(program, location, params);
1326 GLint GetFragDataLocation(GLuint program, const GLchar* name) override
1328 return mImpl->GetFragDataLocation(program, name);
1331 void Uniform1ui(GLint location, GLuint v0) override
1333 mImpl->Uniform1ui(location, v0);
1336 void Uniform2ui(GLint location, GLuint v0, GLuint v1) override
1338 mImpl->Uniform2ui(location, v0, v1);
1341 void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) override
1343 mImpl->Uniform3ui(location, v0, v1, v2);
1346 void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) override
1348 mImpl->Uniform4ui(location, v0, v1, v2, v3);
1351 void Uniform1uiv(GLint location, GLsizei count, const GLuint* value) override
1353 mImpl->Uniform1uiv(location, count, value);
1356 void Uniform2uiv(GLint location, GLsizei count, const GLuint* value) override
1358 mImpl->Uniform2uiv(location, count, value);
1361 void Uniform3uiv(GLint location, GLsizei count, const GLuint* value) override
1363 mImpl->Uniform3uiv(location, count, value);
1366 void Uniform4uiv(GLint location, GLsizei count, const GLuint* value) override
1368 mImpl->Uniform4uiv(location, count, value);
1371 void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) override
1373 mImpl->ClearBufferiv(buffer, drawbuffer, value);
1376 void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) override
1378 mImpl->ClearBufferuiv(buffer, drawbuffer, value);
1381 void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) override
1383 mImpl->ClearBufferfv(buffer, drawbuffer, value);
1386 void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) override
1388 mImpl->ClearBufferfi(buffer, drawbuffer, depth, stencil);
1391 const GLubyte* GetStringi(GLenum name, GLuint index) override
1393 return mImpl->GetStringi(name, index);
1396 void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) override
1398 mImpl->CopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
1401 void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) override
1403 mImpl->GetUniformIndices(program, uniformCount, uniformNames, uniformIndices);
1406 void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) override
1408 mImpl->GetActiveUniformsiv(program, uniformCount, uniformIndices, pname, params);
1411 GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) override
1413 return mImpl->GetUniformBlockIndex(program, uniformBlockName);
1416 void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) override
1418 mImpl->GetActiveUniformBlockiv(program, uniformBlockIndex, pname, params);
1421 void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) override
1423 mImpl->GetActiveUniformBlockName(program, uniformBlockIndex, bufSize, length, uniformBlockName);
1426 void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) override
1428 mImpl->UniformBlockBinding(program, uniformBlockIndex, uniformBlockBinding);
1431 void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) override
1433 mImpl->DrawArraysInstanced(mode, first, count, instanceCount);
1436 void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) override
1438 mImpl->DrawElementsInstanced(mode, count, type, indices, instanceCount);
1441 GLsync FenceSync(GLenum condition, GLbitfield flags) override
1443 return mImpl->FenceSync(condition, flags);
1446 GLboolean IsSync(GLsync sync) override
1448 return mImpl->IsSync(sync);
1451 void DeleteSync(GLsync sync) override
1453 mImpl->DeleteSync(sync);
1456 GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) override
1458 return mImpl->ClientWaitSync(sync, flags, timeout);
1461 void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) override
1463 mImpl->WaitSync(sync, flags, timeout);
1466 void GetInteger64v(GLenum pname, GLint64* params) override
1468 mImpl->GetInteger64v(pname, params);
1471 void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) override
1473 mImpl->GetSynciv(sync, pname, bufSize, length, values);
1476 void GetInteger64i_v(GLenum target, GLuint index, GLint64* data) override
1478 mImpl->GetInteger64i_v(target, index, data);
1481 void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) override
1483 mImpl->GetBufferParameteri64v(target, pname, params);
1486 void GenSamplers(GLsizei count, GLuint* samplers) override
1488 mImpl->GenSamplers(count, samplers);
1491 void DeleteSamplers(GLsizei count, const GLuint* samplers) override
1493 mImpl->DeleteSamplers(count, samplers);
1496 GLboolean IsSampler(GLuint sampler) override
1498 return mImpl->IsSampler(sampler);
1501 void BindSampler(GLuint unit, GLuint sampler) override
1503 mImpl->BindSampler(unit, sampler);
1506 void SamplerParameteri(GLuint sampler, GLenum pname, GLint param) override
1508 mImpl->SamplerParameteri(sampler, pname, param);
1511 void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) override
1513 mImpl->SamplerParameteriv(sampler, pname, param);
1516 void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) override
1518 mImpl->SamplerParameterf(sampler, pname, param);
1521 void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) override
1523 mImpl->SamplerParameterfv(sampler, pname, param);
1526 void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) override
1528 mImpl->GetSamplerParameteriv(sampler, pname, params);
1531 void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) override
1533 mImpl->GetSamplerParameterfv(sampler, pname, params);
1536 void VertexAttribDivisor(GLuint index, GLuint divisor) override
1538 mImpl->VertexAttribDivisor(index, divisor);
1541 void BindTransformFeedback(GLenum target, GLuint id) override
1543 mImpl->BindTransformFeedback(target, id);
1546 void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids) override
1548 mImpl->DeleteTransformFeedbacks(n, ids);
1551 void GenTransformFeedbacks(GLsizei n, GLuint* ids) override
1553 mImpl->GenTransformFeedbacks(n, ids);
1556 GLboolean IsTransformFeedback(GLuint id) override
1558 return mImpl->IsTransformFeedback(id);
1561 void PauseTransformFeedback(void) override
1563 mImpl->PauseTransformFeedback();
1566 void ResumeTransformFeedback(void) override
1568 mImpl->ResumeTransformFeedback();
1571 void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) override
1573 mImpl->GetProgramBinary(program, bufSize, length, binaryFormat, binary);
1576 void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) override
1578 mImpl->ProgramBinary(program, binaryFormat, binary, length);
1581 void ProgramParameteri(GLuint program, GLenum pname, GLint value) override
1583 mImpl->ProgramParameteri(program, pname, value);
1586 void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) override
1588 mImpl->InvalidateFramebuffer(target, numAttachments, attachments);
1591 void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) override
1593 mImpl->InvalidateSubFramebuffer(target, numAttachments, attachments, x, y, width, height);
1596 void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) override
1598 mImpl->TexStorage2D(target, levels, internalformat, width, height);
1601 void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) override
1603 mImpl->TexStorage3D(target, levels, internalformat, width, height, depth);
1606 void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) override
1608 mImpl->GetInternalformativ(target, internalformat, pname, bufSize, params);
1611 void BlendBarrier(void)
1613 if(mIsAdvancedBlendEquationSupported)
1615 mImpl->BlendBarrier();
1620 std::unique_ptr<GlesAbstraction> mImpl;
1622 ConditionalWait mContextCreatedWaitCondition;
1623 GLint mMaxTextureSize;
1624 std::string mShaderVersionPrefix;
1625 std::string mVertexShaderPrefix;
1626 std::string mFragmentShaderPrefix;
1627 int32_t mGlesVersion;
1628 int32_t mShadingLanguageVersion;
1629 bool mShadingLanguageVersionCached;
1630 bool mIsSurfacelessContextSupported;
1631 bool mIsAdvancedBlendEquationSupportedCached;
1632 bool mIsAdvancedBlendEquationSupported;
1633 bool mIsContextCreated;
1636 } // namespace Adaptor
1638 } // namespace Internal
1642 #endif // DALI_INTERNAL_GL_IMPLEMENTATION_H