2 * Copyright (c) 2021 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>
33 GlExtensions::GlExtensions()
35 #ifdef GL_EXT_discard_framebuffer
36 mGlDiscardFramebuffer(nullptr),
38 #ifdef GL_OES_get_program_binary
39 mGlGetProgramBinaryOES(nullptr),
40 mGlProgramBinaryOES(nullptr),
42 #ifdef GL_KHR_blend_equation_advanced
43 mBlendBarrierKHR(nullptr),
49 GlExtensions::~GlExtensions()
53 void GlExtensions::DiscardFrameBuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
55 // initialize extension on first use as on some hw platforms a context
56 // has to be bound for the extensions to return correct pointer
62 #ifdef GL_EXT_discard_framebuffer
63 if(mGlDiscardFramebuffer)
65 mGlDiscardFramebuffer(target, numAttachments, attachments);
69 DALI_LOG_ERROR("Error: glDiscardFramebufferEXT extension is not available\n");
74 void GlExtensions::GetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
76 // initialize extension on first use as on some hw platforms a context
77 // has to be bound for the extensions to return correct pointer
83 #ifdef GL_OES_get_program_binary
84 if(mGlGetProgramBinaryOES)
86 mGlGetProgramBinaryOES(program, bufSize, length, binaryFormat, binary);
90 DALI_LOG_ERROR("Error: glGetProgramBinaryOES extension is not available\n");
96 void GlExtensions::ProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLint length)
98 // initialize extension on first use as on some hw platforms a context
99 // has to be bound for the extensions to return correct pointer
105 #ifdef GL_OES_get_program_binary
106 if(mGlProgramBinaryOES)
108 mGlProgramBinaryOES(program, binaryFormat, binary, length);
112 DALI_LOG_ERROR("Error: glProgramBinaryOES extension is not available\n");
113 DALI_ASSERT_DEBUG(0);
118 bool GlExtensions::BlendBarrierKHR()
120 // initialize extension on first use as on some hw platforms a context
121 // has to be bound for the extensions to return correct pointer
127 #ifdef GL_KHR_blend_equation_advanced
139 void GlExtensions::Initialize()
143 #ifdef GL_EXT_discard_framebuffer
144 mGlDiscardFramebuffer = reinterpret_cast<PFNGLDISCARDFRAMEBUFFEREXTPROC>(eglGetProcAddress("glDiscardFramebufferEXT"));
147 #ifdef GL_OES_get_program_binary
148 mGlGetProgramBinaryOES = reinterpret_cast<PFNGLGETPROGRAMBINARYOESPROC>(eglGetProcAddress("glGetProgramBinaryOES"));
149 mGlProgramBinaryOES = reinterpret_cast<PFNGLPROGRAMBINARYOESPROC>(eglGetProcAddress("glProgramBinaryOES"));
152 #ifdef GL_KHR_blend_equation_advanced
153 mBlendBarrierKHR = reinterpret_cast<PFNGLBLENDBARRIERKHRPROC>(eglGetProcAddress("glBlendBarrierKHR"));
157 } // namespace Adaptor
159 } // namespace Internal