[Drape] Remove GLES2-related code

Signed-off-by: renderexpert <expert@renderconsulting.co.uk>
This commit is contained in:
renderexpert
2025-01-20 11:05:45 +00:00
committed by Konstantin Pastbin
parent 705c715356
commit b23c2ba3e3
47 changed files with 235 additions and 623 deletions

View File

@@ -229,8 +229,7 @@ bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi
LOG(LWARNING, ("Invalid GL context.")); LOG(LWARNING, ("Invalid GL context."));
return false; return false;
} }
p.m_apiVersion = oglFactory->IsSupportedOpenGLES3() ? dp::ApiVersion::OpenGLES3 : p.m_apiVersion = dp::ApiVersion::OpenGLES3;
dp::ApiVersion::OpenGLES2;
p.m_surfaceWidth = oglFactory->GetWidth(); p.m_surfaceWidth = oglFactory->GetWidth();
p.m_surfaceHeight = oglFactory->GetHeight(); p.m_surfaceHeight = oglFactory->GetHeight();

View File

@@ -8,20 +8,16 @@
namespace android namespace android
{ {
static EGLint * getContextAttributesList(bool supportedES3) static EGLint * getContextAttributesList()
{ {
static EGLint contextAttrList[] = { static EGLint contextAttrList[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
static EGLint contextAttrListES3[] = {
EGL_CONTEXT_CLIENT_VERSION, 3, EGL_CONTEXT_CLIENT_VERSION, 3,
EGL_NONE 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) EGLConfig config, AndroidOGLContext * contextToShareWith)
: m_nativeContext(EGL_NO_CONTEXT) : m_nativeContext(EGL_NO_CONTEXT)
, m_surface(surface) , m_surface(surface)
@@ -32,7 +28,7 @@ AndroidOGLContext::AndroidOGLContext(bool supportedES3, EGLDisplay display, EGLS
ASSERT(m_display != EGL_NO_DISPLAY, ()); ASSERT(m_display != EGL_NO_DISPLAY, ());
EGLContext sharedContext = (contextToShareWith == NULL) ? EGL_NO_CONTEXT : contextToShareWith->m_nativeContext; 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, ()); CHECK(m_nativeContext != EGL_NO_CONTEXT, ());
} }

View File

@@ -10,7 +10,7 @@ namespace android
class AndroidOGLContext : public dp::OGLContext class AndroidOGLContext : public dp::OGLContext
{ {
public: public:
AndroidOGLContext(bool supportedES3, EGLDisplay display, EGLSurface surface, AndroidOGLContext(EGLDisplay display, EGLSurface surface,
EGLConfig config, AndroidOGLContext * contextToShareWith); EGLConfig config, AndroidOGLContext * contextToShareWith);
~AndroidOGLContext(); ~AndroidOGLContext();

View File

@@ -16,26 +16,13 @@
#define EGL_OPENGL_ES3_BIT 0x00000040 #define EGL_OPENGL_ES3_BIT 0x00000040
int constexpr kMinSdkVersionForES3 = 21;
namespace android namespace android
{ {
namespace namespace
{ {
static EGLint * getConfigAttributesListRGB8(bool supportedES3) static EGLint * getConfigAttributesListRGB8()
{ {
static EGLint attr_list[] = { 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_RED_SIZE, 8,
EGL_GREEN_SIZE, 8, EGL_GREEN_SIZE, 8,
EGL_BLUE_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_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_WINDOW_BIT,
EGL_NONE EGL_NONE
}; };
return supportedES3 ? attr_list_es3 : attr_list; return attr_list;
} }
int const kMaxConfigCount = 40; int const kMaxConfigCount = 40;
static EGLint * getConfigAttributesListR5G6B5() bool IsSupportedRGB8(EGLDisplay display)
{
// 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)
{ {
EGLConfig configs[kMaxConfigCount]; EGLConfig configs[kMaxConfigCount];
int count = 0; int count = 0;
return eglChooseConfig(display, getConfigAttributesListRGB8(es3), configs, return eglChooseConfig(display, getConfigAttributesListRGB8(), configs,
kMaxConfigCount, &count) == EGL_TRUE && count != 0; kMaxConfigCount, &count) == EGL_TRUE && count != 0;
} }
@@ -90,7 +60,6 @@ AndroidOGLContextFactory::AndroidOGLContextFactory(JNIEnv * env, jobject jsurfac
, m_surfaceWidth(0) , m_surfaceWidth(0)
, m_surfaceHeight(0) , m_surfaceHeight(0)
, m_windowSurfaceValid(false) , m_windowSurfaceValid(false)
, m_supportedES3(false)
{ {
m_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); m_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (m_display == EGL_NO_DISPLAY) if (m_display == EGL_NO_DISPLAY)
@@ -106,10 +75,7 @@ AndroidOGLContextFactory::AndroidOGLContextFactory(JNIEnv * env, jobject jsurfac
return; return;
} }
// Check ES3 availability. CHECK(gl3stubInit(), ("Could not initialize OpenGL ES3"));
bool const isES3Supported = IsSupportedRGB8(m_display, true /* es3 */) &&
android_get_device_api_level() >= kMinSdkVersionForES3;
m_supportedES3 = isES3Supported && gl3stubInit();
SetSurface(env, jsurface); SetSurface(env, jsurface);
@@ -266,7 +232,7 @@ dp::GraphicsContext * AndroidOGLContextFactory::GetDrawContext()
ASSERT(m_windowSurface != EGL_NO_SURFACE, ()); ASSERT(m_windowSurface != EGL_NO_SURFACE, ());
if (m_drawContext == nullptr) 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); m_config, m_uploadContext);
} }
return m_drawContext; return m_drawContext;
@@ -278,7 +244,7 @@ dp::GraphicsContext * AndroidOGLContextFactory::GetResourcesUploadContext()
ASSERT(m_pixelbufferSurface != EGL_NO_SURFACE, ()); ASSERT(m_pixelbufferSurface != EGL_NO_SURFACE, ());
if (m_uploadContext == nullptr) 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); m_config, m_drawContext);
} }
return m_uploadContext; return m_uploadContext;
@@ -322,17 +288,15 @@ bool AndroidOGLContextFactory::CreateWindowSurface()
{ {
EGLConfig configs[kMaxConfigCount]; EGLConfig configs[kMaxConfigCount];
int count = 0; int count = 0;
if (eglChooseConfig(m_display, getConfigAttributesListRGB8(m_supportedES3), configs, if (eglChooseConfig(m_display, getConfigAttributesListRGB8(), configs,
kMaxConfigCount, &count) != EGL_TRUE) kMaxConfigCount, &count) == EGL_TRUE)
{ {
ASSERT(!m_supportedES3, ()); CHECK(IsSupportedRGB8(m_display), ("RGB8 is not suported on this device"));
VERIFY(eglChooseConfig(m_display, getConfigAttributesListR5G6B5(), configs, LOG(LDEBUG, ("Backbuffer format: RGB8"));
kMaxConfigCount, &count) == EGL_TRUE, ());
LOG(LDEBUG, ("Backbuffer format: R5G6B5"));
} }
else else
{ {
LOG(LDEBUG, ("Backbuffer format: RGB8")); CHECK(false, ("OpenGL ES3 is not supported"));
} }
ASSERT(count > 0, ("Didn't find any configs.")); ASSERT(count > 0, ("Didn't find any configs."));

View File

@@ -33,8 +33,6 @@ public:
int GetHeight() const; int GetHeight() const;
void UpdateSurfaceSize(int w, int h); void UpdateSurfaceSize(int w, int h);
bool IsSupportedOpenGLES3() const { return m_supportedES3; }
private: private:
bool QuerySurfaceSize(); bool QuerySurfaceSize();
@@ -56,7 +54,6 @@ private:
int m_surfaceHeight; int m_surfaceHeight;
bool m_windowSurfaceValid; bool m_windowSurfaceValid;
bool m_supportedES3;
bool m_isInitialized = false; bool m_isInitialized = false;
size_t m_initializationCounter = 0; size_t m_initializationCounter = 0;

View File

@@ -81,7 +81,7 @@ double getExactDPI(double contentScaleFactor)
if (tempContext != nil) if (tempContext != nil)
apiVersion = dp::ApiVersion::OpenGLES3; apiVersion = dp::ApiVersion::OpenGLES3;
else else
apiVersion = dp::ApiVersion::OpenGLES2; CHECK(false, ("OpenGL ES3 is not supported"));
} }
return apiVersion; return apiVersion;

View File

@@ -17,20 +17,14 @@ iosOGLContext::iosOGLContext(CAEAGLLayer * layer, dp::ApiVersion apiVersion,
, m_frameBufferId(0) , m_frameBufferId(0)
, m_presentAvailable(true) , m_presentAvailable(true)
{ {
EAGLRenderingAPI api;
if (m_apiVersion == dp::ApiVersion::OpenGLES3)
api = kEAGLRenderingAPIOpenGLES3;
else
api = kEAGLRenderingAPIOpenGLES2;
if (contextToShareWith != NULL) if (contextToShareWith != NULL)
{ {
m_nativeContext = [[EAGLContext alloc] initWithAPI:api m_nativeContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3
sharegroup: contextToShareWith->m_nativeContext.sharegroup]; sharegroup: contextToShareWith->m_nativeContext.sharegroup];
} }
else else
{ {
m_nativeContext = [[EAGLContext alloc] initWithAPI:api]; m_nativeContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
} }
} }

View File

@@ -21,7 +21,7 @@ void DataBuffer::MoveToGPU(ref_ptr<GraphicsContext> context, GPUBuffer::Target t
uint32_t const currentSize = m_impl->GetCurrentSize(); uint32_t const currentSize = m_impl->GetCurrentSize();
auto const apiVersion = context->GetApiVersion(); auto const apiVersion = context->GetApiVersion();
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) if (apiVersion == dp::ApiVersion::OpenGLES3)
{ {
if (currentSize != 0) if (currentSize != 0)
{ {

View File

@@ -26,7 +26,6 @@ namespace dp
enum class ApiVersion enum class ApiVersion
{ {
Invalid = -1, Invalid = -1,
OpenGLES2 = 0,
OpenGLES3, OpenGLES3,
Metal, Metal,
Vulkan Vulkan
@@ -101,7 +100,6 @@ inline std::string DebugPrint(dp::ApiVersion apiVersion)
switch (apiVersion) switch (apiVersion)
{ {
case dp::ApiVersion::Invalid: return "Invalid"; case dp::ApiVersion::Invalid: return "Invalid";
case dp::ApiVersion::OpenGLES2: return "OpenGLES2";
case dp::ApiVersion::OpenGLES3: return "OpenGLES3"; case dp::ApiVersion::OpenGLES3: return "OpenGLES3";
case dp::ApiVersion::Metal: return "Metal"; case dp::ApiVersion::Metal: return "Metal";
case dp::ApiVersion::Vulkan: return "Vulkan"; case dp::ApiVersion::Vulkan: return "Vulkan";
@@ -121,9 +119,6 @@ inline dp::ApiVersion ApiVersionFromString(std::string const & str)
return dp::ApiVersion::Vulkan; return dp::ApiVersion::Vulkan;
#endif #endif
if (str == "OpenGLES2")
return dp::ApiVersion::OpenGLES2;
if (str == "OpenGLES3") if (str == "OpenGLES3")
return dp::ApiVersion::OpenGLES3; return dp::ApiVersion::OpenGLES3;

View File

@@ -107,7 +107,7 @@ UNIT_TEST(UploadingGlyphs)
TestingGraphicsContext context; TestingGraphicsContext context;
Texture::Params p; Texture::Params p;
p.m_allocator = GetDefaultAllocator(make_ref(&context)); 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; p.m_width = p.m_height = kTextureSize;
DummyTexture tex; DummyTexture tex;

View File

@@ -2,7 +2,7 @@
#include "drape/graphics_context.hpp" #include "drape/graphics_context.hpp"
// Testing context simulates OpenGLES2 API version. // Testing context simulates OpenGLES3 API version.
class TestingGraphicsContext : public dp::GraphicsContext class TestingGraphicsContext : public dp::GraphicsContext
{ {
public: public:
@@ -38,5 +38,5 @@ public:
void SetCullingEnabled(bool enabled) override {} void SetCullingEnabled(bool enabled) override {}
private: private:
dp::ApiVersion m_apiVersion = dp::ApiVersion::OpenGLES2; dp::ApiVersion m_apiVersion = dp::ApiVersion::OpenGLES3;
}; };

View File

@@ -81,7 +81,7 @@ public:
FontTexture(m2::PointU const & size, ref_ptr<GlyphManager> glyphMng, ref_ptr<HWTextureAllocator> allocator) FontTexture(m2::PointU const & size, ref_ptr<GlyphManager> glyphMng, ref_ptr<HWTextureAllocator> allocator)
: m_index(size, glyphMng) : 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); Init(allocator, make_ref(&m_index), params);
} }

View File

@@ -134,7 +134,7 @@ void Framebuffer::SetSize(ref_ptr<dp::GraphicsContext> context, uint32_t width,
m_depthStencilRef->SetSize(context, m_width, m_height); m_depthStencilRef->SetSize(context, m_width, m_height);
auto const apiVersion = context->GetApiVersion(); auto const apiVersion = context->GetApiVersion();
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) if (apiVersion == dp::ApiVersion::OpenGLES3)
{ {
glConst depthAttachmentId = 0; glConst depthAttachmentId = 0;
glConst stencilAttachmentId = 0; glConst stencilAttachmentId = 0;

View File

@@ -7,67 +7,14 @@
namespace dp 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 #ifdef OMIM_OS_ANDROID
SetExtension(VertexArrayObject, false); // NOTE: MapBuffer/MapBufferRange are disabled by performance reasons according to
// On some Android devices glMapBufferRange/glMapBuffer works very slow. // https://github.com/organicmaps/organicmaps/commit/d72ab7c8cd8be0eb5a622d9d33ae943b391d5707
// We have to substitute these functions to glBufferData/glBufferSubData. SetExtension(MapBuffer, false);
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);
}
#else #else
SetExtension(MapBuffer, true); 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 #endif
} }

View File

@@ -14,14 +14,11 @@ class GLExtensionsList
public: public:
enum ExtensionName enum ExtensionName
{ {
VertexArrayObject,
MapBuffer, MapBuffer,
UintIndices,
MapBufferRange
}; };
GLExtensionsList() = default; GLExtensionsList() = default;
void Init(dp::ApiVersion apiVersion); void Init();
bool IsSupported(ExtensionName extName) const; bool IsSupported(ExtensionName extName) const;
private: private:

View File

@@ -244,71 +244,18 @@ void GLFunctions::Init(dp::ApiVersion apiVersion)
return; return;
CurrentApiVersion = apiVersion; CurrentApiVersion = apiVersion;
ExtensionsList.Init(apiVersion); ExtensionsList.Init();
s_inited = true; s_inited = true;
/// VAO
#if !defined(OMIM_OS_WINDOWS) #if !defined(OMIM_OS_WINDOWS)
if (CurrentApiVersion == dp::ApiVersion::OpenGLES2) // OpenGL ES3 api is the same for all systems, except WINDOWS.
{ glGenVertexArraysFn = ::glGenVertexArrays;
#if defined(OMIM_OS_MAC) glBindVertexArrayFn = ::glBindVertexArray;
glDeleteVertexArrayFn = ::glDeleteVertexArrays;
glGenVertexArraysFn = &glGenVertexArraysAPPLE; glUnmapBufferFn = ::glUnmapBuffer;
glBindVertexArrayFn = &glBindVertexArrayAPPLE; glMapBufferRangeFn = ::glMapBufferRange;
glDeleteVertexArrayFn = &glDeleteVertexArraysAPPLE; glFlushMappedBufferRangeFn = ::glFlushMappedBufferRange;
glMapBufferFn = &::glMapBuffer; glGetStringiFn = ::glGetStringi;
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"));
}
glClearColorFn = LOAD_GL_FUNC(TglClearColorFn, glClearColor); glClearColorFn = LOAD_GL_FUNC(TglClearColorFn, glClearColor);
glClearFn = LOAD_GL_FUNC(TglClearFn, glClear); glClearFn = LOAD_GL_FUNC(TglClearFn, glClear);
@@ -316,13 +263,9 @@ void GLFunctions::Init(dp::ApiVersion apiVersion)
glScissorFn = LOAD_GL_FUNC(TglScissorFn, glScissor); glScissorFn = LOAD_GL_FUNC(TglScissorFn, glScissor);
glFlushFn = LOAD_GL_FUNC(TglFlushFn, glFlush); glFlushFn = LOAD_GL_FUNC(TglFlushFn, glFlush);
#else // OMIM_OS_WINDOWS #else // OMIM_OS_WINDOWS
if (ExtensionsList.IsSupported(dp::GLExtensionsList::VertexArrayObject)) glGenVertexArraysFn = LOAD_GL_FUNC(TglGenVertexArraysFn, glGenVertexArrays);
{ glBindVertexArrayFn = LOAD_GL_FUNC(TglBindVertexArrayFn, glBindVertexArray);
glGenVertexArraysFn = LOAD_GL_FUNC(TglGenVertexArraysFn, glGenVertexArrays); glDeleteVertexArrayFn = LOAD_GL_FUNC(TglDeleteVertexArrayFn, glDeleteVertexArrays);
glBindVertexArrayFn = LOAD_GL_FUNC(TglBindVertexArrayFn, glBindVertexArray);
glDeleteVertexArrayFn = LOAD_GL_FUNC(TglDeleteVertexArrayFn, glDeleteVertexArrays);
}
glMapBufferFn = LOAD_GL_FUNC(TglMapBufferFn, glMapBuffer);
glUnmapBufferFn = LOAD_GL_FUNC(TglUnmapBufferFn, glUnmapBuffer); glUnmapBufferFn = LOAD_GL_FUNC(TglUnmapBufferFn, glUnmapBuffer);
glMapBufferRangeFn = LOAD_GL_FUNC(TglMapBufferRangeFn, glMapBufferRange); glMapBufferRangeFn = LOAD_GL_FUNC(TglMapBufferRangeFn, glMapBufferRange);
glFlushMappedBufferRangeFn = LOAD_GL_FUNC(TglFlushMappedBufferRangeFn, glFlushMappedBufferRange); glFlushMappedBufferRangeFn = LOAD_GL_FUNC(TglFlushMappedBufferRangeFn, glFlushMappedBufferRange);
@@ -403,115 +346,94 @@ void GLFunctions::Init(dp::ApiVersion apiVersion)
bool GLFunctions::glHasExtension(std::string const & name) bool GLFunctions::glHasExtension(std::string const & name)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
if (CurrentApiVersion == dp::ApiVersion::OpenGLES2) ASSERT(glGetStringiFn != nullptr, ());
GLint n = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
for (GLint i = 0; i < n; i++)
{ {
char const * extensions = reinterpret_cast<char const *>(::glGetString(GL_EXTENSIONS)); std::string const extension =
GLCHECKCALL(); std::string(reinterpret_cast<char const *>(glGetStringiFn(GL_EXTENSIONS, i)));
if (extensions == nullptr) if (extension == name)
return false; return true;
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<char const *>(glGetStringiFn(GL_EXTENSIONS, i)));
if (extension == name)
return true;
}
} }
return false; return false;
} }
void GLFunctions::glClearColor(float r, float g, float b, float a) 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, ()); ASSERT(glClearColorFn != nullptr, ());
GLCHECK(glClearColorFn(r, g, b, a)); GLCHECK(glClearColorFn(r, g, b, a));
} }
void GLFunctions::glClear(uint32_t clearBits) void GLFunctions::glClear(uint32_t clearBits)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glClearFn != nullptr, ()); ASSERT(glClearFn != nullptr, ());
GLCHECK(glClearFn(clearBits)); GLCHECK(glClearFn(clearBits));
} }
void GLFunctions::glViewport(uint32_t x, uint32_t y, uint32_t w, uint32_t h) 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, ()); ASSERT(glViewportFn != nullptr, ());
GLCHECK(glViewportFn(x, y, w, h)); GLCHECK(glViewportFn(x, y, w, h));
} }
void GLFunctions::glScissor(uint32_t x, uint32_t y, uint32_t w, uint32_t 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, ()); ASSERT(glScissorFn != nullptr, ());
GLCHECK(glScissorFn(x, y, w, h)); GLCHECK(glScissorFn(x, y, w, h));
} }
void GLFunctions::glFlush() void GLFunctions::glFlush()
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glFlushFn != nullptr, ()); ASSERT(glFlushFn != nullptr, ());
GLCHECK(glFlushFn()); GLCHECK(glFlushFn());
} }
void GLFunctions::glFinish() void GLFunctions::glFinish()
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLCHECK(::glFinish()); GLCHECK(::glFinish());
} }
void GLFunctions::glFrontFace(glConst mode) void GLFunctions::glFrontFace(glConst mode)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLCHECK(::glFrontFace(mode)); GLCHECK(::glFrontFace(mode));
} }
void GLFunctions::glCullFace(glConst face) void GLFunctions::glCullFace(glConst face)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLCHECK(::glCullFace(face)); GLCHECK(::glCullFace(face));
} }
void GLFunctions::glStencilOpSeparate(glConst face, glConst sfail, glConst dpfail, glConst dppass) 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)); GLCHECK(glStencilOpSeparateFn(face, sfail, dpfail, dppass));
} }
void GLFunctions::glStencilFuncSeparate(glConst face, glConst func, int ref, uint32_t mask) 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)); GLCHECK(glStencilFuncSeparateFn(face, func, ref, mask));
} }
void GLFunctions::glPixelStore(glConst name, uint32_t value) 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)); GLCHECK(::glPixelStorei(name, value));
} }
int32_t GLFunctions::glGetInteger(glConst pname) int32_t GLFunctions::glGetInteger(glConst pname)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLint value; GLint value;
GLCHECK(::glGetIntegerv(pname, &value)); GLCHECK(::glGetIntegerv(pname, &value));
return (int32_t)value; return (int32_t)value;
@@ -519,7 +441,7 @@ int32_t GLFunctions::glGetInteger(glConst pname)
std::string GLFunctions::glGetString(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<char const *>(::glGetString(pname)); char const * str = reinterpret_cast<char const *>(::glGetString(pname));
GLCHECKCALL(); GLCHECKCALL();
if (str == nullptr) if (str == nullptr)
@@ -530,7 +452,7 @@ std::string GLFunctions::glGetString(glConst pname)
int32_t GLFunctions::glGetMaxLineWidth() int32_t GLFunctions::glGetMaxLineWidth()
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLint range[2]; GLint range[2];
GLCHECK(::glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, range)); GLCHECK(::glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, range));
return std::max(range[0], range[1]); return std::max(range[0], range[1]);
@@ -538,7 +460,7 @@ int32_t GLFunctions::glGetMaxLineWidth()
int32_t GLFunctions::glGetBufferParameter(glConst target, glConst name) int32_t GLFunctions::glGetBufferParameter(glConst target, glConst name)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLint result; GLint result;
ASSERT(glGetBufferParameterFn != nullptr, ()); ASSERT(glGetBufferParameterFn != nullptr, ());
GLCHECK(glGetBufferParameterFn(target, name, &result)); GLCHECK(glGetBufferParameterFn(target, name, &result));
@@ -547,19 +469,19 @@ int32_t GLFunctions::glGetBufferParameter(glConst target, glConst name)
void GLFunctions::glEnable(glConst mode) void GLFunctions::glEnable(glConst mode)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLCHECK(::glEnable(mode)); GLCHECK(::glEnable(mode));
} }
void GLFunctions::glDisable(glConst mode) void GLFunctions::glDisable(glConst mode)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLCHECK(::glDisable(mode)); GLCHECK(::glDisable(mode));
} }
void GLFunctions::glClearDepthValue(double depth) 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) #if defined(OMIM_OS_IPHONE) || defined(OMIM_OS_ANDROID) || defined(OMIM_OS_LINUX)
GLCHECK(::glClearDepthf(static_cast<GLclampf>(depth))); GLCHECK(::glClearDepthf(static_cast<GLclampf>(depth)));
#else #else
@@ -569,32 +491,32 @@ void GLFunctions::glClearDepthValue(double depth)
void GLFunctions::glDepthMask(bool needWriteToDepthBuffer) void GLFunctions::glDepthMask(bool needWriteToDepthBuffer)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLCHECK(::glDepthMask(convert(needWriteToDepthBuffer))); GLCHECK(::glDepthMask(convert(needWriteToDepthBuffer)));
} }
void GLFunctions::glDepthFunc(glConst depthFunc) void GLFunctions::glDepthFunc(glConst depthFunc)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLCHECK(::glDepthFunc(depthFunc)); GLCHECK(::glDepthFunc(depthFunc));
} }
void GLFunctions::glBlendEquation(glConst function) void GLFunctions::glBlendEquation(glConst function)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glBlendEquationFn != nullptr, ()); ASSERT(glBlendEquationFn != nullptr, ());
GLCHECK(glBlendEquationFn(function)); GLCHECK(glBlendEquationFn(function));
} }
void GLFunctions::glBlendFunc(glConst srcFactor, glConst dstFactor) void GLFunctions::glBlendFunc(glConst srcFactor, glConst dstFactor)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLCHECK(::glBlendFunc(srcFactor, dstFactor)); GLCHECK(::glBlendFunc(srcFactor, dstFactor));
} }
bool GLFunctions::CanEnableDebugMessages() bool GLFunctions::CanEnableDebugMessages()
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
if (glDebugMessageCallbackFn == nullptr) if (glDebugMessageCallbackFn == nullptr)
return false; return false;
if (glDebugMessageControlFn == nullptr) if (glDebugMessageControlFn == nullptr)
@@ -606,7 +528,7 @@ bool GLFunctions::CanEnableDebugMessages()
void GLFunctions::glDebugMessageCallback(TglDebugProc messageCallback, void * userParam) void GLFunctions::glDebugMessageCallback(TglDebugProc messageCallback, void * userParam)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glDebugMessageCallbackFn != nullptr, ()); ASSERT(glDebugMessageCallbackFn != nullptr, ());
GLCHECK(glDebugMessageCallbackFn(reinterpret_cast<GLDEBUGPROC>(messageCallback), userParam)); GLCHECK(glDebugMessageCallbackFn(reinterpret_cast<GLDEBUGPROC>(messageCallback), userParam));
} }
@@ -614,14 +536,14 @@ void GLFunctions::glDebugMessageCallback(TglDebugProc messageCallback, void * us
void GLFunctions::glDebugMessageControl(glConst source, glConst type, glConst severity, void GLFunctions::glDebugMessageControl(glConst source, glConst type, glConst severity,
int32_t count, uint32_t const * ids, uint8_t enabled) 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, ()); ASSERT(glDebugMessageControlFn != nullptr, ());
GLCHECK(glDebugMessageControlFn(source, type, severity, count, ids, enabled)); GLCHECK(glDebugMessageControlFn(source, type, severity, count, ids, enabled));
} }
uint32_t GLFunctions::glGenVertexArray() uint32_t GLFunctions::glGenVertexArray()
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glGenVertexArraysFn != nullptr, ()); ASSERT(glGenVertexArraysFn != nullptr, ());
GLuint result = std::numeric_limits<GLuint>::max(); GLuint result = std::numeric_limits<GLuint>::max();
GLCHECK(glGenVertexArraysFn(1, &result)); GLCHECK(glGenVertexArraysFn(1, &result));
@@ -630,21 +552,21 @@ uint32_t GLFunctions::glGenVertexArray()
void GLFunctions::glBindVertexArray(uint32_t vao) void GLFunctions::glBindVertexArray(uint32_t vao)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glBindVertexArrayFn != nullptr, ()); ASSERT(glBindVertexArrayFn != nullptr, ());
GLCHECK(glBindVertexArrayFn(vao)); GLCHECK(glBindVertexArrayFn(vao));
} }
void GLFunctions::glDeleteVertexArray(uint32_t vao) void GLFunctions::glDeleteVertexArray(uint32_t vao)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glDeleteVertexArrayFn != nullptr, ()); ASSERT(glDeleteVertexArrayFn != nullptr, ());
GLCHECK(glDeleteVertexArrayFn(1, &vao)); GLCHECK(glDeleteVertexArrayFn(1, &vao));
} }
uint32_t GLFunctions::glGenBuffer() uint32_t GLFunctions::glGenBuffer()
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glGenBuffersFn != nullptr, ()); ASSERT(glGenBuffersFn != nullptr, ());
GLuint result = std::numeric_limits<GLuint>::max(); GLuint result = std::numeric_limits<GLuint>::max();
GLCHECK(glGenBuffersFn(1, &result)); GLCHECK(glGenBuffersFn(1, &result));
@@ -653,7 +575,7 @@ uint32_t GLFunctions::glGenBuffer()
void GLFunctions::glBindBuffer(uint32_t vbo, uint32_t target) 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, ()); ASSERT(glBindBufferFn != nullptr, ());
#ifdef DEBUG #ifdef DEBUG
std::lock_guard<std::mutex> guard(g_boundBuffersMutex); std::lock_guard<std::mutex> guard(g_boundBuffersMutex);
@@ -664,7 +586,7 @@ void GLFunctions::glBindBuffer(uint32_t vbo, uint32_t target)
void GLFunctions::glDeleteBuffer(uint32_t vbo) void GLFunctions::glDeleteBuffer(uint32_t vbo)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glDeleteBuffersFn != nullptr, ()); ASSERT(glDeleteBuffersFn != nullptr, ());
#ifdef DEBUG #ifdef DEBUG
std::lock_guard<std::mutex> guard(g_boundBuffersMutex); std::lock_guard<std::mutex> 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) 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, ()); ASSERT(glBufferDataFn != nullptr, ());
GLCHECK(glBufferDataFn(target, size, data, usage)); GLCHECK(glBufferDataFn(target, size, data, usage));
} }
void GLFunctions::glBufferSubData(glConst target, uint32_t size, void const * data, uint32_t offset) 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, ()); ASSERT(glBufferSubDataFn != nullptr, ());
GLCHECK(glBufferSubDataFn(target, offset, size, data)); GLCHECK(glBufferSubDataFn(target, offset, size, data));
} }
void * GLFunctions::glMapBuffer(glConst target, glConst access) void * GLFunctions::glMapBuffer(glConst target, glConst access)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glMapBufferFn != nullptr, ()); ASSERT(glMapBufferFn != nullptr, ());
void * result = glMapBufferFn(target, access); void * result = glMapBufferFn(target, access);
GLCHECKCALL(); GLCHECKCALL();
@@ -699,7 +621,7 @@ void * GLFunctions::glMapBuffer(glConst target, glConst access)
void GLFunctions::glUnmapBuffer(glConst target) void GLFunctions::glUnmapBuffer(glConst target)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glUnmapBufferFn != nullptr, ()); ASSERT(glUnmapBufferFn != nullptr, ());
VERIFY(glUnmapBufferFn(target) == GL_TRUE, ()); VERIFY(glUnmapBufferFn(target) == GL_TRUE, ());
GLCHECKCALL(); GLCHECKCALL();
@@ -708,7 +630,7 @@ void GLFunctions::glUnmapBuffer(glConst target)
void * GLFunctions::glMapBufferRange(glConst target, uint32_t offset, uint32_t length, void * GLFunctions::glMapBufferRange(glConst target, uint32_t offset, uint32_t length,
glConst access) glConst access)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glMapBufferRangeFn != nullptr, ()); ASSERT(glMapBufferRangeFn != nullptr, ());
void * result = glMapBufferRangeFn(target, offset, length, access); void * result = glMapBufferRangeFn(target, offset, length, access);
GLCHECKCALL(); 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) 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, ()); ASSERT(glFlushMappedBufferRangeFn != nullptr, ());
GLCHECK(glFlushMappedBufferRangeFn(target, offset, length)); GLCHECK(glFlushMappedBufferRangeFn(target, offset, length));
} }
uint32_t GLFunctions::glCreateShader(glConst type) uint32_t GLFunctions::glCreateShader(glConst type)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glCreateShaderFn != nullptr, ()); ASSERT(glCreateShaderFn != nullptr, ());
GLuint result = glCreateShaderFn(type); GLuint result = glCreateShaderFn(type);
GLCHECKCALL(); 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) 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, ()); ASSERT(glShaderSourceFn != nullptr, ());
std::string fullSrc; 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) 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(glCompileShaderFn != nullptr, ());
ASSERT(glGetShaderivFn != nullptr, ()); ASSERT(glGetShaderivFn != nullptr, ());
ASSERT(glGetShaderInfoLogFn != nullptr, ()); ASSERT(glGetShaderInfoLogFn != nullptr, ());
@@ -776,14 +698,14 @@ bool GLFunctions::glCompileShader(uint32_t shaderID, std::string & errorLog)
void GLFunctions::glDeleteShader(uint32_t shaderID) void GLFunctions::glDeleteShader(uint32_t shaderID)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glDeleteShaderFn != nullptr, ()); ASSERT(glDeleteShaderFn != nullptr, ());
GLCHECK(glDeleteBuffersFn(1, &shaderID)); GLCHECK(glDeleteBuffersFn(1, &shaderID));
} }
uint32_t GLFunctions::glCreateProgram() uint32_t GLFunctions::glCreateProgram()
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glCreateProgramFn != nullptr, ()); ASSERT(glCreateProgramFn != nullptr, ());
GLuint result = glCreateProgramFn(); GLuint result = glCreateProgramFn();
GLCHECKCALL(); GLCHECKCALL();
@@ -792,21 +714,21 @@ uint32_t GLFunctions::glCreateProgram()
void GLFunctions::glAttachShader(uint32_t programID, uint32_t shaderID) 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, ()); ASSERT(glAttachShaderFn != nullptr, ());
GLCHECK(glAttachShaderFn(programID, shaderID)); GLCHECK(glAttachShaderFn(programID, shaderID));
} }
void GLFunctions::glDetachShader(uint32_t programID, uint32_t 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, ()); ASSERT(glDetachShaderFn != nullptr, ());
GLCHECK(glDetachShaderFn(programID, shaderID)); GLCHECK(glDetachShaderFn(programID, shaderID));
} }
bool GLFunctions::glLinkProgram(uint32_t programID, std::string & errorLog) 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(glLinkProgramFn != nullptr, ());
ASSERT(glGetProgramivFn != nullptr, ()); ASSERT(glGetProgramivFn != nullptr, ());
ASSERT(glGetProgramInfoLogFn != nullptr, ()); ASSERT(glGetProgramInfoLogFn != nullptr, ());
@@ -827,21 +749,21 @@ bool GLFunctions::glLinkProgram(uint32_t programID, std::string & errorLog)
void GLFunctions::glDeleteProgram(uint32_t programID) void GLFunctions::glDeleteProgram(uint32_t programID)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glDeleteProgramFn != nullptr, ()); ASSERT(glDeleteProgramFn != nullptr, ());
GLCHECK(glDeleteProgramFn(programID)); GLCHECK(glDeleteProgramFn(programID));
} }
void GLFunctions::glUseProgram(uint32_t programID) void GLFunctions::glUseProgram(uint32_t programID)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glUseProgramFn != nullptr, ()); ASSERT(glUseProgramFn != nullptr, ());
GLCHECK(glUseProgramFn(programID)); GLCHECK(glUseProgramFn(programID));
} }
int8_t GLFunctions::glGetAttribLocation(uint32_t programID, std::string const & name) 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, ()); ASSERT(glGetAttribLocationFn != nullptr, ());
int result = glGetAttribLocationFn(programID, name.c_str()); int result = glGetAttribLocationFn(programID, name.c_str());
GLCHECKCALL(); 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) 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, ()); ASSERT(glBindAttribLocationFn != nullptr, ());
GLCHECK(glBindAttribLocationFn(programID, index, name.c_str())); GLCHECK(glBindAttribLocationFn(programID, index, name.c_str()));
} }
void GLFunctions::glEnableVertexAttribute(int attributeLocation) void GLFunctions::glEnableVertexAttribute(int attributeLocation)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glEnableVertexAttributeFn != nullptr, ()); ASSERT(glEnableVertexAttributeFn != nullptr, ());
GLCHECK(glEnableVertexAttributeFn(attributeLocation)); GLCHECK(glEnableVertexAttributeFn(attributeLocation));
} }
@@ -866,7 +788,7 @@ void GLFunctions::glEnableVertexAttribute(int attributeLocation)
void GLFunctions::glVertexAttributePointer(int attrLocation, uint32_t count, glConst type, void GLFunctions::glVertexAttributePointer(int attrLocation, uint32_t count, glConst type,
bool needNormalize, uint32_t stride, uint32_t offset) bool needNormalize, uint32_t stride, uint32_t offset)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glVertexAttributePointerFn != nullptr, ()); ASSERT(glVertexAttributePointerFn != nullptr, ());
GLCHECK(glVertexAttributePointerFn(attrLocation, count, type, convert(needNormalize), stride, GLCHECK(glVertexAttributePointerFn(attrLocation, count, type, convert(needNormalize), stride,
reinterpret_cast<void *>(offset))); reinterpret_cast<void *>(offset)));
@@ -875,7 +797,7 @@ void GLFunctions::glVertexAttributePointer(int attrLocation, uint32_t count, glC
void GLFunctions::glGetActiveUniform(uint32_t programID, uint32_t uniformIndex, void GLFunctions::glGetActiveUniform(uint32_t programID, uint32_t uniformIndex,
int32_t * uniformSize, glConst * type, std::string & name) int32_t * uniformSize, glConst * type, std::string & name)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glGetActiveUniformFn != nullptr, ()); ASSERT(glGetActiveUniformFn != nullptr, ());
GLchar buff[256]; GLchar buff[256];
GLCHECK(glGetActiveUniformFn(programID, uniformIndex, ARRAY_SIZE(buff), nullptr, uniformSize, 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) 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, ()); ASSERT(glGetUniformLocationFn != nullptr, ());
int result = glGetUniformLocationFn(programID, name.c_str()); int result = glGetUniformLocationFn(programID, name.c_str());
GLCHECKCALL(); GLCHECKCALL();
@@ -895,7 +817,7 @@ int8_t GLFunctions::glGetUniformLocation(uint32_t programID, std::string const &
void GLFunctions::glUniformValuei(int8_t location, int32_t v) 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(glUniform1iFn != nullptr, ());
ASSERT(location != -1, ()); ASSERT(location != -1, ());
GLCHECK(glUniform1iFn(location, v)); 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) 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(glUniform2iFn != nullptr, ());
ASSERT(location != -1, ()); ASSERT(location != -1, ());
GLCHECK(glUniform2iFn(location, v1, v2)); 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) 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(glUniform3iFn != nullptr, ());
ASSERT(location != -1, ()); ASSERT(location != -1, ());
GLCHECK(glUniform3iFn(location, v1, v2, v3)); 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) 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(glUniform4iFn != nullptr, ());
ASSERT(location != -1, ()); ASSERT(location != -1, ());
GLCHECK(glUniform4iFn(location, v1, v2, v3, v4)); 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) 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(glUniform1ivFn != nullptr, ());
ASSERT(location != -1, ()); ASSERT(location != -1, ());
GLCHECK(glUniform1ivFn(location, size, v)); 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) 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(glUniform1fFn != nullptr, ());
ASSERT(location != -1, ()); ASSERT(location != -1, ());
GLCHECK(glUniform1fFn(location, v)); 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) 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(glUniform2fFn != nullptr, ());
ASSERT(location != -1, ()); ASSERT(location != -1, ());
GLCHECK(glUniform2fFn(location, v1, v2)); 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) 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(glUniform3fFn != nullptr, ());
ASSERT(location != -1, ()); ASSERT(location != -1, ());
GLCHECK(glUniform3fFn(location, v1, v2, v3)); 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) 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(glUniform4fFn != nullptr, ());
ASSERT(location != -1, ()); ASSERT(location != -1, ());
GLCHECK(glUniform4fFn(location, v1, v2, v3, v4)); 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) 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(glUniform1fvFn != nullptr, ());
ASSERT(location != -1, ()); ASSERT(location != -1, ());
GLCHECK(glUniform1fvFn(location, size, v)); 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) 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(glUniformMatrix4fvFn != nullptr, ());
ASSERT(location != -1, ()); ASSERT(location != -1, ());
GLCHECK(glUniformMatrix4fvFn(location, 1, GL_FALSE, values)); GLCHECK(glUniformMatrix4fvFn(location, 1, GL_FALSE, values));
@@ -983,7 +905,7 @@ void GLFunctions::glUniformMatrix4x4Value(int8_t location, float const * values)
uint32_t GLFunctions::glGetCurrentProgram() uint32_t GLFunctions::glGetCurrentProgram()
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLint programIndex = 0; GLint programIndex = 0;
GLCHECK(glGetIntegerv(GL_CURRENT_PROGRAM, &programIndex)); GLCHECK(glGetIntegerv(GL_CURRENT_PROGRAM, &programIndex));
ASSERT_GREATER_OR_EQUAL(programIndex, 0, ()); ASSERT_GREATER_OR_EQUAL(programIndex, 0, ());
@@ -992,7 +914,7 @@ uint32_t GLFunctions::glGetCurrentProgram()
int32_t GLFunctions::glGetProgramiv(uint32_t program, glConst paramName) 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, ()); ASSERT(glGetProgramivFn != nullptr, ());
GLint paramValue = 0; GLint paramValue = 0;
GLCHECK(glGetProgramivFn(program, paramName, &paramValue)); GLCHECK(glGetProgramivFn(program, paramName, &paramValue));
@@ -1001,14 +923,14 @@ int32_t GLFunctions::glGetProgramiv(uint32_t program, glConst paramName)
void GLFunctions::glActiveTexture(glConst texBlock) void GLFunctions::glActiveTexture(glConst texBlock)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glActiveTextureFn != nullptr, ()); ASSERT(glActiveTextureFn != nullptr, ());
GLCHECK(glActiveTextureFn(texBlock)); GLCHECK(glActiveTextureFn(texBlock));
} }
uint32_t GLFunctions::glGenTexture() uint32_t GLFunctions::glGenTexture()
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLuint result = std::numeric_limits<GLuint>::max(); GLuint result = std::numeric_limits<GLuint>::max();
GLCHECK(::glGenTextures(1, &result)); GLCHECK(::glGenTextures(1, &result));
return result; return result;
@@ -1016,20 +938,20 @@ uint32_t GLFunctions::glGenTexture()
void GLFunctions::glDeleteTexture(uint32_t id) void GLFunctions::glDeleteTexture(uint32_t id)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLCHECK(::glDeleteTextures(1, &id)); GLCHECK(::glDeleteTextures(1, &id));
} }
void GLFunctions::glBindTexture(uint32_t textureID) 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)); GLCHECK(::glBindTexture(GL_TEXTURE_2D, textureID));
} }
void GLFunctions::glTexImage2D(int width, int height, glConst layout, glConst pixelType, void GLFunctions::glTexImage2D(int width, int height, glConst layout, glConst pixelType,
void const * data) void const * data)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
// In OpenGL ES3: // In OpenGL ES3:
// - we can't create unsized GL_RED texture, so we use GL_R8; // - 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; // - 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, void GLFunctions::glTexSubImage2D(int x, int y, int width, int height, glConst layout,
glConst pixelType, void const * data) 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)); GLCHECK(::glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, layout, pixelType, data));
} }
void GLFunctions::glTexParameter(glConst param, glConst value) 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)); GLCHECK(::glTexParameteri(GL_TEXTURE_2D, param, value));
} }
void GLFunctions::glDrawElements(glConst primitive, uint32_t sizeOfIndex, uint32_t indexCount, void GLFunctions::glDrawElements(glConst primitive, uint32_t sizeOfIndex, uint32_t indexCount,
uint32_t startIndex) uint32_t startIndex)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLCHECK(::glDrawElements(primitive, indexCount, GLCHECK(::glDrawElements(primitive, indexCount,
sizeOfIndex == sizeof(uint32_t) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, sizeOfIndex == sizeof(uint32_t) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT,
reinterpret_cast<GLvoid *>(startIndex * sizeOfIndex))); reinterpret_cast<GLvoid *>(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) 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)); GLCHECK(::glDrawArrays(mode, first, count));
} }
void GLFunctions::glGenFramebuffer(uint32_t * fbo) void GLFunctions::glGenFramebuffer(uint32_t * fbo)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glGenFramebuffersFn != nullptr, ()); ASSERT(glGenFramebuffersFn != nullptr, ());
GLCHECK(glGenFramebuffersFn(1, fbo)); GLCHECK(glGenFramebuffersFn(1, fbo));
} }
void GLFunctions::glDeleteFramebuffer(uint32_t * fbo) void GLFunctions::glDeleteFramebuffer(uint32_t * fbo)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glDeleteFramebuffersFn != nullptr, ()); ASSERT(glDeleteFramebuffersFn != nullptr, ());
GLCHECK(glDeleteFramebuffersFn(1, fbo)); GLCHECK(glDeleteFramebuffersFn(1, fbo));
} }
void GLFunctions::glFramebufferTexture2D(glConst attachment, glConst texture) void GLFunctions::glFramebufferTexture2D(glConst attachment, glConst texture)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glFramebufferTexture2DFn != nullptr, ()); ASSERT(glFramebufferTexture2DFn != nullptr, ());
GLCHECK(glFramebufferTexture2DFn(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, texture, 0)); GLCHECK(glFramebufferTexture2DFn(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, texture, 0));
} }
void GLFunctions::glBindFramebuffer(uint32_t fbo) void GLFunctions::glBindFramebuffer(uint32_t fbo)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glBindFramebufferFn != nullptr, ()); ASSERT(glBindFramebufferFn != nullptr, ());
GLCHECK(glBindFramebufferFn(GL_FRAMEBUFFER, fbo)); GLCHECK(glBindFramebufferFn(GL_FRAMEBUFFER, fbo));
} }
uint32_t GLFunctions::glCheckFramebufferStatus() uint32_t GLFunctions::glCheckFramebufferStatus()
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
ASSERT(glCheckFramebufferStatusFn != nullptr, ()); ASSERT(glCheckFramebufferStatusFn != nullptr, ());
uint32_t const result = glCheckFramebufferStatusFn(GL_FRAMEBUFFER); uint32_t const result = glCheckFramebufferStatusFn(GL_FRAMEBUFFER);
GLCHECKCALL(); GLCHECKCALL();
@@ -1132,7 +1054,7 @@ uint32_t GLFunctions::glCheckFramebufferStatus()
void GLFunctions::glLineWidth(uint32_t value) void GLFunctions::glLineWidth(uint32_t value)
{ {
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLCHECK(::glLineWidth(static_cast<float>(value))); GLCHECK(::glLineWidth(static_cast<float>(value)));
} }
@@ -1153,7 +1075,7 @@ std::string GetGLError(GLenum error)
void CheckGLError(base::SrcPoint const & srcPoint) void CheckGLError(base::SrcPoint const & srcPoint)
{ {
ASSERT_NOT_EQUAL(GLFunctions::CurrentApiVersion, dp::ApiVersion::Invalid, ()); ASSERT_EQUAL(GLFunctions::CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
GLenum result = glGetError(); GLenum result = glGetError();
while (result != GL_NO_ERROR) while (result != GL_NO_ERROR)
{ {

View File

@@ -87,26 +87,17 @@ void * GPUBuffer::Map(uint32_t elementOffset, uint32_t elementCount)
m_isMapped = true; m_isMapped = true;
#endif #endif
if (GLFunctions::CurrentApiVersion == dp::ApiVersion::OpenGLES2) if (!IsMapBufferSupported())
{ {
m_mappingOffset = elementOffset; m_mappingOffset = elementOffset;
return IsMapBufferSupported() ? GLFunctions::glMapBuffer(glTarget(m_t)) : nullptr; return nullptr;
} }
else if (GLFunctions::CurrentApiVersion == dp::ApiVersion::OpenGLES3) m_mappingOffset = 0;
{ uint32_t const elementSize = GetElementSize();
if (!IsMapBufferSupported()) uint32_t const byteOffset = elementOffset * elementSize;
{ uint32_t const byteCount = elementCount * elementSize;
m_mappingOffset = elementOffset; return GLFunctions::glMapBufferRange(glTarget(m_t), byteOffset, byteCount,
return nullptr; gl_const::GLWriteBufferBit);
}
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;
} }
void GPUBuffer::UpdateData(void * gpuPtr, void const * data, uint32_t elementOffset, void GPUBuffer::UpdateData(void * gpuPtr, void const * data, uint32_t elementOffset,

View File

@@ -36,7 +36,7 @@ void UnpackFormat(ref_ptr<dp::GraphicsContext> context, TextureFormat format,
glConst & layout, glConst & pixelType) glConst & layout, glConst & pixelType)
{ {
auto const apiVersion = context->GetApiVersion(); auto const apiVersion = context->GetApiVersion();
CHECK(apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3, ()); CHECK(apiVersion == dp::ApiVersion::OpenGLES3, ());
switch (format) switch (format)
{ {
@@ -45,21 +45,17 @@ void UnpackFormat(ref_ptr<dp::GraphicsContext> context, TextureFormat format,
pixelType = gl_const::GL8BitOnChannel; pixelType = gl_const::GL8BitOnChannel;
return; return;
case TextureFormat::Alpha: case TextureFormat::Red:
// On OpenGL ES3 GLAlpha is not supported, we use GLRed instead. layout = gl_const::GLRed;
layout = apiVersion == dp::ApiVersion::OpenGLES2 ? gl_const::GLAlpha : gl_const::GLRed;
pixelType = gl_const::GL8BitOnChannel; pixelType = gl_const::GL8BitOnChannel;
return; return;
case TextureFormat::RedGreen: case TextureFormat::RedGreen:
// On OpenGL ES2 2-channel textures are not supported. layout = gl_const::GLRedGreen;
layout = (apiVersion == dp::ApiVersion::OpenGLES2) ? gl_const::GLRGBA : gl_const::GLRedGreen;
pixelType = gl_const::GL8BitOnChannel; pixelType = gl_const::GL8BitOnChannel;
return; return;
case TextureFormat::DepthStencil: case TextureFormat::DepthStencil:
// OpenGLES2 does not support texture-based depth-stencil.
CHECK(apiVersion != dp::ApiVersion::OpenGLES2, ());
layout = gl_const::GLDepthStencil; layout = gl_const::GLDepthStencil;
pixelType = gl_const::GLUnsignedInt24_8Type; pixelType = gl_const::GLUnsignedInt24_8Type;
return; return;

View File

@@ -61,7 +61,7 @@ CVPixelBufferRef HWTextureAllocatorApple::CVCreatePixelBuffer(uint32_t width, ui
cvRetval = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_32BGRA, cvRetval = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_32BGRA,
attrsRef, &result); attrsRef, &result);
break; break;
case dp::TextureFormat::Alpha: case dp::TextureFormat::Red:
cvRetval = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_OneComponent8, cvRetval = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_OneComponent8,
attrsRef, &result); attrsRef, &result);
break; break;

View File

@@ -56,7 +56,7 @@ void const * IndexStorage::GetRawConst() const
bool IndexStorage::IsSupported32bit() bool IndexStorage::IsSupported32bit()
{ {
// We do not use 32-bit indices now to reduce size of index buffers. // 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; return supports32Bit;
} }

View File

@@ -36,13 +36,8 @@ public:
{ {
UNUSED_VALUE(context); UNUSED_VALUE(context);
bool const isVAOSupported = m_VAO = GLFunctions::glGenVertexArray();
GLFunctions::ExtensionsList.IsSupported(dp::GLExtensionsList::VertexArrayObject); GLFunctions::glBindVertexArray(m_VAO);
if (isVAOSupported)
{
m_VAO = GLFunctions::glGenVertexArray();
GLFunctions::glBindVertexArray(m_VAO);
}
for (auto & buffer : m_mesh->m_buffers) for (auto & buffer : m_mesh->m_buffers)
{ {
@@ -64,23 +59,19 @@ public:
m_mesh->m_indices.data(), gl_const::GLStaticDraw); m_mesh->m_indices.data(), gl_const::GLStaticDraw);
} }
if (isVAOSupported) ref_ptr<dp::GLGpuProgram> p = program;
for (auto const & attribute : buffer->m_attributes)
{ {
ref_ptr<dp::GLGpuProgram> p = program; int8_t const attributePosition = p->GetAttributeLocation(attribute.m_attributeName);
for (auto const & attribute : buffer->m_attributes) ASSERT_NOT_EQUAL(attributePosition, -1, ());
{ GLFunctions::glEnableVertexAttribute(attributePosition);
int8_t const attributePosition = p->GetAttributeLocation(attribute.m_attributeName); GLFunctions::glVertexAttributePointer(attributePosition, attribute.m_componentsCount,
ASSERT_NOT_EQUAL(attributePosition, -1, ()); attribute.m_type, false, buffer->GetStrideInBytes(),
GLFunctions::glEnableVertexAttribute(attributePosition); attribute.m_offset);
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); GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer);
if (!m_mesh->m_indices.empty()) if (!m_mesh->m_indices.empty())
GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer); GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer);
@@ -134,34 +125,12 @@ public:
void Bind(ref_ptr<dp::GpuProgram> program) override void Bind(ref_ptr<dp::GpuProgram> program) override
{ {
if (GLFunctions::ExtensionsList.IsSupported(dp::GLExtensionsList::VertexArrayObject)) GLFunctions::glBindVertexArray(m_VAO);
{
GLFunctions::glBindVertexArray(m_VAO);
return;
}
ref_ptr<dp::GLGpuProgram> 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);
}
}
} }
void Unbind() override void Unbind() override
{ {
if (GLFunctions::ExtensionsList.IsSupported(dp::GLExtensionsList::VertexArrayObject)) GLFunctions::glBindVertexArray(0);
GLFunctions::glBindVertexArray(0);
GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer); GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer);
if (m_indexBuffer != 0) if (m_indexBuffer != 0)
GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer); GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer);
@@ -197,7 +166,7 @@ MeshObject::MeshObject(ref_ptr<dp::GraphicsContext> context, DrawPrimitive drawP
, m_debugName(debugName) , m_debugName(debugName)
{ {
auto const apiVersion = context->GetApiVersion(); auto const apiVersion = context->GetApiVersion();
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) if (apiVersion == dp::ApiVersion::OpenGLES3)
{ {
InitForOpenGL(); InitForOpenGL();
} }

View File

@@ -25,7 +25,7 @@ MTLPixelFormat UnpackFormat(TextureFormat format)
switch (format) switch (format)
{ {
case TextureFormat::RGBA8: return MTLPixelFormatRGBA8Unorm; 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::RedGreen: return MTLPixelFormatRG8Unorm;
case TextureFormat::DepthStencil: return MTLPixelFormatDepth32Float_Stencil8; case TextureFormat::DepthStencil: return MTLPixelFormatDepth32Float_Stencil8;
case TextureFormat::Depth: return MTLPixelFormatDepth32Float; case TextureFormat::Depth: return MTLPixelFormatDepth32Float;

View File

@@ -30,7 +30,7 @@ void AlphaBlendingState::Apply(ref_ptr<GraphicsContext> context)
{ {
// For Metal Rendering these settings must be set in the pipeline state. // For Metal Rendering these settings must be set in the pipeline state.
auto const apiVersion = context->GetApiVersion(); 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::glBlendEquation(gl_const::GLAddBlend);
GLFunctions::glBlendFunc(gl_const::GLSrcAlpha, gl_const::GLOneMinusSrcAlpha); GLFunctions::glBlendFunc(gl_const::GLSrcAlpha, gl_const::GLOneMinusSrcAlpha);
@@ -45,7 +45,7 @@ void Blending::Apply(ref_ptr<GraphicsContext> context, ref_ptr<GpuProgram> progr
{ {
// For Metal Rendering these settings must be set in the pipeline state. // For Metal Rendering these settings must be set in the pipeline state.
auto const apiVersion = context->GetApiVersion(); auto const apiVersion = context->GetApiVersion();
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) if (apiVersion == dp::ApiVersion::OpenGLES3)
{ {
if (m_isEnabled) if (m_isEnabled)
GLFunctions::glEnable(gl_const::GLBlending); GLFunctions::glEnable(gl_const::GLBlending);
@@ -216,7 +216,7 @@ void TextureState::ApplyTextures(ref_ptr<GraphicsContext> context, RenderState c
{ {
m_usedSlots = 0; m_usedSlots = 0;
auto const apiVersion = context->GetApiVersion(); auto const apiVersion = context->GetApiVersion();
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) if (apiVersion == dp::ApiVersion::OpenGLES3)
{ {
ref_ptr<dp::GLGpuProgram> p = program; ref_ptr<dp::GLGpuProgram> p = program;
for (auto const & texture : state.GetTextures()) for (auto const & texture : state.GetTextures())
@@ -324,7 +324,7 @@ void ApplyState(ref_ptr<GraphicsContext> context, ref_ptr<GpuProgram> program, R
if (state.GetDrawAsLine()) if (state.GetDrawAsLine())
{ {
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) if (apiVersion == dp::ApiVersion::OpenGLES3)
{ {
ASSERT_GREATER_OR_EQUAL(state.GetLineWidth(), 0, ()); ASSERT_GREATER_OR_EQUAL(state.GetLineWidth(), 0, ());
GLFunctions::glLineWidth(static_cast<uint32_t>(state.GetLineWidth())); GLFunctions::glLineWidth(static_cast<uint32_t>(state.GetLineWidth()));

View File

@@ -176,7 +176,7 @@ ref_ptr<Texture::ResourceInfo> StipplePenIndex::MapResource(StipplePenKey const
void StipplePenIndex::UploadResources(ref_ptr<dp::GraphicsContext> context, ref_ptr<Texture> texture) void StipplePenIndex::UploadResources(ref_ptr<dp::GraphicsContext> context, ref_ptr<Texture> texture)
{ {
ASSERT(texture->GetFormat() == dp::TextureFormat::Alpha, ()); ASSERT(texture->GetFormat() == dp::TextureFormat::Red, ());
TPendingNodes pendingNodes; TPendingNodes pendingNodes;
{ {
std::lock_guard<std::mutex> g(m_lock); std::lock_guard<std::mutex> g(m_lock);

View File

@@ -139,7 +139,7 @@ public:
StipplePenTexture(m2::PointU const & size, ref_ptr<HWTextureAllocator> allocator) StipplePenTexture(m2::PointU const & size, ref_ptr<HWTextureAllocator> allocator)
: m_index(size) : m_index(size)
{ {
TBase::DynamicTextureParams params{size, TextureFormat::Alpha, TextureFilter::Nearest, TBase::DynamicTextureParams params{size, TextureFormat::Red, TextureFilter::Nearest,
false /* m_usePixelBuffer */}; false /* m_usePixelBuffer */};
TBase::Init(allocator, make_ref(&m_index), params); TBase::Init(allocator, make_ref(&m_index), params);
} }

View File

@@ -56,7 +56,7 @@ void SupportManager::Init(ref_ptr<GraphicsContext> context)
LOG(LINFO, ("NVidia Tegra device detected.")); LOG(LINFO, ("NVidia Tegra device detected."));
auto const apiVersion = context->GetApiVersion(); auto const apiVersion = context->GetApiVersion();
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) if (apiVersion == dp::ApiVersion::OpenGLES3)
{ {
m_maxLineWidth = static_cast<float>(std::max(1, GLFunctions::glGetMaxLineWidth())); m_maxLineWidth = static_cast<float>(std::max(1, GLFunctions::glGetMaxLineWidth()));
m_maxTextureSize = static_cast<uint32_t>(GLFunctions::glGetInteger(gl_const::GLMaxTextureSize)); m_maxTextureSize = static_cast<uint32_t>(GLFunctions::glGetInteger(gl_const::GLMaxTextureSize));

View File

@@ -184,7 +184,7 @@ bool TextureManager::UpdateDynamicTextures(ref_ptr<dp::GraphicsContext> context)
if (m_nothingToUpload.test_and_set()) if (m_nothingToUpload.test_and_set())
{ {
auto const apiVersion = context->GetApiVersion(); 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. // For some reasons OpenGL can not update textures immediately.
// Here we use some timeout to prevent rendering frozening. // Here we use some timeout to prevent rendering frozening.
@@ -303,7 +303,7 @@ void TextureManager::Init(ref_ptr<dp::GraphicsContext> context, Params const & p
m_maxTextureSize = std::min(kMaxTextureSize, dp::SupportManager::Instance().GetMaxTextureSize()); m_maxTextureSize = std::min(kMaxTextureSize, dp::SupportManager::Instance().GetMaxTextureSize());
auto const apiVersion = context->GetApiVersion(); 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); GLFunctions::glPixelStore(gl_const::GLUnpackAlignment, 1);
// Initialize symbols. // Initialize symbols.
@@ -324,16 +324,13 @@ void TextureManager::Init(ref_ptr<dp::GraphicsContext> context, Params const & p
CreateArrowTexture(context, make_ref(m_textureAllocator), params.m_arrowTexturePath, CreateArrowTexture(context, make_ref(m_textureAllocator), params.m_arrowTexturePath,
params.m_arrowTextureUseDefaultResourceFolder); params.m_arrowTextureUseDefaultResourceFolder);
// SMAA is not supported on OpenGL ES2. // SMAA.
if (apiVersion != dp::ApiVersion::OpenGLES2) m_smaaAreaTexture =
{ make_unique_dp<StaticTexture>(context, "smaa-area.png", StaticTexture::kDefaultResource,
m_smaaAreaTexture = dp::TextureFormat::RedGreen, make_ref(m_textureAllocator));
make_unique_dp<StaticTexture>(context, "smaa-area.png", StaticTexture::kDefaultResource, m_smaaSearchTexture =
dp::TextureFormat::RedGreen, make_ref(m_textureAllocator)); make_unique_dp<StaticTexture>(context, "smaa-search.png", StaticTexture::kDefaultResource,
m_smaaSearchTexture = dp::TextureFormat::Red, make_ref(m_textureAllocator));
make_unique_dp<StaticTexture>(context, "smaa-search.png", StaticTexture::kDefaultResource,
dp::TextureFormat::Alpha, make_ref(m_textureAllocator));
}
// Initialize patterns (reserved ./data/patterns.txt lines count). // Initialize patterns (reserved ./data/patterns.txt lines count).
std::set<PenPatternT> patterns; std::set<PenPatternT> patterns;

View File

@@ -9,7 +9,7 @@ namespace dp
enum class TextureFormat : uint8_t enum class TextureFormat : uint8_t
{ {
RGBA8, RGBA8,
Alpha, Red,
RedGreen, RedGreen,
DepthStencil, DepthStencil,
Depth, Depth,
@@ -21,7 +21,7 @@ inline std::string DebugPrint(TextureFormat tf)
switch (tf) switch (tf)
{ {
case TextureFormat::RGBA8: return "RGBA8"; case TextureFormat::RGBA8: return "RGBA8";
case TextureFormat::Alpha: return "Alpha"; case TextureFormat::Red: return "Red";
case TextureFormat::RedGreen: return "RedGreen"; case TextureFormat::RedGreen: return "RedGreen";
case TextureFormat::DepthStencil: return "DepthStencil"; case TextureFormat::DepthStencil: return "DepthStencil";
case TextureFormat::Depth: return "Depth"; case TextureFormat::Depth: return "Depth";
@@ -50,7 +50,7 @@ inline uint8_t GetBytesPerPixel(TextureFormat format)
switch (format) switch (format)
{ {
case TextureFormat::RGBA8: result = 4; break; 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::RedGreen: result = 2; break;
case TextureFormat::DepthStencil: result = 4; break; case TextureFormat::DepthStencil: result = 4; break;
case TextureFormat::Depth: result = 4; break; case TextureFormat::Depth: result = 4; break;

View File

@@ -56,9 +56,6 @@ public:
return false; return false;
m_program = program; 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) if (m_VAO != 0)
GLFunctions::glDeleteVertexArray(m_VAO); GLFunctions::glDeleteVertexArray(m_VAO);
@@ -68,19 +65,14 @@ public:
bool Bind() override 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);
ASSERT(m_VAO != 0, ("You need to call Build method before bind it and render.")); return true;
GLFunctions::glBindVertexArray(m_VAO);
return true;
}
return false;
} }
void Unbind() override void Unbind() override
{ {
if (GLFunctions::ExtensionsList.IsSupported(GLExtensionsList::VertexArrayObject)) GLFunctions::glBindVertexArray(0);
GLFunctions::glBindVertexArray(0);
} }
void BindBuffers(BuffersMap const & buffers) const override void BindBuffers(BuffersMap const & buffers) const override
@@ -163,7 +155,7 @@ void VertexArrayBuffer::PreflushImpl(ref_ptr<GraphicsContext> context)
// Preflush can be called on BR, where impl is not initialized. // Preflush can be called on BR, where impl is not initialized.
// For Metal rendering this code has no meaning. // For Metal rendering this code has no meaning.
auto const apiVersion = context->GetApiVersion(); 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::GLElementArrayBuffer);
GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer); GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer);
@@ -208,7 +200,7 @@ void VertexArrayBuffer::Build(ref_ptr<GraphicsContext> context, ref_ptr<GpuProgr
if (!m_impl) if (!m_impl)
{ {
auto const apiVersion = context->GetApiVersion(); auto const apiVersion = context->GetApiVersion();
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) if (apiVersion == dp::ApiVersion::OpenGLES3)
{ {
m_impl = make_unique_dp<GLVertexArrayBufferImpl>(); m_impl = make_unique_dp<GLVertexArrayBufferImpl>();
} }

View File

@@ -162,7 +162,7 @@ VkFormat VulkanFormatUnpacker::Unpack(TextureFormat format)
switch (format) switch (format)
{ {
case TextureFormat::RGBA8: return VK_FORMAT_R8G8B8A8_UNORM; 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; case TextureFormat::RedGreen: return VK_FORMAT_R8G8_UNORM;
#if defined(OMIM_OS_MAC) #if defined(OMIM_OS_MAC)
case TextureFormat::DepthStencil: return VK_FORMAT_D32_SFLOAT_S8_UINT; case TextureFormat::DepthStencil: return VK_FORMAT_D32_SFLOAT_S8_UINT;

View File

@@ -308,7 +308,7 @@ Arrow3d::Arrow3d(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::TextureManage
// Workaround for OpenGL: some devices require any texture to be set in the rendering pipeline. // Workaround for OpenGL: some devices require any texture to be set in the rendering pipeline.
auto const apiVersion = context->GetApiVersion(); auto const apiVersion = context->GetApiVersion();
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) if (apiVersion == dp::ApiVersion::OpenGLES3)
m_state.SetColorTexture(texMng->GetSymbolsTexture()); m_state.SetColorTexture(texMng->GetSymbolsTexture());
m_isValid = preloadedData.m_meshData.has_value(); m_isValid = preloadedData.m_meshData.has_value();

View File

@@ -1424,7 +1424,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView, bool activeFram
RefreshBgColor(); RefreshBgColor();
uint32_t clearBits = dp::ClearBits::ColorBit | dp::ClearBits::DepthBit; 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; clearBits |= dp::ClearBits::StencilBit;
uint32_t storeBits = dp::ClearBits::ColorBit; uint32_t storeBits = dp::ClearBits::ColorBit;
@@ -1522,7 +1522,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView, bool activeFram
if (IsValidCurrentZoom()) if (IsValidCurrentZoom())
{ {
uint32_t clearBits = dp::ClearBits::DepthBit; 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; clearBits |= dp::ClearBits::StencilBit;
m_context->Clear(clearBits, dp::kClearBitsStoreAll); m_context->Clear(clearBits, dp::kClearBitsStoreAll);

View File

@@ -369,7 +369,6 @@ void LayerCacher::CacheScaleFpsLabel(ref_ptr<dp::GraphicsContext> context, Posit
std::string apiLabel; std::string apiLabel;
switch (apiVersion) switch (apiVersion)
{ {
case dp::ApiVersion::OpenGLES2: apiLabel = "GL2"; break;
case dp::ApiVersion::OpenGLES3: apiLabel = "GL3"; break; case dp::ApiVersion::OpenGLES3: apiLabel = "GL3"; break;
case dp::ApiVersion::Metal: apiLabel = "M"; break; case dp::ApiVersion::Metal: apiLabel = "M"; break;
case dp::ApiVersion::Vulkan: apiLabel = "V"; break; case dp::ApiVersion::Vulkan: apiLabel = "V"; break;

View File

@@ -203,10 +203,6 @@ bool PostprocessRenderer::IsEnabled() const
void PostprocessRenderer::SetEffectEnabled(ref_ptr<dp::GraphicsContext> context, void PostprocessRenderer::SetEffectEnabled(ref_ptr<dp::GraphicsContext> context,
Effect effect, bool enabled) 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 oldValue = m_effects;
auto const effectMask = static_cast<uint32_t>(effect); auto const effectMask = static_cast<uint32_t>(effect);
m_effects = (m_effects & ~effectMask) | (enabled ? effectMask : 0); m_effects = (m_effects & ~effectMask) | (enabled ? effectMask : 0);
@@ -238,7 +234,7 @@ bool PostprocessRenderer::CanRenderAntialiasing() const
return false; 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 && return m_staticTextures->m_smaaAreaTexture->GetID() != 0 &&
m_staticTextures->m_smaaSearchTexture->GetID() != 0; m_staticTextures->m_smaaSearchTexture->GetID() != 0;
@@ -289,7 +285,7 @@ bool PostprocessRenderer::EndFrame(ref_ptr<dp::GraphicsContext> context,
ASSERT(m_staticTextures->m_smaaAreaTexture != nullptr, ()); ASSERT(m_staticTextures->m_smaaAreaTexture != nullptr, ());
ASSERT(m_staticTextures->m_smaaSearchTexture != 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_smaaAreaTexture->GetID(), 0, ());
ASSERT_GREATER(m_staticTextures->m_smaaSearchTexture->GetID(), 0, ()); ASSERT_GREATER(m_staticTextures->m_smaaSearchTexture->GetID(), 0, ());
@@ -418,15 +414,12 @@ void PostprocessRenderer::UpdateFramebuffers(ref_ptr<dp::GraphicsContext> contex
ASSERT_NOT_EQUAL(height, 0, ()); ASSERT_NOT_EQUAL(height, 0, ());
CHECK_EQUAL(m_apiVersion, context->GetApiVersion(), ()); CHECK_EQUAL(m_apiVersion, context->GetApiVersion(), ());
InitFramebuffer(context, m_mainFramebuffer, width, height, true /* depthEnabled */, InitFramebuffer(context, m_mainFramebuffer, width, height, true /* depthEnabled */, true /* stencilEnabled */);
m_apiVersion != dp::ApiVersion::OpenGLES2 /* stencilEnabled */);
m_isMainFramebufferRendered = false; m_isMainFramebufferRendered = false;
m_isSmaaFramebufferRendered = false; m_isSmaaFramebufferRendered = false;
if (!m_isRouteFollowingActive && IsEffectEnabled(Effect::Antialiasing)) if (!m_isRouteFollowingActive && IsEffectEnabled(Effect::Antialiasing))
{ {
CHECK_NOT_EQUAL(m_apiVersion, dp::ApiVersion::OpenGLES2, ());
InitFramebuffer(context, m_edgesFramebuffer, dp::TextureFormat::RedGreen, InitFramebuffer(context, m_edgesFramebuffer, dp::TextureFormat::RedGreen,
m_mainFramebuffer->GetDepthStencilRef(), m_mainFramebuffer->GetDepthStencilRef(),
width, height); width, height);

View File

@@ -395,7 +395,7 @@ private:
public: public:
struct DrapeCreationParams struct DrapeCreationParams
{ {
dp::ApiVersion m_apiVersion = dp::ApiVersion::OpenGLES2; dp::ApiVersion m_apiVersion = dp::ApiVersion::OpenGLES3;
float m_visualScale = 1.0f; float m_visualScale = 1.0f;
int m_surfaceWidth = 0; int m_surfaceWidth = 0;
int m_surfaceHeight = 0; int m_surfaceHeight = 0;

View File

@@ -51,8 +51,7 @@ void RunTestLoop(char const * testName, testing::RenderFunction && fn, bool auto
app.exec(); app.exec();
} }
void RunTestInOpenGLOffscreenEnvironment(char const * testName, bool apiOpenGLES3, void RunTestInOpenGLOffscreenEnvironment(char const * testName, testing::TestFunction const & fn)
testing::TestFunction const & fn)
{ {
std::vector<char> buf(strlen(testName) + 1); std::vector<char> buf(strlen(testName) + 1);
strcpy(buf.data(), testName); strcpy(buf.data(), testName);
@@ -71,16 +70,8 @@ void RunTestInOpenGLOffscreenEnvironment(char const * testName, bool apiOpenGLES
fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer); fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
fmt.setSwapInterval(1); fmt.setSwapInterval(1);
fmt.setDepthBufferSize(16); fmt.setDepthBufferSize(16);
if (apiOpenGLES3) fmt.setProfile(QSurfaceFormat::CoreProfile);
{ fmt.setVersion(3, 2);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setVersion(3, 2);
}
else
{
fmt.setProfile(QSurfaceFormat::CompatibilityProfile);
fmt.setVersion(2, 1);
}
auto surface = std::make_unique<QOffscreenSurface>(); auto surface = std::make_unique<QOffscreenSurface>();
surface->setFormat(fmt); surface->setFormat(fmt);
@@ -92,7 +83,7 @@ void RunTestInOpenGLOffscreenEnvironment(char const * testName, bool apiOpenGLES
context->makeCurrent(surface.get()); context->makeCurrent(surface.get());
if (fn) if (fn)
fn(apiOpenGLES3); fn();
context->doneCurrent(); context->doneCurrent();
surface->destroy(); surface->destroy();

View File

@@ -6,9 +6,9 @@ class QPaintDevice;
namespace testing namespace testing
{ {
using RenderFunction = std::function<void (QPaintDevice *)>; using RenderFunction = std::function<void (QPaintDevice *)>;
using TestFunction = std::function<void (bool apiOpenGLES3)>; using TestFunction = std::function<void ()>;
} // namespace testing } // namespace testing
extern void RunTestLoop(char const * testName, testing::RenderFunction && fn, bool autoExit = true); 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);

View File

@@ -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("GLProgramInfo GetProgramInfo(dp::ApiVersion apiVersion, Program program)\n")
file.write("{\n") file.write("{\n")
file.write(" if (apiVersion == dp::ApiVersion::OpenGLES2)\n") file.write(" if (apiVersion == dp::ApiVersion::OpenGLES3)\n") # TODO: remove
file.write(" {\n")
file.write(" static std::array<GLProgramInfo, static_cast<size_t>(Program::ProgramsCount)> gpuIndex = {{\n")
write_gpu_programs_map(file, programs_def, '')
file.write(" }};\n")
file.write(" return gpuIndex[static_cast<size_t>(program)];\n")
file.write(" }\n")
file.write(" else if (apiVersion == dp::ApiVersion::OpenGLES3)\n")
file.write(" {\n") file.write(" {\n")
file.write(" static std::array<GLProgramInfo, static_cast<size_t>(Program::ProgramsCount)> gpuIndex = {{\n") file.write(" static std::array<GLProgramInfo, static_cast<size_t>(Program::ProgramsCount)> gpuIndex = {{\n")
write_gpu_programs_map(file, programs_def, GLES3_PREFIX) write_gpu_programs_map(file, programs_def, GLES3_PREFIX)

View File

@@ -19,7 +19,7 @@ void ProgramManager::Init(ref_ptr<dp::GraphicsContext> context)
{ {
CHECK_THREAD_CHECKER(m_threadChecker, ()); CHECK_THREAD_CHECKER(m_threadChecker, ());
auto const apiVersion = context->GetApiVersion(); auto const apiVersion = context->GetApiVersion();
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) if (apiVersion == dp::ApiVersion::OpenGLES3)
{ {
InitForOpenGL(context); InitForOpenGL(context);
} }

View File

@@ -15,9 +15,9 @@
using namespace std::placeholders; using namespace std::placeholders;
template <typename ProgramParams> template <typename ProgramParams>
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); TestingGraphicsContext context(api);
GLFunctions::Init(api); GLFunctions::Init(api);
gpu::GLProgramPool pool(api); gpu::GLProgramPool pool(api);
@@ -37,91 +37,61 @@ void TestProgramParams(bool apiOpenGLES3)
#ifdef OMIM_OS_MAC #ifdef OMIM_OS_MAC
UNIT_TEST(MapProgramParams_Test) UNIT_TEST(MapProgramParams_Test)
{ {
RunTestInOpenGLOffscreenEnvironment("MapProgramParams_Test", false /* apiOpenGLES3 */, RunTestInOpenGLOffscreenEnvironment("MapProgramParams_Test",
std::bind(&TestProgramParams<gpu::MapProgramParams>, _1)); std::bind(&TestProgramParams<gpu::MapProgramParams>));
RunTestInOpenGLOffscreenEnvironment("MapProgramParams_Test", true /* apiOpenGLES3 */,
std::bind(&TestProgramParams<gpu::MapProgramParams>, _1));
} }
UNIT_TEST(RouteProgramParams_Test) UNIT_TEST(RouteProgramParams_Test)
{ {
RunTestInOpenGLOffscreenEnvironment("RouteProgramParams_Test", false /* apiOpenGLES3 */, RunTestInOpenGLOffscreenEnvironment("RouteProgramParams_Test",
std::bind(&TestProgramParams<gpu::RouteProgramParams>, _1)); std::bind(&TestProgramParams<gpu::RouteProgramParams>));
RunTestInOpenGLOffscreenEnvironment("RouteProgramParams_Test", true /* apiOpenGLES3 */,
std::bind(&TestProgramParams<gpu::RouteProgramParams>, _1));
} }
UNIT_TEST(TrafficProgramParams_Test) UNIT_TEST(TrafficProgramParams_Test)
{ {
RunTestInOpenGLOffscreenEnvironment("TrafficProgramParams_Test", false /* apiOpenGLES3 */, RunTestInOpenGLOffscreenEnvironment("TrafficProgramParams_Test",
std::bind(&TestProgramParams<gpu::TrafficProgramParams>, _1)); std::bind(&TestProgramParams<gpu::TrafficProgramParams>));
RunTestInOpenGLOffscreenEnvironment("TrafficProgramParams_Test", true /* apiOpenGLES3 */,
std::bind(&TestProgramParams<gpu::TrafficProgramParams>, _1));
} }
UNIT_TEST(TransitProgramParams_Test) UNIT_TEST(TransitProgramParams_Test)
{ {
RunTestInOpenGLOffscreenEnvironment("TransitProgramParams_Test", false /* apiOpenGLES3 */, RunTestInOpenGLOffscreenEnvironment("TransitProgramParams_Test",
std::bind(&TestProgramParams<gpu::TransitProgramParams>, _1)); std::bind(&TestProgramParams<gpu::TransitProgramParams>));
RunTestInOpenGLOffscreenEnvironment("TransitProgramParams_Test", true /* apiOpenGLES3 */,
std::bind(&TestProgramParams<gpu::TransitProgramParams>, _1));
} }
UNIT_TEST(GuiProgramParams_Test) UNIT_TEST(GuiProgramParams_Test)
{ {
RunTestInOpenGLOffscreenEnvironment("GuiProgramParams_Test", false /* apiOpenGLES3 */, RunTestInOpenGLOffscreenEnvironment("GuiProgramParams_Test",
std::bind(&TestProgramParams<gpu::GuiProgramParams>, _1)); std::bind(&TestProgramParams<gpu::GuiProgramParams>));
RunTestInOpenGLOffscreenEnvironment("GuiProgramParams_Test", true /* apiOpenGLES3 */,
std::bind(&TestProgramParams<gpu::GuiProgramParams>, _1));
} }
UNIT_TEST(ShapesProgramParams_Test) UNIT_TEST(ShapesProgramParams_Test)
{ {
RunTestInOpenGLOffscreenEnvironment("ShapesProgramParams_Test", false /* apiOpenGLES3 */, RunTestInOpenGLOffscreenEnvironment("ShapesProgramParams_Test",
std::bind(&TestProgramParams<gpu::ShapesProgramParams>, _1)); std::bind(&TestProgramParams<gpu::ShapesProgramParams>));
RunTestInOpenGLOffscreenEnvironment("ShapesProgramParams_Test", true /* apiOpenGLES3 */,
std::bind(&TestProgramParams<gpu::ShapesProgramParams>, _1));
} }
UNIT_TEST(Arrow3dProgramParams_Test) UNIT_TEST(Arrow3dProgramParams_Test)
{ {
RunTestInOpenGLOffscreenEnvironment("Arrow3dProgramParams_Test", false /* apiOpenGLES3 */, RunTestInOpenGLOffscreenEnvironment("Arrow3dProgramParams_Test",
std::bind(&TestProgramParams<gpu::Arrow3dProgramParams>, _1)); std::bind(&TestProgramParams<gpu::Arrow3dProgramParams>));
RunTestInOpenGLOffscreenEnvironment("Arrow3dProgramParams_Test", true /* apiOpenGLES3 */,
std::bind(&TestProgramParams<gpu::Arrow3dProgramParams>, _1));
} }
UNIT_TEST(DebugRectProgramParams_Test) UNIT_TEST(DebugRectProgramParams_Test)
{ {
RunTestInOpenGLOffscreenEnvironment("DebugRectProgramParams_Test", false /* apiOpenGLES3 */, RunTestInOpenGLOffscreenEnvironment("DebugRectProgramParams_Test",
std::bind(&TestProgramParams<gpu::DebugRectProgramParams>, _1)); std::bind(&TestProgramParams<gpu::DebugRectProgramParams>));
RunTestInOpenGLOffscreenEnvironment("DebugRectProgramParams_Test", true /* apiOpenGLES3 */,
std::bind(&TestProgramParams<gpu::DebugRectProgramParams>, _1));
} }
UNIT_TEST(ScreenQuadProgramParams_Test) UNIT_TEST(ScreenQuadProgramParams_Test)
{ {
RunTestInOpenGLOffscreenEnvironment("ScreenQuadProgramParams_Test", false /* apiOpenGLES3 */, RunTestInOpenGLOffscreenEnvironment("ScreenQuadProgramParams_Test",
std::bind(&TestProgramParams<gpu::ScreenQuadProgramParams>, _1)); std::bind(&TestProgramParams<gpu::ScreenQuadProgramParams>));
RunTestInOpenGLOffscreenEnvironment("ScreenQuadProgramParams_Test", true /* apiOpenGLES3 */,
std::bind(&TestProgramParams<gpu::ScreenQuadProgramParams>, _1));
} }
UNIT_TEST(SMAAProgramParams_Test) UNIT_TEST(SMAAProgramParams_Test)
{ {
RunTestInOpenGLOffscreenEnvironment("SMAAProgramParams_Test", false /* apiOpenGLES3 */, RunTestInOpenGLOffscreenEnvironment("SMAAProgramParams_Test",
std::bind(&TestProgramParams<gpu::SMAAProgramParams>, _1)); std::bind(&TestProgramParams<gpu::SMAAProgramParams>));
RunTestInOpenGLOffscreenEnvironment("SMAAProgramParams_Test", true /* apiOpenGLES3 */,
std::bind(&TestProgramParams<gpu::SMAAProgramParams>, _1));
} }
#endif #endif

View File

@@ -10,9 +10,9 @@
using namespace std::placeholders; 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); GLFunctions::Init(api);
gpu::GLProgramPool pool(api); gpu::GLProgramPool pool(api);
if (enableVTF) 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. // These unit tests create Qt application and OGL context so can't be run in GUI-less Linux machine.
#ifdef OMIM_OS_MAC #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) UNIT_TEST(DesktopCompileShaders_GLES3_Test)
{ {
RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES3_Test", true /* apiOpenGLES3 */, RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES3_Test",
std::bind(&CompileShaders, _1, false /* enableVTF */)); 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) UNIT_TEST(DesktopCompileShaders_GLES3_VTF_Test)
{ {
RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES3_VTF_Test", true /* apiOpenGLES3 */, RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES3_VTF_Test",
std::bind(&CompileShaders, _1, true /* enableVTF */)); std::bind(&CompileShaders, true /* enableVTF */));
} }
#endif #endif

View File

@@ -26,9 +26,7 @@
std::string const kCompilersDir = "shaders_compiler"; std::string const kCompilersDir = "shaders_compiler";
#if defined(OMIM_OS_MAC) #if defined(OMIM_OS_MAC)
std::string const kMaliCompilerOpenGLES2Dir = "macos/mali_compiler";
std::string const kMaliCompilerOpenGLES3Dir = "macos/mali_compiler_es3"; std::string const kMaliCompilerOpenGLES3Dir = "macos/mali_compiler_es3";
std::string const kCompilerMaliOpenGLES2 = kMaliCompilerOpenGLES2Dir + "/malisc";
std::string const kCompilerMaliOpenGLES3 = kMaliCompilerOpenGLES3Dir + "/malisc"; std::string const kCompilerMaliOpenGLES3 = kMaliCompilerOpenGLES3Dir + "/malisc";
std::string const kCompilerOpenGLES = "macos/glslangValidator"; std::string const kCompilerOpenGLES = "macos/glslangValidator";
#elif defined(OMIM_OS_LINUX) #elif defined(OMIM_OS_LINUX)
@@ -166,29 +164,15 @@ UNIT_TEST(MobileCompileShaders_Test)
{ {
base::DelayedThreadPool workerThread(6 /* threadsCount */); base::DelayedThreadPool workerThread(6 /* threadsCount */);
workerThread.Push([] {
CompileShaders({dp::ApiVersion::OpenGLES2, GetCompilerPath(kCompilerOpenGLES)});
});
workerThread.Push([] { workerThread.Push([] {
CompileShaders({dp::ApiVersion::OpenGLES3, GetCompilerPath(kCompilerOpenGLES)}); CompileShaders({dp::ApiVersion::OpenGLES3, GetCompilerPath(kCompilerOpenGLES)});
}); });
workerThread.Push([] {
CompileShaders({dp::ApiVersion::OpenGLES2, GetCompilerPath(kCompilerOpenGLES)},
"#define ENABLE_VTF\n");
});
workerThread.Push([] { workerThread.Push([] {
CompileShaders({dp::ApiVersion::OpenGLES3, GetCompilerPath(kCompilerOpenGLES)}, CompileShaders({dp::ApiVersion::OpenGLES3, GetCompilerPath(kCompilerOpenGLES)},
"#define ENABLE_VTF\n"); "#define ENABLE_VTF\n");
}); });
workerThread.Push([] {
CompileShaders({dp::ApiVersion::OpenGLES2, GetCompilerPath(kCompilerOpenGLES)},
"#define SAMSUNG_GOOGLE_NEXUS\n");
});
workerThread.Push([] { workerThread.Push([] {
CompileShaders({dp::ApiVersion::OpenGLES3, GetCompilerPath(kCompilerOpenGLES)}, CompileShaders({dp::ApiVersion::OpenGLES3, GetCompilerPath(kCompilerOpenGLES)},
"#define SAMSUNG_GOOGLE_NEXUS\n"); "#define SAMSUNG_GOOGLE_NEXUS\n");
@@ -474,16 +458,6 @@ UNIT_TEST(MALI_MobileCompileShaders_Test)
driversES2new.insert(driversES2new.end(), driversES3new.begin(), driversES3new.end()); driversES2new.insert(driversES2new.end(), driversES3new.begin(), driversES3new.end());
std::vector<MaliCompilerData> const compilers = { std::vector<MaliCompilerData> 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, {dp::ApiVersion::OpenGLES3,
GetCompilerPath(kCompilerMaliOpenGLES3), GetCompilerPath(kCompilerMaliOpenGLES3),
GetCompilerPath(kMaliCompilerOpenGLES3Dir), GetCompilerPath(kMaliCompilerOpenGLES3Dir),

View File

@@ -107,7 +107,7 @@ void MapWidget::CreateEngine()
{ {
Framework::DrapeCreationParams p; 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<int>(m_ratio * width()); p.m_surfaceWidth = m_screenshotMode ? width() : static_cast<int>(m_ratio * width());
p.m_surfaceHeight = m_screenshotMode ? height() : static_cast<int>(m_ratio * height()); p.m_surfaceHeight = m_screenshotMode ? height() : static_cast<int>(m_ratio * height());
@@ -232,8 +232,6 @@ void MapWidget::Build()
{ {
std::string_view vertexSrc; std::string_view vertexSrc;
std::string_view fragmentSrc; std::string_view fragmentSrc;
if (m_apiOpenGLES3)
{
#if defined(OMIM_OS_LINUX) #if defined(OMIM_OS_LINUX)
vertexSrc = ":common/shaders/gles_300.vsh.glsl"; vertexSrc = ":common/shaders/gles_300.vsh.glsl";
fragmentSrc = ":common/shaders/gles_300.fsh.glsl"; fragmentSrc = ":common/shaders/gles_300.fsh.glsl";
@@ -241,12 +239,6 @@ void MapWidget::Build()
vertexSrc = ":common/shaders/gl_150.vsh.glsl"; vertexSrc = ":common/shaders/gl_150.vsh.glsl";
fragmentSrc = ":common/shaders/gl_150.fsh.glsl"; fragmentSrc = ":common/shaders/gl_150.fsh.glsl";
#endif #endif
}
else
{
vertexSrc = ":common/shaders/gles_200.vsh.glsl";
fragmentSrc = ":common/shaders/gles_200.fsh.glsl";
}
m_program = std::make_unique<QOpenGLShaderProgram>(this); m_program = std::make_unique<QOpenGLShaderProgram>(this);
m_program->addShaderFromSourceFile(QOpenGLShader::Vertex, vertexSrc.data()); m_program->addShaderFromSourceFile(QOpenGLShader::Vertex, vertexSrc.data());
@@ -348,8 +340,6 @@ void MapWidget::initializeGL()
if (!m_screenshotMode) if (!m_screenshotMode)
m_ratio = devicePixelRatio(); m_ratio = devicePixelRatio();
m_apiOpenGLES3 = true;
#if defined(OMIM_OS_LINUX) #if defined(OMIM_OS_LINUX)
{ {
QOpenGLFunctions * funcs = context()->functions(); QOpenGLFunctions * funcs = context()->functions();
@@ -367,29 +357,14 @@ void MapWidget::initializeGL()
auto fmt = context()->format(); auto fmt = context()->format();
if (context()->format().version() < qMakePair(3, 0)) if (context()->format().version() < qMakePair(3, 0))
{ {
LOG(LINFO, ("OpenGL ES version is below 3.0, taking the OpenGL ES 2.0 path")); CHECK(false, ("OpenGL ES2 is not supported"));
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);
} }
else else
{ {
LOG(LINFO, ("OpenGL version is at least 3.0, enabling GLSL '#version 300 es'")); LOG(LINFO, ("OpenGL version is at least 3.0, enabling GLSL '#version 300 es'"));
m_apiOpenGLES3 = true;
fmt.setVersion(3, 0); fmt.setVersion(3, 0);
} }
QSurfaceFormat::setDefaultFormat(fmt); QSurfaceFormat::setDefaultFormat(fmt);
} }
#endif #endif

View File

@@ -97,7 +97,6 @@ protected:
void wheelEvent(QWheelEvent * e) override; void wheelEvent(QWheelEvent * e) override;
Framework & m_framework; Framework & m_framework;
bool m_apiOpenGLES3;
bool m_screenshotMode; bool m_screenshotMode;
ScaleSlider * m_slider; ScaleSlider * m_slider;
SliderState m_sliderState; SliderState m_sliderState;

View File

@@ -16,8 +16,6 @@
<file>spinner12.png</file> <file>spinner12.png</file>
<file>shaders/gl_150.fsh.glsl</file> <file>shaders/gl_150.fsh.glsl</file>
<file>shaders/gl_150.vsh.glsl</file> <file>shaders/gl_150.vsh.glsl</file>
<file>shaders/gles_200.fsh.glsl</file>
<file>shaders/gles_200.vsh.glsl</file>
<file>shaders/gles_300.fsh.glsl</file> <file>shaders/gles_300.fsh.glsl</file>
<file>shaders/gles_300.vsh.glsl</file> <file>shaders/gles_300.vsh.glsl</file>
</qresource> </qresource>

View File

@@ -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);
}

View File

@@ -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);
}