diff --git a/android/sdk/src/main/cpp/app/organicmaps/sdk/Framework.cpp b/android/sdk/src/main/cpp/app/organicmaps/sdk/Framework.cpp index 5152a4bf7..8eed02401 100644 --- a/android/sdk/src/main/cpp/app/organicmaps/sdk/Framework.cpp +++ b/android/sdk/src/main/cpp/app/organicmaps/sdk/Framework.cpp @@ -229,8 +229,7 @@ bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi LOG(LWARNING, ("Invalid GL context.")); return false; } - p.m_apiVersion = oglFactory->IsSupportedOpenGLES3() ? dp::ApiVersion::OpenGLES3 : - dp::ApiVersion::OpenGLES2; + p.m_apiVersion = dp::ApiVersion::OpenGLES3; p.m_surfaceWidth = oglFactory->GetWidth(); p.m_surfaceHeight = oglFactory->GetHeight(); diff --git a/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontext.cpp b/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontext.cpp index 0c7376121..bfe5b3841 100644 --- a/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontext.cpp +++ b/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontext.cpp @@ -8,20 +8,16 @@ namespace android { -static EGLint * getContextAttributesList(bool supportedES3) +static EGLint * getContextAttributesList() { static EGLint contextAttrList[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE - }; - static EGLint contextAttrListES3[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE }; - return supportedES3 ? contextAttrListES3 : contextAttrList; + return contextAttrList; } -AndroidOGLContext::AndroidOGLContext(bool supportedES3, EGLDisplay display, EGLSurface surface, +AndroidOGLContext::AndroidOGLContext(EGLDisplay display, EGLSurface surface, EGLConfig config, AndroidOGLContext * contextToShareWith) : m_nativeContext(EGL_NO_CONTEXT) , m_surface(surface) @@ -32,7 +28,7 @@ AndroidOGLContext::AndroidOGLContext(bool supportedES3, EGLDisplay display, EGLS ASSERT(m_display != EGL_NO_DISPLAY, ()); EGLContext sharedContext = (contextToShareWith == NULL) ? EGL_NO_CONTEXT : contextToShareWith->m_nativeContext; - m_nativeContext = eglCreateContext(m_display, config, sharedContext, getContextAttributesList(supportedES3)); + m_nativeContext = eglCreateContext(m_display, config, sharedContext, getContextAttributesList()); CHECK(m_nativeContext != EGL_NO_CONTEXT, ()); } diff --git a/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontext.hpp b/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontext.hpp index 385d80154..6f7885b64 100644 --- a/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontext.hpp +++ b/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontext.hpp @@ -10,7 +10,7 @@ namespace android class AndroidOGLContext : public dp::OGLContext { public: - AndroidOGLContext(bool supportedES3, EGLDisplay display, EGLSurface surface, + AndroidOGLContext(EGLDisplay display, EGLSurface surface, EGLConfig config, AndroidOGLContext * contextToShareWith); ~AndroidOGLContext(); diff --git a/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontextfactory.cpp b/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontextfactory.cpp index 0d7a73e31..4cdedf081 100644 --- a/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontextfactory.cpp +++ b/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontextfactory.cpp @@ -16,26 +16,13 @@ #define EGL_OPENGL_ES3_BIT 0x00000040 -int constexpr kMinSdkVersionForES3 = 21; - namespace android { namespace { -static EGLint * getConfigAttributesListRGB8(bool supportedES3) +static EGLint * getConfigAttributesListRGB8() { static EGLint attr_list[] = { - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, 0, - EGL_STENCIL_SIZE, 0, - EGL_DEPTH_SIZE, 16, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_WINDOW_BIT, - EGL_NONE - }; - static EGLint attr_list_es3[] = { EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, @@ -46,33 +33,16 @@ static EGLint * getConfigAttributesListRGB8(bool supportedES3) EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_WINDOW_BIT, EGL_NONE }; - return supportedES3 ? attr_list_es3 : attr_list; + return attr_list; } int const kMaxConfigCount = 40; -static EGLint * getConfigAttributesListR5G6B5() -{ - // We do not support OpenGL ES3 for R5G6B5, because some Android devices - // are not able to create OpenGL context in such mode. - static EGLint attr_list[] = { - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, - EGL_STENCIL_SIZE, 0, - EGL_DEPTH_SIZE, 16, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_WINDOW_BIT, - EGL_NONE - }; - return attr_list; -} - -bool IsSupportedRGB8(EGLDisplay display, bool es3) +bool IsSupportedRGB8(EGLDisplay display) { EGLConfig configs[kMaxConfigCount]; int count = 0; - return eglChooseConfig(display, getConfigAttributesListRGB8(es3), configs, + return eglChooseConfig(display, getConfigAttributesListRGB8(), configs, kMaxConfigCount, &count) == EGL_TRUE && count != 0; } @@ -90,7 +60,6 @@ AndroidOGLContextFactory::AndroidOGLContextFactory(JNIEnv * env, jobject jsurfac , m_surfaceWidth(0) , m_surfaceHeight(0) , m_windowSurfaceValid(false) - , m_supportedES3(false) { m_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); if (m_display == EGL_NO_DISPLAY) @@ -106,10 +75,7 @@ AndroidOGLContextFactory::AndroidOGLContextFactory(JNIEnv * env, jobject jsurfac return; } - // Check ES3 availability. - bool const isES3Supported = IsSupportedRGB8(m_display, true /* es3 */) && - android_get_device_api_level() >= kMinSdkVersionForES3; - m_supportedES3 = isES3Supported && gl3stubInit(); + CHECK(gl3stubInit(), ("Could not initialize OpenGL ES3")); SetSurface(env, jsurface); @@ -266,7 +232,7 @@ dp::GraphicsContext * AndroidOGLContextFactory::GetDrawContext() ASSERT(m_windowSurface != EGL_NO_SURFACE, ()); if (m_drawContext == nullptr) { - m_drawContext = new AndroidOGLContext(m_supportedES3, m_display, m_windowSurface, + m_drawContext = new AndroidOGLContext(m_display, m_windowSurface, m_config, m_uploadContext); } return m_drawContext; @@ -278,7 +244,7 @@ dp::GraphicsContext * AndroidOGLContextFactory::GetResourcesUploadContext() ASSERT(m_pixelbufferSurface != EGL_NO_SURFACE, ()); if (m_uploadContext == nullptr) { - m_uploadContext = new AndroidOGLContext(m_supportedES3, m_display, m_pixelbufferSurface, + m_uploadContext = new AndroidOGLContext(m_display, m_pixelbufferSurface, m_config, m_drawContext); } return m_uploadContext; @@ -322,17 +288,15 @@ bool AndroidOGLContextFactory::CreateWindowSurface() { EGLConfig configs[kMaxConfigCount]; int count = 0; - if (eglChooseConfig(m_display, getConfigAttributesListRGB8(m_supportedES3), configs, - kMaxConfigCount, &count) != EGL_TRUE) + if (eglChooseConfig(m_display, getConfigAttributesListRGB8(), configs, + kMaxConfigCount, &count) == EGL_TRUE) { - ASSERT(!m_supportedES3, ()); - VERIFY(eglChooseConfig(m_display, getConfigAttributesListR5G6B5(), configs, - kMaxConfigCount, &count) == EGL_TRUE, ()); - LOG(LDEBUG, ("Backbuffer format: R5G6B5")); + CHECK(IsSupportedRGB8(m_display), ("RGB8 is not suported on this device")); + LOG(LDEBUG, ("Backbuffer format: RGB8")); } else { - LOG(LDEBUG, ("Backbuffer format: RGB8")); + CHECK(false, ("OpenGL ES3 is not supported")); } ASSERT(count > 0, ("Didn't find any configs.")); diff --git a/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontextfactory.hpp b/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontextfactory.hpp index 17e9e0b8a..44015dcb0 100644 --- a/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontextfactory.hpp +++ b/android/sdk/src/main/cpp/app/organicmaps/sdk/opengl/androidoglcontextfactory.hpp @@ -33,8 +33,6 @@ public: int GetHeight() const; void UpdateSurfaceSize(int w, int h); - bool IsSupportedOpenGLES3() const { return m_supportedES3; } - private: bool QuerySurfaceSize(); @@ -56,7 +54,6 @@ private: int m_surfaceHeight; bool m_windowSurfaceValid; - bool m_supportedES3; bool m_isInitialized = false; size_t m_initializationCounter = 0; diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm index 7a0ae3730..c681bd86d 100644 --- a/iphone/Maps/Classes/EAGLView.mm +++ b/iphone/Maps/Classes/EAGLView.mm @@ -81,7 +81,7 @@ double getExactDPI(double contentScaleFactor) if (tempContext != nil) apiVersion = dp::ApiVersion::OpenGLES3; else - apiVersion = dp::ApiVersion::OpenGLES2; + CHECK(false, ("OpenGL ES3 is not supported")); } return apiVersion; diff --git a/iphone/Maps/Classes/iosOGLContext.mm b/iphone/Maps/Classes/iosOGLContext.mm index ec18d14c8..04b86cb0d 100644 --- a/iphone/Maps/Classes/iosOGLContext.mm +++ b/iphone/Maps/Classes/iosOGLContext.mm @@ -17,20 +17,14 @@ iosOGLContext::iosOGLContext(CAEAGLLayer * layer, dp::ApiVersion apiVersion, , m_frameBufferId(0) , m_presentAvailable(true) { - EAGLRenderingAPI api; - if (m_apiVersion == dp::ApiVersion::OpenGLES3) - api = kEAGLRenderingAPIOpenGLES3; - else - api = kEAGLRenderingAPIOpenGLES2; - if (contextToShareWith != NULL) { - m_nativeContext = [[EAGLContext alloc] initWithAPI:api + m_nativeContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3 sharegroup: contextToShareWith->m_nativeContext.sharegroup]; } else { - m_nativeContext = [[EAGLContext alloc] initWithAPI:api]; + m_nativeContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; } } diff --git a/libs/drape/data_buffer.cpp b/libs/drape/data_buffer.cpp index 8040056cc..878757782 100644 --- a/libs/drape/data_buffer.cpp +++ b/libs/drape/data_buffer.cpp @@ -21,7 +21,7 @@ void DataBuffer::MoveToGPU(ref_ptr context, GPUBuffer::Target t uint32_t const currentSize = m_impl->GetCurrentSize(); auto const apiVersion = context->GetApiVersion(); - if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) + if (apiVersion == dp::ApiVersion::OpenGLES3) { if (currentSize != 0) { diff --git a/libs/drape/drape_global.hpp b/libs/drape/drape_global.hpp index d0f449483..3939ad942 100644 --- a/libs/drape/drape_global.hpp +++ b/libs/drape/drape_global.hpp @@ -26,7 +26,6 @@ namespace dp enum class ApiVersion { Invalid = -1, - OpenGLES2 = 0, OpenGLES3, Metal, Vulkan @@ -101,7 +100,6 @@ inline std::string DebugPrint(dp::ApiVersion apiVersion) switch (apiVersion) { case dp::ApiVersion::Invalid: return "Invalid"; - case dp::ApiVersion::OpenGLES2: return "OpenGLES2"; case dp::ApiVersion::OpenGLES3: return "OpenGLES3"; case dp::ApiVersion::Metal: return "Metal"; case dp::ApiVersion::Vulkan: return "Vulkan"; @@ -121,9 +119,6 @@ inline dp::ApiVersion ApiVersionFromString(std::string const & str) return dp::ApiVersion::Vulkan; #endif - if (str == "OpenGLES2") - return dp::ApiVersion::OpenGLES2; - if (str == "OpenGLES3") return dp::ApiVersion::OpenGLES3; diff --git a/libs/drape/drape_tests/font_texture_tests.cpp b/libs/drape/drape_tests/font_texture_tests.cpp index 6eade2b5a..72e6f0ba8 100644 --- a/libs/drape/drape_tests/font_texture_tests.cpp +++ b/libs/drape/drape_tests/font_texture_tests.cpp @@ -107,7 +107,7 @@ UNIT_TEST(UploadingGlyphs) TestingGraphicsContext context; Texture::Params p; p.m_allocator = GetDefaultAllocator(make_ref(&context)); - p.m_format = dp::TextureFormat::Alpha; + p.m_format = dp::TextureFormat::Red; p.m_width = p.m_height = kTextureSize; DummyTexture tex; diff --git a/libs/drape/drape_tests/testing_graphics_context.hpp b/libs/drape/drape_tests/testing_graphics_context.hpp index 95b9580c3..e7f3d1da7 100644 --- a/libs/drape/drape_tests/testing_graphics_context.hpp +++ b/libs/drape/drape_tests/testing_graphics_context.hpp @@ -2,7 +2,7 @@ #include "drape/graphics_context.hpp" -// Testing context simulates OpenGLES2 API version. +// Testing context simulates OpenGLES3 API version. class TestingGraphicsContext : public dp::GraphicsContext { public: @@ -38,5 +38,5 @@ public: void SetCullingEnabled(bool enabled) override {} private: - dp::ApiVersion m_apiVersion = dp::ApiVersion::OpenGLES2; + dp::ApiVersion m_apiVersion = dp::ApiVersion::OpenGLES3; }; diff --git a/libs/drape/font_texture.hpp b/libs/drape/font_texture.hpp index ac25ad094..b658ba0dc 100644 --- a/libs/drape/font_texture.hpp +++ b/libs/drape/font_texture.hpp @@ -81,7 +81,7 @@ public: FontTexture(m2::PointU const & size, ref_ptr glyphMng, ref_ptr allocator) : m_index(size, glyphMng) { - DynamicTextureParams const params{size, TextureFormat::Alpha, TextureFilter::Linear, true /* m_usePixelBuffer */}; + DynamicTextureParams const params{size, TextureFormat::Red, TextureFilter::Linear, true /* m_usePixelBuffer */}; Init(allocator, make_ref(&m_index), params); } diff --git a/libs/drape/framebuffer.cpp b/libs/drape/framebuffer.cpp index 72b6d098b..c2b5f4f99 100644 --- a/libs/drape/framebuffer.cpp +++ b/libs/drape/framebuffer.cpp @@ -134,7 +134,7 @@ void Framebuffer::SetSize(ref_ptr context, uint32_t width, m_depthStencilRef->SetSize(context, m_width, m_height); auto const apiVersion = context->GetApiVersion(); - if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) + if (apiVersion == dp::ApiVersion::OpenGLES3) { glConst depthAttachmentId = 0; glConst stencilAttachmentId = 0; diff --git a/libs/drape/gl_extensions_list.cpp b/libs/drape/gl_extensions_list.cpp index bd80605cf..a616d232d 100644 --- a/libs/drape/gl_extensions_list.cpp +++ b/libs/drape/gl_extensions_list.cpp @@ -7,67 +7,14 @@ namespace dp { -void GLExtensionsList::Init(dp::ApiVersion apiVersion) +void GLExtensionsList::Init() { -#if defined(OMIM_OS_MOBILE) - if (apiVersion == dp::ApiVersion::OpenGLES2) - { #ifdef OMIM_OS_ANDROID - SetExtension(VertexArrayObject, false); - // On some Android devices glMapBufferRange/glMapBuffer works very slow. - // We have to substitute these functions to glBufferData/glBufferSubData. - SetExtension(MapBuffer, false); - SetExtension(MapBufferRange, false); -#else - CheckExtension(VertexArrayObject, "GL_OES_vertex_array_object"); - CheckExtension(MapBuffer, "GL_OES_mapbuffer"); - CheckExtension(MapBufferRange, "GL_EXT_map_buffer_range"); -#endif - CheckExtension(UintIndices, "GL_OES_element_index_uint"); - } - else - { -#ifdef OMIM_OS_ANDROID - SetExtension(MapBuffer, false); - SetExtension(MapBufferRange, false); -#else - SetExtension(MapBuffer, true); - SetExtension(MapBufferRange, true); -#endif - SetExtension(VertexArrayObject, true); - SetExtension(UintIndices, true); - } -#elif defined(OMIM_OS_LINUX) - SetExtension(MapBuffer, true); - SetExtension(UintIndices, true); - SetExtension(VertexArrayObject, true); - SetExtension(MapBufferRange, true); -#elif defined(OMIM_OS_WINDOWS) - SetExtension(MapBuffer, true); - SetExtension(UintIndices, true); - if (apiVersion == dp::ApiVersion::OpenGLES2) - { - SetExtension(VertexArrayObject, false); - SetExtension(MapBufferRange, false); - } - else - { - SetExtension(VertexArrayObject, true); - SetExtension(MapBufferRange, true); - } + // NOTE: MapBuffer/MapBufferRange are disabled by performance reasons according to + // https://github.com/organicmaps/organicmaps/commit/d72ab7c8cd8be0eb5a622d9d33ae943b391d5707 + SetExtension(MapBuffer, false); #else SetExtension(MapBuffer, true); - SetExtension(UintIndices, true); - if (apiVersion == dp::ApiVersion::OpenGLES2) - { - CheckExtension(VertexArrayObject, "GL_APPLE_vertex_array_object"); - SetExtension(MapBufferRange, false); - } - else - { - SetExtension(VertexArrayObject, true); - SetExtension(MapBufferRange, true); - } #endif } diff --git a/libs/drape/gl_extensions_list.hpp b/libs/drape/gl_extensions_list.hpp index c5fb4dfc1..c962c0714 100644 --- a/libs/drape/gl_extensions_list.hpp +++ b/libs/drape/gl_extensions_list.hpp @@ -14,14 +14,11 @@ class GLExtensionsList public: enum ExtensionName { - VertexArrayObject, MapBuffer, - UintIndices, - MapBufferRange }; GLExtensionsList() = default; - void Init(dp::ApiVersion apiVersion); + void Init(); bool IsSupported(ExtensionName extName) const; private: diff --git a/libs/drape/gl_functions.cpp b/libs/drape/gl_functions.cpp index 0a7bd3372..2abd199f8 100644 --- a/libs/drape/gl_functions.cpp +++ b/libs/drape/gl_functions.cpp @@ -244,71 +244,18 @@ void GLFunctions::Init(dp::ApiVersion apiVersion) return; CurrentApiVersion = apiVersion; - ExtensionsList.Init(apiVersion); + ExtensionsList.Init(); s_inited = true; -/// VAO #if !defined(OMIM_OS_WINDOWS) - if (CurrentApiVersion == dp::ApiVersion::OpenGLES2) - { -#if defined(OMIM_OS_MAC) - - glGenVertexArraysFn = &glGenVertexArraysAPPLE; - glBindVertexArrayFn = &glBindVertexArrayAPPLE; - glDeleteVertexArrayFn = &glDeleteVertexArraysAPPLE; - glMapBufferFn = &::glMapBuffer; - glUnmapBufferFn = &::glUnmapBuffer; - -#elif defined(OMIM_OS_LINUX) - void *libhandle = dlopen("libGL.so.1", RTLD_LAZY); - if (!libhandle) - LOG(LCRITICAL, ("Failed to open libGL.so.1:", dlerror())); - glGenVertexArraysFn = (TglGenVertexArraysFn)dlsym(libhandle,"glGenVertexArraysOES"); - glBindVertexArrayFn = (TglBindVertexArrayFn)dlsym(libhandle, "glBindVertexArrayOES"); - glDeleteVertexArrayFn = (TglDeleteVertexArrayFn)dlsym(libhandle,"glDeleteVertexArraysOES"); - glMapBufferFn = (TglMapBufferFn)dlsym(libhandle, "glMapBufferOES"); - glUnmapBufferFn = (TglUnmapBufferFn)dlsym(libhandle, "glUnmapBufferOES"); - glMapBufferRangeFn = (TglMapBufferRangeFn)dlsym(libhandle, "glMapBufferRangeEXT"); - glFlushMappedBufferRangeFn = - (TglFlushMappedBufferRangeFn)dlsym(libhandle, "glFlushMappedBufferRangeEXT"); - -#elif defined(OMIM_OS_ANDROID) - - glGenVertexArraysFn = (TglGenVertexArraysFn)eglGetProcAddress("glGenVertexArraysOES"); - glBindVertexArrayFn = (TglBindVertexArrayFn)eglGetProcAddress("glBindVertexArrayOES"); - glDeleteVertexArrayFn = (TglDeleteVertexArrayFn)eglGetProcAddress("glDeleteVertexArraysOES"); - glMapBufferFn = &::glMapBufferOES; - glUnmapBufferFn = &::glUnmapBufferOES; - glMapBufferRangeFn = (TglMapBufferRangeFn)eglGetProcAddress("glMapBufferRangeEXT"); - glFlushMappedBufferRangeFn = - (TglFlushMappedBufferRangeFn)eglGetProcAddress("glFlushMappedBufferRangeEXT"); - -#elif defined(OMIM_OS_MOBILE) - - glGenVertexArraysFn = &glGenVertexArraysOES; - glBindVertexArrayFn = &glBindVertexArrayOES; - glDeleteVertexArrayFn = &glDeleteVertexArraysOES; - glMapBufferFn = &::glMapBufferOES; - glUnmapBufferFn = &::glUnmapBufferOES; - glMapBufferRangeFn = &::glMapBufferRangeEXT; - glFlushMappedBufferRangeFn = &::glFlushMappedBufferRangeEXT; -#endif // #if defined(OMIM_OS_MAC) - } - else if (CurrentApiVersion == dp::ApiVersion::OpenGLES3) - { - // OpenGL ES3 api is the same for all systems, except WINDOWS. - glGenVertexArraysFn = ::glGenVertexArrays; - glBindVertexArrayFn = ::glBindVertexArray; - glDeleteVertexArrayFn = ::glDeleteVertexArrays; - glUnmapBufferFn = ::glUnmapBuffer; - glMapBufferRangeFn = ::glMapBufferRange; - glFlushMappedBufferRangeFn = ::glFlushMappedBufferRange; - glGetStringiFn = ::glGetStringi; - } - else - { - CHECK(false, ("Unknown Graphics API")); - } + // OpenGL ES3 api is the same for all systems, except WINDOWS. + glGenVertexArraysFn = ::glGenVertexArrays; + glBindVertexArrayFn = ::glBindVertexArray; + glDeleteVertexArrayFn = ::glDeleteVertexArrays; + glUnmapBufferFn = ::glUnmapBuffer; + glMapBufferRangeFn = ::glMapBufferRange; + glFlushMappedBufferRangeFn = ::glFlushMappedBufferRange; + glGetStringiFn = ::glGetStringi; glClearColorFn = LOAD_GL_FUNC(TglClearColorFn, glClearColor); glClearFn = LOAD_GL_FUNC(TglClearFn, glClear); @@ -316,13 +263,9 @@ void GLFunctions::Init(dp::ApiVersion apiVersion) glScissorFn = LOAD_GL_FUNC(TglScissorFn, glScissor); glFlushFn = LOAD_GL_FUNC(TglFlushFn, glFlush); #else // OMIM_OS_WINDOWS - if (ExtensionsList.IsSupported(dp::GLExtensionsList::VertexArrayObject)) - { - glGenVertexArraysFn = LOAD_GL_FUNC(TglGenVertexArraysFn, glGenVertexArrays); - glBindVertexArrayFn = LOAD_GL_FUNC(TglBindVertexArrayFn, glBindVertexArray); - glDeleteVertexArrayFn = LOAD_GL_FUNC(TglDeleteVertexArrayFn, glDeleteVertexArrays); - } - glMapBufferFn = LOAD_GL_FUNC(TglMapBufferFn, glMapBuffer); + glGenVertexArraysFn = LOAD_GL_FUNC(TglGenVertexArraysFn, glGenVertexArrays); + glBindVertexArrayFn = LOAD_GL_FUNC(TglBindVertexArrayFn, glBindVertexArray); + glDeleteVertexArrayFn = LOAD_GL_FUNC(TglDeleteVertexArrayFn, glDeleteVertexArrays); glUnmapBufferFn = LOAD_GL_FUNC(TglUnmapBufferFn, glUnmapBuffer); glMapBufferRangeFn = LOAD_GL_FUNC(TglMapBufferRangeFn, glMapBufferRange); glFlushMappedBufferRangeFn = LOAD_GL_FUNC(TglFlushMappedBufferRangeFn, glFlushMappedBufferRange); @@ -403,115 +346,94 @@ void GLFunctions::Init(dp::ApiVersion apiVersion) bool GLFunctions::glHasExtension(std::string const & name) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); - if (CurrentApiVersion == dp::ApiVersion::OpenGLES2) + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); + ASSERT(glGetStringiFn != nullptr, ()); + GLint n = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &n); + for (GLint i = 0; i < n; i++) { - char const * extensions = reinterpret_cast(::glGetString(GL_EXTENSIONS)); - GLCHECKCALL(); - if (extensions == nullptr) - return false; - - char const * extName = name.c_str(); - char const * ptr = nullptr; - while ((ptr = strstr(extensions, extName)) != nullptr) - { - char const * end = ptr + strlen(extName); - if (isspace(*end) || *end == '\0') - return true; - - extensions = end; - } - } - else if (CurrentApiVersion == dp::ApiVersion::OpenGLES3) - { - ASSERT(glGetStringiFn != nullptr, ()); - GLint n = 0; - glGetIntegerv(GL_NUM_EXTENSIONS, &n); - for (GLint i = 0; i < n; i++) - { - std::string const extension = - std::string(reinterpret_cast(glGetStringiFn(GL_EXTENSIONS, i))); - if (extension == name) - return true; - } + std::string const extension = + std::string(reinterpret_cast(glGetStringiFn(GL_EXTENSIONS, i))); + if (extension == name) + return true; } return false; } void GLFunctions::glClearColor(float r, float g, float b, float a) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glClearColorFn != nullptr, ()); GLCHECK(glClearColorFn(r, g, b, a)); } void GLFunctions::glClear(uint32_t clearBits) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glClearFn != nullptr, ()); GLCHECK(glClearFn(clearBits)); } void GLFunctions::glViewport(uint32_t x, uint32_t y, uint32_t w, uint32_t h) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glViewportFn != nullptr, ()); GLCHECK(glViewportFn(x, y, w, h)); } void GLFunctions::glScissor(uint32_t x, uint32_t y, uint32_t w, uint32_t h) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glScissorFn != nullptr, ()); GLCHECK(glScissorFn(x, y, w, h)); } void GLFunctions::glFlush() { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glFlushFn != nullptr, ()); GLCHECK(glFlushFn()); } void GLFunctions::glFinish() { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glFinish()); } void GLFunctions::glFrontFace(glConst mode) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glFrontFace(mode)); } void GLFunctions::glCullFace(glConst face) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glCullFace(face)); } void GLFunctions::glStencilOpSeparate(glConst face, glConst sfail, glConst dpfail, glConst dppass) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(glStencilOpSeparateFn(face, sfail, dpfail, dppass)); } void GLFunctions::glStencilFuncSeparate(glConst face, glConst func, int ref, uint32_t mask) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(glStencilFuncSeparateFn(face, func, ref, mask)); } void GLFunctions::glPixelStore(glConst name, uint32_t value) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glPixelStorei(name, value)); } int32_t GLFunctions::glGetInteger(glConst pname) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLint value; GLCHECK(::glGetIntegerv(pname, &value)); return (int32_t)value; @@ -519,7 +441,7 @@ int32_t GLFunctions::glGetInteger(glConst pname) std::string GLFunctions::glGetString(glConst pname) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); char const * str = reinterpret_cast(::glGetString(pname)); GLCHECKCALL(); if (str == nullptr) @@ -530,7 +452,7 @@ std::string GLFunctions::glGetString(glConst pname) int32_t GLFunctions::glGetMaxLineWidth() { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLint range[2]; GLCHECK(::glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, range)); return std::max(range[0], range[1]); @@ -538,7 +460,7 @@ int32_t GLFunctions::glGetMaxLineWidth() int32_t GLFunctions::glGetBufferParameter(glConst target, glConst name) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLint result; ASSERT(glGetBufferParameterFn != nullptr, ()); GLCHECK(glGetBufferParameterFn(target, name, &result)); @@ -547,19 +469,19 @@ int32_t GLFunctions::glGetBufferParameter(glConst target, glConst name) void GLFunctions::glEnable(glConst mode) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glEnable(mode)); } void GLFunctions::glDisable(glConst mode) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glDisable(mode)); } void GLFunctions::glClearDepthValue(double depth) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); #if defined(OMIM_OS_IPHONE) || defined(OMIM_OS_ANDROID) || defined(OMIM_OS_LINUX) GLCHECK(::glClearDepthf(static_cast(depth))); #else @@ -569,32 +491,32 @@ void GLFunctions::glClearDepthValue(double depth) void GLFunctions::glDepthMask(bool needWriteToDepthBuffer) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glDepthMask(convert(needWriteToDepthBuffer))); } void GLFunctions::glDepthFunc(glConst depthFunc) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glDepthFunc(depthFunc)); } void GLFunctions::glBlendEquation(glConst function) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glBlendEquationFn != nullptr, ()); GLCHECK(glBlendEquationFn(function)); } void GLFunctions::glBlendFunc(glConst srcFactor, glConst dstFactor) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glBlendFunc(srcFactor, dstFactor)); } bool GLFunctions::CanEnableDebugMessages() { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); if (glDebugMessageCallbackFn == nullptr) return false; if (glDebugMessageControlFn == nullptr) @@ -606,7 +528,7 @@ bool GLFunctions::CanEnableDebugMessages() void GLFunctions::glDebugMessageCallback(TglDebugProc messageCallback, void * userParam) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glDebugMessageCallbackFn != nullptr, ()); GLCHECK(glDebugMessageCallbackFn(reinterpret_cast(messageCallback), userParam)); } @@ -614,14 +536,14 @@ void GLFunctions::glDebugMessageCallback(TglDebugProc messageCallback, void * us void GLFunctions::glDebugMessageControl(glConst source, glConst type, glConst severity, int32_t count, uint32_t const * ids, uint8_t enabled) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glDebugMessageControlFn != nullptr, ()); GLCHECK(glDebugMessageControlFn(source, type, severity, count, ids, enabled)); } uint32_t GLFunctions::glGenVertexArray() { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glGenVertexArraysFn != nullptr, ()); GLuint result = std::numeric_limits::max(); GLCHECK(glGenVertexArraysFn(1, &result)); @@ -630,21 +552,21 @@ uint32_t GLFunctions::glGenVertexArray() void GLFunctions::glBindVertexArray(uint32_t vao) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glBindVertexArrayFn != nullptr, ()); GLCHECK(glBindVertexArrayFn(vao)); } void GLFunctions::glDeleteVertexArray(uint32_t vao) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glDeleteVertexArrayFn != nullptr, ()); GLCHECK(glDeleteVertexArrayFn(1, &vao)); } uint32_t GLFunctions::glGenBuffer() { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glGenBuffersFn != nullptr, ()); GLuint result = std::numeric_limits::max(); GLCHECK(glGenBuffersFn(1, &result)); @@ -653,7 +575,7 @@ uint32_t GLFunctions::glGenBuffer() void GLFunctions::glBindBuffer(uint32_t vbo, uint32_t target) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glBindBufferFn != nullptr, ()); #ifdef DEBUG std::lock_guard guard(g_boundBuffersMutex); @@ -664,7 +586,7 @@ void GLFunctions::glBindBuffer(uint32_t vbo, uint32_t target) void GLFunctions::glDeleteBuffer(uint32_t vbo) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glDeleteBuffersFn != nullptr, ()); #ifdef DEBUG std::lock_guard guard(g_boundBuffersMutex); @@ -676,21 +598,21 @@ void GLFunctions::glDeleteBuffer(uint32_t vbo) void GLFunctions::glBufferData(glConst target, uint32_t size, void const * data, glConst usage) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glBufferDataFn != nullptr, ()); GLCHECK(glBufferDataFn(target, size, data, usage)); } void GLFunctions::glBufferSubData(glConst target, uint32_t size, void const * data, uint32_t offset) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glBufferSubDataFn != nullptr, ()); GLCHECK(glBufferSubDataFn(target, offset, size, data)); } void * GLFunctions::glMapBuffer(glConst target, glConst access) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glMapBufferFn != nullptr, ()); void * result = glMapBufferFn(target, access); GLCHECKCALL(); @@ -699,7 +621,7 @@ void * GLFunctions::glMapBuffer(glConst target, glConst access) void GLFunctions::glUnmapBuffer(glConst target) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glUnmapBufferFn != nullptr, ()); VERIFY(glUnmapBufferFn(target) == GL_TRUE, ()); GLCHECKCALL(); @@ -708,7 +630,7 @@ void GLFunctions::glUnmapBuffer(glConst target) void * GLFunctions::glMapBufferRange(glConst target, uint32_t offset, uint32_t length, glConst access) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glMapBufferRangeFn != nullptr, ()); void * result = glMapBufferRangeFn(target, offset, length, access); GLCHECKCALL(); @@ -717,14 +639,14 @@ void * GLFunctions::glMapBufferRange(glConst target, uint32_t offset, uint32_t l void GLFunctions::glFlushMappedBufferRange(glConst target, uint32_t offset, uint32_t length) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glFlushMappedBufferRangeFn != nullptr, ()); GLCHECK(glFlushMappedBufferRangeFn(target, offset, length)); } uint32_t GLFunctions::glCreateShader(glConst type) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glCreateShaderFn != nullptr, ()); GLuint result = glCreateShaderFn(type); GLCHECKCALL(); @@ -733,7 +655,7 @@ uint32_t GLFunctions::glCreateShader(glConst type) void GLFunctions::glShaderSource(uint32_t shaderID, std::string const & src, std::string const & defines) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glShaderSourceFn != nullptr, ()); std::string fullSrc; @@ -756,7 +678,7 @@ void GLFunctions::glShaderSource(uint32_t shaderID, std::string const & src, std bool GLFunctions::glCompileShader(uint32_t shaderID, std::string & errorLog) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glCompileShaderFn != nullptr, ()); ASSERT(glGetShaderivFn != nullptr, ()); ASSERT(glGetShaderInfoLogFn != nullptr, ()); @@ -776,14 +698,14 @@ bool GLFunctions::glCompileShader(uint32_t shaderID, std::string & errorLog) void GLFunctions::glDeleteShader(uint32_t shaderID) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glDeleteShaderFn != nullptr, ()); GLCHECK(glDeleteBuffersFn(1, &shaderID)); } uint32_t GLFunctions::glCreateProgram() { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glCreateProgramFn != nullptr, ()); GLuint result = glCreateProgramFn(); GLCHECKCALL(); @@ -792,21 +714,21 @@ uint32_t GLFunctions::glCreateProgram() void GLFunctions::glAttachShader(uint32_t programID, uint32_t shaderID) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glAttachShaderFn != nullptr, ()); GLCHECK(glAttachShaderFn(programID, shaderID)); } void GLFunctions::glDetachShader(uint32_t programID, uint32_t shaderID) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glDetachShaderFn != nullptr, ()); GLCHECK(glDetachShaderFn(programID, shaderID)); } bool GLFunctions::glLinkProgram(uint32_t programID, std::string & errorLog) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glLinkProgramFn != nullptr, ()); ASSERT(glGetProgramivFn != nullptr, ()); ASSERT(glGetProgramInfoLogFn != nullptr, ()); @@ -827,21 +749,21 @@ bool GLFunctions::glLinkProgram(uint32_t programID, std::string & errorLog) void GLFunctions::glDeleteProgram(uint32_t programID) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glDeleteProgramFn != nullptr, ()); GLCHECK(glDeleteProgramFn(programID)); } void GLFunctions::glUseProgram(uint32_t programID) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glUseProgramFn != nullptr, ()); GLCHECK(glUseProgramFn(programID)); } int8_t GLFunctions::glGetAttribLocation(uint32_t programID, std::string const & name) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glGetAttribLocationFn != nullptr, ()); int result = glGetAttribLocationFn(programID, name.c_str()); GLCHECKCALL(); @@ -851,14 +773,14 @@ int8_t GLFunctions::glGetAttribLocation(uint32_t programID, std::string const & void GLFunctions::glBindAttribLocation(uint32_t programID, uint8_t index, std::string const & name) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glBindAttribLocationFn != nullptr, ()); GLCHECK(glBindAttribLocationFn(programID, index, name.c_str())); } void GLFunctions::glEnableVertexAttribute(int attributeLocation) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glEnableVertexAttributeFn != nullptr, ()); GLCHECK(glEnableVertexAttributeFn(attributeLocation)); } @@ -866,7 +788,7 @@ void GLFunctions::glEnableVertexAttribute(int attributeLocation) void GLFunctions::glVertexAttributePointer(int attrLocation, uint32_t count, glConst type, bool needNormalize, uint32_t stride, uint32_t offset) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glVertexAttributePointerFn != nullptr, ()); GLCHECK(glVertexAttributePointerFn(attrLocation, count, type, convert(needNormalize), stride, reinterpret_cast(offset))); @@ -875,7 +797,7 @@ void GLFunctions::glVertexAttributePointer(int attrLocation, uint32_t count, glC void GLFunctions::glGetActiveUniform(uint32_t programID, uint32_t uniformIndex, int32_t * uniformSize, glConst * type, std::string & name) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glGetActiveUniformFn != nullptr, ()); GLchar buff[256]; GLCHECK(glGetActiveUniformFn(programID, uniformIndex, ARRAY_SIZE(buff), nullptr, uniformSize, @@ -885,7 +807,7 @@ void GLFunctions::glGetActiveUniform(uint32_t programID, uint32_t uniformIndex, int8_t GLFunctions::glGetUniformLocation(uint32_t programID, std::string const & name) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glGetUniformLocationFn != nullptr, ()); int result = glGetUniformLocationFn(programID, name.c_str()); GLCHECKCALL(); @@ -895,7 +817,7 @@ int8_t GLFunctions::glGetUniformLocation(uint32_t programID, std::string const & void GLFunctions::glUniformValuei(int8_t location, int32_t v) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glUniform1iFn != nullptr, ()); ASSERT(location != -1, ()); GLCHECK(glUniform1iFn(location, v)); @@ -903,7 +825,7 @@ void GLFunctions::glUniformValuei(int8_t location, int32_t v) void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glUniform2iFn != nullptr, ()); ASSERT(location != -1, ()); GLCHECK(glUniform2iFn(location, v1, v2)); @@ -911,7 +833,7 @@ void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2) void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2, int32_t v3) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glUniform3iFn != nullptr, ()); ASSERT(location != -1, ()); GLCHECK(glUniform3iFn(location, v1, v2, v3)); @@ -919,7 +841,7 @@ void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2, int32 void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2, int32_t v3, int32_t v4) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glUniform4iFn != nullptr, ()); ASSERT(location != -1, ()); GLCHECK(glUniform4iFn(location, v1, v2, v3, v4)); @@ -927,7 +849,7 @@ void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2, int32 void GLFunctions::glUniformValueiv(int8_t location, int32_t * v, uint32_t size) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glUniform1ivFn != nullptr, ()); ASSERT(location != -1, ()); GLCHECK(glUniform1ivFn(location, size, v)); @@ -935,7 +857,7 @@ void GLFunctions::glUniformValueiv(int8_t location, int32_t * v, uint32_t size) void GLFunctions::glUniformValuef(int8_t location, float v) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glUniform1fFn != nullptr, ()); ASSERT(location != -1, ()); GLCHECK(glUniform1fFn(location, v)); @@ -943,7 +865,7 @@ void GLFunctions::glUniformValuef(int8_t location, float v) void GLFunctions::glUniformValuef(int8_t location, float v1, float v2) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glUniform2fFn != nullptr, ()); ASSERT(location != -1, ()); GLCHECK(glUniform2fFn(location, v1, v2)); @@ -951,7 +873,7 @@ void GLFunctions::glUniformValuef(int8_t location, float v1, float v2) void GLFunctions::glUniformValuef(int8_t location, float v1, float v2, float v3) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glUniform3fFn != nullptr, ()); ASSERT(location != -1, ()); GLCHECK(glUniform3fFn(location, v1, v2, v3)); @@ -959,7 +881,7 @@ void GLFunctions::glUniformValuef(int8_t location, float v1, float v2, float v3) void GLFunctions::glUniformValuef(int8_t location, float v1, float v2, float v3, float v4) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glUniform4fFn != nullptr, ()); ASSERT(location != -1, ()); GLCHECK(glUniform4fFn(location, v1, v2, v3, v4)); @@ -967,7 +889,7 @@ void GLFunctions::glUniformValuef(int8_t location, float v1, float v2, float v3, void GLFunctions::glUniformValuefv(int8_t location, float * v, uint32_t size) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glUniform1fvFn != nullptr, ()); ASSERT(location != -1, ()); GLCHECK(glUniform1fvFn(location, size, v)); @@ -975,7 +897,7 @@ void GLFunctions::glUniformValuefv(int8_t location, float * v, uint32_t size) void GLFunctions::glUniformMatrix4x4Value(int8_t location, float const * values) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glUniformMatrix4fvFn != nullptr, ()); ASSERT(location != -1, ()); GLCHECK(glUniformMatrix4fvFn(location, 1, GL_FALSE, values)); @@ -983,7 +905,7 @@ void GLFunctions::glUniformMatrix4x4Value(int8_t location, float const * values) uint32_t GLFunctions::glGetCurrentProgram() { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLint programIndex = 0; GLCHECK(glGetIntegerv(GL_CURRENT_PROGRAM, &programIndex)); ASSERT_GREATER_OR_EQUAL(programIndex, 0, ()); @@ -992,7 +914,7 @@ uint32_t GLFunctions::glGetCurrentProgram() int32_t GLFunctions::glGetProgramiv(uint32_t program, glConst paramName) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glGetProgramivFn != nullptr, ()); GLint paramValue = 0; GLCHECK(glGetProgramivFn(program, paramName, ¶mValue)); @@ -1001,14 +923,14 @@ int32_t GLFunctions::glGetProgramiv(uint32_t program, glConst paramName) void GLFunctions::glActiveTexture(glConst texBlock) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glActiveTextureFn != nullptr, ()); GLCHECK(glActiveTextureFn(texBlock)); } uint32_t GLFunctions::glGenTexture() { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLuint result = std::numeric_limits::max(); GLCHECK(::glGenTextures(1, &result)); return result; @@ -1016,20 +938,20 @@ uint32_t GLFunctions::glGenTexture() void GLFunctions::glDeleteTexture(uint32_t id) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glDeleteTextures(1, &id)); } void GLFunctions::glBindTexture(uint32_t textureID) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glBindTexture(GL_TEXTURE_2D, textureID)); } void GLFunctions::glTexImage2D(int width, int height, glConst layout, glConst pixelType, void const * data) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); // In OpenGL ES3: // - we can't create unsized GL_RED texture, so we use GL_R8; // - we can't create unsized GL_RG texture, so we use GL_RG8; @@ -1068,20 +990,20 @@ void GLFunctions::glTexImage2D(int width, int height, glConst layout, glConst pi void GLFunctions::glTexSubImage2D(int x, int y, int width, int height, glConst layout, glConst pixelType, void const * data) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, layout, pixelType, data)); } void GLFunctions::glTexParameter(glConst param, glConst value) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glTexParameteri(GL_TEXTURE_2D, param, value)); } void GLFunctions::glDrawElements(glConst primitive, uint32_t sizeOfIndex, uint32_t indexCount, uint32_t startIndex) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glDrawElements(primitive, indexCount, sizeOfIndex == sizeof(uint32_t) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, reinterpret_cast(startIndex * sizeOfIndex))); @@ -1089,41 +1011,41 @@ void GLFunctions::glDrawElements(glConst primitive, uint32_t sizeOfIndex, uint32 void GLFunctions::glDrawArrays(glConst mode, int32_t first, uint32_t count) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glDrawArrays(mode, first, count)); } void GLFunctions::glGenFramebuffer(uint32_t * fbo) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glGenFramebuffersFn != nullptr, ()); GLCHECK(glGenFramebuffersFn(1, fbo)); } void GLFunctions::glDeleteFramebuffer(uint32_t * fbo) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glDeleteFramebuffersFn != nullptr, ()); GLCHECK(glDeleteFramebuffersFn(1, fbo)); } void GLFunctions::glFramebufferTexture2D(glConst attachment, glConst texture) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glFramebufferTexture2DFn != nullptr, ()); GLCHECK(glFramebufferTexture2DFn(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, texture, 0)); } void GLFunctions::glBindFramebuffer(uint32_t fbo) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glBindFramebufferFn != nullptr, ()); GLCHECK(glBindFramebufferFn(GL_FRAMEBUFFER, fbo)); } uint32_t GLFunctions::glCheckFramebufferStatus() { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); ASSERT(glCheckFramebufferStatusFn != nullptr, ()); uint32_t const result = glCheckFramebufferStatusFn(GL_FRAMEBUFFER); GLCHECKCALL(); @@ -1132,7 +1054,7 @@ uint32_t GLFunctions::glCheckFramebufferStatus() void GLFunctions::glLineWidth(uint32_t value) { - ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLCHECK(::glLineWidth(static_cast(value))); } @@ -1153,7 +1075,7 @@ std::string GetGLError(GLenum error) void CheckGLError(base::SrcPoint const & srcPoint) { - ASSERT_NOT_EQUAL(GLFunctions::CurrentApiVersion, dp::ApiVersion::Invalid, ()); + ASSERT_EQUAL(GLFunctions::CurrentApiVersion, dp::ApiVersion::OpenGLES3, ()); GLenum result = glGetError(); while (result != GL_NO_ERROR) { diff --git a/libs/drape/gpu_buffer.cpp b/libs/drape/gpu_buffer.cpp index af8490690..a280aeddd 100644 --- a/libs/drape/gpu_buffer.cpp +++ b/libs/drape/gpu_buffer.cpp @@ -87,26 +87,17 @@ void * GPUBuffer::Map(uint32_t elementOffset, uint32_t elementCount) m_isMapped = true; #endif - if (GLFunctions::CurrentApiVersion == dp::ApiVersion::OpenGLES2) + if (!IsMapBufferSupported()) { m_mappingOffset = elementOffset; - return IsMapBufferSupported() ? GLFunctions::glMapBuffer(glTarget(m_t)) : nullptr; + return nullptr; } - else if (GLFunctions::CurrentApiVersion == dp::ApiVersion::OpenGLES3) - { - if (!IsMapBufferSupported()) - { - m_mappingOffset = elementOffset; - return nullptr; - } - m_mappingOffset = 0; - uint32_t const elementSize = GetElementSize(); - uint32_t const byteOffset = elementOffset * elementSize; - uint32_t const byteCount = elementCount * elementSize; - return GLFunctions::glMapBufferRange(glTarget(m_t), byteOffset, byteCount, - gl_const::GLWriteBufferBit); - } - return nullptr; + m_mappingOffset = 0; + uint32_t const elementSize = GetElementSize(); + uint32_t const byteOffset = elementOffset * elementSize; + uint32_t const byteCount = elementCount * elementSize; + return GLFunctions::glMapBufferRange(glTarget(m_t), byteOffset, byteCount, + gl_const::GLWriteBufferBit); } void GPUBuffer::UpdateData(void * gpuPtr, void const * data, uint32_t elementOffset, diff --git a/libs/drape/hw_texture.cpp b/libs/drape/hw_texture.cpp index 560e8978f..1d99e2028 100644 --- a/libs/drape/hw_texture.cpp +++ b/libs/drape/hw_texture.cpp @@ -36,7 +36,7 @@ void UnpackFormat(ref_ptr context, TextureFormat format, glConst & layout, glConst & pixelType) { auto const apiVersion = context->GetApiVersion(); - CHECK(apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3, ()); + CHECK(apiVersion == dp::ApiVersion::OpenGLES3, ()); switch (format) { @@ -45,21 +45,17 @@ void UnpackFormat(ref_ptr context, TextureFormat format, pixelType = gl_const::GL8BitOnChannel; return; - case TextureFormat::Alpha: - // On OpenGL ES3 GLAlpha is not supported, we use GLRed instead. - layout = apiVersion == dp::ApiVersion::OpenGLES2 ? gl_const::GLAlpha : gl_const::GLRed; + case TextureFormat::Red: + layout = gl_const::GLRed; pixelType = gl_const::GL8BitOnChannel; return; case TextureFormat::RedGreen: - // On OpenGL ES2 2-channel textures are not supported. - layout = (apiVersion == dp::ApiVersion::OpenGLES2) ? gl_const::GLRGBA : gl_const::GLRedGreen; + layout = gl_const::GLRedGreen; pixelType = gl_const::GL8BitOnChannel; return; case TextureFormat::DepthStencil: - // OpenGLES2 does not support texture-based depth-stencil. - CHECK(apiVersion != dp::ApiVersion::OpenGLES2, ()); layout = gl_const::GLDepthStencil; pixelType = gl_const::GLUnsignedInt24_8Type; return; diff --git a/libs/drape/hw_texture_ios.mm b/libs/drape/hw_texture_ios.mm index f83725f41..658ce02e0 100644 --- a/libs/drape/hw_texture_ios.mm +++ b/libs/drape/hw_texture_ios.mm @@ -61,7 +61,7 @@ CVPixelBufferRef HWTextureAllocatorApple::CVCreatePixelBuffer(uint32_t width, ui cvRetval = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_32BGRA, attrsRef, &result); break; - case dp::TextureFormat::Alpha: + case dp::TextureFormat::Red: cvRetval = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_OneComponent8, attrsRef, &result); break; diff --git a/libs/drape/index_storage.cpp b/libs/drape/index_storage.cpp index 5f6bb8fc9..3432e8be9 100644 --- a/libs/drape/index_storage.cpp +++ b/libs/drape/index_storage.cpp @@ -56,7 +56,7 @@ void const * IndexStorage::GetRawConst() const bool IndexStorage::IsSupported32bit() { // We do not use 32-bit indices now to reduce size of index buffers. - static bool const supports32Bit = false;//GLFunctions::ExtensionsList.IsSupported(GLExtensionsList::UintIndices); + static bool const supports32Bit = false; return supports32Bit; } diff --git a/libs/drape/mesh_object.cpp b/libs/drape/mesh_object.cpp index 525c31b0c..4fbaa899e 100644 --- a/libs/drape/mesh_object.cpp +++ b/libs/drape/mesh_object.cpp @@ -36,13 +36,8 @@ public: { UNUSED_VALUE(context); - bool const isVAOSupported = - GLFunctions::ExtensionsList.IsSupported(dp::GLExtensionsList::VertexArrayObject); - if (isVAOSupported) - { - m_VAO = GLFunctions::glGenVertexArray(); - GLFunctions::glBindVertexArray(m_VAO); - } + m_VAO = GLFunctions::glGenVertexArray(); + GLFunctions::glBindVertexArray(m_VAO); for (auto & buffer : m_mesh->m_buffers) { @@ -64,23 +59,19 @@ public: m_mesh->m_indices.data(), gl_const::GLStaticDraw); } - if (isVAOSupported) + ref_ptr p = program; + for (auto const & attribute : buffer->m_attributes) { - ref_ptr p = program; - for (auto const & attribute : buffer->m_attributes) - { - int8_t const attributePosition = p->GetAttributeLocation(attribute.m_attributeName); - ASSERT_NOT_EQUAL(attributePosition, -1, ()); - GLFunctions::glEnableVertexAttribute(attributePosition); - GLFunctions::glVertexAttributePointer(attributePosition, attribute.m_componentsCount, - attribute.m_type, false, buffer->GetStrideInBytes(), - attribute.m_offset); - } + int8_t const attributePosition = p->GetAttributeLocation(attribute.m_attributeName); + ASSERT_NOT_EQUAL(attributePosition, -1, ()); + GLFunctions::glEnableVertexAttribute(attributePosition); + GLFunctions::glVertexAttributePointer(attributePosition, attribute.m_componentsCount, + attribute.m_type, false, buffer->GetStrideInBytes(), + attribute.m_offset); } } - if (isVAOSupported) - GLFunctions::glBindVertexArray(0); + GLFunctions::glBindVertexArray(0); GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer); if (!m_mesh->m_indices.empty()) GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer); @@ -134,34 +125,12 @@ public: void Bind(ref_ptr program) override { - if (GLFunctions::ExtensionsList.IsSupported(dp::GLExtensionsList::VertexArrayObject)) - { - GLFunctions::glBindVertexArray(m_VAO); - return; - } - - ref_ptr p = program; - for (auto const & buffer : m_mesh->m_buffers) - { - GLFunctions::glBindBuffer(buffer->m_bufferId, gl_const::GLArrayBuffer); - if (m_indexBuffer != 0) - GLFunctions::glBindBuffer(m_indexBuffer, gl_const::GLElementArrayBuffer); - for (auto const & attribute : buffer->m_attributes) - { - int8_t const attributePosition = p->GetAttributeLocation(attribute.m_attributeName); - ASSERT_NOT_EQUAL(attributePosition, -1, ()); - GLFunctions::glEnableVertexAttribute(attributePosition); - GLFunctions::glVertexAttributePointer(attributePosition, attribute.m_componentsCount, - attribute.m_type, false, buffer->GetStrideInBytes(), - attribute.m_offset); - } - } + GLFunctions::glBindVertexArray(m_VAO); } void Unbind() override { - if (GLFunctions::ExtensionsList.IsSupported(dp::GLExtensionsList::VertexArrayObject)) - GLFunctions::glBindVertexArray(0); + GLFunctions::glBindVertexArray(0); GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer); if (m_indexBuffer != 0) GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer); @@ -197,7 +166,7 @@ MeshObject::MeshObject(ref_ptr context, DrawPrimitive drawP , m_debugName(debugName) { auto const apiVersion = context->GetApiVersion(); - if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) + if (apiVersion == dp::ApiVersion::OpenGLES3) { InitForOpenGL(); } diff --git a/libs/drape/metal/metal_texture.mm b/libs/drape/metal/metal_texture.mm index cd0a94617..89d674ef0 100644 --- a/libs/drape/metal/metal_texture.mm +++ b/libs/drape/metal/metal_texture.mm @@ -25,7 +25,7 @@ MTLPixelFormat UnpackFormat(TextureFormat format) switch (format) { case TextureFormat::RGBA8: return MTLPixelFormatRGBA8Unorm; - case TextureFormat::Alpha: return MTLPixelFormatA8Unorm; + case TextureFormat::Red: return MTLPixelFormatA8Unorm; // TODO: change to R8, fix shaders case TextureFormat::RedGreen: return MTLPixelFormatRG8Unorm; case TextureFormat::DepthStencil: return MTLPixelFormatDepth32Float_Stencil8; case TextureFormat::Depth: return MTLPixelFormatDepth32Float; diff --git a/libs/drape/render_state.cpp b/libs/drape/render_state.cpp index 5c09fd807..55611a203 100644 --- a/libs/drape/render_state.cpp +++ b/libs/drape/render_state.cpp @@ -30,7 +30,7 @@ void AlphaBlendingState::Apply(ref_ptr context) { // For Metal Rendering these settings must be set in the pipeline state. auto const apiVersion = context->GetApiVersion(); - if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) + if (apiVersion == dp::ApiVersion::OpenGLES3) { GLFunctions::glBlendEquation(gl_const::GLAddBlend); GLFunctions::glBlendFunc(gl_const::GLSrcAlpha, gl_const::GLOneMinusSrcAlpha); @@ -45,7 +45,7 @@ void Blending::Apply(ref_ptr context, ref_ptr progr { // For Metal Rendering these settings must be set in the pipeline state. auto const apiVersion = context->GetApiVersion(); - if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) + if (apiVersion == dp::ApiVersion::OpenGLES3) { if (m_isEnabled) GLFunctions::glEnable(gl_const::GLBlending); @@ -216,7 +216,7 @@ void TextureState::ApplyTextures(ref_ptr context, RenderState c { m_usedSlots = 0; auto const apiVersion = context->GetApiVersion(); - if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) + if (apiVersion == dp::ApiVersion::OpenGLES3) { ref_ptr p = program; for (auto const & texture : state.GetTextures()) @@ -324,7 +324,7 @@ void ApplyState(ref_ptr context, ref_ptr program, R if (state.GetDrawAsLine()) { - if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) + if (apiVersion == dp::ApiVersion::OpenGLES3) { ASSERT_GREATER_OR_EQUAL(state.GetLineWidth(), 0, ()); GLFunctions::glLineWidth(static_cast(state.GetLineWidth())); diff --git a/libs/drape/stipple_pen_resource.cpp b/libs/drape/stipple_pen_resource.cpp index 5f4cb4b5a..e5d4a9e74 100644 --- a/libs/drape/stipple_pen_resource.cpp +++ b/libs/drape/stipple_pen_resource.cpp @@ -176,7 +176,7 @@ ref_ptr StipplePenIndex::MapResource(StipplePenKey const void StipplePenIndex::UploadResources(ref_ptr context, ref_ptr texture) { - ASSERT(texture->GetFormat() == dp::TextureFormat::Alpha, ()); + ASSERT(texture->GetFormat() == dp::TextureFormat::Red, ()); TPendingNodes pendingNodes; { std::lock_guard g(m_lock); diff --git a/libs/drape/stipple_pen_resource.hpp b/libs/drape/stipple_pen_resource.hpp index 3095e09bd..03c6e1e26 100644 --- a/libs/drape/stipple_pen_resource.hpp +++ b/libs/drape/stipple_pen_resource.hpp @@ -139,7 +139,7 @@ public: StipplePenTexture(m2::PointU const & size, ref_ptr allocator) : m_index(size) { - TBase::DynamicTextureParams params{size, TextureFormat::Alpha, TextureFilter::Nearest, + TBase::DynamicTextureParams params{size, TextureFormat::Red, TextureFilter::Nearest, false /* m_usePixelBuffer */}; TBase::Init(allocator, make_ref(&m_index), params); } diff --git a/libs/drape/support_manager.cpp b/libs/drape/support_manager.cpp index d3fde0fa2..21497ed9c 100644 --- a/libs/drape/support_manager.cpp +++ b/libs/drape/support_manager.cpp @@ -56,7 +56,7 @@ void SupportManager::Init(ref_ptr context) LOG(LINFO, ("NVidia Tegra device detected.")); auto const apiVersion = context->GetApiVersion(); - if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) + if (apiVersion == dp::ApiVersion::OpenGLES3) { m_maxLineWidth = static_cast(std::max(1, GLFunctions::glGetMaxLineWidth())); m_maxTextureSize = static_cast(GLFunctions::glGetInteger(gl_const::GLMaxTextureSize)); diff --git a/libs/drape/texture_manager.cpp b/libs/drape/texture_manager.cpp index fcb183d26..03e472a29 100644 --- a/libs/drape/texture_manager.cpp +++ b/libs/drape/texture_manager.cpp @@ -184,7 +184,7 @@ bool TextureManager::UpdateDynamicTextures(ref_ptr context) if (m_nothingToUpload.test_and_set()) { auto const apiVersion = context->GetApiVersion(); - if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) + if (apiVersion == dp::ApiVersion::OpenGLES3) { // For some reasons OpenGL can not update textures immediately. // Here we use some timeout to prevent rendering frozening. @@ -303,7 +303,7 @@ void TextureManager::Init(ref_ptr context, Params const & p m_maxTextureSize = std::min(kMaxTextureSize, dp::SupportManager::Instance().GetMaxTextureSize()); auto const apiVersion = context->GetApiVersion(); - if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) + if (apiVersion == dp::ApiVersion::OpenGLES3) GLFunctions::glPixelStore(gl_const::GLUnpackAlignment, 1); // Initialize symbols. @@ -324,16 +324,13 @@ void TextureManager::Init(ref_ptr context, Params const & p CreateArrowTexture(context, make_ref(m_textureAllocator), params.m_arrowTexturePath, params.m_arrowTextureUseDefaultResourceFolder); - // SMAA is not supported on OpenGL ES2. - if (apiVersion != dp::ApiVersion::OpenGLES2) - { - m_smaaAreaTexture = - make_unique_dp(context, "smaa-area.png", StaticTexture::kDefaultResource, - dp::TextureFormat::RedGreen, make_ref(m_textureAllocator)); - m_smaaSearchTexture = - make_unique_dp(context, "smaa-search.png", StaticTexture::kDefaultResource, - dp::TextureFormat::Alpha, make_ref(m_textureAllocator)); - } + // SMAA. + m_smaaAreaTexture = + make_unique_dp(context, "smaa-area.png", StaticTexture::kDefaultResource, + dp::TextureFormat::RedGreen, make_ref(m_textureAllocator)); + m_smaaSearchTexture = + make_unique_dp(context, "smaa-search.png", StaticTexture::kDefaultResource, + dp::TextureFormat::Red, make_ref(m_textureAllocator)); // Initialize patterns (reserved ./data/patterns.txt lines count). std::set patterns; diff --git a/libs/drape/texture_types.hpp b/libs/drape/texture_types.hpp index 5aa79221d..ff95c59d3 100644 --- a/libs/drape/texture_types.hpp +++ b/libs/drape/texture_types.hpp @@ -9,7 +9,7 @@ namespace dp enum class TextureFormat : uint8_t { RGBA8, - Alpha, + Red, RedGreen, DepthStencil, Depth, @@ -21,7 +21,7 @@ inline std::string DebugPrint(TextureFormat tf) switch (tf) { case TextureFormat::RGBA8: return "RGBA8"; - case TextureFormat::Alpha: return "Alpha"; + case TextureFormat::Red: return "Red"; case TextureFormat::RedGreen: return "RedGreen"; case TextureFormat::DepthStencil: return "DepthStencil"; case TextureFormat::Depth: return "Depth"; @@ -50,7 +50,7 @@ inline uint8_t GetBytesPerPixel(TextureFormat format) switch (format) { case TextureFormat::RGBA8: result = 4; break; - case TextureFormat::Alpha: result = 1; break; + case TextureFormat::Red: result = 1; break; case TextureFormat::RedGreen: result = 2; break; case TextureFormat::DepthStencil: result = 4; break; case TextureFormat::Depth: result = 4; break; diff --git a/libs/drape/vertex_array_buffer.cpp b/libs/drape/vertex_array_buffer.cpp index 6190fa029..17f528d3f 100644 --- a/libs/drape/vertex_array_buffer.cpp +++ b/libs/drape/vertex_array_buffer.cpp @@ -56,9 +56,6 @@ public: return false; m_program = program; - // If OES_vertex_array_object not supported, than buffers will be bound on each render call. - if (!GLFunctions::ExtensionsList.IsSupported(GLExtensionsList::VertexArrayObject)) - return false; if (m_VAO != 0) GLFunctions::glDeleteVertexArray(m_VAO); @@ -68,19 +65,14 @@ public: bool Bind() override { - if (GLFunctions::ExtensionsList.IsSupported(GLExtensionsList::VertexArrayObject)) - { - ASSERT(m_VAO != 0, ("You need to call Build method before bind it and render.")); - GLFunctions::glBindVertexArray(m_VAO); - return true; - } - return false; + ASSERT(m_VAO != 0, ("You need to call Build method before bind it and render.")); + GLFunctions::glBindVertexArray(m_VAO); + return true; } void Unbind() override { - if (GLFunctions::ExtensionsList.IsSupported(GLExtensionsList::VertexArrayObject)) - GLFunctions::glBindVertexArray(0); + GLFunctions::glBindVertexArray(0); } void BindBuffers(BuffersMap const & buffers) const override @@ -163,7 +155,7 @@ void VertexArrayBuffer::PreflushImpl(ref_ptr context) // Preflush can be called on BR, where impl is not initialized. // For Metal rendering this code has no meaning. auto const apiVersion = context->GetApiVersion(); - if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) + if (apiVersion == dp::ApiVersion::OpenGLES3) { GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer); GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer); @@ -208,7 +200,7 @@ void VertexArrayBuffer::Build(ref_ptr context, ref_ptrGetApiVersion(); - if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) + if (apiVersion == dp::ApiVersion::OpenGLES3) { m_impl = make_unique_dp(); } diff --git a/libs/drape/vulkan/vulkan_utils.cpp b/libs/drape/vulkan/vulkan_utils.cpp index bd76b10c1..096bb7a0c 100644 --- a/libs/drape/vulkan/vulkan_utils.cpp +++ b/libs/drape/vulkan/vulkan_utils.cpp @@ -162,7 +162,7 @@ VkFormat VulkanFormatUnpacker::Unpack(TextureFormat format) switch (format) { case TextureFormat::RGBA8: return VK_FORMAT_R8G8B8A8_UNORM; - case TextureFormat::Alpha: return VK_FORMAT_R8_UNORM; + case TextureFormat::Red: return VK_FORMAT_R8_UNORM; case TextureFormat::RedGreen: return VK_FORMAT_R8G8_UNORM; #if defined(OMIM_OS_MAC) case TextureFormat::DepthStencil: return VK_FORMAT_D32_SFLOAT_S8_UINT; diff --git a/libs/drape_frontend/arrow3d.cpp b/libs/drape_frontend/arrow3d.cpp index 48bf8f6e6..d76340757 100644 --- a/libs/drape_frontend/arrow3d.cpp +++ b/libs/drape_frontend/arrow3d.cpp @@ -308,7 +308,7 @@ Arrow3d::Arrow3d(ref_ptr context, ref_ptrGetApiVersion(); - if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) + if (apiVersion == dp::ApiVersion::OpenGLES3) m_state.SetColorTexture(texMng->GetSymbolsTexture()); m_isValid = preloadedData.m_meshData.has_value(); diff --git a/libs/drape_frontend/frontend_renderer.cpp b/libs/drape_frontend/frontend_renderer.cpp index b0a3154ae..a34cc558d 100755 --- a/libs/drape_frontend/frontend_renderer.cpp +++ b/libs/drape_frontend/frontend_renderer.cpp @@ -1424,7 +1424,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView, bool activeFram RefreshBgColor(); uint32_t clearBits = dp::ClearBits::ColorBit | dp::ClearBits::DepthBit; - if (m_apiVersion == dp::ApiVersion::OpenGLES2 || m_apiVersion == dp::ApiVersion::OpenGLES3) + if (m_apiVersion == dp::ApiVersion::OpenGLES3) clearBits |= dp::ClearBits::StencilBit; uint32_t storeBits = dp::ClearBits::ColorBit; @@ -1522,7 +1522,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView, bool activeFram if (IsValidCurrentZoom()) { uint32_t clearBits = dp::ClearBits::DepthBit; - if (m_apiVersion == dp::ApiVersion::OpenGLES2 || m_apiVersion == dp::ApiVersion::OpenGLES3) + if (m_apiVersion == dp::ApiVersion::OpenGLES3) clearBits |= dp::ClearBits::StencilBit; m_context->Clear(clearBits, dp::kClearBitsStoreAll); diff --git a/libs/drape_frontend/gui/layer_render.cpp b/libs/drape_frontend/gui/layer_render.cpp index bace4c1a5..5ab3239c9 100644 --- a/libs/drape_frontend/gui/layer_render.cpp +++ b/libs/drape_frontend/gui/layer_render.cpp @@ -369,7 +369,6 @@ void LayerCacher::CacheScaleFpsLabel(ref_ptr context, Posit std::string apiLabel; switch (apiVersion) { - case dp::ApiVersion::OpenGLES2: apiLabel = "GL2"; break; case dp::ApiVersion::OpenGLES3: apiLabel = "GL3"; break; case dp::ApiVersion::Metal: apiLabel = "M"; break; case dp::ApiVersion::Vulkan: apiLabel = "V"; break; diff --git a/libs/drape_frontend/postprocess_renderer.cpp b/libs/drape_frontend/postprocess_renderer.cpp index 0118f5dd1..083eeabe2 100644 --- a/libs/drape_frontend/postprocess_renderer.cpp +++ b/libs/drape_frontend/postprocess_renderer.cpp @@ -203,10 +203,6 @@ bool PostprocessRenderer::IsEnabled() const void PostprocessRenderer::SetEffectEnabled(ref_ptr context, Effect effect, bool enabled) { - // Do not support AA for OpenGLES 2.0. - if (m_apiVersion == dp::ApiVersion::OpenGLES2 && effect == Effect::Antialiasing) - return; - auto const oldValue = m_effects; auto const effectMask = static_cast(effect); m_effects = (m_effects & ~effectMask) | (enabled ? effectMask : 0); @@ -238,7 +234,7 @@ bool PostprocessRenderer::CanRenderAntialiasing() const return false; } - if (m_apiVersion == dp::ApiVersion::OpenGLES2 || m_apiVersion == dp::ApiVersion::OpenGLES3) + if (m_apiVersion == dp::ApiVersion::OpenGLES3) { return m_staticTextures->m_smaaAreaTexture->GetID() != 0 && m_staticTextures->m_smaaSearchTexture->GetID() != 0; @@ -289,7 +285,7 @@ bool PostprocessRenderer::EndFrame(ref_ptr context, ASSERT(m_staticTextures->m_smaaAreaTexture != nullptr, ()); ASSERT(m_staticTextures->m_smaaSearchTexture != nullptr, ()); - if (m_apiVersion == dp::ApiVersion::OpenGLES2 || m_apiVersion == dp::ApiVersion::OpenGLES3) + if (m_apiVersion == dp::ApiVersion::OpenGLES3) { ASSERT_GREATER(m_staticTextures->m_smaaAreaTexture->GetID(), 0, ()); ASSERT_GREATER(m_staticTextures->m_smaaSearchTexture->GetID(), 0, ()); @@ -418,15 +414,12 @@ void PostprocessRenderer::UpdateFramebuffers(ref_ptr contex ASSERT_NOT_EQUAL(height, 0, ()); CHECK_EQUAL(m_apiVersion, context->GetApiVersion(), ()); - InitFramebuffer(context, m_mainFramebuffer, width, height, true /* depthEnabled */, - m_apiVersion != dp::ApiVersion::OpenGLES2 /* stencilEnabled */); + InitFramebuffer(context, m_mainFramebuffer, width, height, true /* depthEnabled */, true /* stencilEnabled */); m_isMainFramebufferRendered = false; m_isSmaaFramebufferRendered = false; if (!m_isRouteFollowingActive && IsEffectEnabled(Effect::Antialiasing)) { - CHECK_NOT_EQUAL(m_apiVersion, dp::ApiVersion::OpenGLES2, ()); - InitFramebuffer(context, m_edgesFramebuffer, dp::TextureFormat::RedGreen, m_mainFramebuffer->GetDepthStencilRef(), width, height); diff --git a/libs/map/framework.hpp b/libs/map/framework.hpp index c2e4aee68..5df56f8dc 100644 --- a/libs/map/framework.hpp +++ b/libs/map/framework.hpp @@ -395,7 +395,7 @@ private: public: struct DrapeCreationParams { - dp::ApiVersion m_apiVersion = dp::ApiVersion::OpenGLES2; + dp::ApiVersion m_apiVersion = dp::ApiVersion::OpenGLES3; float m_visualScale = 1.0f; int m_surfaceWidth = 0; int m_surfaceHeight = 0; diff --git a/libs/qt_tstfrm/test_main_loop.cpp b/libs/qt_tstfrm/test_main_loop.cpp index 1f773c307..ecd051886 100644 --- a/libs/qt_tstfrm/test_main_loop.cpp +++ b/libs/qt_tstfrm/test_main_loop.cpp @@ -51,8 +51,7 @@ void RunTestLoop(char const * testName, testing::RenderFunction && fn, bool auto app.exec(); } -void RunTestInOpenGLOffscreenEnvironment(char const * testName, bool apiOpenGLES3, - testing::TestFunction const & fn) +void RunTestInOpenGLOffscreenEnvironment(char const * testName, testing::TestFunction const & fn) { std::vector buf(strlen(testName) + 1); strcpy(buf.data(), testName); @@ -71,16 +70,8 @@ void RunTestInOpenGLOffscreenEnvironment(char const * testName, bool apiOpenGLES fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer); fmt.setSwapInterval(1); fmt.setDepthBufferSize(16); - if (apiOpenGLES3) - { - fmt.setProfile(QSurfaceFormat::CoreProfile); - fmt.setVersion(3, 2); - } - else - { - fmt.setProfile(QSurfaceFormat::CompatibilityProfile); - fmt.setVersion(2, 1); - } + fmt.setProfile(QSurfaceFormat::CoreProfile); + fmt.setVersion(3, 2); auto surface = std::make_unique(); surface->setFormat(fmt); @@ -92,7 +83,7 @@ void RunTestInOpenGLOffscreenEnvironment(char const * testName, bool apiOpenGLES context->makeCurrent(surface.get()); if (fn) - fn(apiOpenGLES3); + fn(); context->doneCurrent(); surface->destroy(); diff --git a/libs/qt_tstfrm/test_main_loop.hpp b/libs/qt_tstfrm/test_main_loop.hpp index f47e0a2ee..4796b99f7 100644 --- a/libs/qt_tstfrm/test_main_loop.hpp +++ b/libs/qt_tstfrm/test_main_loop.hpp @@ -6,9 +6,9 @@ class QPaintDevice; namespace testing { using RenderFunction = std::function; -using TestFunction = std::function; +using TestFunction = std::function; } // namespace testing extern void RunTestLoop(char const * testName, testing::RenderFunction && fn, bool autoExit = true); -extern void RunTestInOpenGLOffscreenEnvironment(char const * testName, bool apiOpenGLES3, testing::TestFunction const & fn); +extern void RunTestInOpenGLOffscreenEnvironment(char const * testName, testing::TestFunction const & fn); diff --git a/libs/shaders/gl_shaders_preprocessor.py b/libs/shaders/gl_shaders_preprocessor.py index f327697be..a3f2aac1f 100755 --- a/libs/shaders/gl_shaders_preprocessor.py +++ b/libs/shaders/gl_shaders_preprocessor.py @@ -253,14 +253,7 @@ def write_implementation_file(programs_def, shader_index, shader_dir, impl_file, file.write("GLProgramInfo GetProgramInfo(dp::ApiVersion apiVersion, Program program)\n") file.write("{\n") - file.write(" if (apiVersion == dp::ApiVersion::OpenGLES2)\n") - file.write(" {\n") - file.write(" static std::array(Program::ProgramsCount)> gpuIndex = {{\n") - write_gpu_programs_map(file, programs_def, '') - file.write(" }};\n") - file.write(" return gpuIndex[static_cast(program)];\n") - file.write(" }\n") - file.write(" else if (apiVersion == dp::ApiVersion::OpenGLES3)\n") + file.write(" if (apiVersion == dp::ApiVersion::OpenGLES3)\n") # TODO: remove file.write(" {\n") file.write(" static std::array(Program::ProgramsCount)> gpuIndex = {{\n") write_gpu_programs_map(file, programs_def, GLES3_PREFIX) diff --git a/libs/shaders/program_manager.cpp b/libs/shaders/program_manager.cpp index e983eb2da..e413c7021 100644 --- a/libs/shaders/program_manager.cpp +++ b/libs/shaders/program_manager.cpp @@ -19,7 +19,7 @@ void ProgramManager::Init(ref_ptr context) { CHECK_THREAD_CHECKER(m_threadChecker, ()); auto const apiVersion = context->GetApiVersion(); - if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) + if (apiVersion == dp::ApiVersion::OpenGLES3) { InitForOpenGL(context); } diff --git a/libs/shaders/shaders_tests/gl_program_params_tests.cpp b/libs/shaders/shaders_tests/gl_program_params_tests.cpp index 6a69ff0ed..3b96e0d53 100644 --- a/libs/shaders/shaders_tests/gl_program_params_tests.cpp +++ b/libs/shaders/shaders_tests/gl_program_params_tests.cpp @@ -15,9 +15,9 @@ using namespace std::placeholders; template -void TestProgramParams(bool apiOpenGLES3) +void TestProgramParams() { - auto const api = apiOpenGLES3 ? dp::ApiVersion::OpenGLES3 : dp::ApiVersion::OpenGLES2; + auto constexpr api = dp::ApiVersion::OpenGLES3; TestingGraphicsContext context(api); GLFunctions::Init(api); gpu::GLProgramPool pool(api); @@ -37,91 +37,61 @@ void TestProgramParams(bool apiOpenGLES3) #ifdef OMIM_OS_MAC UNIT_TEST(MapProgramParams_Test) { - RunTestInOpenGLOffscreenEnvironment("MapProgramParams_Test", false /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); - - RunTestInOpenGLOffscreenEnvironment("MapProgramParams_Test", true /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); + RunTestInOpenGLOffscreenEnvironment("MapProgramParams_Test", + std::bind(&TestProgramParams)); } UNIT_TEST(RouteProgramParams_Test) { - RunTestInOpenGLOffscreenEnvironment("RouteProgramParams_Test", false /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); - - RunTestInOpenGLOffscreenEnvironment("RouteProgramParams_Test", true /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); + RunTestInOpenGLOffscreenEnvironment("RouteProgramParams_Test", + std::bind(&TestProgramParams)); } UNIT_TEST(TrafficProgramParams_Test) { - RunTestInOpenGLOffscreenEnvironment("TrafficProgramParams_Test", false /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); - - RunTestInOpenGLOffscreenEnvironment("TrafficProgramParams_Test", true /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); + RunTestInOpenGLOffscreenEnvironment("TrafficProgramParams_Test", + std::bind(&TestProgramParams)); } UNIT_TEST(TransitProgramParams_Test) { - RunTestInOpenGLOffscreenEnvironment("TransitProgramParams_Test", false /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); - - RunTestInOpenGLOffscreenEnvironment("TransitProgramParams_Test", true /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); + RunTestInOpenGLOffscreenEnvironment("TransitProgramParams_Test", + std::bind(&TestProgramParams)); } UNIT_TEST(GuiProgramParams_Test) { - RunTestInOpenGLOffscreenEnvironment("GuiProgramParams_Test", false /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); - - RunTestInOpenGLOffscreenEnvironment("GuiProgramParams_Test", true /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); + RunTestInOpenGLOffscreenEnvironment("GuiProgramParams_Test", + std::bind(&TestProgramParams)); } UNIT_TEST(ShapesProgramParams_Test) { - RunTestInOpenGLOffscreenEnvironment("ShapesProgramParams_Test", false /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); - - RunTestInOpenGLOffscreenEnvironment("ShapesProgramParams_Test", true /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); + RunTestInOpenGLOffscreenEnvironment("ShapesProgramParams_Test", + std::bind(&TestProgramParams)); } UNIT_TEST(Arrow3dProgramParams_Test) { - RunTestInOpenGLOffscreenEnvironment("Arrow3dProgramParams_Test", false /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); - - RunTestInOpenGLOffscreenEnvironment("Arrow3dProgramParams_Test", true /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); + RunTestInOpenGLOffscreenEnvironment("Arrow3dProgramParams_Test", + std::bind(&TestProgramParams)); } UNIT_TEST(DebugRectProgramParams_Test) { - RunTestInOpenGLOffscreenEnvironment("DebugRectProgramParams_Test", false /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); - - RunTestInOpenGLOffscreenEnvironment("DebugRectProgramParams_Test", true /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); + RunTestInOpenGLOffscreenEnvironment("DebugRectProgramParams_Test", + std::bind(&TestProgramParams)); } UNIT_TEST(ScreenQuadProgramParams_Test) { - RunTestInOpenGLOffscreenEnvironment("ScreenQuadProgramParams_Test", false /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); - - RunTestInOpenGLOffscreenEnvironment("ScreenQuadProgramParams_Test", true /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); + RunTestInOpenGLOffscreenEnvironment("ScreenQuadProgramParams_Test", + std::bind(&TestProgramParams)); } UNIT_TEST(SMAAProgramParams_Test) { - RunTestInOpenGLOffscreenEnvironment("SMAAProgramParams_Test", false /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); - - RunTestInOpenGLOffscreenEnvironment("SMAAProgramParams_Test", true /* apiOpenGLES3 */, - std::bind(&TestProgramParams, _1)); + RunTestInOpenGLOffscreenEnvironment("SMAAProgramParams_Test", + std::bind(&TestProgramParams)); } #endif diff --git a/libs/shaders/shaders_tests/gl_shaders_desktop_compile_tests.cpp b/libs/shaders/shaders_tests/gl_shaders_desktop_compile_tests.cpp index 67c84e9fb..10f8eeec8 100644 --- a/libs/shaders/shaders_tests/gl_shaders_desktop_compile_tests.cpp +++ b/libs/shaders/shaders_tests/gl_shaders_desktop_compile_tests.cpp @@ -10,9 +10,9 @@ using namespace std::placeholders; -void CompileShaders(bool apiOpenGLES3, bool enableVTF) +void CompileShaders(bool enableVTF) { - auto const api = apiOpenGLES3 ? dp::ApiVersion::OpenGLES3 : dp::ApiVersion::OpenGLES2; + auto constexpr api = dp::ApiVersion::OpenGLES3; GLFunctions::Init(api); gpu::GLProgramPool pool(api); if (enableVTF) @@ -24,29 +24,17 @@ void CompileShaders(bool apiOpenGLES3, bool enableVTF) // These unit tests create Qt application and OGL context so can't be run in GUI-less Linux machine. #ifdef OMIM_OS_MAC -UNIT_TEST(DesktopCompileShaders_GLES2_Test) -{ - RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES2_Test", false /* apiOpenGLES3 */, - std::bind(&CompileShaders, _1, false /* enableVTF */)); -} - UNIT_TEST(DesktopCompileShaders_GLES3_Test) { - RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES3_Test", true /* apiOpenGLES3 */, - std::bind(&CompileShaders, _1, false /* enableVTF */)); + RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES3_Test", + std::bind(&CompileShaders, false /* enableVTF */)); } -UNIT_TEST(DesktopCompileShaders_GLES2_VTF_Test) -{ - RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES2_VTF_Test", false /* apiOpenGLES3 */, - std::bind(&CompileShaders, _1, true /* enableVTF */)); -} - UNIT_TEST(DesktopCompileShaders_GLES3_VTF_Test) { - RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES3_VTF_Test", true /* apiOpenGLES3 */, - std::bind(&CompileShaders, _1, true /* enableVTF */)); + RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES3_VTF_Test", + std::bind(&CompileShaders, true /* enableVTF */)); } #endif diff --git a/libs/shaders/shaders_tests/gl_shaders_mobile_compile_test.cpp b/libs/shaders/shaders_tests/gl_shaders_mobile_compile_test.cpp index 9ef3dc22c..ec25d31d8 100644 --- a/libs/shaders/shaders_tests/gl_shaders_mobile_compile_test.cpp +++ b/libs/shaders/shaders_tests/gl_shaders_mobile_compile_test.cpp @@ -26,9 +26,7 @@ std::string const kCompilersDir = "shaders_compiler"; #if defined(OMIM_OS_MAC) -std::string const kMaliCompilerOpenGLES2Dir = "macos/mali_compiler"; std::string const kMaliCompilerOpenGLES3Dir = "macos/mali_compiler_es3"; -std::string const kCompilerMaliOpenGLES2 = kMaliCompilerOpenGLES2Dir + "/malisc"; std::string const kCompilerMaliOpenGLES3 = kMaliCompilerOpenGLES3Dir + "/malisc"; std::string const kCompilerOpenGLES = "macos/glslangValidator"; #elif defined(OMIM_OS_LINUX) @@ -166,29 +164,15 @@ UNIT_TEST(MobileCompileShaders_Test) { base::DelayedThreadPool workerThread(6 /* threadsCount */); - workerThread.Push([] { - CompileShaders({dp::ApiVersion::OpenGLES2, GetCompilerPath(kCompilerOpenGLES)}); - }); - workerThread.Push([] { CompileShaders({dp::ApiVersion::OpenGLES3, GetCompilerPath(kCompilerOpenGLES)}); }); - workerThread.Push([] { - CompileShaders({dp::ApiVersion::OpenGLES2, GetCompilerPath(kCompilerOpenGLES)}, - "#define ENABLE_VTF\n"); - }); - workerThread.Push([] { CompileShaders({dp::ApiVersion::OpenGLES3, GetCompilerPath(kCompilerOpenGLES)}, "#define ENABLE_VTF\n"); }); - workerThread.Push([] { - CompileShaders({dp::ApiVersion::OpenGLES2, GetCompilerPath(kCompilerOpenGLES)}, - "#define SAMSUNG_GOOGLE_NEXUS\n"); - }); - workerThread.Push([] { CompileShaders({dp::ApiVersion::OpenGLES3, GetCompilerPath(kCompilerOpenGLES)}, "#define SAMSUNG_GOOGLE_NEXUS\n"); @@ -474,16 +458,6 @@ UNIT_TEST(MALI_MobileCompileShaders_Test) driversES2new.insert(driversES2new.end(), driversES3new.begin(), driversES3new.end()); std::vector const compilers = { -#if defined(OMIM_OS_MAC) - {dp::ApiVersion::OpenGLES2, - GetCompilerPath(kCompilerMaliOpenGLES2), - GetCompilerPath(kMaliCompilerOpenGLES2Dir), - driversES2old}, -#endif - {dp::ApiVersion::OpenGLES2, - GetCompilerPath(kCompilerMaliOpenGLES3), - GetCompilerPath(kMaliCompilerOpenGLES3Dir), - driversES2new}, {dp::ApiVersion::OpenGLES3, GetCompilerPath(kCompilerMaliOpenGLES3), GetCompilerPath(kMaliCompilerOpenGLES3Dir), diff --git a/qt/qt_common/map_widget.cpp b/qt/qt_common/map_widget.cpp index 07da1e31f..dc3f2455a 100644 --- a/qt/qt_common/map_widget.cpp +++ b/qt/qt_common/map_widget.cpp @@ -107,7 +107,7 @@ void MapWidget::CreateEngine() { Framework::DrapeCreationParams p; - p.m_apiVersion = m_apiOpenGLES3 ? dp::ApiVersion::OpenGLES3 : dp::ApiVersion::OpenGLES2; + p.m_apiVersion = dp::ApiVersion::OpenGLES3; p.m_surfaceWidth = m_screenshotMode ? width() : static_cast(m_ratio * width()); p.m_surfaceHeight = m_screenshotMode ? height() : static_cast(m_ratio * height()); @@ -232,8 +232,6 @@ void MapWidget::Build() { std::string_view vertexSrc; std::string_view fragmentSrc; - if (m_apiOpenGLES3) - { #if defined(OMIM_OS_LINUX) vertexSrc = ":common/shaders/gles_300.vsh.glsl"; fragmentSrc = ":common/shaders/gles_300.fsh.glsl"; @@ -241,12 +239,6 @@ void MapWidget::Build() vertexSrc = ":common/shaders/gl_150.vsh.glsl"; fragmentSrc = ":common/shaders/gl_150.fsh.glsl"; #endif - } - else - { - vertexSrc = ":common/shaders/gles_200.vsh.glsl"; - fragmentSrc = ":common/shaders/gles_200.fsh.glsl"; - } m_program = std::make_unique(this); m_program->addShaderFromSourceFile(QOpenGLShader::Vertex, vertexSrc.data()); @@ -348,8 +340,6 @@ void MapWidget::initializeGL() if (!m_screenshotMode) m_ratio = devicePixelRatio(); - m_apiOpenGLES3 = true; - #if defined(OMIM_OS_LINUX) { QOpenGLFunctions * funcs = context()->functions(); @@ -367,29 +357,14 @@ void MapWidget::initializeGL() auto fmt = context()->format(); if (context()->format().version() < qMakePair(3, 0)) { - LOG(LINFO, ("OpenGL ES version is below 3.0, taking the OpenGL ES 2.0 path")); - m_apiOpenGLES3 = false; - - constexpr const char* requiredExtensions[3] = - { "GL_EXT_map_buffer_range", "GL_OES_mapbuffer", "GL_OES_vertex_array_object" }; - for (auto & requiredExtension : requiredExtensions) - { - if (context()->hasExtension(QByteArray::fromStdString(requiredExtension))) - LOG(LDEBUG, ("Found OpenGL ES 2.0 extension: ", requiredExtension)); - else - LOG(LCRITICAL, ("A required OpenGL ES 2.0 extension is missing:", requiredExtension)); - } - fmt.setProfile(QSurfaceFormat::CompatibilityProfile); - fmt.setVersion(2, 0); + CHECK(false, ("OpenGL ES2 is not supported")); } else { LOG(LINFO, ("OpenGL version is at least 3.0, enabling GLSL '#version 300 es'")); - m_apiOpenGLES3 = true; fmt.setVersion(3, 0); } - QSurfaceFormat::setDefaultFormat(fmt); } #endif diff --git a/qt/qt_common/map_widget.hpp b/qt/qt_common/map_widget.hpp index 304a51aea..aacb29237 100644 --- a/qt/qt_common/map_widget.hpp +++ b/qt/qt_common/map_widget.hpp @@ -97,7 +97,6 @@ protected: void wheelEvent(QWheelEvent * e) override; Framework & m_framework; - bool m_apiOpenGLES3; bool m_screenshotMode; ScaleSlider * m_slider; SliderState m_sliderState; diff --git a/qt/qt_common/res/resources_common.qrc b/qt/qt_common/res/resources_common.qrc index 8aa243bd9..0bc03d9f7 100644 --- a/qt/qt_common/res/resources_common.qrc +++ b/qt/qt_common/res/resources_common.qrc @@ -16,8 +16,6 @@ spinner12.png shaders/gl_150.fsh.glsl shaders/gl_150.vsh.glsl - shaders/gles_200.fsh.glsl - shaders/gles_200.vsh.glsl shaders/gles_300.fsh.glsl shaders/gles_300.vsh.glsl diff --git a/qt/qt_common/res/shaders/gles_200.fsh.glsl b/qt/qt_common/res/shaders/gles_200.fsh.glsl deleted file mode 100644 index baa46225b..000000000 --- a/qt/qt_common/res/shaders/gles_200.fsh.glsl +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef GL_ES -#ifdef GL_FRAGMENT_PRECISION_HIGH -precision highp float; -#else -precision mediump float; -#endif -#endif - -uniform sampler2D u_sampler; -varying vec2 v_texCoord; - -void main() -{ - gl_FragColor = vec4(texture2D(u_sampler, v_texCoord).rgb, 1.0); -} diff --git a/qt/qt_common/res/shaders/gles_200.vsh.glsl b/qt/qt_common/res/shaders/gles_200.vsh.glsl deleted file mode 100644 index 7d1208f96..000000000 --- a/qt/qt_common/res/shaders/gles_200.vsh.glsl +++ /dev/null @@ -1,9 +0,0 @@ -attribute vec4 a_position; -uniform vec2 u_samplerSize; -varying vec2 v_texCoord; - -void main() -{ - v_texCoord = vec2(a_position.z * u_samplerSize.x, a_position.w * u_samplerSize.y); - gl_Position = vec4(a_position.x, a_position.y, 0.0, 1.0); -}