2 * Copyright (c) 2022 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-support.h>
22 #include <GLES2/gl2.h>
23 #include <GLES2/gl2ext.h>
24 #include <GLES3/gl3.h>
26 #include <algorithm> // for std::find_if
29 #include <string_view>
30 #include <utility> // for std::pair
40 static constexpr const char* KHR_BLEND_EQUATION_ADVANCED = "GL_KHR_blend_equation_advanced";
41 static constexpr const char* EXT_MULTISAMPLED_RENDER_TO_TEXTURE = "GL_EXT_multisampled_render_to_texture";
45 namespace GlExtensionCache
47 void GlExtensionSupportedCacheList::EnsureGlExtensionSupportedCheck()
49 // Note that this function calls at most one time.
50 // But the number of GL_EXTENSIONS itmes are so vairous.
51 // We need to reduce extension checkup
53 const char* const extensionStr = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
54 std::istringstream stream(extensionStr);
55 std::string currentExtension;
57 // Create expected string-to-checkertype convertor.
58 using StringTypePair = std::pair<std::string_view, GlExtensionCheckerType>;
60 std::vector<StringTypePair> extensionStringToTypeList
62 {KHR_BLEND_EQUATION_ADVANCED, GlExtensionCheckerType::BLEND_EQUATION_ADVANCED },
64 #ifndef DALI_PROFILE_UBUNTU
65 // @todo : Current ubuntu profile's multisamples FBO make crash when eglDestroyContext.
66 // Invalidate multisampled render to texture feature hardly.
67 {EXT_MULTISAMPLED_RENDER_TO_TEXTURE, GlExtensionCheckerType::MULTISAMPLED_RENDER_TO_TEXTURE},
68 #endif //DALI_PROFILE_UBUNTU
70 ///< Append additional extension checker type here.
74 while(!extensionStringToTypeList.empty() && std::getline(stream, currentExtension, ' '))
76 auto findResult = std::find_if(extensionStringToTypeList.begin(),
77 extensionStringToTypeList.end(),
78 [¤tExtension](const StringTypePair& value) {
79 return value.first == currentExtension;
81 if(findResult != extensionStringToTypeList.end())
83 auto type = findResult->second;
86 MarkSupported(type, true);
88 // Remove from list. we don't need to check this extension.
89 extensionStringToTypeList.erase(findResult);
93 // Set supported as false if extension keyword not exist.
94 SetAllUncachedAsNotSupported();
96 } // namespace GlExtensionCache
97 } // namespace Adaptor
98 } // namespace Internal