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 "#ifdef GL_KHR_blend_equation_advanced\n"
53 "#extension GL_KHR_blend_equation_advanced : enable\n"
56 "#if defined(GL_KHR_blend_equation_advanced) || __VERSION__>=320\n"
57 " layout(blend_support_all_equations) out;\n"
60 static constexpr const char* FRAGMENT_SHADER_OUTPUT_COLOR_STRING =
61 "out mediump vec4 fragColor;\n";
63 static constexpr const char* OES_EGL_IMAGE_EXTERNAL_STRING = "#extension GL_OES_EGL_image_external:require\n";
65 static constexpr const char* OES_EGL_IMAGE_EXTERNAL_STRING_ESSL3 = "#extension GL_OES_EGL_image_external_essl3:require\n";
69 * GlImplementation is a concrete implementation for GlAbstraction.
70 * The class provides an OpenGL-ES 2.0 or 3.0 implementation.
71 * The class is provided when creating the Integration::Core object.
73 class GlImplementation : public Dali::Integration::GlAbstraction
77 : mContextCreatedWaitCondition(),
79 mVertexShaderPrefix(""),
80 mGlesVersion(INITIAL_GLES_VERSION),
81 mShadingLanguageVersion(100),
82 mShadingLanguageVersionCached(false),
83 mIsSurfacelessContextSupported(false),
84 mIsAdvancedBlendEquationSupportedCached(false),
85 mIsAdvancedBlendEquationSupported(false),
86 mIsContextCreated(false)
88 mImpl.reset(new Gles3Implementation());
91 virtual ~GlImplementation()
95 void PreRender() override
97 /* Do nothing in main implementation */
100 void PostRender() override
102 /* Do nothing in main implementation */
105 void ContextCreated()
107 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
109 // Only change gles version for the device that support above gles 3.0.
110 if(mGlesVersion >= INITIAL_GLES_VERSION)
112 GLint majorVersion, minorVersion;
113 glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
114 glGetIntegerv(GL_MINOR_VERSION, &minorVersion);
115 mGlesVersion = majorVersion * 10 + minorVersion;
118 if(mGlesVersion >= GLES_VERSION_SUPPORT_BLEND_EQUATION_ADVANCED)
120 mIsAdvancedBlendEquationSupported = true;
124 // when mIsAdvancedBlendEquationSupported is cached, we don't need to check all the extensions.
125 if(!mIsAdvancedBlendEquationSupportedCached)
127 const char* const extensionStr = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
128 std::istringstream stream(extensionStr);
129 std::string currentExtension;
130 while(std::getline(stream, currentExtension, ' '))
132 if(currentExtension == KHR_BLEND_EQUATION_ADVANCED)
134 mIsAdvancedBlendEquationSupported = true;
141 if(!mShadingLanguageVersionCached)
143 std::istringstream shadingLanguageVersionStream(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
145 uint32_t tokenCount = 0;
146 while(std::getline(shadingLanguageVersionStream, token, ' '))
148 if(tokenCount == 3 && token == "ES")
150 std::getline(shadingLanguageVersionStream, token, '.');
151 mShadingLanguageVersion = std::atoi(token.c_str());
152 mShadingLanguageVersion *= 100;
153 std::getline(shadingLanguageVersionStream, token, '.');
154 mShadingLanguageVersion += std::atoi(token.c_str());
162 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
163 mIsContextCreated = true;
164 mContextCreatedWaitCondition.Notify(lock);
168 void SetGlesVersion(const int32_t glesVersion)
170 if(mGlesVersion / 10 != glesVersion / 10)
172 mGlesVersion = glesVersion;
173 if(mGlesVersion >= 30)
175 mImpl.reset(new Gles3Implementation());
179 mImpl.reset(new Gles2Implementation());
184 void SetIsSurfacelessContextSupported(const bool isSupported)
186 mIsSurfacelessContextSupported = isSupported;
189 bool IsSurfacelessContextSupported() const override
191 return mIsSurfacelessContextSupported;
194 void SetIsAdvancedBlendEquationSupported(const bool isSupported)
196 mIsAdvancedBlendEquationSupported = isSupported;
197 mIsAdvancedBlendEquationSupportedCached = true;
200 bool IsAdvancedBlendEquationSupported()
202 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
203 if(!mIsContextCreated && !mIsAdvancedBlendEquationSupportedCached)
205 mContextCreatedWaitCondition.Wait(lock);
207 return mIsAdvancedBlendEquationSupported;
210 bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation)
212 switch(blendEquation)
214 case DevelBlendEquation::ADD:
215 case DevelBlendEquation::SUBTRACT:
216 case DevelBlendEquation::REVERSE_SUBTRACT:
220 case DevelBlendEquation::MIN:
221 case DevelBlendEquation::MAX:
223 return (GetGlesVersion() >= 30);
225 case DevelBlendEquation::MULTIPLY:
226 case DevelBlendEquation::SCREEN:
227 case DevelBlendEquation::OVERLAY:
228 case DevelBlendEquation::DARKEN:
229 case DevelBlendEquation::LIGHTEN:
230 case DevelBlendEquation::COLOR_DODGE:
231 case DevelBlendEquation::COLOR_BURN:
232 case DevelBlendEquation::HARD_LIGHT:
233 case DevelBlendEquation::SOFT_LIGHT:
234 case DevelBlendEquation::DIFFERENCE:
235 case DevelBlendEquation::EXCLUSION:
236 case DevelBlendEquation::HUE:
237 case DevelBlendEquation::SATURATION:
238 case DevelBlendEquation::COLOR:
239 case DevelBlendEquation::LUMINOSITY:
241 return IsAdvancedBlendEquationSupported();
253 std::string GetShaderVersionPrefix()
255 if(mShaderVersionPrefix == "")
257 mShaderVersionPrefix = "#version " + std::to_string(GetShadingLanguageVersion());
258 if(GetShadingLanguageVersion() < 300)
260 mShaderVersionPrefix += "\n";
264 mShaderVersionPrefix += " es\n";
267 return mShaderVersionPrefix;
270 std::string GetVertexShaderPrefix()
272 if(mVertexShaderPrefix == "")
274 mVertexShaderPrefix = GetShaderVersionPrefix();
276 if(GetShadingLanguageVersion() < 300)
278 mVertexShaderPrefix += "#define INPUT attribute\n";
279 mVertexShaderPrefix += "#define OUTPUT varying\n";
283 mVertexShaderPrefix += "#define INPUT in\n";
284 mVertexShaderPrefix += "#define OUTPUT out\n";
287 return mVertexShaderPrefix;
290 std::string GetFragmentShaderPrefix()
292 if(mFragmentShaderPrefix == "")
294 mFragmentShaderPrefix = GetShaderVersionPrefix();
296 if(GetShadingLanguageVersion() < 300)
298 mFragmentShaderPrefix += "#define INPUT varying\n";
299 mFragmentShaderPrefix += "#define OUT_COLOR gl_FragColor\n";
300 mFragmentShaderPrefix += "#define TEXTURE texture2D\n";
304 mFragmentShaderPrefix += "#define INPUT in\n";
305 mFragmentShaderPrefix += "#define OUT_COLOR fragColor\n";
306 mFragmentShaderPrefix += "#define TEXTURE texture\n";
308 if(IsAdvancedBlendEquationSupported())
310 mFragmentShaderPrefix += FRAGMENT_SHADER_ADVANCED_BLEND_EQUATION_PREFIX;
313 mFragmentShaderPrefix += FRAGMENT_SHADER_OUTPUT_COLOR_STRING;
316 return mFragmentShaderPrefix;
319 bool TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const override
321 bool convert = ((imageGlFormat == GL_RGB) && (textureGlFormat == GL_RGBA));
322 if(mGlesVersion >= 30)
324 // Don't convert manually from RGB to RGBA if GLES >= 3.0 and a sub-image is uploaded.
325 convert = (convert && !isSubImage);
330 int GetMaxTextureSize()
332 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
333 if(!mIsContextCreated)
335 mContextCreatedWaitCondition.Wait(lock);
337 return mMaxTextureSize;
342 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
343 if(!mIsContextCreated)
345 mContextCreatedWaitCondition.Wait(lock);
350 void SetShadingLanguageVersion(int shadingLanguageVersion)
352 mShadingLanguageVersion = shadingLanguageVersion;
353 mShadingLanguageVersionCached = true;
356 int GetShadingLanguageVersion()
358 ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
359 if(!mIsContextCreated && !mShadingLanguageVersionCached)
361 mContextCreatedWaitCondition.Wait(lock);
363 return mShadingLanguageVersion;
366 bool ApplyNativeFragmentShader(std::string& shader, const char* customSamplerType)
368 bool modified = false;
369 std::string versionString = "#version";
370 size_t versionPosition = shader.find(versionString);
371 if(versionPosition != std::string::npos)
373 std::string extensionString;
374 size_t shadingLanguageVersionPosition = shader.find_first_not_of(" \t", versionPosition + versionString.length());
375 if(shadingLanguageVersionPosition != std::string::npos &&
376 shader.substr(shadingLanguageVersionPosition, 3) == LEGACY_SHADING_LANGUAGE_VERSION)
378 extensionString = OES_EGL_IMAGE_EXTERNAL_STRING;
382 extensionString = OES_EGL_IMAGE_EXTERNAL_STRING_ESSL3;
385 if(shader.find(extensionString) == std::string::npos)
388 size_t extensionPosition = shader.find_first_of("\n", versionPosition) + 1;
389 shader.insert(extensionPosition, extensionString);
394 if(shader.find(OES_EGL_IMAGE_EXTERNAL_STRING) == std::string::npos)
397 shader = OES_EGL_IMAGE_EXTERNAL_STRING + shader;
401 if(shader.find(customSamplerType) == std::string::npos)
403 size_t pos = shader.find(DEFAULT_SAMPLER_TYPE);
404 if(pos != std::string::npos)
407 shader.replace(pos, strlen(DEFAULT_SAMPLER_TYPE), customSamplerType);
416 void ActiveTexture(GLenum texture) override
418 glActiveTexture(texture);
421 void AttachShader(GLuint program, GLuint shader) override
423 glAttachShader(program, shader);
426 void BindAttribLocation(GLuint program, GLuint index, const char* name) override
428 glBindAttribLocation(program, index, name);
431 void BindBuffer(GLenum target, GLuint buffer) override
433 glBindBuffer(target, buffer);
436 void BindFramebuffer(GLenum target, GLuint framebuffer) override
438 glBindFramebuffer(target, framebuffer);
441 void BindRenderbuffer(GLenum target, GLuint renderbuffer) override
443 glBindRenderbuffer(target, renderbuffer);
446 void BindTexture(GLenum target, GLuint texture) override
448 glBindTexture(target, texture);
451 void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) override
453 glBlendColor(red, green, blue, alpha);
456 void BlendEquation(GLenum mode) override
458 glBlendEquation(mode);
461 void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) override
463 glBlendEquationSeparate(modeRGB, modeAlpha);
466 void BlendFunc(GLenum sfactor, GLenum dfactor) override
468 glBlendFunc(sfactor, dfactor);
471 void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) override
473 glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
476 void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) override
478 glBufferData(target, size, data, usage);
481 void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) override
483 glBufferSubData(target, offset, size, data);
486 GLenum CheckFramebufferStatus(GLenum target) override
488 return glCheckFramebufferStatus(target);
491 void Clear(GLbitfield mask) override
496 void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) override
498 glClearColor(red, green, blue, alpha);
501 void ClearDepthf(GLclampf depth) override
503 glClearDepthf(depth);
506 void ClearStencil(GLint s) override
511 void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) override
513 glColorMask(red, green, blue, alpha);
516 void CompileShader(GLuint shader) override
518 glCompileShader(shader);
521 void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) override
523 glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
526 void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) override
528 glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
531 void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) override
533 glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
536 void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) override
538 glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
541 GLuint CreateProgram(void) override
543 return glCreateProgram();
546 GLuint CreateShader(GLenum type) override
548 return glCreateShader(type);
551 void CullFace(GLenum mode) override
556 void DeleteBuffers(GLsizei n, const GLuint* buffers) override
558 glDeleteBuffers(n, buffers);
561 void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) override
563 glDeleteFramebuffers(n, framebuffers);
566 void DeleteProgram(GLuint program) override
568 glDeleteProgram(program);
571 void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) override
573 glDeleteRenderbuffers(n, renderbuffers);
576 void DeleteShader(GLuint shader) override
578 glDeleteShader(shader);
581 void DeleteTextures(GLsizei n, const GLuint* textures) override
583 glDeleteTextures(n, textures);
586 void DepthFunc(GLenum func) override
591 void DepthMask(GLboolean flag) override
596 void DepthRangef(GLclampf zNear, GLclampf zFar) override
598 glDepthRangef(zNear, zFar);
601 void DetachShader(GLuint program, GLuint shader) override
603 glDetachShader(program, shader);
606 void Disable(GLenum cap) override
611 void DisableVertexAttribArray(GLuint index) override
613 glDisableVertexAttribArray(index);
616 void DrawArrays(GLenum mode, GLint first, GLsizei count) override
618 glDrawArrays(mode, first, count);
621 void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) override
623 glDrawElements(mode, count, type, indices);
626 void Enable(GLenum cap) override
631 void EnableVertexAttribArray(GLuint index) override
633 glEnableVertexAttribArray(index);
636 void Finish(void) override
641 void Flush(void) override
646 void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) override
648 glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
651 void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) override
653 glFramebufferTexture2D(target, attachment, textarget, texture, level);
656 void FrontFace(GLenum mode) override
661 void GenBuffers(GLsizei n, GLuint* buffers) override
663 glGenBuffers(n, buffers);
666 void GenerateMipmap(GLenum target) override
668 glGenerateMipmap(target);
671 void GenFramebuffers(GLsizei n, GLuint* framebuffers) override
673 glGenFramebuffers(n, framebuffers);
676 void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) override
678 glGenRenderbuffers(n, renderbuffers);
681 void GenTextures(GLsizei n, GLuint* textures) override
683 glGenTextures(n, textures);
686 void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) override
688 glGetActiveAttrib(program, index, bufsize, length, size, type, name);
691 void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) override
693 glGetActiveUniform(program, index, bufsize, length, size, type, name);
696 void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) override
698 glGetAttachedShaders(program, maxcount, count, shaders);
701 int GetAttribLocation(GLuint program, const char* name) override
703 return glGetAttribLocation(program, name);
706 void GetBooleanv(GLenum pname, GLboolean* params) override
708 glGetBooleanv(pname, params);
711 void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) override
713 glGetBufferParameteriv(target, pname, params);
716 GLenum GetError(void) override
721 void GetFloatv(GLenum pname, GLfloat* params) override
723 glGetFloatv(pname, params);
726 void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) override
728 glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
731 void GetIntegerv(GLenum pname, GLint* params) override
733 glGetIntegerv(pname, params);
736 void GetProgramiv(GLuint program, GLenum pname, GLint* params) override
738 glGetProgramiv(program, pname, params);
741 void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) override
743 glGetProgramInfoLog(program, bufsize, length, infolog);
746 void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) override
748 glGetRenderbufferParameteriv(target, pname, params);
751 void GetShaderiv(GLuint shader, GLenum pname, GLint* params) override
753 glGetShaderiv(shader, pname, params);
756 void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) override
758 glGetShaderInfoLog(shader, bufsize, length, infolog);
761 void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) override
763 glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
766 void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) override
768 glGetShaderSource(shader, bufsize, length, source);
771 const GLubyte* GetString(GLenum name) override
773 return glGetString(name);
776 void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) override
778 glGetTexParameterfv(target, pname, params);
781 void GetTexParameteriv(GLenum target, GLenum pname, GLint* params) override
783 glGetTexParameteriv(target, pname, params);
786 void GetUniformfv(GLuint program, GLint location, GLfloat* params) override
788 glGetUniformfv(program, location, params);
791 void GetUniformiv(GLuint program, GLint location, GLint* params) override
793 glGetUniformiv(program, location, params);
796 int GetUniformLocation(GLuint program, const char* name) override
798 return glGetUniformLocation(program, name);
801 void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) override
803 glGetVertexAttribfv(index, pname, params);
806 void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) override
808 glGetVertexAttribiv(index, pname, params);
811 void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) override
813 glGetVertexAttribPointerv(index, pname, pointer);
816 void Hint(GLenum target, GLenum mode) override
818 glHint(target, mode);
821 GLboolean IsBuffer(GLuint buffer) override
823 return glIsBuffer(buffer);
826 GLboolean IsEnabled(GLenum cap) override
828 return glIsEnabled(cap);
831 GLboolean IsFramebuffer(GLuint framebuffer) override
833 return glIsFramebuffer(framebuffer);
836 GLboolean IsProgram(GLuint program) override
838 return glIsProgram(program);
841 GLboolean IsRenderbuffer(GLuint renderbuffer) override
843 return glIsRenderbuffer(renderbuffer);
846 GLboolean IsShader(GLuint shader) override
848 return glIsShader(shader);
851 GLboolean IsTexture(GLuint texture) override
853 return glIsTexture(texture);
856 void LineWidth(GLfloat width) override
861 void LinkProgram(GLuint program) override
863 glLinkProgram(program);
866 void PixelStorei(GLenum pname, GLint param) override
868 glPixelStorei(pname, param);
871 void PolygonOffset(GLfloat factor, GLfloat units) override
873 glPolygonOffset(factor, units);
876 void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) override
878 glReadPixels(x, y, width, height, format, type, pixels);
881 void ReleaseShaderCompiler(void) override
883 glReleaseShaderCompiler();
886 void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) override
888 glRenderbufferStorage(target, internalformat, width, height);
891 void SampleCoverage(GLclampf value, GLboolean invert) override
893 glSampleCoverage(value, invert);
896 void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) override
898 glScissor(x, y, width, height);
901 void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) override
903 glShaderBinary(n, shaders, binaryformat, binary, length);
906 void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) override
908 glShaderSource(shader, count, string, length);
911 void StencilFunc(GLenum func, GLint ref, GLuint mask) override
913 glStencilFunc(func, ref, mask);
916 void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) override
918 glStencilFuncSeparate(face, func, ref, mask);
921 void StencilMask(GLuint mask) override
926 void StencilMaskSeparate(GLenum face, GLuint mask) override
928 glStencilMaskSeparate(face, mask);
931 void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) override
933 glStencilOp(fail, zfail, zpass);
936 void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) override
938 glStencilOpSeparate(face, fail, zfail, zpass);
941 void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) override
943 glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
946 void TexParameterf(GLenum target, GLenum pname, GLfloat param) override
948 glTexParameterf(target, pname, param);
951 void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params) override
953 glTexParameterfv(target, pname, params);
956 void TexParameteri(GLenum target, GLenum pname, GLint param) override
958 glTexParameteri(target, pname, param);
961 void TexParameteriv(GLenum target, GLenum pname, const GLint* params) override
963 glTexParameteriv(target, pname, params);
966 void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) override
968 glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
971 void Uniform1f(GLint location, GLfloat x) override
973 glUniform1f(location, x);
976 void Uniform1fv(GLint location, GLsizei count, const GLfloat* v) override
978 glUniform1fv(location, count, v);
981 void Uniform1i(GLint location, GLint x) override
983 glUniform1i(location, x);
986 void Uniform1iv(GLint location, GLsizei count, const GLint* v) override
988 glUniform1iv(location, count, v);
991 void Uniform2f(GLint location, GLfloat x, GLfloat y) override
993 glUniform2f(location, x, y);
996 void Uniform2fv(GLint location, GLsizei count, const GLfloat* v) override
998 glUniform2fv(location, count, v);
1001 void Uniform2i(GLint location, GLint x, GLint y) override
1003 glUniform2i(location, x, y);
1006 void Uniform2iv(GLint location, GLsizei count, const GLint* v) override
1008 glUniform2iv(location, count, v);
1011 void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) override
1013 glUniform3f(location, x, y, z);
1016 void Uniform3fv(GLint location, GLsizei count, const GLfloat* v) override
1018 glUniform3fv(location, count, v);
1021 void Uniform3i(GLint location, GLint x, GLint y, GLint z) override
1023 glUniform3i(location, x, y, z);
1026 void Uniform3iv(GLint location, GLsizei count, const GLint* v) override
1028 glUniform3iv(location, count, v);
1031 void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) override
1033 glUniform4f(location, x, y, z, w);
1036 void Uniform4fv(GLint location, GLsizei count, const GLfloat* v) override
1038 glUniform4fv(location, count, v);
1041 void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) override
1043 glUniform4i(location, x, y, z, w);
1046 void Uniform4iv(GLint location, GLsizei count, const GLint* v) override
1048 glUniform4iv(location, count, v);
1051 void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1053 glUniformMatrix2fv(location, count, transpose, value);
1056 void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1058 glUniformMatrix3fv(location, count, transpose, value);
1061 void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1063 glUniformMatrix4fv(location, count, transpose, value);
1066 void UseProgram(GLuint program) override
1068 glUseProgram(program);
1071 void ValidateProgram(GLuint program) override
1073 glValidateProgram(program);
1076 void VertexAttrib1f(GLuint indx, GLfloat x) override
1078 glVertexAttrib1f(indx, x);
1081 void VertexAttrib1fv(GLuint indx, const GLfloat* values) override
1083 glVertexAttrib1fv(indx, values);
1086 void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) override
1088 glVertexAttrib2f(indx, x, y);
1091 void VertexAttrib2fv(GLuint indx, const GLfloat* values) override
1093 glVertexAttrib2fv(indx, values);
1096 void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) override
1098 glVertexAttrib3f(indx, x, y, z);
1101 void VertexAttrib3fv(GLuint indx, const GLfloat* values) override
1103 glVertexAttrib3fv(indx, values);
1106 void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) override
1108 glVertexAttrib4f(indx, x, y, z, w);
1111 void VertexAttrib4fv(GLuint indx, const GLfloat* values) override
1113 glVertexAttrib4fv(indx, values);
1116 void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) override
1118 glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
1121 void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) override
1123 glViewport(x, y, width, height);
1128 void ReadBuffer(GLenum mode) override
1130 mImpl->ReadBuffer(mode);
1133 void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) override
1135 mImpl->DrawRangeElements(mode, start, end, count, type, indices);
1138 void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) override
1140 mImpl->TexImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels);
1143 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
1145 mImpl->TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
1148 void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) override
1150 mImpl->CopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height);
1153 void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) override
1155 mImpl->CompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data);
1158 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
1160 mImpl->CompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
1163 void GenQueries(GLsizei n, GLuint* ids) override
1165 mImpl->GenQueries(n, ids);
1168 void DeleteQueries(GLsizei n, const GLuint* ids) override
1170 mImpl->DeleteQueries(n, ids);
1173 GLboolean IsQuery(GLuint id) override
1175 return mImpl->IsQuery(id);
1178 void BeginQuery(GLenum target, GLuint id) override
1180 mImpl->BeginQuery(target, id);
1183 void EndQuery(GLenum target) override
1185 mImpl->EndQuery(target);
1188 void GetQueryiv(GLenum target, GLenum pname, GLint* params) override
1190 mImpl->GetQueryiv(target, pname, params);
1193 void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) override
1195 mImpl->GetQueryObjectuiv(id, pname, params);
1198 GLboolean UnmapBuffer(GLenum target) override
1200 return mImpl->UnmapBuffer(target);
1203 void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) override
1205 mImpl->GetBufferPointerv(target, pname, params);
1208 void DrawBuffers(GLsizei n, const GLenum* bufs) override
1210 mImpl->DrawBuffers(n, bufs);
1213 void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1215 mImpl->UniformMatrix2x3fv(location, count, transpose, value);
1218 void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1220 mImpl->UniformMatrix3x2fv(location, count, transpose, value);
1223 void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1225 mImpl->UniformMatrix2x4fv(location, count, transpose, value);
1228 void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1230 mImpl->UniformMatrix4x2fv(location, count, transpose, value);
1233 void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1235 mImpl->UniformMatrix3x4fv(location, count, transpose, value);
1238 void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
1240 mImpl->UniformMatrix4x3fv(location, count, transpose, value);
1243 void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) override
1245 mImpl->BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
1248 void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) override
1250 mImpl->RenderbufferStorageMultisample(target, samples, internalformat, width, height);
1253 void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) override
1255 mImpl->FramebufferTextureLayer(target, attachment, texture, level, layer);
1258 GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) override
1260 return mImpl->MapBufferRange(target, offset, length, access);
1263 void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) override
1265 mImpl->FlushMappedBufferRange(target, offset, length);
1268 void BindVertexArray(GLuint array) override
1270 mImpl->BindVertexArray(array);
1273 void DeleteVertexArrays(GLsizei n, const GLuint* arrays) override
1275 mImpl->DeleteVertexArrays(n, arrays);
1278 void GenVertexArrays(GLsizei n, GLuint* arrays) override
1280 mImpl->GenVertexArrays(n, arrays);
1283 GLboolean IsVertexArray(GLuint array) override
1285 return mImpl->IsVertexArray(array);
1288 void GetIntegeri_v(GLenum target, GLuint index, GLint* data) override
1290 mImpl->GetIntegeri_v(target, index, data);
1293 void BeginTransformFeedback(GLenum primitiveMode) override
1295 mImpl->BeginTransformFeedback(primitiveMode);
1298 void EndTransformFeedback(void) override
1300 mImpl->EndTransformFeedback();
1303 void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) override
1305 mImpl->BindBufferRange(target, index, buffer, offset, size);
1308 void BindBufferBase(GLenum target, GLuint index, GLuint buffer) override
1310 mImpl->BindBufferBase(target, index, buffer);
1313 void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) override
1315 mImpl->TransformFeedbackVaryings(program, count, varyings, bufferMode);
1318 void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) override
1320 mImpl->GetTransformFeedbackVarying(program, index, bufSize, length, size, type, name);
1323 void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) override
1325 mImpl->VertexAttribIPointer(index, size, type, stride, pointer);
1328 void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) override
1330 mImpl->GetVertexAttribIiv(index, pname, params);
1333 void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) override
1335 mImpl->GetVertexAttribIuiv(index, pname, params);
1338 void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) override
1340 mImpl->VertexAttribI4i(index, x, y, z, w);
1343 void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) override
1345 mImpl->VertexAttribI4ui(index, x, y, z, w);
1348 void VertexAttribI4iv(GLuint index, const GLint* v) override
1350 mImpl->VertexAttribI4iv(index, v);
1353 void VertexAttribI4uiv(GLuint index, const GLuint* v) override
1355 mImpl->VertexAttribI4uiv(index, v);
1358 void GetUniformuiv(GLuint program, GLint location, GLuint* params) override
1360 mImpl->GetUniformuiv(program, location, params);
1363 GLint GetFragDataLocation(GLuint program, const GLchar* name) override
1365 return mImpl->GetFragDataLocation(program, name);
1368 void Uniform1ui(GLint location, GLuint v0) override
1370 mImpl->Uniform1ui(location, v0);
1373 void Uniform2ui(GLint location, GLuint v0, GLuint v1) override
1375 mImpl->Uniform2ui(location, v0, v1);
1378 void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) override
1380 mImpl->Uniform3ui(location, v0, v1, v2);
1383 void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) override
1385 mImpl->Uniform4ui(location, v0, v1, v2, v3);
1388 void Uniform1uiv(GLint location, GLsizei count, const GLuint* value) override
1390 mImpl->Uniform1uiv(location, count, value);
1393 void Uniform2uiv(GLint location, GLsizei count, const GLuint* value) override
1395 mImpl->Uniform2uiv(location, count, value);
1398 void Uniform3uiv(GLint location, GLsizei count, const GLuint* value) override
1400 mImpl->Uniform3uiv(location, count, value);
1403 void Uniform4uiv(GLint location, GLsizei count, const GLuint* value) override
1405 mImpl->Uniform4uiv(location, count, value);
1408 void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) override
1410 mImpl->ClearBufferiv(buffer, drawbuffer, value);
1413 void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) override
1415 mImpl->ClearBufferuiv(buffer, drawbuffer, value);
1418 void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) override
1420 mImpl->ClearBufferfv(buffer, drawbuffer, value);
1423 void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) override
1425 mImpl->ClearBufferfi(buffer, drawbuffer, depth, stencil);
1428 const GLubyte* GetStringi(GLenum name, GLuint index) override
1430 return mImpl->GetStringi(name, index);
1433 void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) override
1435 mImpl->CopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
1438 void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) override
1440 mImpl->GetUniformIndices(program, uniformCount, uniformNames, uniformIndices);
1443 void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) override
1445 mImpl->GetActiveUniformsiv(program, uniformCount, uniformIndices, pname, params);
1448 GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) override
1450 return mImpl->GetUniformBlockIndex(program, uniformBlockName);
1453 void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) override
1455 mImpl->GetActiveUniformBlockiv(program, uniformBlockIndex, pname, params);
1458 void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) override
1460 mImpl->GetActiveUniformBlockName(program, uniformBlockIndex, bufSize, length, uniformBlockName);
1463 void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) override
1465 mImpl->UniformBlockBinding(program, uniformBlockIndex, uniformBlockBinding);
1468 void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) override
1470 mImpl->DrawArraysInstanced(mode, first, count, instanceCount);
1473 void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) override
1475 mImpl->DrawElementsInstanced(mode, count, type, indices, instanceCount);
1478 GLsync FenceSync(GLenum condition, GLbitfield flags) override
1480 return mImpl->FenceSync(condition, flags);
1483 GLboolean IsSync(GLsync sync) override
1485 return mImpl->IsSync(sync);
1488 void DeleteSync(GLsync sync) override
1490 mImpl->DeleteSync(sync);
1493 GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) override
1495 return mImpl->ClientWaitSync(sync, flags, timeout);
1498 void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) override
1500 mImpl->WaitSync(sync, flags, timeout);
1503 void GetInteger64v(GLenum pname, GLint64* params) override
1505 mImpl->GetInteger64v(pname, params);
1508 void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) override
1510 mImpl->GetSynciv(sync, pname, bufSize, length, values);
1513 void GetInteger64i_v(GLenum target, GLuint index, GLint64* data) override
1515 mImpl->GetInteger64i_v(target, index, data);
1518 void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) override
1520 mImpl->GetBufferParameteri64v(target, pname, params);
1523 void GenSamplers(GLsizei count, GLuint* samplers) override
1525 mImpl->GenSamplers(count, samplers);
1528 void DeleteSamplers(GLsizei count, const GLuint* samplers) override
1530 mImpl->DeleteSamplers(count, samplers);
1533 GLboolean IsSampler(GLuint sampler) override
1535 return mImpl->IsSampler(sampler);
1538 void BindSampler(GLuint unit, GLuint sampler) override
1540 mImpl->BindSampler(unit, sampler);
1543 void SamplerParameteri(GLuint sampler, GLenum pname, GLint param) override
1545 mImpl->SamplerParameteri(sampler, pname, param);
1548 void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) override
1550 mImpl->SamplerParameteriv(sampler, pname, param);
1553 void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) override
1555 mImpl->SamplerParameterf(sampler, pname, param);
1558 void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) override
1560 mImpl->SamplerParameterfv(sampler, pname, param);
1563 void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) override
1565 mImpl->GetSamplerParameteriv(sampler, pname, params);
1568 void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) override
1570 mImpl->GetSamplerParameterfv(sampler, pname, params);
1573 void VertexAttribDivisor(GLuint index, GLuint divisor) override
1575 mImpl->VertexAttribDivisor(index, divisor);
1578 void BindTransformFeedback(GLenum target, GLuint id) override
1580 mImpl->BindTransformFeedback(target, id);
1583 void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids) override
1585 mImpl->DeleteTransformFeedbacks(n, ids);
1588 void GenTransformFeedbacks(GLsizei n, GLuint* ids) override
1590 mImpl->GenTransformFeedbacks(n, ids);
1593 GLboolean IsTransformFeedback(GLuint id) override
1595 return mImpl->IsTransformFeedback(id);
1598 void PauseTransformFeedback(void) override
1600 mImpl->PauseTransformFeedback();
1603 void ResumeTransformFeedback(void) override
1605 mImpl->ResumeTransformFeedback();
1608 void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) override
1610 mImpl->GetProgramBinary(program, bufSize, length, binaryFormat, binary);
1613 void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) override
1615 mImpl->ProgramBinary(program, binaryFormat, binary, length);
1618 void ProgramParameteri(GLuint program, GLenum pname, GLint value) override
1620 mImpl->ProgramParameteri(program, pname, value);
1623 void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) override
1625 mImpl->InvalidateFramebuffer(target, numAttachments, attachments);
1628 void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) override
1630 mImpl->InvalidateSubFramebuffer(target, numAttachments, attachments, x, y, width, height);
1633 void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) override
1635 mImpl->TexStorage2D(target, levels, internalformat, width, height);
1638 void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) override
1640 mImpl->TexStorage3D(target, levels, internalformat, width, height, depth);
1643 void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) override
1645 mImpl->GetInternalformativ(target, internalformat, pname, bufSize, params);
1648 void BlendBarrier(void)
1650 if(mIsAdvancedBlendEquationSupported)
1652 mImpl->BlendBarrier();
1657 std::unique_ptr<GlesAbstraction> mImpl;
1659 ConditionalWait mContextCreatedWaitCondition;
1660 GLint mMaxTextureSize;
1661 std::string mShaderVersionPrefix;
1662 std::string mVertexShaderPrefix;
1663 std::string mFragmentShaderPrefix;
1664 int32_t mGlesVersion;
1665 int32_t mShadingLanguageVersion;
1666 bool mShadingLanguageVersionCached;
1667 bool mIsSurfacelessContextSupported;
1668 bool mIsAdvancedBlendEquationSupportedCached;
1669 bool mIsAdvancedBlendEquationSupported;
1670 bool mIsContextCreated;
1673 } // namespace Adaptor
1675 } // namespace Internal
1679 #endif // DALI_INTERNAL_GL_IMPLEMENTATION_H