[Drape] Remove GLES2-related code
Signed-off-by: renderexpert <expert@renderconsulting.co.uk>
This commit is contained in:
parent
855f678ddc
commit
10b6597eca
52 changed files with 238 additions and 624 deletions
|
@ -224,8 +224,7 @@ bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi
|
|||
LOG(LWARNING, ("Invalid GL context."));
|
||||
return false;
|
||||
}
|
||||
p.m_apiVersion = oglFactory->IsSupportedOpenGLES3() ? dp::ApiVersion::OpenGLES3 :
|
||||
dp::ApiVersion::OpenGLES2;
|
||||
p.m_apiVersion = dp::ApiVersion::OpenGLES3;
|
||||
p.m_surfaceWidth = oglFactory->GetWidth();
|
||||
p.m_surfaceHeight = oglFactory->GetHeight();
|
||||
|
||||
|
|
|
@ -8,20 +8,16 @@
|
|||
namespace android
|
||||
{
|
||||
|
||||
static EGLint * getContextAttributesList(bool supportedES3)
|
||||
static EGLint * getContextAttributesList()
|
||||
{
|
||||
static EGLint contextAttrList[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_NONE
|
||||
};
|
||||
static EGLint contextAttrListES3[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 3,
|
||||
EGL_NONE
|
||||
};
|
||||
return supportedES3 ? contextAttrListES3 : contextAttrList;
|
||||
return contextAttrList;
|
||||
}
|
||||
|
||||
AndroidOGLContext::AndroidOGLContext(bool supportedES3, EGLDisplay display, EGLSurface surface,
|
||||
AndroidOGLContext::AndroidOGLContext(EGLDisplay display, EGLSurface surface,
|
||||
EGLConfig config, AndroidOGLContext * contextToShareWith)
|
||||
: m_nativeContext(EGL_NO_CONTEXT)
|
||||
, m_surface(surface)
|
||||
|
@ -32,7 +28,7 @@ AndroidOGLContext::AndroidOGLContext(bool supportedES3, EGLDisplay display, EGLS
|
|||
ASSERT(m_display != EGL_NO_DISPLAY, ());
|
||||
|
||||
EGLContext sharedContext = (contextToShareWith == NULL) ? EGL_NO_CONTEXT : contextToShareWith->m_nativeContext;
|
||||
m_nativeContext = eglCreateContext(m_display, config, sharedContext, getContextAttributesList(supportedES3));
|
||||
m_nativeContext = eglCreateContext(m_display, config, sharedContext, getContextAttributesList());
|
||||
CHECK(m_nativeContext != EGL_NO_CONTEXT, ());
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace android
|
|||
class AndroidOGLContext : public dp::OGLContext
|
||||
{
|
||||
public:
|
||||
AndroidOGLContext(bool supportedES3, EGLDisplay display, EGLSurface surface,
|
||||
AndroidOGLContext(EGLDisplay display, EGLSurface surface,
|
||||
EGLConfig config, AndroidOGLContext * contextToShareWith);
|
||||
~AndroidOGLContext();
|
||||
|
||||
|
|
|
@ -16,26 +16,13 @@
|
|||
|
||||
#define EGL_OPENGL_ES3_BIT 0x00000040
|
||||
|
||||
int constexpr kMinSdkVersionForES3 = 21;
|
||||
|
||||
namespace android
|
||||
{
|
||||
namespace
|
||||
{
|
||||
static EGLint * getConfigAttributesListRGB8(bool supportedES3)
|
||||
static EGLint * getConfigAttributesListRGB8()
|
||||
{
|
||||
static EGLint attr_list[] = {
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 0,
|
||||
EGL_STENCIL_SIZE, 0,
|
||||
EGL_DEPTH_SIZE, 16,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_WINDOW_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
static EGLint attr_list_es3[] = {
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
|
@ -46,33 +33,16 @@ static EGLint * getConfigAttributesListRGB8(bool supportedES3)
|
|||
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_WINDOW_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
return supportedES3 ? attr_list_es3 : attr_list;
|
||||
return attr_list;
|
||||
}
|
||||
|
||||
int const kMaxConfigCount = 40;
|
||||
|
||||
static EGLint * getConfigAttributesListR5G6B5()
|
||||
{
|
||||
// We do not support OpenGL ES3 for R5G6B5, because some Android devices
|
||||
// are not able to create OpenGL context in such mode.
|
||||
static EGLint attr_list[] = {
|
||||
EGL_RED_SIZE, 5,
|
||||
EGL_GREEN_SIZE, 6,
|
||||
EGL_BLUE_SIZE, 5,
|
||||
EGL_STENCIL_SIZE, 0,
|
||||
EGL_DEPTH_SIZE, 16,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT | EGL_WINDOW_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
return attr_list;
|
||||
}
|
||||
|
||||
bool IsSupportedRGB8(EGLDisplay display, bool es3)
|
||||
bool IsSupportedRGB8(EGLDisplay display)
|
||||
{
|
||||
EGLConfig configs[kMaxConfigCount];
|
||||
int count = 0;
|
||||
return eglChooseConfig(display, getConfigAttributesListRGB8(es3), configs,
|
||||
return eglChooseConfig(display, getConfigAttributesListRGB8(), configs,
|
||||
kMaxConfigCount, &count) == EGL_TRUE && count != 0;
|
||||
}
|
||||
|
||||
|
@ -90,7 +60,6 @@ AndroidOGLContextFactory::AndroidOGLContextFactory(JNIEnv * env, jobject jsurfac
|
|||
, m_surfaceWidth(0)
|
||||
, m_surfaceHeight(0)
|
||||
, m_windowSurfaceValid(false)
|
||||
, m_supportedES3(false)
|
||||
{
|
||||
m_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if (m_display == EGL_NO_DISPLAY)
|
||||
|
@ -106,10 +75,7 @@ AndroidOGLContextFactory::AndroidOGLContextFactory(JNIEnv * env, jobject jsurfac
|
|||
return;
|
||||
}
|
||||
|
||||
// Check ES3 availability.
|
||||
bool const isES3Supported = IsSupportedRGB8(m_display, true /* es3 */) &&
|
||||
android_get_device_api_level() >= kMinSdkVersionForES3;
|
||||
m_supportedES3 = isES3Supported && gl3stubInit();
|
||||
CHECK(gl3stubInit(), ("Could not initialize OpenGL ES3"));
|
||||
|
||||
SetSurface(env, jsurface);
|
||||
|
||||
|
@ -266,7 +232,7 @@ dp::GraphicsContext * AndroidOGLContextFactory::GetDrawContext()
|
|||
ASSERT(m_windowSurface != EGL_NO_SURFACE, ());
|
||||
if (m_drawContext == nullptr)
|
||||
{
|
||||
m_drawContext = new AndroidOGLContext(m_supportedES3, m_display, m_windowSurface,
|
||||
m_drawContext = new AndroidOGLContext(m_display, m_windowSurface,
|
||||
m_config, m_uploadContext);
|
||||
}
|
||||
return m_drawContext;
|
||||
|
@ -278,7 +244,7 @@ dp::GraphicsContext * AndroidOGLContextFactory::GetResourcesUploadContext()
|
|||
ASSERT(m_pixelbufferSurface != EGL_NO_SURFACE, ());
|
||||
if (m_uploadContext == nullptr)
|
||||
{
|
||||
m_uploadContext = new AndroidOGLContext(m_supportedES3, m_display, m_pixelbufferSurface,
|
||||
m_uploadContext = new AndroidOGLContext(m_display, m_pixelbufferSurface,
|
||||
m_config, m_drawContext);
|
||||
}
|
||||
return m_uploadContext;
|
||||
|
@ -322,17 +288,15 @@ bool AndroidOGLContextFactory::CreateWindowSurface()
|
|||
{
|
||||
EGLConfig configs[kMaxConfigCount];
|
||||
int count = 0;
|
||||
if (eglChooseConfig(m_display, getConfigAttributesListRGB8(m_supportedES3), configs,
|
||||
kMaxConfigCount, &count) != EGL_TRUE)
|
||||
if (eglChooseConfig(m_display, getConfigAttributesListRGB8(), configs,
|
||||
kMaxConfigCount, &count) == EGL_TRUE)
|
||||
{
|
||||
ASSERT(!m_supportedES3, ());
|
||||
VERIFY(eglChooseConfig(m_display, getConfigAttributesListR5G6B5(), configs,
|
||||
kMaxConfigCount, &count) == EGL_TRUE, ());
|
||||
LOG(LDEBUG, ("Backbuffer format: R5G6B5"));
|
||||
CHECK(IsSupportedRGB8(m_display), ("RGB8 is not suported on this device"));
|
||||
LOG(LDEBUG, ("Backbuffer format: RGB8"));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(LDEBUG, ("Backbuffer format: RGB8"));
|
||||
CHECK(false, ("OpenGL ES3 is not supported"));
|
||||
}
|
||||
ASSERT(count > 0, ("Didn't find any configs."));
|
||||
|
||||
|
|
|
@ -33,8 +33,6 @@ public:
|
|||
int GetHeight() const;
|
||||
void UpdateSurfaceSize(int w, int h);
|
||||
|
||||
bool IsSupportedOpenGLES3() const { return m_supportedES3; }
|
||||
|
||||
private:
|
||||
bool QuerySurfaceSize();
|
||||
|
||||
|
@ -56,7 +54,6 @@ private:
|
|||
int m_surfaceHeight;
|
||||
|
||||
bool m_windowSurfaceValid;
|
||||
bool m_supportedES3;
|
||||
|
||||
bool m_isInitialized = false;
|
||||
size_t m_initializationCounter = 0;
|
||||
|
|
|
@ -21,7 +21,7 @@ void DataBuffer::MoveToGPU(ref_ptr<GraphicsContext> context, GPUBuffer::Target t
|
|||
uint32_t const currentSize = m_impl->GetCurrentSize();
|
||||
|
||||
auto const apiVersion = context->GetApiVersion();
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
if (currentSize != 0)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,6 @@ namespace dp
|
|||
enum class ApiVersion
|
||||
{
|
||||
Invalid = -1,
|
||||
OpenGLES2 = 0,
|
||||
OpenGLES3,
|
||||
Metal,
|
||||
Vulkan
|
||||
|
@ -101,7 +100,6 @@ inline std::string DebugPrint(dp::ApiVersion apiVersion)
|
|||
switch (apiVersion)
|
||||
{
|
||||
case dp::ApiVersion::Invalid: return "Invalid";
|
||||
case dp::ApiVersion::OpenGLES2: return "OpenGLES2";
|
||||
case dp::ApiVersion::OpenGLES3: return "OpenGLES3";
|
||||
case dp::ApiVersion::Metal: return "Metal";
|
||||
case dp::ApiVersion::Vulkan: return "Vulkan";
|
||||
|
@ -121,9 +119,6 @@ inline dp::ApiVersion ApiVersionFromString(std::string const & str)
|
|||
return dp::ApiVersion::Vulkan;
|
||||
#endif
|
||||
|
||||
if (str == "OpenGLES2")
|
||||
return dp::ApiVersion::OpenGLES2;
|
||||
|
||||
if (str == "OpenGLES3")
|
||||
return dp::ApiVersion::OpenGLES3;
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ UNIT_TEST(UploadingGlyphs)
|
|||
TestingGraphicsContext context;
|
||||
Texture::Params p;
|
||||
p.m_allocator = GetDefaultAllocator(make_ref(&context));
|
||||
p.m_format = dp::TextureFormat::Alpha;
|
||||
p.m_format = dp::TextureFormat::Red;
|
||||
p.m_width = p.m_height = kTextureSize;
|
||||
|
||||
DummyTexture tex;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "drape/graphics_context.hpp"
|
||||
|
||||
// Testing context simulates OpenGLES2 API version.
|
||||
// Testing context simulates OpenGLES3 API version.
|
||||
class TestingGraphicsContext : public dp::GraphicsContext
|
||||
{
|
||||
public:
|
||||
|
@ -38,5 +38,5 @@ public:
|
|||
void SetCullingEnabled(bool enabled) override {}
|
||||
|
||||
private:
|
||||
dp::ApiVersion m_apiVersion = dp::ApiVersion::OpenGLES2;
|
||||
dp::ApiVersion m_apiVersion = dp::ApiVersion::OpenGLES3;
|
||||
};
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
FontTexture(m2::PointU const & size, ref_ptr<GlyphManager> glyphMng, ref_ptr<HWTextureAllocator> allocator)
|
||||
: m_index(size, glyphMng)
|
||||
{
|
||||
DynamicTextureParams const params{size, TextureFormat::Alpha, TextureFilter::Linear, true /* m_usePixelBuffer */};
|
||||
DynamicTextureParams const params{size, TextureFormat::Red, TextureFilter::Linear, true /* m_usePixelBuffer */};
|
||||
Init(allocator, make_ref(&m_index), params);
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ void Framebuffer::SetSize(ref_ptr<dp::GraphicsContext> context, uint32_t width,
|
|||
m_depthStencilRef->SetSize(context, m_width, m_height);
|
||||
|
||||
auto const apiVersion = context->GetApiVersion();
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
glConst depthAttachmentId = 0;
|
||||
glConst stencilAttachmentId = 0;
|
||||
|
|
|
@ -7,67 +7,14 @@
|
|||
|
||||
namespace dp
|
||||
{
|
||||
void GLExtensionsList::Init(dp::ApiVersion apiVersion)
|
||||
void GLExtensionsList::Init()
|
||||
{
|
||||
#if defined(OMIM_OS_MOBILE)
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES2)
|
||||
{
|
||||
#ifdef OMIM_OS_ANDROID
|
||||
SetExtension(VertexArrayObject, false);
|
||||
// On some Android devices glMapBufferRange/glMapBuffer works very slow.
|
||||
// We have to substitute these functions to glBufferData/glBufferSubData.
|
||||
SetExtension(MapBuffer, false);
|
||||
SetExtension(MapBufferRange, false);
|
||||
#else
|
||||
CheckExtension(VertexArrayObject, "GL_OES_vertex_array_object");
|
||||
CheckExtension(MapBuffer, "GL_OES_mapbuffer");
|
||||
CheckExtension(MapBufferRange, "GL_EXT_map_buffer_range");
|
||||
#endif
|
||||
CheckExtension(UintIndices, "GL_OES_element_index_uint");
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef OMIM_OS_ANDROID
|
||||
SetExtension(MapBuffer, false);
|
||||
SetExtension(MapBufferRange, false);
|
||||
#else
|
||||
SetExtension(MapBuffer, true);
|
||||
SetExtension(MapBufferRange, true);
|
||||
#endif
|
||||
SetExtension(VertexArrayObject, true);
|
||||
SetExtension(UintIndices, true);
|
||||
}
|
||||
#elif defined(OMIM_OS_LINUX)
|
||||
SetExtension(MapBuffer, true);
|
||||
SetExtension(UintIndices, true);
|
||||
SetExtension(VertexArrayObject, true);
|
||||
SetExtension(MapBufferRange, true);
|
||||
#elif defined(OMIM_OS_WINDOWS)
|
||||
SetExtension(MapBuffer, true);
|
||||
SetExtension(UintIndices, true);
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES2)
|
||||
{
|
||||
SetExtension(VertexArrayObject, false);
|
||||
SetExtension(MapBufferRange, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetExtension(VertexArrayObject, true);
|
||||
SetExtension(MapBufferRange, true);
|
||||
}
|
||||
// NOTE: MapBuffer/MapBufferRange are disabled by performance reasons according to
|
||||
// https://github.com/organicmaps/organicmaps/commit/d72ab7c8cd8be0eb5a622d9d33ae943b391d5707
|
||||
SetExtension(MapBuffer, false);
|
||||
#else
|
||||
SetExtension(MapBuffer, true);
|
||||
SetExtension(UintIndices, true);
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES2)
|
||||
{
|
||||
CheckExtension(VertexArrayObject, "GL_APPLE_vertex_array_object");
|
||||
SetExtension(MapBufferRange, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetExtension(VertexArrayObject, true);
|
||||
SetExtension(MapBufferRange, true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -14,14 +14,11 @@ class GLExtensionsList
|
|||
public:
|
||||
enum ExtensionName
|
||||
{
|
||||
VertexArrayObject,
|
||||
MapBuffer,
|
||||
UintIndices,
|
||||
MapBufferRange
|
||||
};
|
||||
|
||||
GLExtensionsList() = default;
|
||||
void Init(dp::ApiVersion apiVersion);
|
||||
void Init();
|
||||
bool IsSupported(ExtensionName extName) const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -239,81 +239,26 @@ void GLFunctions::Init(dp::ApiVersion apiVersion)
|
|||
return;
|
||||
|
||||
CurrentApiVersion = apiVersion;
|
||||
ExtensionsList.Init(apiVersion);
|
||||
ExtensionsList.Init();
|
||||
s_inited = true;
|
||||
|
||||
/// VAO
|
||||
#if !defined(OMIM_OS_WINDOWS)
|
||||
if (CurrentApiVersion == dp::ApiVersion::OpenGLES2)
|
||||
{
|
||||
#if defined(OMIM_OS_MAC)
|
||||
|
||||
glGenVertexArraysFn = &glGenVertexArraysAPPLE;
|
||||
glBindVertexArrayFn = &glBindVertexArrayAPPLE;
|
||||
glDeleteVertexArrayFn = &glDeleteVertexArraysAPPLE;
|
||||
glMapBufferFn = &::glMapBuffer;
|
||||
glUnmapBufferFn = &::glUnmapBuffer;
|
||||
|
||||
#elif defined(OMIM_OS_LINUX)
|
||||
void *libhandle = dlopen("libGL.so.1", RTLD_LAZY);
|
||||
if (!libhandle)
|
||||
LOG(LCRITICAL, ("Failed to open libGL.so.1:", dlerror()));
|
||||
glGenVertexArraysFn = (TglGenVertexArraysFn)dlsym(libhandle,"glGenVertexArraysOES");
|
||||
glBindVertexArrayFn = (TglBindVertexArrayFn)dlsym(libhandle, "glBindVertexArrayOES");
|
||||
glDeleteVertexArrayFn = (TglDeleteVertexArrayFn)dlsym(libhandle,"glDeleteVertexArraysOES");
|
||||
glMapBufferFn = (TglMapBufferFn)dlsym(libhandle, "glMapBufferOES");
|
||||
glUnmapBufferFn = (TglUnmapBufferFn)dlsym(libhandle, "glUnmapBufferOES");
|
||||
glMapBufferRangeFn = (TglMapBufferRangeFn)dlsym(libhandle, "glMapBufferRangeEXT");
|
||||
glFlushMappedBufferRangeFn =
|
||||
(TglFlushMappedBufferRangeFn)dlsym(libhandle, "glFlushMappedBufferRangeEXT");
|
||||
|
||||
#elif defined(OMIM_OS_ANDROID)
|
||||
|
||||
glGenVertexArraysFn = (TglGenVertexArraysFn)eglGetProcAddress("glGenVertexArraysOES");
|
||||
glBindVertexArrayFn = (TglBindVertexArrayFn)eglGetProcAddress("glBindVertexArrayOES");
|
||||
glDeleteVertexArrayFn = (TglDeleteVertexArrayFn)eglGetProcAddress("glDeleteVertexArraysOES");
|
||||
glMapBufferFn = &::glMapBufferOES;
|
||||
glUnmapBufferFn = &::glUnmapBufferOES;
|
||||
glMapBufferRangeFn = (TglMapBufferRangeFn)eglGetProcAddress("glMapBufferRangeEXT");
|
||||
glFlushMappedBufferRangeFn =
|
||||
(TglFlushMappedBufferRangeFn)eglGetProcAddress("glFlushMappedBufferRangeEXT");
|
||||
|
||||
#elif defined(OMIM_OS_MOBILE)
|
||||
|
||||
glGenVertexArraysFn = &glGenVertexArraysOES;
|
||||
glBindVertexArrayFn = &glBindVertexArrayOES;
|
||||
glDeleteVertexArrayFn = &glDeleteVertexArraysOES;
|
||||
glMapBufferFn = &::glMapBufferOES;
|
||||
glUnmapBufferFn = &::glUnmapBufferOES;
|
||||
glMapBufferRangeFn = &::glMapBufferRangeEXT;
|
||||
glFlushMappedBufferRangeFn = &::glFlushMappedBufferRangeEXT;
|
||||
#endif // #if defined(OMIM_OS_MAC)
|
||||
}
|
||||
else if (CurrentApiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
// OpenGL ES3 api is the same for all systems, except WINDOWS.
|
||||
glGenVertexArraysFn = ::glGenVertexArrays;
|
||||
glBindVertexArrayFn = ::glBindVertexArray;
|
||||
glDeleteVertexArrayFn = ::glDeleteVertexArrays;
|
||||
glUnmapBufferFn = ::glUnmapBuffer;
|
||||
glMapBufferRangeFn = ::glMapBufferRange;
|
||||
glFlushMappedBufferRangeFn = ::glFlushMappedBufferRange;
|
||||
glGetStringiFn = ::glGetStringi;
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECK(false, ("Unknown Graphics API"));
|
||||
}
|
||||
|
||||
// OpenGL ES3 api is the same for all systems, except WINDOWS.
|
||||
glGenVertexArraysFn = ::glGenVertexArrays;
|
||||
glBindVertexArrayFn = ::glBindVertexArray;
|
||||
glDeleteVertexArrayFn = ::glDeleteVertexArrays;
|
||||
glUnmapBufferFn = ::glUnmapBuffer;
|
||||
glMapBufferRangeFn = ::glMapBufferRange;
|
||||
glFlushMappedBufferRangeFn = ::glFlushMappedBufferRange;
|
||||
glGetStringiFn = ::glGetStringi;
|
||||
#else // OMIM_OS_WINDOWS
|
||||
if (ExtensionsList.IsSupported(dp::GLExtensionsList::VertexArrayObject))
|
||||
{
|
||||
glGenVertexArraysFn = LOAD_GL_FUNC(TglGenVertexArraysFn, glGenVertexArrays);
|
||||
glBindVertexArrayFn = LOAD_GL_FUNC(TglBindVertexArrayFn, glBindVertexArray);
|
||||
glDeleteVertexArrayFn = LOAD_GL_FUNC(TglDeleteVertexArrayFn, glDeleteVertexArrays);
|
||||
}
|
||||
glMapBufferFn = LOAD_GL_FUNC(TglMapBufferFn, glMapBuffer);
|
||||
glGenVertexArraysFn = LOAD_GL_FUNC(TglGenVertexArraysFn, glGenVertexArrays);
|
||||
glBindVertexArrayFn = LOAD_GL_FUNC(TglBindVertexArrayFn, glBindVertexArray);
|
||||
glDeleteVertexArrayFn = LOAD_GL_FUNC(TglDeleteVertexArrayFn, glDeleteVertexArrays);
|
||||
glUnmapBufferFn = LOAD_GL_FUNC(TglUnmapBufferFn, glUnmapBuffer);
|
||||
glMapBufferFn = LOAD_GL_FUNC(TglMapBufferFn, glMapBuffer);
|
||||
glFlushMappedBufferRangeFn = LOAD_GL_FUNC(TglFlushMappedBufferRangeFn, glFlushMappedBufferRange);
|
||||
glGetStringiFn = LOAD_GL_FUNC(TglGetStringiFn, glGetStringi);
|
||||
#endif
|
||||
|
||||
glClearColorFn = LOAD_GL_FUNC(TglClearColorFn, glClearColor);
|
||||
|
@ -393,115 +338,94 @@ void GLFunctions::Init(dp::ApiVersion apiVersion)
|
|||
|
||||
bool GLFunctions::glHasExtension(std::string const & name)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
if (CurrentApiVersion == dp::ApiVersion::OpenGLES2)
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGetStringiFn != nullptr, ());
|
||||
GLint n = 0;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
||||
for (GLint i = 0; i < n; i++)
|
||||
{
|
||||
char const * extensions = reinterpret_cast<char const *>(::glGetString(GL_EXTENSIONS));
|
||||
GLCHECKCALL();
|
||||
if (extensions == nullptr)
|
||||
return false;
|
||||
|
||||
char const * extName = name.c_str();
|
||||
char const * ptr = nullptr;
|
||||
while ((ptr = strstr(extensions, extName)) != nullptr)
|
||||
{
|
||||
char const * end = ptr + strlen(extName);
|
||||
if (isspace(*end) || *end == '\0')
|
||||
return true;
|
||||
|
||||
extensions = end;
|
||||
}
|
||||
}
|
||||
else if (CurrentApiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
ASSERT(glGetStringiFn != nullptr, ());
|
||||
GLint n = 0;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
||||
for (GLint i = 0; i < n; i++)
|
||||
{
|
||||
std::string const extension =
|
||||
std::string(reinterpret_cast<char const *>(glGetStringiFn(GL_EXTENSIONS, i)));
|
||||
if (extension == name)
|
||||
return true;
|
||||
}
|
||||
std::string const extension =
|
||||
std::string(reinterpret_cast<char const *>(glGetStringiFn(GL_EXTENSIONS, i)));
|
||||
if (extension == name)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GLFunctions::glClearColor(float r, float g, float b, float a)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glClearColorFn != nullptr, ());
|
||||
GLCHECK(glClearColorFn(r, g, b, a));
|
||||
}
|
||||
|
||||
void GLFunctions::glClear(uint32_t clearBits)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glClearFn != nullptr, ());
|
||||
GLCHECK(glClearFn(clearBits));
|
||||
}
|
||||
|
||||
void GLFunctions::glViewport(uint32_t x, uint32_t y, uint32_t w, uint32_t h)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glViewportFn != nullptr, ());
|
||||
GLCHECK(glViewportFn(x, y, w, h));
|
||||
}
|
||||
|
||||
void GLFunctions::glScissor(uint32_t x, uint32_t y, uint32_t w, uint32_t h)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glScissorFn != nullptr, ());
|
||||
GLCHECK(glScissorFn(x, y, w, h));
|
||||
}
|
||||
|
||||
void GLFunctions::glFlush()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glFlushFn != nullptr, ());
|
||||
GLCHECK(glFlushFn());
|
||||
}
|
||||
|
||||
void GLFunctions::glFinish()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glFinish());
|
||||
}
|
||||
|
||||
void GLFunctions::glFrontFace(glConst mode)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glFrontFace(mode));
|
||||
}
|
||||
|
||||
void GLFunctions::glCullFace(glConst face)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glCullFace(face));
|
||||
}
|
||||
|
||||
void GLFunctions::glStencilOpSeparate(glConst face, glConst sfail, glConst dpfail, glConst dppass)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glStencilOpSeparate(face, sfail, dpfail, dppass));
|
||||
}
|
||||
|
||||
void GLFunctions::glStencilFuncSeparate(glConst face, glConst func, int ref, uint32_t mask)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glStencilFuncSeparate(face, func, ref, mask));
|
||||
}
|
||||
|
||||
void GLFunctions::glPixelStore(glConst name, uint32_t value)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glPixelStorei(name, value));
|
||||
}
|
||||
|
||||
int32_t GLFunctions::glGetInteger(glConst pname)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLint value;
|
||||
GLCHECK(::glGetIntegerv(pname, &value));
|
||||
return (int32_t)value;
|
||||
|
@ -509,7 +433,7 @@ int32_t GLFunctions::glGetInteger(glConst pname)
|
|||
|
||||
std::string GLFunctions::glGetString(glConst pname)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
char const * str = reinterpret_cast<char const *>(::glGetString(pname));
|
||||
GLCHECKCALL();
|
||||
if (str == nullptr)
|
||||
|
@ -520,7 +444,7 @@ std::string GLFunctions::glGetString(glConst pname)
|
|||
|
||||
int32_t GLFunctions::glGetMaxLineWidth()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLint range[2];
|
||||
GLCHECK(::glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, range));
|
||||
return std::max(range[0], range[1]);
|
||||
|
@ -528,7 +452,7 @@ int32_t GLFunctions::glGetMaxLineWidth()
|
|||
|
||||
int32_t GLFunctions::glGetBufferParameter(glConst target, glConst name)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLint result;
|
||||
ASSERT(glGetBufferParameterFn != nullptr, ());
|
||||
GLCHECK(glGetBufferParameterFn(target, name, &result));
|
||||
|
@ -537,19 +461,19 @@ int32_t GLFunctions::glGetBufferParameter(glConst target, glConst name)
|
|||
|
||||
void GLFunctions::glEnable(glConst mode)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glEnable(mode));
|
||||
}
|
||||
|
||||
void GLFunctions::glDisable(glConst mode)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glDisable(mode));
|
||||
}
|
||||
|
||||
void GLFunctions::glClearDepthValue(double depth)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
#if defined(OMIM_OS_IPHONE) || defined(OMIM_OS_ANDROID) || defined(OMIM_OS_LINUX)
|
||||
GLCHECK(::glClearDepthf(static_cast<GLclampf>(depth)));
|
||||
#else
|
||||
|
@ -559,32 +483,32 @@ void GLFunctions::glClearDepthValue(double depth)
|
|||
|
||||
void GLFunctions::glDepthMask(bool needWriteToDepthBuffer)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glDepthMask(convert(needWriteToDepthBuffer)));
|
||||
}
|
||||
|
||||
void GLFunctions::glDepthFunc(glConst depthFunc)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glDepthFunc(depthFunc));
|
||||
}
|
||||
|
||||
void GLFunctions::glBlendEquation(glConst function)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glBlendEquationFn != nullptr, ());
|
||||
GLCHECK(glBlendEquationFn(function));
|
||||
}
|
||||
|
||||
void GLFunctions::glBlendFunc(glConst srcFactor, glConst dstFactor)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glBlendFunc(srcFactor, dstFactor));
|
||||
}
|
||||
|
||||
bool GLFunctions::CanEnableDebugMessages()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
if (glDebugMessageCallbackFn == nullptr)
|
||||
return false;
|
||||
if (glDebugMessageControlFn == nullptr)
|
||||
|
@ -596,7 +520,7 @@ bool GLFunctions::CanEnableDebugMessages()
|
|||
|
||||
void GLFunctions::glDebugMessageCallback(TglDebugProc messageCallback, void * userParam)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDebugMessageCallbackFn != nullptr, ());
|
||||
GLCHECK(glDebugMessageCallbackFn(reinterpret_cast<GLDEBUGPROC>(messageCallback), userParam));
|
||||
}
|
||||
|
@ -604,14 +528,14 @@ void GLFunctions::glDebugMessageCallback(TglDebugProc messageCallback, void * us
|
|||
void GLFunctions::glDebugMessageControl(glConst source, glConst type, glConst severity,
|
||||
int32_t count, uint32_t const * ids, uint8_t enabled)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDebugMessageControlFn != nullptr, ());
|
||||
GLCHECK(glDebugMessageControlFn(source, type, severity, count, ids, enabled));
|
||||
}
|
||||
|
||||
uint32_t GLFunctions::glGenVertexArray()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGenVertexArraysFn != nullptr, ());
|
||||
GLuint result = std::numeric_limits<GLuint>::max();
|
||||
GLCHECK(glGenVertexArraysFn(1, &result));
|
||||
|
@ -620,21 +544,21 @@ uint32_t GLFunctions::glGenVertexArray()
|
|||
|
||||
void GLFunctions::glBindVertexArray(uint32_t vao)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glBindVertexArrayFn != nullptr, ());
|
||||
GLCHECK(glBindVertexArrayFn(vao));
|
||||
}
|
||||
|
||||
void GLFunctions::glDeleteVertexArray(uint32_t vao)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDeleteVertexArrayFn != nullptr, ());
|
||||
GLCHECK(glDeleteVertexArrayFn(1, &vao));
|
||||
}
|
||||
|
||||
uint32_t GLFunctions::glGenBuffer()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGenBuffersFn != nullptr, ());
|
||||
GLuint result = std::numeric_limits<GLuint>::max();
|
||||
GLCHECK(glGenBuffersFn(1, &result));
|
||||
|
@ -643,7 +567,7 @@ uint32_t GLFunctions::glGenBuffer()
|
|||
|
||||
void GLFunctions::glBindBuffer(uint32_t vbo, uint32_t target)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glBindBufferFn != nullptr, ());
|
||||
#ifdef DEBUG
|
||||
std::lock_guard<std::mutex> guard(g_boundBuffersMutex);
|
||||
|
@ -654,7 +578,7 @@ void GLFunctions::glBindBuffer(uint32_t vbo, uint32_t target)
|
|||
|
||||
void GLFunctions::glDeleteBuffer(uint32_t vbo)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDeleteBuffersFn != nullptr, ());
|
||||
#ifdef DEBUG
|
||||
std::lock_guard<std::mutex> guard(g_boundBuffersMutex);
|
||||
|
@ -666,21 +590,21 @@ void GLFunctions::glDeleteBuffer(uint32_t vbo)
|
|||
|
||||
void GLFunctions::glBufferData(glConst target, uint32_t size, void const * data, glConst usage)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glBufferDataFn != nullptr, ());
|
||||
GLCHECK(glBufferDataFn(target, size, data, usage));
|
||||
}
|
||||
|
||||
void GLFunctions::glBufferSubData(glConst target, uint32_t size, void const * data, uint32_t offset)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glBufferSubDataFn != nullptr, ());
|
||||
GLCHECK(glBufferSubDataFn(target, offset, size, data));
|
||||
}
|
||||
|
||||
void * GLFunctions::glMapBuffer(glConst target, glConst access)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glMapBufferFn != nullptr, ());
|
||||
void * result = glMapBufferFn(target, access);
|
||||
GLCHECKCALL();
|
||||
|
@ -689,7 +613,7 @@ void * GLFunctions::glMapBuffer(glConst target, glConst access)
|
|||
|
||||
void GLFunctions::glUnmapBuffer(glConst target)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUnmapBufferFn != nullptr, ());
|
||||
VERIFY(glUnmapBufferFn(target) == GL_TRUE, ());
|
||||
GLCHECKCALL();
|
||||
|
@ -698,7 +622,7 @@ void GLFunctions::glUnmapBuffer(glConst target)
|
|||
void * GLFunctions::glMapBufferRange(glConst target, uint32_t offset, uint32_t length,
|
||||
glConst access)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glMapBufferRangeFn != nullptr, ());
|
||||
void * result = glMapBufferRangeFn(target, offset, length, access);
|
||||
GLCHECKCALL();
|
||||
|
@ -707,14 +631,14 @@ void * GLFunctions::glMapBufferRange(glConst target, uint32_t offset, uint32_t l
|
|||
|
||||
void GLFunctions::glFlushMappedBufferRange(glConst target, uint32_t offset, uint32_t length)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glFlushMappedBufferRangeFn != nullptr, ());
|
||||
GLCHECK(glFlushMappedBufferRangeFn(target, offset, length));
|
||||
}
|
||||
|
||||
uint32_t GLFunctions::glCreateShader(glConst type)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glCreateShaderFn != nullptr, ());
|
||||
GLuint result = glCreateShaderFn(type);
|
||||
GLCHECKCALL();
|
||||
|
@ -723,7 +647,7 @@ uint32_t GLFunctions::glCreateShader(glConst type)
|
|||
|
||||
void GLFunctions::glShaderSource(uint32_t shaderID, std::string const & src, std::string const & defines)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glShaderSourceFn != nullptr, ());
|
||||
|
||||
std::string fullSrc;
|
||||
|
@ -746,7 +670,7 @@ void GLFunctions::glShaderSource(uint32_t shaderID, std::string const & src, std
|
|||
|
||||
bool GLFunctions::glCompileShader(uint32_t shaderID, std::string & errorLog)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glCompileShaderFn != nullptr, ());
|
||||
ASSERT(glGetShaderivFn != nullptr, ());
|
||||
ASSERT(glGetShaderInfoLogFn != nullptr, ());
|
||||
|
@ -766,14 +690,14 @@ bool GLFunctions::glCompileShader(uint32_t shaderID, std::string & errorLog)
|
|||
|
||||
void GLFunctions::glDeleteShader(uint32_t shaderID)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDeleteShaderFn != nullptr, ());
|
||||
GLCHECK(glDeleteBuffersFn(1, &shaderID));
|
||||
}
|
||||
|
||||
uint32_t GLFunctions::glCreateProgram()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glCreateProgramFn != nullptr, ());
|
||||
GLuint result = glCreateProgramFn();
|
||||
GLCHECKCALL();
|
||||
|
@ -782,21 +706,21 @@ uint32_t GLFunctions::glCreateProgram()
|
|||
|
||||
void GLFunctions::glAttachShader(uint32_t programID, uint32_t shaderID)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glAttachShaderFn != nullptr, ());
|
||||
GLCHECK(glAttachShaderFn(programID, shaderID));
|
||||
}
|
||||
|
||||
void GLFunctions::glDetachShader(uint32_t programID, uint32_t shaderID)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDetachShaderFn != nullptr, ());
|
||||
GLCHECK(glDetachShaderFn(programID, shaderID));
|
||||
}
|
||||
|
||||
bool GLFunctions::glLinkProgram(uint32_t programID, std::string & errorLog)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glLinkProgramFn != nullptr, ());
|
||||
ASSERT(glGetProgramivFn != nullptr, ());
|
||||
ASSERT(glGetProgramInfoLogFn != nullptr, ());
|
||||
|
@ -817,21 +741,21 @@ bool GLFunctions::glLinkProgram(uint32_t programID, std::string & errorLog)
|
|||
|
||||
void GLFunctions::glDeleteProgram(uint32_t programID)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDeleteProgramFn != nullptr, ());
|
||||
GLCHECK(glDeleteProgramFn(programID));
|
||||
}
|
||||
|
||||
void GLFunctions::glUseProgram(uint32_t programID)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUseProgramFn != nullptr, ());
|
||||
GLCHECK(glUseProgramFn(programID));
|
||||
}
|
||||
|
||||
int8_t GLFunctions::glGetAttribLocation(uint32_t programID, std::string const & name)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGetAttribLocationFn != nullptr, ());
|
||||
int result = glGetAttribLocationFn(programID, name.c_str());
|
||||
GLCHECKCALL();
|
||||
|
@ -841,14 +765,14 @@ int8_t GLFunctions::glGetAttribLocation(uint32_t programID, std::string const &
|
|||
|
||||
void GLFunctions::glBindAttribLocation(uint32_t programID, uint8_t index, std::string const & name)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glBindAttribLocationFn != nullptr, ());
|
||||
GLCHECK(glBindAttribLocationFn(programID, index, name.c_str()));
|
||||
}
|
||||
|
||||
void GLFunctions::glEnableVertexAttribute(int attributeLocation)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glEnableVertexAttributeFn != nullptr, ());
|
||||
GLCHECK(glEnableVertexAttributeFn(attributeLocation));
|
||||
}
|
||||
|
@ -856,7 +780,7 @@ void GLFunctions::glEnableVertexAttribute(int attributeLocation)
|
|||
void GLFunctions::glVertexAttributePointer(int attrLocation, uint32_t count, glConst type,
|
||||
bool needNormalize, uint32_t stride, uint32_t offset)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glVertexAttributePointerFn != nullptr, ());
|
||||
GLCHECK(glVertexAttributePointerFn(attrLocation, count, type, convert(needNormalize), stride,
|
||||
reinterpret_cast<void *>(offset)));
|
||||
|
@ -865,7 +789,7 @@ void GLFunctions::glVertexAttributePointer(int attrLocation, uint32_t count, glC
|
|||
void GLFunctions::glGetActiveUniform(uint32_t programID, uint32_t uniformIndex,
|
||||
int32_t * uniformSize, glConst * type, std::string & name)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGetActiveUniformFn != nullptr, ());
|
||||
GLchar buff[256];
|
||||
GLCHECK(glGetActiveUniformFn(programID, uniformIndex, ARRAY_SIZE(buff), nullptr, uniformSize,
|
||||
|
@ -875,7 +799,7 @@ void GLFunctions::glGetActiveUniform(uint32_t programID, uint32_t uniformIndex,
|
|||
|
||||
int8_t GLFunctions::glGetUniformLocation(uint32_t programID, std::string const & name)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGetUniformLocationFn != nullptr, ());
|
||||
int result = glGetUniformLocationFn(programID, name.c_str());
|
||||
GLCHECKCALL();
|
||||
|
@ -885,7 +809,7 @@ int8_t GLFunctions::glGetUniformLocation(uint32_t programID, std::string const &
|
|||
|
||||
void GLFunctions::glUniformValuei(int8_t location, int32_t v)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform1iFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform1iFn(location, v));
|
||||
|
@ -893,7 +817,7 @@ void GLFunctions::glUniformValuei(int8_t location, int32_t v)
|
|||
|
||||
void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform2iFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform2iFn(location, v1, v2));
|
||||
|
@ -901,7 +825,7 @@ void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2)
|
|||
|
||||
void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2, int32_t v3)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform3iFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform3iFn(location, v1, v2, v3));
|
||||
|
@ -909,7 +833,7 @@ void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2, int32
|
|||
|
||||
void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2, int32_t v3, int32_t v4)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform4iFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform4iFn(location, v1, v2, v3, v4));
|
||||
|
@ -917,7 +841,7 @@ void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2, int32
|
|||
|
||||
void GLFunctions::glUniformValueiv(int8_t location, int32_t * v, uint32_t size)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform1ivFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform1ivFn(location, size, v));
|
||||
|
@ -925,7 +849,7 @@ void GLFunctions::glUniformValueiv(int8_t location, int32_t * v, uint32_t size)
|
|||
|
||||
void GLFunctions::glUniformValuef(int8_t location, float v)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform1fFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform1fFn(location, v));
|
||||
|
@ -933,7 +857,7 @@ void GLFunctions::glUniformValuef(int8_t location, float v)
|
|||
|
||||
void GLFunctions::glUniformValuef(int8_t location, float v1, float v2)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform2fFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform2fFn(location, v1, v2));
|
||||
|
@ -941,7 +865,7 @@ void GLFunctions::glUniformValuef(int8_t location, float v1, float v2)
|
|||
|
||||
void GLFunctions::glUniformValuef(int8_t location, float v1, float v2, float v3)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform3fFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform3fFn(location, v1, v2, v3));
|
||||
|
@ -949,7 +873,7 @@ void GLFunctions::glUniformValuef(int8_t location, float v1, float v2, float v3)
|
|||
|
||||
void GLFunctions::glUniformValuef(int8_t location, float v1, float v2, float v3, float v4)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform4fFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform4fFn(location, v1, v2, v3, v4));
|
||||
|
@ -957,7 +881,7 @@ void GLFunctions::glUniformValuef(int8_t location, float v1, float v2, float v3,
|
|||
|
||||
void GLFunctions::glUniformValuefv(int8_t location, float * v, uint32_t size)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform1fvFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform1fvFn(location, size, v));
|
||||
|
@ -965,7 +889,7 @@ void GLFunctions::glUniformValuefv(int8_t location, float * v, uint32_t size)
|
|||
|
||||
void GLFunctions::glUniformMatrix4x4Value(int8_t location, float const * values)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniformMatrix4fvFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniformMatrix4fvFn(location, 1, GL_FALSE, values));
|
||||
|
@ -973,7 +897,7 @@ void GLFunctions::glUniformMatrix4x4Value(int8_t location, float const * values)
|
|||
|
||||
uint32_t GLFunctions::glGetCurrentProgram()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLint programIndex = 0;
|
||||
GLCHECK(glGetIntegerv(GL_CURRENT_PROGRAM, &programIndex));
|
||||
ASSERT_GREATER_OR_EQUAL(programIndex, 0, ());
|
||||
|
@ -982,7 +906,7 @@ uint32_t GLFunctions::glGetCurrentProgram()
|
|||
|
||||
int32_t GLFunctions::glGetProgramiv(uint32_t program, glConst paramName)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGetProgramivFn != nullptr, ());
|
||||
GLint paramValue = 0;
|
||||
GLCHECK(glGetProgramivFn(program, paramName, ¶mValue));
|
||||
|
@ -991,14 +915,14 @@ int32_t GLFunctions::glGetProgramiv(uint32_t program, glConst paramName)
|
|||
|
||||
void GLFunctions::glActiveTexture(glConst texBlock)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glActiveTextureFn != nullptr, ());
|
||||
GLCHECK(glActiveTextureFn(texBlock));
|
||||
}
|
||||
|
||||
uint32_t GLFunctions::glGenTexture()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLuint result = std::numeric_limits<GLuint>::max();
|
||||
GLCHECK(::glGenTextures(1, &result));
|
||||
return result;
|
||||
|
@ -1006,20 +930,20 @@ uint32_t GLFunctions::glGenTexture()
|
|||
|
||||
void GLFunctions::glDeleteTexture(uint32_t id)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glDeleteTextures(1, &id));
|
||||
}
|
||||
|
||||
void GLFunctions::glBindTexture(uint32_t textureID)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glBindTexture(GL_TEXTURE_2D, textureID));
|
||||
}
|
||||
|
||||
void GLFunctions::glTexImage2D(int width, int height, glConst layout, glConst pixelType,
|
||||
void const * data)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
// In OpenGL ES3:
|
||||
// - we can't create unsized GL_RED texture, so we use GL_R8;
|
||||
// - we can't create unsized GL_RG texture, so we use GL_RG8;
|
||||
|
@ -1058,20 +982,20 @@ void GLFunctions::glTexImage2D(int width, int height, glConst layout, glConst pi
|
|||
void GLFunctions::glTexSubImage2D(int x, int y, int width, int height, glConst layout,
|
||||
glConst pixelType, void const * data)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, layout, pixelType, data));
|
||||
}
|
||||
|
||||
void GLFunctions::glTexParameter(glConst param, glConst value)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glTexParameteri(GL_TEXTURE_2D, param, value));
|
||||
}
|
||||
|
||||
void GLFunctions::glDrawElements(glConst primitive, uint32_t sizeOfIndex, uint32_t indexCount,
|
||||
uint32_t startIndex)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glDrawElements(primitive, indexCount,
|
||||
sizeOfIndex == sizeof(uint32_t) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT,
|
||||
reinterpret_cast<GLvoid *>(startIndex * sizeOfIndex)));
|
||||
|
@ -1079,41 +1003,41 @@ void GLFunctions::glDrawElements(glConst primitive, uint32_t sizeOfIndex, uint32
|
|||
|
||||
void GLFunctions::glDrawArrays(glConst mode, int32_t first, uint32_t count)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glDrawArrays(mode, first, count));
|
||||
}
|
||||
|
||||
void GLFunctions::glGenFramebuffer(uint32_t * fbo)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGenFramebuffersFn != nullptr, ());
|
||||
GLCHECK(glGenFramebuffersFn(1, fbo));
|
||||
}
|
||||
|
||||
void GLFunctions::glDeleteFramebuffer(uint32_t * fbo)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDeleteFramebuffersFn != nullptr, ());
|
||||
GLCHECK(glDeleteFramebuffersFn(1, fbo));
|
||||
}
|
||||
|
||||
void GLFunctions::glFramebufferTexture2D(glConst attachment, glConst texture)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glFramebufferTexture2DFn != nullptr, ());
|
||||
GLCHECK(glFramebufferTexture2DFn(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, texture, 0));
|
||||
}
|
||||
|
||||
void GLFunctions::glBindFramebuffer(uint32_t fbo)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glBindFramebufferFn != nullptr, ());
|
||||
GLCHECK(glBindFramebufferFn(GL_FRAMEBUFFER, fbo));
|
||||
}
|
||||
|
||||
uint32_t GLFunctions::glCheckFramebufferStatus()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glCheckFramebufferStatusFn != nullptr, ());
|
||||
uint32_t const result = glCheckFramebufferStatusFn(GL_FRAMEBUFFER);
|
||||
GLCHECKCALL();
|
||||
|
@ -1122,7 +1046,7 @@ uint32_t GLFunctions::glCheckFramebufferStatus()
|
|||
|
||||
void GLFunctions::glLineWidth(uint32_t value)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glLineWidth(static_cast<float>(value)));
|
||||
}
|
||||
|
||||
|
@ -1143,7 +1067,7 @@ std::string GetGLError(GLenum error)
|
|||
|
||||
void CheckGLError(base::SrcPoint const & srcPoint)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(GLFunctions::CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(GLFunctions::CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLenum result = glGetError();
|
||||
while (result != GL_NO_ERROR)
|
||||
{
|
||||
|
|
|
@ -87,26 +87,17 @@ void * GPUBuffer::Map(uint32_t elementOffset, uint32_t elementCount)
|
|||
m_isMapped = true;
|
||||
#endif
|
||||
|
||||
if (GLFunctions::CurrentApiVersion == dp::ApiVersion::OpenGLES2)
|
||||
if (!IsMapBufferSupported())
|
||||
{
|
||||
m_mappingOffset = elementOffset;
|
||||
return IsMapBufferSupported() ? GLFunctions::glMapBuffer(glTarget(m_t)) : nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
else if (GLFunctions::CurrentApiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
if (!IsMapBufferSupported())
|
||||
{
|
||||
m_mappingOffset = elementOffset;
|
||||
return nullptr;
|
||||
}
|
||||
m_mappingOffset = 0;
|
||||
uint32_t const elementSize = GetElementSize();
|
||||
uint32_t const byteOffset = elementOffset * elementSize;
|
||||
uint32_t const byteCount = elementCount * elementSize;
|
||||
return GLFunctions::glMapBufferRange(glTarget(m_t), byteOffset, byteCount,
|
||||
gl_const::GLWriteBufferBit);
|
||||
}
|
||||
return nullptr;
|
||||
m_mappingOffset = 0;
|
||||
uint32_t const elementSize = GetElementSize();
|
||||
uint32_t const byteOffset = elementOffset * elementSize;
|
||||
uint32_t const byteCount = elementCount * elementSize;
|
||||
return GLFunctions::glMapBufferRange(glTarget(m_t), byteOffset, byteCount,
|
||||
gl_const::GLWriteBufferBit);
|
||||
}
|
||||
|
||||
void GPUBuffer::UpdateData(void * gpuPtr, void const * data, uint32_t elementOffset,
|
||||
|
|
|
@ -36,7 +36,7 @@ void UnpackFormat(ref_ptr<dp::GraphicsContext> context, TextureFormat format,
|
|||
glConst & layout, glConst & pixelType)
|
||||
{
|
||||
auto const apiVersion = context->GetApiVersion();
|
||||
CHECK(apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3, ());
|
||||
CHECK(apiVersion == dp::ApiVersion::OpenGLES3, ());
|
||||
|
||||
switch (format)
|
||||
{
|
||||
|
@ -45,21 +45,17 @@ void UnpackFormat(ref_ptr<dp::GraphicsContext> context, TextureFormat format,
|
|||
pixelType = gl_const::GL8BitOnChannel;
|
||||
return;
|
||||
|
||||
case TextureFormat::Alpha:
|
||||
// On OpenGL ES3 GLAlpha is not supported, we use GLRed instead.
|
||||
layout = apiVersion == dp::ApiVersion::OpenGLES2 ? gl_const::GLAlpha : gl_const::GLRed;
|
||||
case TextureFormat::Red:
|
||||
layout = gl_const::GLRed;
|
||||
pixelType = gl_const::GL8BitOnChannel;
|
||||
return;
|
||||
|
||||
case TextureFormat::RedGreen:
|
||||
// On OpenGL ES2 2-channel textures are not supported.
|
||||
layout = (apiVersion == dp::ApiVersion::OpenGLES2) ? gl_const::GLRGBA : gl_const::GLRedGreen;
|
||||
layout = gl_const::GLRedGreen;
|
||||
pixelType = gl_const::GL8BitOnChannel;
|
||||
return;
|
||||
|
||||
case TextureFormat::DepthStencil:
|
||||
// OpenGLES2 does not support texture-based depth-stencil.
|
||||
CHECK(apiVersion != dp::ApiVersion::OpenGLES2, ());
|
||||
layout = gl_const::GLDepthStencil;
|
||||
pixelType = gl_const::GLUnsignedInt24_8Type;
|
||||
return;
|
||||
|
|
|
@ -61,7 +61,7 @@ CVPixelBufferRef HWTextureAllocatorApple::CVCreatePixelBuffer(uint32_t width, ui
|
|||
cvRetval = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_32BGRA,
|
||||
attrsRef, &result);
|
||||
break;
|
||||
case dp::TextureFormat::Alpha:
|
||||
case dp::TextureFormat::Red:
|
||||
cvRetval = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_OneComponent8,
|
||||
attrsRef, &result);
|
||||
break;
|
||||
|
|
|
@ -56,7 +56,7 @@ void const * IndexStorage::GetRawConst() const
|
|||
bool IndexStorage::IsSupported32bit()
|
||||
{
|
||||
// We do not use 32-bit indices now to reduce size of index buffers.
|
||||
static bool const supports32Bit = false;//GLFunctions::ExtensionsList.IsSupported(GLExtensionsList::UintIndices);
|
||||
static bool const supports32Bit = false;
|
||||
return supports32Bit;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,13 +36,8 @@ public:
|
|||
{
|
||||
UNUSED_VALUE(context);
|
||||
|
||||
bool const isVAOSupported =
|
||||
GLFunctions::ExtensionsList.IsSupported(dp::GLExtensionsList::VertexArrayObject);
|
||||
if (isVAOSupported)
|
||||
{
|
||||
m_VAO = GLFunctions::glGenVertexArray();
|
||||
GLFunctions::glBindVertexArray(m_VAO);
|
||||
}
|
||||
m_VAO = GLFunctions::glGenVertexArray();
|
||||
GLFunctions::glBindVertexArray(m_VAO);
|
||||
|
||||
for (auto & buffer : m_mesh->m_buffers)
|
||||
{
|
||||
|
@ -64,23 +59,19 @@ public:
|
|||
m_mesh->m_indices.data(), gl_const::GLStaticDraw);
|
||||
}
|
||||
|
||||
if (isVAOSupported)
|
||||
ref_ptr<dp::GLGpuProgram> p = program;
|
||||
for (auto const & attribute : buffer->m_attributes)
|
||||
{
|
||||
ref_ptr<dp::GLGpuProgram> p = program;
|
||||
for (auto const & attribute : buffer->m_attributes)
|
||||
{
|
||||
int8_t const attributePosition = p->GetAttributeLocation(attribute.m_attributeName);
|
||||
ASSERT_NOT_EQUAL(attributePosition, -1, ());
|
||||
GLFunctions::glEnableVertexAttribute(attributePosition);
|
||||
GLFunctions::glVertexAttributePointer(attributePosition, attribute.m_componentsCount,
|
||||
attribute.m_type, false, buffer->GetStrideInBytes(),
|
||||
attribute.m_offset);
|
||||
}
|
||||
int8_t const attributePosition = p->GetAttributeLocation(attribute.m_attributeName);
|
||||
ASSERT_NOT_EQUAL(attributePosition, -1, ());
|
||||
GLFunctions::glEnableVertexAttribute(attributePosition);
|
||||
GLFunctions::glVertexAttributePointer(attributePosition, attribute.m_componentsCount,
|
||||
attribute.m_type, false, buffer->GetStrideInBytes(),
|
||||
attribute.m_offset);
|
||||
}
|
||||
}
|
||||
|
||||
if (isVAOSupported)
|
||||
GLFunctions::glBindVertexArray(0);
|
||||
GLFunctions::glBindVertexArray(0);
|
||||
GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer);
|
||||
if (!m_mesh->m_indices.empty())
|
||||
GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer);
|
||||
|
@ -134,34 +125,12 @@ public:
|
|||
|
||||
void Bind(ref_ptr<dp::GpuProgram> program) override
|
||||
{
|
||||
if (GLFunctions::ExtensionsList.IsSupported(dp::GLExtensionsList::VertexArrayObject))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
GLFunctions::glBindVertexArray(m_VAO);
|
||||
}
|
||||
|
||||
void Unbind() override
|
||||
{
|
||||
if (GLFunctions::ExtensionsList.IsSupported(dp::GLExtensionsList::VertexArrayObject))
|
||||
GLFunctions::glBindVertexArray(0);
|
||||
GLFunctions::glBindVertexArray(0);
|
||||
GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer);
|
||||
if (m_indexBuffer != 0)
|
||||
GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer);
|
||||
|
@ -197,7 +166,7 @@ MeshObject::MeshObject(ref_ptr<dp::GraphicsContext> context, DrawPrimitive drawP
|
|||
, m_debugName(debugName)
|
||||
{
|
||||
auto const apiVersion = context->GetApiVersion();
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
InitForOpenGL();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ MTLPixelFormat UnpackFormat(TextureFormat format)
|
|||
switch (format)
|
||||
{
|
||||
case TextureFormat::RGBA8: return MTLPixelFormatRGBA8Unorm;
|
||||
case TextureFormat::Alpha: return MTLPixelFormatA8Unorm;
|
||||
case TextureFormat::Red: return MTLPixelFormatA8Unorm; // TODO: change to R8, fix shaders
|
||||
case TextureFormat::RedGreen: return MTLPixelFormatRG8Unorm;
|
||||
case TextureFormat::DepthStencil: return MTLPixelFormatDepth32Float_Stencil8;
|
||||
case TextureFormat::Depth: return MTLPixelFormatDepth32Float;
|
||||
|
|
|
@ -30,7 +30,7 @@ void AlphaBlendingState::Apply(ref_ptr<GraphicsContext> context)
|
|||
{
|
||||
// For Metal Rendering these settings must be set in the pipeline state.
|
||||
auto const apiVersion = context->GetApiVersion();
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
GLFunctions::glBlendEquation(gl_const::GLAddBlend);
|
||||
GLFunctions::glBlendFunc(gl_const::GLSrcAlpha, gl_const::GLOneMinusSrcAlpha);
|
||||
|
@ -45,7 +45,7 @@ void Blending::Apply(ref_ptr<GraphicsContext> context, ref_ptr<GpuProgram> progr
|
|||
{
|
||||
// For Metal Rendering these settings must be set in the pipeline state.
|
||||
auto const apiVersion = context->GetApiVersion();
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
if (m_isEnabled)
|
||||
GLFunctions::glEnable(gl_const::GLBlending);
|
||||
|
@ -216,7 +216,7 @@ void TextureState::ApplyTextures(ref_ptr<GraphicsContext> context, RenderState c
|
|||
{
|
||||
m_usedSlots = 0;
|
||||
auto const apiVersion = context->GetApiVersion();
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
ref_ptr<dp::GLGpuProgram> p = program;
|
||||
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 (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
ASSERT_GREATER_OR_EQUAL(state.GetLineWidth(), 0, ());
|
||||
GLFunctions::glLineWidth(static_cast<uint32_t>(state.GetLineWidth()));
|
||||
|
|
|
@ -175,7 +175,7 @@ ref_ptr<Texture::ResourceInfo> StipplePenIndex::MapResource(StipplePenKey const
|
|||
|
||||
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;
|
||||
{
|
||||
std::lock_guard<std::mutex> g(m_lock);
|
||||
|
|
|
@ -138,7 +138,7 @@ public:
|
|||
StipplePenTexture(m2::PointU const & size, ref_ptr<HWTextureAllocator> allocator)
|
||||
: m_index(size)
|
||||
{
|
||||
TBase::DynamicTextureParams params{size, TextureFormat::Alpha, TextureFilter::Nearest,
|
||||
TBase::DynamicTextureParams params{size, TextureFormat::Red, TextureFilter::Nearest,
|
||||
false /* m_usePixelBuffer */};
|
||||
TBase::Init(allocator, make_ref(&m_index), params);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ void SupportManager::Init(ref_ptr<GraphicsContext> context)
|
|||
LOG(LINFO, ("NVidia Tegra device detected."));
|
||||
|
||||
auto const apiVersion = context->GetApiVersion();
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
m_maxLineWidth = static_cast<float>(std::max(1, GLFunctions::glGetMaxLineWidth()));
|
||||
m_maxTextureSize = static_cast<uint32_t>(GLFunctions::glGetInteger(gl_const::GLMaxTextureSize));
|
||||
|
|
|
@ -183,7 +183,7 @@ bool TextureManager::UpdateDynamicTextures(ref_ptr<dp::GraphicsContext> context)
|
|||
if (m_nothingToUpload.test_and_set())
|
||||
{
|
||||
auto const apiVersion = context->GetApiVersion();
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
// For some reasons OpenGL can not update textures immediately.
|
||||
// Here we use some timeout to prevent rendering frozening.
|
||||
|
@ -302,7 +302,7 @@ void TextureManager::Init(ref_ptr<dp::GraphicsContext> context, Params const & p
|
|||
|
||||
m_maxTextureSize = std::min(kMaxTextureSize, dp::SupportManager::Instance().GetMaxTextureSize());
|
||||
auto const apiVersion = context->GetApiVersion();
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
GLFunctions::glPixelStore(gl_const::GLUnpackAlignment, 1);
|
||||
|
||||
// Initialize symbols.
|
||||
|
@ -323,16 +323,13 @@ void TextureManager::Init(ref_ptr<dp::GraphicsContext> context, Params const & p
|
|||
CreateArrowTexture(context, make_ref(m_textureAllocator), params.m_arrowTexturePath,
|
||||
params.m_arrowTextureUseDefaultResourceFolder);
|
||||
|
||||
// SMAA is not supported on OpenGL ES2.
|
||||
if (apiVersion != dp::ApiVersion::OpenGLES2)
|
||||
{
|
||||
m_smaaAreaTexture =
|
||||
make_unique_dp<StaticTexture>(context, "smaa-area.png", StaticTexture::kDefaultResource,
|
||||
dp::TextureFormat::RedGreen, make_ref(m_textureAllocator));
|
||||
m_smaaSearchTexture =
|
||||
make_unique_dp<StaticTexture>(context, "smaa-search.png", StaticTexture::kDefaultResource,
|
||||
dp::TextureFormat::Alpha, make_ref(m_textureAllocator));
|
||||
}
|
||||
// SMAA.
|
||||
m_smaaAreaTexture =
|
||||
make_unique_dp<StaticTexture>(context, "smaa-area.png", StaticTexture::kDefaultResource,
|
||||
dp::TextureFormat::RedGreen, make_ref(m_textureAllocator));
|
||||
m_smaaSearchTexture =
|
||||
make_unique_dp<StaticTexture>(context, "smaa-search.png", StaticTexture::kDefaultResource,
|
||||
dp::TextureFormat::Red, make_ref(m_textureAllocator));
|
||||
|
||||
// Initialize patterns (reserved ./data/patterns.txt lines count).
|
||||
std::set<PenPatternT> patterns;
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace dp
|
|||
enum class TextureFormat : uint8_t
|
||||
{
|
||||
RGBA8,
|
||||
Alpha,
|
||||
Red,
|
||||
RedGreen,
|
||||
DepthStencil,
|
||||
Depth,
|
||||
|
@ -21,7 +21,7 @@ inline std::string DebugPrint(TextureFormat tf)
|
|||
switch (tf)
|
||||
{
|
||||
case TextureFormat::RGBA8: return "RGBA8";
|
||||
case TextureFormat::Alpha: return "Alpha";
|
||||
case TextureFormat::Red: return "Red";
|
||||
case TextureFormat::RedGreen: return "RedGreen";
|
||||
case TextureFormat::DepthStencil: return "DepthStencil";
|
||||
case TextureFormat::Depth: return "Depth";
|
||||
|
@ -50,7 +50,7 @@ inline uint8_t GetBytesPerPixel(TextureFormat format)
|
|||
switch (format)
|
||||
{
|
||||
case TextureFormat::RGBA8: result = 4; break;
|
||||
case TextureFormat::Alpha: result = 1; break;
|
||||
case TextureFormat::Red: result = 1; break;
|
||||
case TextureFormat::RedGreen: result = 2; break;
|
||||
case TextureFormat::DepthStencil: result = 4; break;
|
||||
case TextureFormat::Depth: result = 4; break;
|
||||
|
|
|
@ -56,9 +56,6 @@ public:
|
|||
return false;
|
||||
|
||||
m_program = program;
|
||||
// If OES_vertex_array_object not supported, than buffers will be bound on each render call.
|
||||
if (!GLFunctions::ExtensionsList.IsSupported(GLExtensionsList::VertexArrayObject))
|
||||
return false;
|
||||
|
||||
if (m_VAO != 0)
|
||||
GLFunctions::glDeleteVertexArray(m_VAO);
|
||||
|
@ -68,19 +65,14 @@ public:
|
|||
|
||||
bool Bind() override
|
||||
{
|
||||
if (GLFunctions::ExtensionsList.IsSupported(GLExtensionsList::VertexArrayObject))
|
||||
{
|
||||
ASSERT(m_VAO != 0, ("You need to call Build method before bind it and render."));
|
||||
GLFunctions::glBindVertexArray(m_VAO);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
ASSERT(m_VAO != 0, ("You need to call Build method before bind it and render."));
|
||||
GLFunctions::glBindVertexArray(m_VAO);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Unbind() override
|
||||
{
|
||||
if (GLFunctions::ExtensionsList.IsSupported(GLExtensionsList::VertexArrayObject))
|
||||
GLFunctions::glBindVertexArray(0);
|
||||
GLFunctions::glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void BindBuffers(BuffersMap const & buffers) const override
|
||||
|
@ -163,7 +155,7 @@ void VertexArrayBuffer::PreflushImpl(ref_ptr<GraphicsContext> context)
|
|||
// Preflush can be called on BR, where impl is not initialized.
|
||||
// For Metal rendering this code has no meaning.
|
||||
auto const apiVersion = context->GetApiVersion();
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
GLFunctions::glBindBuffer(0, gl_const::GLElementArrayBuffer);
|
||||
GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer);
|
||||
|
@ -208,7 +200,7 @@ void VertexArrayBuffer::Build(ref_ptr<GraphicsContext> context, ref_ptr<GpuProgr
|
|||
if (!m_impl)
|
||||
{
|
||||
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>();
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ VkFormat VulkanFormatUnpacker::Unpack(TextureFormat format)
|
|||
switch (format)
|
||||
{
|
||||
case TextureFormat::RGBA8: return VK_FORMAT_R8G8B8A8_UNORM;
|
||||
case TextureFormat::Alpha: return VK_FORMAT_R8_UNORM;
|
||||
case TextureFormat::Red: return VK_FORMAT_R8_UNORM;
|
||||
case TextureFormat::RedGreen: return VK_FORMAT_R8G8_UNORM;
|
||||
#if defined(OMIM_OS_MAC)
|
||||
case TextureFormat::DepthStencil: return VK_FORMAT_D32_SFLOAT_S8_UINT;
|
||||
|
|
|
@ -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.
|
||||
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_isValid = preloadedData.m_meshData.has_value();
|
||||
|
|
|
@ -1426,7 +1426,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView, bool activeFram
|
|||
RefreshBgColor();
|
||||
|
||||
uint32_t clearBits = dp::ClearBits::ColorBit | dp::ClearBits::DepthBit;
|
||||
if (m_apiVersion == dp::ApiVersion::OpenGLES2 || m_apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (m_apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
clearBits |= dp::ClearBits::StencilBit;
|
||||
|
||||
uint32_t storeBits = dp::ClearBits::ColorBit;
|
||||
|
@ -1524,7 +1524,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView, bool activeFram
|
|||
if (IsValidCurrentZoom())
|
||||
{
|
||||
uint32_t clearBits = dp::ClearBits::DepthBit;
|
||||
if (m_apiVersion == dp::ApiVersion::OpenGLES2 || m_apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (m_apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
clearBits |= dp::ClearBits::StencilBit;
|
||||
m_context->Clear(clearBits, dp::kClearBitsStoreAll);
|
||||
|
||||
|
|
|
@ -369,7 +369,6 @@ void LayerCacher::CacheScaleFpsLabel(ref_ptr<dp::GraphicsContext> context, Posit
|
|||
std::string apiLabel;
|
||||
switch (apiVersion)
|
||||
{
|
||||
case dp::ApiVersion::OpenGLES2: apiLabel = "GL2"; break;
|
||||
case dp::ApiVersion::OpenGLES3: apiLabel = "GL3"; break;
|
||||
case dp::ApiVersion::Metal: apiLabel = "M"; break;
|
||||
case dp::ApiVersion::Vulkan: apiLabel = "V"; break;
|
||||
|
|
|
@ -203,10 +203,6 @@ bool PostprocessRenderer::IsEnabled() const
|
|||
void PostprocessRenderer::SetEffectEnabled(ref_ptr<dp::GraphicsContext> context,
|
||||
Effect effect, bool enabled)
|
||||
{
|
||||
// Do not support AA for OpenGLES 2.0.
|
||||
if (m_apiVersion == dp::ApiVersion::OpenGLES2 && effect == Effect::Antialiasing)
|
||||
return;
|
||||
|
||||
auto const oldValue = m_effects;
|
||||
auto const effectMask = static_cast<uint32_t>(effect);
|
||||
m_effects = (m_effects & ~effectMask) | (enabled ? effectMask : 0);
|
||||
|
@ -238,7 +234,7 @@ bool PostprocessRenderer::CanRenderAntialiasing() const
|
|||
return false;
|
||||
}
|
||||
|
||||
if (m_apiVersion == dp::ApiVersion::OpenGLES2 || m_apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (m_apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
return m_staticTextures->m_smaaAreaTexture->GetID() != 0 &&
|
||||
m_staticTextures->m_smaaSearchTexture->GetID() != 0;
|
||||
|
@ -289,7 +285,7 @@ bool PostprocessRenderer::EndFrame(ref_ptr<dp::GraphicsContext> context,
|
|||
ASSERT(m_staticTextures->m_smaaAreaTexture != nullptr, ());
|
||||
ASSERT(m_staticTextures->m_smaaSearchTexture != nullptr, ());
|
||||
|
||||
if (m_apiVersion == dp::ApiVersion::OpenGLES2 || m_apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (m_apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
ASSERT_GREATER(m_staticTextures->m_smaaAreaTexture->GetID(), 0, ());
|
||||
ASSERT_GREATER(m_staticTextures->m_smaaSearchTexture->GetID(), 0, ());
|
||||
|
@ -418,15 +414,12 @@ void PostprocessRenderer::UpdateFramebuffers(ref_ptr<dp::GraphicsContext> contex
|
|||
ASSERT_NOT_EQUAL(height, 0, ());
|
||||
|
||||
CHECK_EQUAL(m_apiVersion, context->GetApiVersion(), ());
|
||||
InitFramebuffer(context, m_mainFramebuffer, width, height, true /* depthEnabled */,
|
||||
m_apiVersion != dp::ApiVersion::OpenGLES2 /* stencilEnabled */);
|
||||
InitFramebuffer(context, m_mainFramebuffer, width, height, true /* depthEnabled */, true /* stencilEnabled */);
|
||||
m_isMainFramebufferRendered = false;
|
||||
|
||||
m_isSmaaFramebufferRendered = false;
|
||||
if (!m_isRouteFollowingActive && IsEffectEnabled(Effect::Antialiasing))
|
||||
{
|
||||
CHECK_NOT_EQUAL(m_apiVersion, dp::ApiVersion::OpenGLES2, ());
|
||||
|
||||
InitFramebuffer(context, m_edgesFramebuffer, dp::TextureFormat::RedGreen,
|
||||
m_mainFramebuffer->GetDepthStencilRef(),
|
||||
width, height);
|
||||
|
|
|
@ -81,7 +81,7 @@ double getExactDPI(double contentScaleFactor)
|
|||
if (tempContext != nil)
|
||||
apiVersion = dp::ApiVersion::OpenGLES3;
|
||||
else
|
||||
apiVersion = dp::ApiVersion::OpenGLES2;
|
||||
CHECK(false, ("OpenGL ES3 is not supported"));
|
||||
}
|
||||
|
||||
return apiVersion;
|
||||
|
|
|
@ -17,20 +17,14 @@ iosOGLContext::iosOGLContext(CAEAGLLayer * layer, dp::ApiVersion apiVersion,
|
|||
, m_frameBufferId(0)
|
||||
, m_presentAvailable(true)
|
||||
{
|
||||
EAGLRenderingAPI api;
|
||||
if (m_apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
api = kEAGLRenderingAPIOpenGLES3;
|
||||
else
|
||||
api = kEAGLRenderingAPIOpenGLES2;
|
||||
|
||||
if (contextToShareWith != NULL)
|
||||
{
|
||||
m_nativeContext = [[EAGLContext alloc] initWithAPI:api
|
||||
m_nativeContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3
|
||||
sharegroup: contextToShareWith->m_nativeContext.sharegroup];
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nativeContext = [[EAGLContext alloc] initWithAPI:api];
|
||||
m_nativeContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -395,7 +395,7 @@ private:
|
|||
public:
|
||||
struct DrapeCreationParams
|
||||
{
|
||||
dp::ApiVersion m_apiVersion = dp::ApiVersion::OpenGLES2;
|
||||
dp::ApiVersion m_apiVersion = dp::ApiVersion::OpenGLES3;
|
||||
float m_visualScale = 1.0f;
|
||||
int m_surfaceWidth = 0;
|
||||
int m_surfaceHeight = 0;
|
||||
|
|
|
@ -107,7 +107,7 @@ void MapWidget::CreateEngine()
|
|||
{
|
||||
Framework::DrapeCreationParams p;
|
||||
|
||||
p.m_apiVersion = m_apiOpenGLES3 ? dp::ApiVersion::OpenGLES3 : dp::ApiVersion::OpenGLES2;
|
||||
p.m_apiVersion = dp::ApiVersion::OpenGLES3;
|
||||
|
||||
p.m_surfaceWidth = m_screenshotMode ? width() : static_cast<int>(m_ratio * width());
|
||||
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 fragmentSrc;
|
||||
if (m_apiOpenGLES3)
|
||||
{
|
||||
#if defined(OMIM_OS_LINUX)
|
||||
vertexSrc = ":common/shaders/gles_300.vsh.glsl";
|
||||
fragmentSrc = ":common/shaders/gles_300.fsh.glsl";
|
||||
|
@ -241,12 +239,6 @@ void MapWidget::Build()
|
|||
vertexSrc = ":common/shaders/gl_150.vsh.glsl";
|
||||
fragmentSrc = ":common/shaders/gl_150.fsh.glsl";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
vertexSrc = ":common/shaders/gles_200.vsh.glsl";
|
||||
fragmentSrc = ":common/shaders/gles_200.fsh.glsl";
|
||||
}
|
||||
|
||||
m_program = std::make_unique<QOpenGLShaderProgram>(this);
|
||||
m_program->addShaderFromSourceFile(QOpenGLShader::Vertex, vertexSrc.data());
|
||||
|
@ -348,8 +340,6 @@ void MapWidget::initializeGL()
|
|||
if (!m_screenshotMode)
|
||||
m_ratio = devicePixelRatio();
|
||||
|
||||
m_apiOpenGLES3 = true;
|
||||
|
||||
#if defined(OMIM_OS_LINUX)
|
||||
{
|
||||
QOpenGLFunctions * funcs = context()->functions();
|
||||
|
@ -367,29 +357,14 @@ void MapWidget::initializeGL()
|
|||
auto fmt = context()->format();
|
||||
if (context()->format().version() < qMakePair(3, 0))
|
||||
{
|
||||
LOG(LINFO, ("OpenGL ES version is below 3.0, taking the OpenGL ES 2.0 path"));
|
||||
m_apiOpenGLES3 = false;
|
||||
|
||||
constexpr const char* requiredExtensions[3] =
|
||||
{ "GL_EXT_map_buffer_range", "GL_OES_mapbuffer", "GL_OES_vertex_array_object" };
|
||||
for (auto & requiredExtension : requiredExtensions)
|
||||
{
|
||||
if (context()->hasExtension(QByteArray::fromStdString(requiredExtension)))
|
||||
LOG(LDEBUG, ("Found OpenGL ES 2.0 extension: ", requiredExtension));
|
||||
else
|
||||
LOG(LCRITICAL, ("A required OpenGL ES 2.0 extension is missing:", requiredExtension));
|
||||
}
|
||||
fmt.setProfile(QSurfaceFormat::CompatibilityProfile);
|
||||
fmt.setVersion(2, 0);
|
||||
CHECK(false, ("OpenGL ES2 is not supported"));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(LINFO, ("OpenGL version is at least 3.0, enabling GLSL '#version 300 es'"));
|
||||
m_apiOpenGLES3 = true;
|
||||
fmt.setVersion(3, 0);
|
||||
}
|
||||
|
||||
|
||||
QSurfaceFormat::setDefaultFormat(fmt);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -97,7 +97,6 @@ protected:
|
|||
void wheelEvent(QWheelEvent * e) override;
|
||||
|
||||
Framework & m_framework;
|
||||
bool m_apiOpenGLES3;
|
||||
bool m_screenshotMode;
|
||||
ScaleSlider * m_slider;
|
||||
SliderState m_sliderState;
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
<file>spinner12.png</file>
|
||||
<file>shaders/gl_150.fsh.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.vsh.glsl</file>
|
||||
</qresource>
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -51,8 +51,7 @@ void RunTestLoop(char const * testName, testing::RenderFunction && fn, bool auto
|
|||
app.exec();
|
||||
}
|
||||
|
||||
void RunTestInOpenGLOffscreenEnvironment(char const * testName, bool apiOpenGLES3,
|
||||
testing::TestFunction const & fn)
|
||||
void RunTestInOpenGLOffscreenEnvironment(char const * testName, testing::TestFunction const & fn)
|
||||
{
|
||||
std::vector<char> buf(strlen(testName) + 1);
|
||||
strcpy(buf.data(), testName);
|
||||
|
@ -71,16 +70,8 @@ void RunTestInOpenGLOffscreenEnvironment(char const * testName, bool apiOpenGLES
|
|||
fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
|
||||
fmt.setSwapInterval(1);
|
||||
fmt.setDepthBufferSize(16);
|
||||
if (apiOpenGLES3)
|
||||
{
|
||||
fmt.setProfile(QSurfaceFormat::CoreProfile);
|
||||
fmt.setVersion(3, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt.setProfile(QSurfaceFormat::CompatibilityProfile);
|
||||
fmt.setVersion(2, 1);
|
||||
}
|
||||
fmt.setProfile(QSurfaceFormat::CoreProfile);
|
||||
fmt.setVersion(3, 2);
|
||||
|
||||
auto surface = std::make_unique<QOffscreenSurface>();
|
||||
surface->setFormat(fmt);
|
||||
|
@ -92,7 +83,7 @@ void RunTestInOpenGLOffscreenEnvironment(char const * testName, bool apiOpenGLES
|
|||
context->makeCurrent(surface.get());
|
||||
|
||||
if (fn)
|
||||
fn(apiOpenGLES3);
|
||||
fn();
|
||||
|
||||
context->doneCurrent();
|
||||
surface->destroy();
|
||||
|
|
|
@ -6,9 +6,9 @@ class QPaintDevice;
|
|||
namespace testing
|
||||
{
|
||||
using RenderFunction = std::function<void (QPaintDevice *)>;
|
||||
using TestFunction = std::function<void (bool apiOpenGLES3)>;
|
||||
using TestFunction = std::function<void ()>;
|
||||
} // namespace testing
|
||||
|
||||
extern void RunTestLoop(char const * testName, testing::RenderFunction && fn, bool autoExit = true);
|
||||
|
||||
extern void RunTestInOpenGLOffscreenEnvironment(char const * testName, bool apiOpenGLES3, testing::TestFunction const & fn);
|
||||
extern void RunTestInOpenGLOffscreenEnvironment(char const * testName, testing::TestFunction const & fn);
|
||||
|
|
|
@ -253,14 +253,7 @@ def write_implementation_file(programs_def, shader_index, shader_dir, impl_file,
|
|||
|
||||
file.write("GLProgramInfo GetProgramInfo(dp::ApiVersion apiVersion, Program program)\n")
|
||||
file.write("{\n")
|
||||
file.write(" if (apiVersion == dp::ApiVersion::OpenGLES2)\n")
|
||||
file.write(" {\n")
|
||||
file.write(" static std::array<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(" 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, GLES3_PREFIX)
|
||||
|
|
|
@ -19,7 +19,7 @@ void ProgramManager::Init(ref_ptr<dp::GraphicsContext> context)
|
|||
{
|
||||
CHECK_THREAD_CHECKER(m_threadChecker, ());
|
||||
auto const apiVersion = context->GetApiVersion();
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
InitForOpenGL(context);
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
using namespace std::placeholders;
|
||||
|
||||
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);
|
||||
GLFunctions::Init(api);
|
||||
gpu::GLProgramPool pool(api);
|
||||
|
@ -37,91 +37,61 @@ void TestProgramParams(bool apiOpenGLES3)
|
|||
#ifdef OMIM_OS_MAC
|
||||
UNIT_TEST(MapProgramParams_Test)
|
||||
{
|
||||
RunTestInOpenGLOffscreenEnvironment("MapProgramParams_Test", false /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::MapProgramParams>, _1));
|
||||
|
||||
RunTestInOpenGLOffscreenEnvironment("MapProgramParams_Test", true /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::MapProgramParams>, _1));
|
||||
RunTestInOpenGLOffscreenEnvironment("MapProgramParams_Test",
|
||||
std::bind(&TestProgramParams<gpu::MapProgramParams>));
|
||||
}
|
||||
|
||||
UNIT_TEST(RouteProgramParams_Test)
|
||||
{
|
||||
RunTestInOpenGLOffscreenEnvironment("RouteProgramParams_Test", false /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::RouteProgramParams>, _1));
|
||||
|
||||
RunTestInOpenGLOffscreenEnvironment("RouteProgramParams_Test", true /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::RouteProgramParams>, _1));
|
||||
RunTestInOpenGLOffscreenEnvironment("RouteProgramParams_Test",
|
||||
std::bind(&TestProgramParams<gpu::RouteProgramParams>));
|
||||
}
|
||||
|
||||
UNIT_TEST(TrafficProgramParams_Test)
|
||||
{
|
||||
RunTestInOpenGLOffscreenEnvironment("TrafficProgramParams_Test", false /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::TrafficProgramParams>, _1));
|
||||
|
||||
RunTestInOpenGLOffscreenEnvironment("TrafficProgramParams_Test", true /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::TrafficProgramParams>, _1));
|
||||
RunTestInOpenGLOffscreenEnvironment("TrafficProgramParams_Test",
|
||||
std::bind(&TestProgramParams<gpu::TrafficProgramParams>));
|
||||
}
|
||||
|
||||
UNIT_TEST(TransitProgramParams_Test)
|
||||
{
|
||||
RunTestInOpenGLOffscreenEnvironment("TransitProgramParams_Test", false /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::TransitProgramParams>, _1));
|
||||
|
||||
RunTestInOpenGLOffscreenEnvironment("TransitProgramParams_Test", true /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::TransitProgramParams>, _1));
|
||||
RunTestInOpenGLOffscreenEnvironment("TransitProgramParams_Test",
|
||||
std::bind(&TestProgramParams<gpu::TransitProgramParams>));
|
||||
}
|
||||
|
||||
UNIT_TEST(GuiProgramParams_Test)
|
||||
{
|
||||
RunTestInOpenGLOffscreenEnvironment("GuiProgramParams_Test", false /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::GuiProgramParams>, _1));
|
||||
|
||||
RunTestInOpenGLOffscreenEnvironment("GuiProgramParams_Test", true /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::GuiProgramParams>, _1));
|
||||
RunTestInOpenGLOffscreenEnvironment("GuiProgramParams_Test",
|
||||
std::bind(&TestProgramParams<gpu::GuiProgramParams>));
|
||||
}
|
||||
|
||||
UNIT_TEST(ShapesProgramParams_Test)
|
||||
{
|
||||
RunTestInOpenGLOffscreenEnvironment("ShapesProgramParams_Test", false /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::ShapesProgramParams>, _1));
|
||||
|
||||
RunTestInOpenGLOffscreenEnvironment("ShapesProgramParams_Test", true /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::ShapesProgramParams>, _1));
|
||||
RunTestInOpenGLOffscreenEnvironment("ShapesProgramParams_Test",
|
||||
std::bind(&TestProgramParams<gpu::ShapesProgramParams>));
|
||||
}
|
||||
|
||||
UNIT_TEST(Arrow3dProgramParams_Test)
|
||||
{
|
||||
RunTestInOpenGLOffscreenEnvironment("Arrow3dProgramParams_Test", false /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::Arrow3dProgramParams>, _1));
|
||||
|
||||
RunTestInOpenGLOffscreenEnvironment("Arrow3dProgramParams_Test", true /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::Arrow3dProgramParams>, _1));
|
||||
RunTestInOpenGLOffscreenEnvironment("Arrow3dProgramParams_Test",
|
||||
std::bind(&TestProgramParams<gpu::Arrow3dProgramParams>));
|
||||
}
|
||||
|
||||
UNIT_TEST(DebugRectProgramParams_Test)
|
||||
{
|
||||
RunTestInOpenGLOffscreenEnvironment("DebugRectProgramParams_Test", false /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::DebugRectProgramParams>, _1));
|
||||
|
||||
RunTestInOpenGLOffscreenEnvironment("DebugRectProgramParams_Test", true /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::DebugRectProgramParams>, _1));
|
||||
RunTestInOpenGLOffscreenEnvironment("DebugRectProgramParams_Test",
|
||||
std::bind(&TestProgramParams<gpu::DebugRectProgramParams>));
|
||||
}
|
||||
|
||||
UNIT_TEST(ScreenQuadProgramParams_Test)
|
||||
{
|
||||
RunTestInOpenGLOffscreenEnvironment("ScreenQuadProgramParams_Test", false /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::ScreenQuadProgramParams>, _1));
|
||||
|
||||
RunTestInOpenGLOffscreenEnvironment("ScreenQuadProgramParams_Test", true /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::ScreenQuadProgramParams>, _1));
|
||||
RunTestInOpenGLOffscreenEnvironment("ScreenQuadProgramParams_Test",
|
||||
std::bind(&TestProgramParams<gpu::ScreenQuadProgramParams>));
|
||||
}
|
||||
|
||||
UNIT_TEST(SMAAProgramParams_Test)
|
||||
{
|
||||
RunTestInOpenGLOffscreenEnvironment("SMAAProgramParams_Test", false /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::SMAAProgramParams>, _1));
|
||||
|
||||
RunTestInOpenGLOffscreenEnvironment("SMAAProgramParams_Test", true /* apiOpenGLES3 */,
|
||||
std::bind(&TestProgramParams<gpu::SMAAProgramParams>, _1));
|
||||
RunTestInOpenGLOffscreenEnvironment("SMAAProgramParams_Test",
|
||||
std::bind(&TestProgramParams<gpu::SMAAProgramParams>));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
using namespace std::placeholders;
|
||||
|
||||
void CompileShaders(bool apiOpenGLES3, bool enableVTF)
|
||||
void CompileShaders(bool enableVTF)
|
||||
{
|
||||
auto const api = apiOpenGLES3 ? dp::ApiVersion::OpenGLES3 : dp::ApiVersion::OpenGLES2;
|
||||
auto constexpr api = dp::ApiVersion::OpenGLES3;
|
||||
GLFunctions::Init(api);
|
||||
gpu::GLProgramPool pool(api);
|
||||
if (enableVTF)
|
||||
|
@ -24,29 +24,17 @@ void CompileShaders(bool apiOpenGLES3, bool enableVTF)
|
|||
|
||||
// These unit tests create Qt application and OGL context so can't be run in GUI-less Linux machine.
|
||||
#ifdef OMIM_OS_MAC
|
||||
UNIT_TEST(DesktopCompileShaders_GLES2_Test)
|
||||
{
|
||||
RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES2_Test", false /* apiOpenGLES3 */,
|
||||
std::bind(&CompileShaders, _1, false /* enableVTF */));
|
||||
}
|
||||
|
||||
UNIT_TEST(DesktopCompileShaders_GLES3_Test)
|
||||
{
|
||||
RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES3_Test", true /* apiOpenGLES3 */,
|
||||
std::bind(&CompileShaders, _1, false /* enableVTF */));
|
||||
RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES3_Test",
|
||||
std::bind(&CompileShaders, false /* enableVTF */));
|
||||
|
||||
}
|
||||
|
||||
UNIT_TEST(DesktopCompileShaders_GLES2_VTF_Test)
|
||||
{
|
||||
RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES2_VTF_Test", false /* apiOpenGLES3 */,
|
||||
std::bind(&CompileShaders, _1, true /* enableVTF */));
|
||||
}
|
||||
|
||||
UNIT_TEST(DesktopCompileShaders_GLES3_VTF_Test)
|
||||
{
|
||||
RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES3_VTF_Test", true /* apiOpenGLES3 */,
|
||||
std::bind(&CompileShaders, _1, true /* enableVTF */));
|
||||
RunTestInOpenGLOffscreenEnvironment("DesktopCompileShaders_GLES3_VTF_Test",
|
||||
std::bind(&CompileShaders, true /* enableVTF */));
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -26,9 +26,7 @@
|
|||
std::string const kCompilersDir = "shaders_compiler";
|
||||
|
||||
#if defined(OMIM_OS_MAC)
|
||||
std::string const kMaliCompilerOpenGLES2Dir = "macos/mali_compiler";
|
||||
std::string const kMaliCompilerOpenGLES3Dir = "macos/mali_compiler_es3";
|
||||
std::string const kCompilerMaliOpenGLES2 = kMaliCompilerOpenGLES2Dir + "/malisc";
|
||||
std::string const kCompilerMaliOpenGLES3 = kMaliCompilerOpenGLES3Dir + "/malisc";
|
||||
std::string const kCompilerOpenGLES = "macos/glslangValidator";
|
||||
#elif defined(OMIM_OS_LINUX)
|
||||
|
@ -166,29 +164,15 @@ UNIT_TEST(MobileCompileShaders_Test)
|
|||
{
|
||||
base::DelayedThreadPool workerThread(6 /* threadsCount */);
|
||||
|
||||
workerThread.Push([] {
|
||||
CompileShaders({dp::ApiVersion::OpenGLES2, GetCompilerPath(kCompilerOpenGLES)});
|
||||
});
|
||||
|
||||
workerThread.Push([] {
|
||||
CompileShaders({dp::ApiVersion::OpenGLES3, GetCompilerPath(kCompilerOpenGLES)});
|
||||
});
|
||||
|
||||
workerThread.Push([] {
|
||||
CompileShaders({dp::ApiVersion::OpenGLES2, GetCompilerPath(kCompilerOpenGLES)},
|
||||
"#define ENABLE_VTF\n");
|
||||
});
|
||||
|
||||
workerThread.Push([] {
|
||||
CompileShaders({dp::ApiVersion::OpenGLES3, GetCompilerPath(kCompilerOpenGLES)},
|
||||
"#define ENABLE_VTF\n");
|
||||
});
|
||||
|
||||
workerThread.Push([] {
|
||||
CompileShaders({dp::ApiVersion::OpenGLES2, GetCompilerPath(kCompilerOpenGLES)},
|
||||
"#define SAMSUNG_GOOGLE_NEXUS\n");
|
||||
});
|
||||
|
||||
workerThread.Push([] {
|
||||
CompileShaders({dp::ApiVersion::OpenGLES3, GetCompilerPath(kCompilerOpenGLES)},
|
||||
"#define SAMSUNG_GOOGLE_NEXUS\n");
|
||||
|
@ -474,16 +458,6 @@ UNIT_TEST(MALI_MobileCompileShaders_Test)
|
|||
driversES2new.insert(driversES2new.end(), driversES3new.begin(), driversES3new.end());
|
||||
|
||||
std::vector<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,
|
||||
GetCompilerPath(kCompilerMaliOpenGLES3),
|
||||
GetCompilerPath(kMaliCompilerOpenGLES3Dir),
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in a new issue