2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/graphics/gles/gl-extensions.h>
22 #include <dali/internal/graphics/common/egl-include.h>
25 #include <dali/integration-api/debug.h>
36 GlExtensions::GlExtensions()
38 #ifdef GL_EXT_discard_framebuffer
39 mGlDiscardFramebuffer( nullptr ),
41 #ifdef GL_OES_get_program_binary
42 mGlGetProgramBinaryOES( nullptr ),
43 mGlProgramBinaryOES( nullptr ),
45 #ifdef GL_KHR_blend_equation_advanced
46 mBlendBarrierKHR( nullptr ),
52 GlExtensions::~GlExtensions()
56 void GlExtensions::DiscardFrameBuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments)
58 // initialize extension on first use as on some hw platforms a context
59 // has to be bound for the extensions to return correct pointer
65 #ifdef GL_EXT_discard_framebuffer
66 if( mGlDiscardFramebuffer )
68 mGlDiscardFramebuffer(target, numAttachments, attachments);
72 DALI_LOG_ERROR("Error: glDiscardFramebufferEXT extension is not available\n");
77 void GlExtensions::GetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary)
79 // initialize extension on first use as on some hw platforms a context
80 // has to be bound for the extensions to return correct pointer
86 #ifdef GL_OES_get_program_binary
87 if (mGlGetProgramBinaryOES)
89 mGlGetProgramBinaryOES(program, bufSize, length, binaryFormat, binary);
93 DALI_LOG_ERROR("Error: glGetProgramBinaryOES extension is not available\n");
99 void GlExtensions::ProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length)
101 // initialize extension on first use as on some hw platforms a context
102 // has to be bound for the extensions to return correct pointer
108 #ifdef GL_OES_get_program_binary
109 if (mGlProgramBinaryOES)
111 mGlProgramBinaryOES(program, binaryFormat, binary, length);
115 DALI_LOG_ERROR("Error: glProgramBinaryOES extension is not available\n");
116 DALI_ASSERT_DEBUG(0);
121 bool GlExtensions::BlendBarrierKHR()
123 // initialize extension on first use as on some hw platforms a context
124 // has to be bound for the extensions to return correct pointer
130 #ifdef GL_KHR_blend_equation_advanced
131 if (mBlendBarrierKHR)
142 void GlExtensions::Initialize()
146 #ifdef GL_EXT_discard_framebuffer
147 mGlDiscardFramebuffer = reinterpret_cast< PFNGLDISCARDFRAMEBUFFEREXTPROC >( eglGetProcAddress("glDiscardFramebufferEXT") );
150 #ifdef GL_OES_get_program_binary
151 mGlGetProgramBinaryOES = reinterpret_cast< PFNGLGETPROGRAMBINARYOESPROC >( eglGetProcAddress("glGetProgramBinaryOES") );
152 mGlProgramBinaryOES = reinterpret_cast< PFNGLPROGRAMBINARYOESPROC >( eglGetProcAddress("glProgramBinaryOES") );
155 #ifdef GL_KHR_blend_equation_advanced
156 mBlendBarrierKHR = reinterpret_cast< PFNGLBLENDBARRIERKHRPROC >( eglGetProcAddress("glBlendBarrierKHR") );
160 } // namespace Adaptor
162 } // namespace Internal