1 #ifndef DALI_INTERNAL_GL_IMPLEMENTATION_H
2 #define DALI_INTERNAL_GL_IMPLEMENTATION_H
5 * Copyright (c) 2020 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.
24 #include <GLES2/gl2.h>
25 #include <GLES2/gl2ext.h>
26 #include <dali/integration-api/gl-abstraction.h>
27 #include <dali/devel-api/threading/conditional-wait.h>
28 #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>
47 const int32_t INITIAL_GLES_VERSION = 30;
48 const int32_t GLES_VERSION_SUPPORT_BLEND_EQUATION_ADVANCED = 32;
49 const char* KHR_BLEND_EQUATION_ADVANCED = "GL_KHR_blend_equation_advanced";
51 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 const char* FRAGMENT_SHADER_OUTPUT_COLOR_STRING =
59 "out mediump vec4 fragColor;\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
72 : mContextCreatedWaitCondition(),
74 mVertexShaderPrefix(""),
75 mGlesVersion( INITIAL_GLES_VERSION ),
76 mShadingLanguageVersion( 100 ),
77 mShadingLanguageVersionCached( false ),
78 mIsSurfacelessContextSupported( false ),
79 mIsAdvancedBlendEquationSupportedCached( false ),
80 mIsAdvancedBlendEquationSupported( false ),
81 mIsContextCreated( false )
83 mImpl.reset( new Gles3Implementation() );
86 virtual ~GlImplementation() {}
88 void PreRender() override
90 /* Do nothing in main implementation */
93 void PostRender() override
95 /* Do nothing in main implementation */
100 glGetIntegerv( GL_MAX_TEXTURE_SIZE, &mMaxTextureSize );
102 GLint majorVersion, minorVersion;
103 glGetIntegerv( GL_MAJOR_VERSION, &majorVersion );
104 glGetIntegerv( GL_MINOR_VERSION, &minorVersion );
105 mGlesVersion = majorVersion * 10 + minorVersion;
107 if( mGlesVersion >= GLES_VERSION_SUPPORT_BLEND_EQUATION_ADVANCED )
109 mIsAdvancedBlendEquationSupported = true;
113 // when mIsAdvancedBlendEquationSupported is cached, we don't need to check all the extensions.
114 if( !mIsAdvancedBlendEquationSupportedCached )
116 const char* const extensionStr = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
117 std::istringstream stream(extensionStr);
118 std::string currentExtension;
119 while(std::getline(stream, currentExtension, ' '))
121 if(currentExtension == KHR_BLEND_EQUATION_ADVANCED)
123 mIsAdvancedBlendEquationSupported = true;
130 if(!mShadingLanguageVersionCached)
132 std::istringstream shadingLanguageVersionStream(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
134 uint32_t tokenCount = 0;
135 while(std::getline(shadingLanguageVersionStream, token, ' '))
137 if(tokenCount == 3 && token == "ES")
139 std::getline(shadingLanguageVersionStream, token, '.');
140 mShadingLanguageVersion = std::atoi(token.c_str());
141 mShadingLanguageVersion *= 100;
142 std::getline(shadingLanguageVersionStream, token, '.');
143 mShadingLanguageVersion += std::atoi(token.c_str());
151 ConditionalWait::ScopedLock lock( mContextCreatedWaitCondition );
152 mIsContextCreated = true;
153 mContextCreatedWaitCondition.Notify( lock );
157 void SetGlesVersion( const int32_t glesVersion )
159 if( mGlesVersion / 10 != glesVersion / 10 )
161 mGlesVersion = glesVersion;
162 if( mGlesVersion >= 30 )
164 mImpl.reset( new Gles3Implementation() );
168 mImpl.reset( new Gles2Implementation() );
173 void SetIsSurfacelessContextSupported( const bool isSupported )
175 mIsSurfacelessContextSupported = isSupported;
178 bool IsSurfacelessContextSupported() const override
180 return mIsSurfacelessContextSupported;
183 void SetIsAdvancedBlendEquationSupported(const bool isSupported)
185 mIsAdvancedBlendEquationSupported = isSupported;
186 mIsAdvancedBlendEquationSupportedCached = true;
189 bool IsAdvancedBlendEquationSupported()
191 ConditionalWait::ScopedLock lock( mContextCreatedWaitCondition );
192 if(!mIsContextCreated && !mIsAdvancedBlendEquationSupportedCached)
194 mContextCreatedWaitCondition.Wait( lock );
196 return mIsAdvancedBlendEquationSupported;
199 bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation)
201 switch(blendEquation)
203 case DevelBlendEquation::ADD:
204 case DevelBlendEquation::SUBTRACT:
205 case DevelBlendEquation::REVERSE_SUBTRACT:
209 case DevelBlendEquation::MIN:
210 case DevelBlendEquation::MAX:
212 return (GetGlesVersion() >= 30);
214 case DevelBlendEquation::MULTIPLY:
215 case DevelBlendEquation::SCREEN:
216 case DevelBlendEquation::OVERLAY:
217 case DevelBlendEquation::DARKEN:
218 case DevelBlendEquation::LIGHTEN:
219 case DevelBlendEquation::COLOR_DODGE:
220 case DevelBlendEquation::COLOR_BURN:
221 case DevelBlendEquation::HARD_LIGHT:
222 case DevelBlendEquation::SOFT_LIGHT:
223 case DevelBlendEquation::DIFFERENCE:
224 case DevelBlendEquation::EXCLUSION:
225 case DevelBlendEquation::HUE:
226 case DevelBlendEquation::SATURATION:
227 case DevelBlendEquation::COLOR:
228 case DevelBlendEquation::LUMINOSITY:
230 return IsAdvancedBlendEquationSupported();
242 std::string GetShaderVersionPrefix()
244 if(mShaderVersionPrefix == "")
246 mShaderVersionPrefix = "#version " + std::to_string( GetShadingLanguageVersion() );
247 if(GetShadingLanguageVersion() < 300)
249 mShaderVersionPrefix += "\n";
253 mShaderVersionPrefix += " es\n";
256 return mShaderVersionPrefix;
259 std::string GetVertexShaderPrefix()
261 if(mVertexShaderPrefix == "")
263 mVertexShaderPrefix = GetShaderVersionPrefix();
265 if(GetShadingLanguageVersion() < 300)
267 mVertexShaderPrefix += "#define INPUT attribute\n";
268 mVertexShaderPrefix += "#define OUTPUT varying\n";
272 mVertexShaderPrefix += "#define INPUT in\n";
273 mVertexShaderPrefix += "#define OUTPUT out\n";
276 return mVertexShaderPrefix;
279 std::string GetFragmentShaderPrefix()
281 if(mFragmentShaderPrefix == "")
283 mFragmentShaderPrefix = GetShaderVersionPrefix();
285 if(GetShadingLanguageVersion() < 300)
287 mFragmentShaderPrefix += "#define INPUT varying\n";
288 mFragmentShaderPrefix += "#define OUT_COLOR gl_FragColor\n";
289 mFragmentShaderPrefix += "#define TEXTURE texture2D\n";
293 mFragmentShaderPrefix += "#define INPUT in\n";
294 mFragmentShaderPrefix += "#define OUT_COLOR fragColor\n";
295 mFragmentShaderPrefix += "#define TEXTURE texture\n";
297 if(IsAdvancedBlendEquationSupported())
299 mFragmentShaderPrefix += FRAGMENT_SHADER_ADVANCED_BLEND_EQUATION_PREFIX;
302 mFragmentShaderPrefix += FRAGMENT_SHADER_OUTPUT_COLOR_STRING;
305 return mFragmentShaderPrefix;
308 bool TextureRequiresConverting( const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage ) const override
310 bool convert = ( ( imageGlFormat == GL_RGB ) && ( textureGlFormat == GL_RGBA ) );
311 if( mGlesVersion >= 30 )
313 // Don't convert manually from RGB to RGBA if GLES >= 3.0 and a sub-image is uploaded.
314 convert = ( convert && !isSubImage );
319 int GetMaxTextureSize()
321 ConditionalWait::ScopedLock lock( mContextCreatedWaitCondition );
322 if( !mIsContextCreated )
324 mContextCreatedWaitCondition.Wait( lock );
326 return mMaxTextureSize;
331 ConditionalWait::ScopedLock lock( mContextCreatedWaitCondition );
332 if( !mIsContextCreated )
334 mContextCreatedWaitCondition.Wait( lock );
339 void SetShadingLanguageVersion( int shadingLanguageVersion )
341 mShadingLanguageVersion = shadingLanguageVersion;
342 mShadingLanguageVersionCached = true;
345 int GetShadingLanguageVersion()
347 ConditionalWait::ScopedLock lock( mContextCreatedWaitCondition );
348 if( !mIsContextCreated && !mShadingLanguageVersionCached )
350 mContextCreatedWaitCondition.Wait( lock );
352 return mShadingLanguageVersion;
357 void ActiveTexture( GLenum texture ) override
359 glActiveTexture( texture );
362 void AttachShader( GLuint program, GLuint shader ) override
364 glAttachShader( program, shader );
367 void BindAttribLocation( GLuint program, GLuint index, const char* name ) override
369 glBindAttribLocation( program, index, name );
372 void BindBuffer( GLenum target, GLuint buffer ) override
374 glBindBuffer( target, buffer );
377 void BindFramebuffer( GLenum target, GLuint framebuffer ) override
379 glBindFramebuffer( target, framebuffer );
382 void BindRenderbuffer( GLenum target, GLuint renderbuffer ) override
384 glBindRenderbuffer( target, renderbuffer );
387 void BindTexture( GLenum target, GLuint texture ) override
389 glBindTexture( target, texture );
392 void BlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) override
394 glBlendColor( red, green, blue, alpha );
397 void BlendEquation( GLenum mode ) override
399 glBlendEquation( mode );
402 void BlendEquationSeparate( GLenum modeRGB, GLenum modeAlpha ) override
404 glBlendEquationSeparate( modeRGB, modeAlpha );
407 void BlendFunc( GLenum sfactor, GLenum dfactor ) override
409 glBlendFunc( sfactor, dfactor );
412 void BlendFuncSeparate( GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha ) override
414 glBlendFuncSeparate( srcRGB, dstRGB, srcAlpha, dstAlpha );
417 void BufferData( GLenum target, GLsizeiptr size, const void* data, GLenum usage ) override
419 glBufferData( target, size, data, usage );
422 void BufferSubData( GLenum target, GLintptr offset, GLsizeiptr size, const void* data ) override
424 glBufferSubData( target, offset, size, data );
427 GLenum CheckFramebufferStatus( GLenum target ) override
429 return glCheckFramebufferStatus( target );
432 void Clear( GLbitfield mask ) override
437 void ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) override
439 glClearColor( red, green, blue, alpha );
442 void ClearDepthf( GLclampf depth ) override
444 glClearDepthf( depth );
447 void ClearStencil( GLint s ) override
452 void ColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ) override
454 glColorMask( red, green, blue, alpha );
457 void CompileShader( GLuint shader ) override
459 glCompileShader( shader );
462 void CompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data ) override
464 glCompressedTexImage2D( target, level, internalformat, width, height, border, imageSize, data );
467 void CompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data ) override
469 glCompressedTexSubImage2D( target, level, xoffset, yoffset, width, height, format, imageSize, data );
472 void CopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border ) override
474 glCopyTexImage2D( target, level, internalformat, x, y, width, height, border );
477 void CopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height ) override
479 glCopyTexSubImage2D( target, level, xoffset, yoffset, x, y, width, height );
482 GLuint CreateProgram( void ) override
484 return glCreateProgram();
487 GLuint CreateShader( GLenum type ) override
489 return glCreateShader( type );
492 void CullFace( GLenum mode ) override
497 void DeleteBuffers( GLsizei n, const GLuint* buffers ) override
499 glDeleteBuffers( n, buffers );
502 void DeleteFramebuffers( GLsizei n, const GLuint* framebuffers ) override
504 glDeleteFramebuffers( n, framebuffers );
507 void DeleteProgram( GLuint program ) override
509 glDeleteProgram( program );
512 void DeleteRenderbuffers( GLsizei n, const GLuint* renderbuffers ) override
514 glDeleteRenderbuffers( n, renderbuffers );
517 void DeleteShader( GLuint shader ) override
519 glDeleteShader( shader );
522 void DeleteTextures( GLsizei n, const GLuint* textures ) override
524 glDeleteTextures( n, textures );
527 void DepthFunc( GLenum func ) override
532 void DepthMask( GLboolean flag ) override
537 void DepthRangef( GLclampf zNear, GLclampf zFar ) override
539 glDepthRangef( zNear, zFar );
542 void DetachShader( GLuint program, GLuint shader ) override
544 glDetachShader( program, shader );
547 void Disable( GLenum cap ) override
552 void DisableVertexAttribArray( GLuint index ) override
554 glDisableVertexAttribArray( index );
557 void DrawArrays( GLenum mode, GLint first, GLsizei count ) override
559 glDrawArrays( mode, first, count );
562 void DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices ) override
564 glDrawElements( mode, count, type, indices );
567 void Enable( GLenum cap ) override
572 void EnableVertexAttribArray( GLuint index ) override
574 glEnableVertexAttribArray( index );
577 void Finish( void ) override
582 void Flush( void ) override
587 void FramebufferRenderbuffer( GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer ) override
589 glFramebufferRenderbuffer( target, attachment, renderbuffertarget, renderbuffer );
592 void FramebufferTexture2D( GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level ) override
594 glFramebufferTexture2D( target, attachment, textarget, texture, level );
597 void FrontFace( GLenum mode ) override
602 void GenBuffers( GLsizei n, GLuint* buffers ) override
604 glGenBuffers( n, buffers );
607 void GenerateMipmap( GLenum target ) override
609 glGenerateMipmap( target );
612 void GenFramebuffers( GLsizei n, GLuint* framebuffers ) override
614 glGenFramebuffers( n, framebuffers );
617 void GenRenderbuffers( GLsizei n, GLuint* renderbuffers ) override
619 glGenRenderbuffers( n, renderbuffers );
622 void GenTextures( GLsizei n, GLuint* textures ) override
624 glGenTextures( n, textures );
627 void GetActiveAttrib( GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name ) override
629 glGetActiveAttrib( program, index, bufsize, length, size, type, name );
632 void GetActiveUniform( GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name ) override
634 glGetActiveUniform( program, index, bufsize, length, size, type, name );
637 void GetAttachedShaders( GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders ) override
639 glGetAttachedShaders( program, maxcount, count, shaders );
642 int GetAttribLocation( GLuint program, const char* name ) override
644 return glGetAttribLocation( program, name );
647 void GetBooleanv( GLenum pname, GLboolean* params ) override
649 glGetBooleanv( pname, params );
652 void GetBufferParameteriv( GLenum target, GLenum pname, GLint* params ) override
654 glGetBufferParameteriv( target, pname, params );
657 GLenum GetError( void ) override
662 void GetFloatv( GLenum pname, GLfloat* params ) override
664 glGetFloatv( pname, params );
667 void GetFramebufferAttachmentParameteriv( GLenum target, GLenum attachment, GLenum pname, GLint* params ) override
669 glGetFramebufferAttachmentParameteriv( target, attachment, pname, params );
672 void GetIntegerv( GLenum pname, GLint* params ) override
674 glGetIntegerv( pname, params );
677 void GetProgramiv( GLuint program, GLenum pname, GLint* params ) override
679 glGetProgramiv( program, pname, params );
682 void GetProgramInfoLog( GLuint program, GLsizei bufsize, GLsizei* length, char* infolog ) override
684 glGetProgramInfoLog( program, bufsize, length, infolog );
687 void GetRenderbufferParameteriv( GLenum target, GLenum pname, GLint* params ) override
689 glGetRenderbufferParameteriv( target, pname, params );
692 void GetShaderiv( GLuint shader, GLenum pname, GLint* params ) override
694 glGetShaderiv( shader, pname, params );
697 void GetShaderInfoLog( GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog ) override
699 glGetShaderInfoLog( shader, bufsize, length, infolog );
702 void GetShaderPrecisionFormat( GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision ) override
704 glGetShaderPrecisionFormat( shadertype, precisiontype, range, precision );
707 void GetShaderSource( GLuint shader, GLsizei bufsize, GLsizei* length, char* source ) override
709 glGetShaderSource( shader, bufsize, length, source );
712 const GLubyte* GetString( GLenum name ) override
714 return glGetString( name );
717 void GetTexParameterfv( GLenum target, GLenum pname, GLfloat* params ) override
719 glGetTexParameterfv( target, pname, params );
722 void GetTexParameteriv( GLenum target, GLenum pname, GLint* params ) override
724 glGetTexParameteriv( target, pname, params );
727 void GetUniformfv( GLuint program, GLint location, GLfloat* params ) override
729 glGetUniformfv( program, location, params );
732 void GetUniformiv( GLuint program, GLint location, GLint* params ) override
734 glGetUniformiv( program, location, params );
737 int GetUniformLocation( GLuint program, const char* name ) override
739 return glGetUniformLocation( program, name );
742 void GetVertexAttribfv( GLuint index, GLenum pname, GLfloat* params ) override
744 glGetVertexAttribfv( index, pname, params );
747 void GetVertexAttribiv( GLuint index, GLenum pname, GLint* params ) override
749 glGetVertexAttribiv( index, pname, params );
752 void GetVertexAttribPointerv( GLuint index, GLenum pname, void** pointer ) override
754 glGetVertexAttribPointerv( index, pname, pointer );
757 void Hint( GLenum target, GLenum mode ) override
759 glHint( target, mode );
762 GLboolean IsBuffer( GLuint buffer ) override
764 return glIsBuffer( buffer );
767 GLboolean IsEnabled( GLenum cap ) override
769 return glIsEnabled( cap );
772 GLboolean IsFramebuffer( GLuint framebuffer ) override
774 return glIsFramebuffer( framebuffer );
777 GLboolean IsProgram( GLuint program ) override
779 return glIsProgram( program );
782 GLboolean IsRenderbuffer( GLuint renderbuffer ) override
784 return glIsRenderbuffer( renderbuffer );
787 GLboolean IsShader( GLuint shader ) override
789 return glIsShader( shader );
792 GLboolean IsTexture( GLuint texture ) override
794 return glIsTexture( texture );
797 void LineWidth( GLfloat width ) override
799 glLineWidth( width );
802 void LinkProgram( GLuint program ) override
804 glLinkProgram( program );
807 void PixelStorei( GLenum pname, GLint param ) override
809 glPixelStorei( pname, param );
812 void PolygonOffset( GLfloat factor, GLfloat units ) override
814 glPolygonOffset( factor, units );
817 void ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels ) override
819 glReadPixels( x, y, width, height, format, type, pixels );
822 void ReleaseShaderCompiler( void ) override
824 glReleaseShaderCompiler();
827 void RenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height ) override
829 glRenderbufferStorage( target, internalformat, width, height );
832 void SampleCoverage( GLclampf value, GLboolean invert ) override
834 glSampleCoverage( value, invert );
837 void Scissor( GLint x, GLint y, GLsizei width, GLsizei height ) override
839 glScissor( x, y, width, height );
842 void ShaderBinary( GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length ) override
844 glShaderBinary( n, shaders, binaryformat, binary, length );
847 void ShaderSource( GLuint shader, GLsizei count, const char** string, const GLint* length ) override
849 glShaderSource( shader, count, string, length );
852 void StencilFunc( GLenum func, GLint ref, GLuint mask ) override
854 glStencilFunc( func, ref, mask );
857 void StencilFuncSeparate( GLenum face, GLenum func, GLint ref, GLuint mask ) override
859 glStencilFuncSeparate( face, func, ref, mask );
862 void StencilMask( GLuint mask ) override
864 glStencilMask( mask );
867 void StencilMaskSeparate( GLenum face, GLuint mask ) override
869 glStencilMaskSeparate( face, mask );
872 void StencilOp( GLenum fail, GLenum zfail, GLenum zpass ) override
874 glStencilOp( fail, zfail, zpass );
877 void StencilOpSeparate( GLenum face, GLenum fail, GLenum zfail, GLenum zpass ) override
879 glStencilOpSeparate( face, fail, zfail, zpass );
882 void TexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels ) override
884 glTexImage2D( target, level, internalformat, width, height, border, format, type, pixels );
887 void TexParameterf( GLenum target, GLenum pname, GLfloat param ) override
889 glTexParameterf( target, pname, param );
892 void TexParameterfv( GLenum target, GLenum pname, const GLfloat* params ) override
894 glTexParameterfv( target, pname, params );
897 void TexParameteri( GLenum target, GLenum pname, GLint param ) override
899 glTexParameteri( target, pname, param );
902 void TexParameteriv( GLenum target, GLenum pname, const GLint* params ) override
904 glTexParameteriv( target, pname, params );
907 void TexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels ) override
909 glTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels );
912 void Uniform1f( GLint location, GLfloat x ) override
914 glUniform1f( location, x );
917 void Uniform1fv( GLint location, GLsizei count, const GLfloat* v ) override
919 glUniform1fv( location, count, v );
922 void Uniform1i( GLint location, GLint x ) override
924 glUniform1i( location, x );
927 void Uniform1iv( GLint location, GLsizei count, const GLint* v ) override
929 glUniform1iv( location, count, v );
932 void Uniform2f( GLint location, GLfloat x, GLfloat y ) override
934 glUniform2f( location, x, y );
937 void Uniform2fv( GLint location, GLsizei count, const GLfloat* v ) override
939 glUniform2fv( location, count, v );
942 void Uniform2i( GLint location, GLint x, GLint y ) override
944 glUniform2i( location, x, y );
947 void Uniform2iv( GLint location, GLsizei count, const GLint* v ) override
949 glUniform2iv( location, count, v );
952 void Uniform3f( GLint location, GLfloat x, GLfloat y, GLfloat z ) override
954 glUniform3f( location, x, y, z );
957 void Uniform3fv( GLint location, GLsizei count, const GLfloat* v ) override
959 glUniform3fv( location, count, v );
962 void Uniform3i( GLint location, GLint x, GLint y, GLint z ) override
964 glUniform3i( location, x, y, z );
967 void Uniform3iv( GLint location, GLsizei count, const GLint* v ) override
969 glUniform3iv( location, count, v );
972 void Uniform4f( GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) override
974 glUniform4f( location, x, y, z, w );
977 void Uniform4fv( GLint location, GLsizei count, const GLfloat* v ) override
979 glUniform4fv( location, count, v );
982 void Uniform4i( GLint location, GLint x, GLint y, GLint z, GLint w ) override
984 glUniform4i( location, x, y, z, w );
987 void Uniform4iv( GLint location, GLsizei count, const GLint* v ) override
989 glUniform4iv( location, count, v );
992 void UniformMatrix2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
994 glUniformMatrix2fv( location, count, transpose, value );
997 void UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
999 glUniformMatrix3fv( location, count, transpose, value );
1002 void UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
1004 glUniformMatrix4fv( location, count, transpose, value );
1007 void UseProgram( GLuint program ) override
1009 glUseProgram( program );
1012 void ValidateProgram( GLuint program ) override
1014 glValidateProgram( program );
1017 void VertexAttrib1f( GLuint indx, GLfloat x ) override
1019 glVertexAttrib1f( indx, x );
1022 void VertexAttrib1fv( GLuint indx, const GLfloat* values ) override
1024 glVertexAttrib1fv( indx, values );
1027 void VertexAttrib2f( GLuint indx, GLfloat x, GLfloat y ) override
1029 glVertexAttrib2f( indx, x, y );
1032 void VertexAttrib2fv( GLuint indx, const GLfloat* values ) override
1034 glVertexAttrib2fv( indx, values );
1037 void VertexAttrib3f( GLuint indx, GLfloat x, GLfloat y, GLfloat z ) override
1039 glVertexAttrib3f( indx, x, y, z );
1042 void VertexAttrib3fv( GLuint indx, const GLfloat* values ) override
1044 glVertexAttrib3fv( indx, values );
1047 void VertexAttrib4f( GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) override
1049 glVertexAttrib4f( indx, x, y, z, w );
1052 void VertexAttrib4fv( GLuint indx, const GLfloat* values ) override
1054 glVertexAttrib4fv( indx, values );
1057 void VertexAttribPointer( GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr ) override
1059 glVertexAttribPointer( indx, size, type, normalized, stride, ptr );
1062 void Viewport( GLint x, GLint y, GLsizei width, GLsizei height ) override
1064 glViewport( x, y, width, height );
1069 void ReadBuffer( GLenum mode ) override
1071 mImpl->ReadBuffer( mode );
1074 void DrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices ) override
1076 mImpl->DrawRangeElements( mode, start, end, count, type, indices );
1079 void TexImage3D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels ) override
1081 mImpl->TexImage3D( target, level, internalformat, width, height, depth, border, format, type, pixels );
1084 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
1086 mImpl->TexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels );
1089 void CopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) override
1091 mImpl->CopyTexSubImage3D( target, level, xoffset, yoffset, zoffset, x, y, width, height );
1094 void CompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data ) override
1096 mImpl->CompressedTexImage3D( target, level, internalformat, width, height, depth, border, imageSize, data );
1099 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
1101 mImpl->CompressedTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data );
1104 void GenQueries( GLsizei n, GLuint* ids ) override
1106 mImpl->GenQueries( n, ids );
1109 void DeleteQueries( GLsizei n, const GLuint* ids ) override
1111 mImpl->DeleteQueries( n, ids );
1114 GLboolean IsQuery( GLuint id ) override
1116 return mImpl->IsQuery( id );
1119 void BeginQuery( GLenum target, GLuint id ) override
1121 mImpl->BeginQuery( target, id );
1124 void EndQuery( GLenum target ) override
1126 mImpl->EndQuery( target );
1129 void GetQueryiv( GLenum target, GLenum pname, GLint* params ) override
1131 mImpl->GetQueryiv( target, pname, params );
1134 void GetQueryObjectuiv( GLuint id, GLenum pname, GLuint* params ) override
1136 mImpl->GetQueryObjectuiv( id, pname, params );
1139 GLboolean UnmapBuffer( GLenum target ) override
1141 return mImpl->UnmapBuffer( target );
1144 void GetBufferPointerv( GLenum target, GLenum pname, GLvoid** params ) override
1146 mImpl->GetBufferPointerv( target, pname, params );
1149 void DrawBuffers( GLsizei n, const GLenum* bufs ) override
1151 mImpl->DrawBuffers( n, bufs );
1154 void UniformMatrix2x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
1156 mImpl->UniformMatrix2x3fv( location, count, transpose, value );
1159 void UniformMatrix3x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
1161 mImpl->UniformMatrix3x2fv( location, count, transpose, value );
1164 void UniformMatrix2x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
1166 mImpl->UniformMatrix2x4fv( location, count, transpose, value );
1169 void UniformMatrix4x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
1171 mImpl->UniformMatrix4x2fv( location, count, transpose, value );
1174 void UniformMatrix3x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
1176 mImpl->UniformMatrix3x4fv( location, count, transpose, value );
1179 void UniformMatrix4x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
1181 mImpl->UniformMatrix4x3fv( location, count, transpose, value );
1184 void BlitFramebuffer( GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter ) override
1186 mImpl->BlitFramebuffer( srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter );
1189 void RenderbufferStorageMultisample( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height ) override
1191 mImpl->RenderbufferStorageMultisample( target, samples, internalformat, width, height );
1194 void FramebufferTextureLayer( GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer ) override
1196 mImpl->FramebufferTextureLayer( target, attachment, texture, level, layer );
1199 GLvoid* MapBufferRange( GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access ) override
1201 return mImpl->MapBufferRange( target, offset, length, access );
1204 void FlushMappedBufferRange( GLenum target, GLintptr offset, GLsizeiptr length ) override
1206 mImpl->FlushMappedBufferRange( target, offset, length );
1209 void BindVertexArray( GLuint array ) override
1211 mImpl->BindVertexArray( array );
1214 void DeleteVertexArrays( GLsizei n, const GLuint* arrays ) override
1216 mImpl->DeleteVertexArrays( n, arrays );
1219 void GenVertexArrays( GLsizei n, GLuint* arrays ) override
1221 mImpl->GenVertexArrays( n, arrays );
1224 GLboolean IsVertexArray( GLuint array ) override
1226 return mImpl->IsVertexArray( array );
1229 void GetIntegeri_v( GLenum target, GLuint index, GLint* data ) override
1231 mImpl->GetIntegeri_v( target, index, data );
1234 void BeginTransformFeedback( GLenum primitiveMode ) override
1236 mImpl->BeginTransformFeedback( primitiveMode );
1239 void EndTransformFeedback( void ) override
1241 mImpl->EndTransformFeedback();
1244 void BindBufferRange( GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size ) override
1246 mImpl->BindBufferRange( target, index, buffer, offset, size );
1249 void BindBufferBase( GLenum target, GLuint index, GLuint buffer ) override
1251 mImpl->BindBufferBase( target, index, buffer );
1254 void TransformFeedbackVaryings( GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode ) override
1256 mImpl->TransformFeedbackVaryings( program, count, varyings, bufferMode );
1259 void GetTransformFeedbackVarying( GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name ) override
1261 mImpl->GetTransformFeedbackVarying( program, index, bufSize, length, size, type, name );
1264 void VertexAttribIPointer( GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer ) override
1266 mImpl->VertexAttribIPointer( index, size, type, stride, pointer );
1269 void GetVertexAttribIiv( GLuint index, GLenum pname, GLint* params ) override
1271 mImpl->GetVertexAttribIiv( index, pname, params );
1274 void GetVertexAttribIuiv( GLuint index, GLenum pname, GLuint* params ) override
1276 mImpl->GetVertexAttribIuiv( index, pname, params );
1279 void VertexAttribI4i( GLuint index, GLint x, GLint y, GLint z, GLint w ) override
1281 mImpl->VertexAttribI4i( index, x, y, z, w );
1284 void VertexAttribI4ui( GLuint index, GLuint x, GLuint y, GLuint z, GLuint w ) override
1286 mImpl->VertexAttribI4ui( index, x, y, z, w );
1289 void VertexAttribI4iv( GLuint index, const GLint* v ) override
1291 mImpl->VertexAttribI4iv( index, v );
1294 void VertexAttribI4uiv( GLuint index, const GLuint* v ) override
1296 mImpl->VertexAttribI4uiv( index, v );
1299 void GetUniformuiv( GLuint program, GLint location, GLuint* params ) override
1301 mImpl->GetUniformuiv( program, location, params );
1304 GLint GetFragDataLocation( GLuint program, const GLchar *name ) override
1306 return mImpl->GetFragDataLocation( program, name );
1309 void Uniform1ui( GLint location, GLuint v0 ) override
1311 mImpl->Uniform1ui( location, v0 );
1314 void Uniform2ui( GLint location, GLuint v0, GLuint v1 ) override
1316 mImpl->Uniform2ui( location, v0, v1 );
1319 void Uniform3ui( GLint location, GLuint v0, GLuint v1, GLuint v2 ) override
1321 mImpl->Uniform3ui( location, v0, v1, v2 );
1324 void Uniform4ui( GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3 ) override
1326 mImpl->Uniform4ui( location, v0, v1, v2, v3 );
1329 void Uniform1uiv( GLint location, GLsizei count, const GLuint* value ) override
1331 mImpl->Uniform1uiv( location, count, value );
1334 void Uniform2uiv( GLint location, GLsizei count, const GLuint* value ) override
1336 mImpl->Uniform2uiv( location, count, value );
1339 void Uniform3uiv( GLint location, GLsizei count, const GLuint* value ) override
1341 mImpl->Uniform3uiv( location, count, value );
1344 void Uniform4uiv( GLint location, GLsizei count, const GLuint* value ) override
1346 mImpl->Uniform4uiv( location, count, value );
1349 void ClearBufferiv( GLenum buffer, GLint drawbuffer, const GLint* value ) override
1351 mImpl->ClearBufferiv( buffer, drawbuffer, value );
1354 void ClearBufferuiv( GLenum buffer, GLint drawbuffer, const GLuint* value ) override
1356 mImpl->ClearBufferuiv( buffer, drawbuffer, value );
1359 void ClearBufferfv( GLenum buffer, GLint drawbuffer, const GLfloat* value ) override
1361 mImpl->ClearBufferfv( buffer, drawbuffer, value );
1364 void ClearBufferfi( GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil ) override
1366 mImpl->ClearBufferfi( buffer, drawbuffer, depth, stencil );
1369 const GLubyte* GetStringi( GLenum name, GLuint index ) override
1371 return mImpl->GetStringi( name, index );
1374 void CopyBufferSubData( GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size ) override
1376 mImpl->CopyBufferSubData( readTarget, writeTarget, readOffset, writeOffset, size );
1379 void GetUniformIndices( GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices ) override
1381 mImpl->GetUniformIndices( program, uniformCount, uniformNames, uniformIndices );
1384 void GetActiveUniformsiv( GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params ) override
1386 mImpl->GetActiveUniformsiv( program, uniformCount, uniformIndices, pname, params );
1389 GLuint GetUniformBlockIndex( GLuint program, const GLchar* uniformBlockName ) override
1391 return mImpl->GetUniformBlockIndex( program, uniformBlockName );
1394 void GetActiveUniformBlockiv( GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params ) override
1396 mImpl->GetActiveUniformBlockiv( program, uniformBlockIndex, pname, params );
1399 void GetActiveUniformBlockName( GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName ) override
1401 mImpl->GetActiveUniformBlockName( program, uniformBlockIndex, bufSize, length, uniformBlockName );
1404 void UniformBlockBinding( GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding ) override
1406 mImpl->UniformBlockBinding( program, uniformBlockIndex, uniformBlockBinding );
1409 void DrawArraysInstanced( GLenum mode, GLint first, GLsizei count, GLsizei instanceCount ) override
1411 mImpl->DrawArraysInstanced( mode, first, count, instanceCount );
1414 void DrawElementsInstanced( GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount ) override
1416 mImpl->DrawElementsInstanced( mode, count, type, indices, instanceCount );
1419 GLsync FenceSync( GLenum condition, GLbitfield flags ) override
1421 return mImpl->FenceSync( condition, flags );
1424 GLboolean IsSync( GLsync sync ) override
1426 return mImpl->IsSync( sync );
1429 void DeleteSync( GLsync sync ) override
1431 mImpl->DeleteSync( sync );
1434 GLenum ClientWaitSync( GLsync sync, GLbitfield flags, GLuint64 timeout ) override
1436 return mImpl->ClientWaitSync( sync, flags, timeout );
1439 void WaitSync( GLsync sync, GLbitfield flags, GLuint64 timeout ) override
1441 mImpl->WaitSync( sync, flags, timeout );
1444 void GetInteger64v( GLenum pname, GLint64* params ) override
1446 mImpl->GetInteger64v( pname, params );
1449 void GetSynciv( GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values ) override
1451 mImpl->GetSynciv( sync, pname, bufSize, length, values );
1454 void GetInteger64i_v( GLenum target, GLuint index, GLint64* data ) override
1456 mImpl->GetInteger64i_v( target, index, data );
1459 void GetBufferParameteri64v( GLenum target, GLenum pname, GLint64* params ) override
1461 mImpl->GetBufferParameteri64v( target, pname, params );
1464 void GenSamplers( GLsizei count, GLuint* samplers ) override
1466 mImpl->GenSamplers( count, samplers );
1469 void DeleteSamplers( GLsizei count, const GLuint* samplers ) override
1471 mImpl->DeleteSamplers( count, samplers );
1474 GLboolean IsSampler( GLuint sampler ) override
1476 return mImpl->IsSampler( sampler );
1479 void BindSampler( GLuint unit, GLuint sampler ) override
1481 mImpl->BindSampler( unit, sampler );
1484 void SamplerParameteri( GLuint sampler, GLenum pname, GLint param ) override
1486 mImpl->SamplerParameteri( sampler, pname, param );
1489 void SamplerParameteriv( GLuint sampler, GLenum pname, const GLint* param ) override
1491 mImpl->SamplerParameteriv( sampler, pname, param );
1494 void SamplerParameterf( GLuint sampler, GLenum pname, GLfloat param ) override
1496 mImpl->SamplerParameterf( sampler, pname, param );
1499 void SamplerParameterfv( GLuint sampler, GLenum pname, const GLfloat* param ) override
1501 mImpl->SamplerParameterfv( sampler, pname, param );
1504 void GetSamplerParameteriv( GLuint sampler, GLenum pname, GLint* params ) override
1506 mImpl->GetSamplerParameteriv( sampler, pname, params );
1509 void GetSamplerParameterfv( GLuint sampler, GLenum pname, GLfloat* params ) override
1511 mImpl->GetSamplerParameterfv( sampler, pname, params );
1514 void VertexAttribDivisor( GLuint index, GLuint divisor ) override
1516 mImpl->VertexAttribDivisor( index, divisor );
1519 void BindTransformFeedback( GLenum target, GLuint id ) override
1521 mImpl->BindTransformFeedback( target, id );
1524 void DeleteTransformFeedbacks( GLsizei n, const GLuint* ids ) override
1526 mImpl->DeleteTransformFeedbacks( n, ids );
1529 void GenTransformFeedbacks( GLsizei n, GLuint* ids ) override
1531 mImpl->GenTransformFeedbacks( n, ids );
1534 GLboolean IsTransformFeedback( GLuint id ) override
1536 return mImpl->IsTransformFeedback( id );
1539 void PauseTransformFeedback( void ) override
1541 mImpl->PauseTransformFeedback();
1544 void ResumeTransformFeedback( void ) override
1546 mImpl->ResumeTransformFeedback();
1549 void GetProgramBinary( GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary ) override
1551 mImpl->GetProgramBinary( program, bufSize, length, binaryFormat, binary );
1554 void ProgramBinary( GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length ) override
1556 mImpl->ProgramBinary( program, binaryFormat, binary, length );
1559 void ProgramParameteri( GLuint program, GLenum pname, GLint value ) override
1561 mImpl->ProgramParameteri( program, pname, value );
1564 void InvalidateFramebuffer( GLenum target, GLsizei numAttachments, const GLenum* attachments ) override
1566 mImpl->InvalidateFramebuffer( target, numAttachments, attachments );
1569 void InvalidateSubFramebuffer( GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height ) override
1571 mImpl->InvalidateSubFramebuffer( target, numAttachments, attachments, x, y, width, height );
1574 void TexStorage2D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height ) override
1576 mImpl->TexStorage2D( target, levels, internalformat, width, height );
1579 void TexStorage3D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth ) override
1581 mImpl->TexStorage3D( target, levels, internalformat, width, height, depth );
1584 void GetInternalformativ( GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params ) override
1586 mImpl->GetInternalformativ( target, internalformat, pname, bufSize, params );
1589 void BlendBarrier(void)
1591 if(mIsAdvancedBlendEquationSupported)
1593 mImpl->BlendBarrier();
1598 std::unique_ptr<GlesAbstraction> mImpl;
1600 ConditionalWait mContextCreatedWaitCondition;
1601 GLint mMaxTextureSize;
1602 std::string mShaderVersionPrefix;
1603 std::string mVertexShaderPrefix;
1604 std::string mFragmentShaderPrefix;
1605 int32_t mGlesVersion;
1606 int32_t mShadingLanguageVersion;
1607 bool mShadingLanguageVersionCached;
1608 bool mIsSurfacelessContextSupported;
1609 bool mIsAdvancedBlendEquationSupportedCached;
1610 bool mIsAdvancedBlendEquationSupported;
1611 bool mIsContextCreated;
1614 } // namespace Adaptor
1616 } // namespace Internal
1620 #endif // DALI_INTERNAL_GL_IMPLEMENTATION_H