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