mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-07 13:03:54 +00:00
[Drape] Remove GLES2-related code
Signed-off-by: renderexpert <expert@renderconsulting.co.uk>
This commit is contained in:
committed by
Konstantin Pastbin
parent
705c715356
commit
b23c2ba3e3
@@ -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;
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ UNIT_TEST(UploadingGlyphs)
|
||||
TestingGraphicsContext context;
|
||||
Texture::Params p;
|
||||
p.m_allocator = GetDefaultAllocator(make_ref(&context));
|
||||
p.m_format = dp::TextureFormat::Alpha;
|
||||
p.m_format = dp::TextureFormat::Red;
|
||||
p.m_width = p.m_height = kTextureSize;
|
||||
|
||||
DummyTexture tex;
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -244,71 +244,18 @@ void GLFunctions::Init(dp::ApiVersion apiVersion)
|
||||
return;
|
||||
|
||||
CurrentApiVersion = apiVersion;
|
||||
ExtensionsList.Init(apiVersion);
|
||||
ExtensionsList.Init();
|
||||
s_inited = true;
|
||||
|
||||
/// VAO
|
||||
#if !defined(OMIM_OS_WINDOWS)
|
||||
if (CurrentApiVersion == dp::ApiVersion::OpenGLES2)
|
||||
{
|
||||
#if defined(OMIM_OS_MAC)
|
||||
|
||||
glGenVertexArraysFn = &glGenVertexArraysAPPLE;
|
||||
glBindVertexArrayFn = &glBindVertexArrayAPPLE;
|
||||
glDeleteVertexArrayFn = &glDeleteVertexArraysAPPLE;
|
||||
glMapBufferFn = &::glMapBuffer;
|
||||
glUnmapBufferFn = &::glUnmapBuffer;
|
||||
|
||||
#elif defined(OMIM_OS_LINUX)
|
||||
void *libhandle = dlopen("libGL.so.1", RTLD_LAZY);
|
||||
if (!libhandle)
|
||||
LOG(LCRITICAL, ("Failed to open libGL.so.1:", dlerror()));
|
||||
glGenVertexArraysFn = (TglGenVertexArraysFn)dlsym(libhandle,"glGenVertexArraysOES");
|
||||
glBindVertexArrayFn = (TglBindVertexArrayFn)dlsym(libhandle, "glBindVertexArrayOES");
|
||||
glDeleteVertexArrayFn = (TglDeleteVertexArrayFn)dlsym(libhandle,"glDeleteVertexArraysOES");
|
||||
glMapBufferFn = (TglMapBufferFn)dlsym(libhandle, "glMapBufferOES");
|
||||
glUnmapBufferFn = (TglUnmapBufferFn)dlsym(libhandle, "glUnmapBufferOES");
|
||||
glMapBufferRangeFn = (TglMapBufferRangeFn)dlsym(libhandle, "glMapBufferRangeEXT");
|
||||
glFlushMappedBufferRangeFn =
|
||||
(TglFlushMappedBufferRangeFn)dlsym(libhandle, "glFlushMappedBufferRangeEXT");
|
||||
|
||||
#elif defined(OMIM_OS_ANDROID)
|
||||
|
||||
glGenVertexArraysFn = (TglGenVertexArraysFn)eglGetProcAddress("glGenVertexArraysOES");
|
||||
glBindVertexArrayFn = (TglBindVertexArrayFn)eglGetProcAddress("glBindVertexArrayOES");
|
||||
glDeleteVertexArrayFn = (TglDeleteVertexArrayFn)eglGetProcAddress("glDeleteVertexArraysOES");
|
||||
glMapBufferFn = &::glMapBufferOES;
|
||||
glUnmapBufferFn = &::glUnmapBufferOES;
|
||||
glMapBufferRangeFn = (TglMapBufferRangeFn)eglGetProcAddress("glMapBufferRangeEXT");
|
||||
glFlushMappedBufferRangeFn =
|
||||
(TglFlushMappedBufferRangeFn)eglGetProcAddress("glFlushMappedBufferRangeEXT");
|
||||
|
||||
#elif defined(OMIM_OS_MOBILE)
|
||||
|
||||
glGenVertexArraysFn = &glGenVertexArraysOES;
|
||||
glBindVertexArrayFn = &glBindVertexArrayOES;
|
||||
glDeleteVertexArrayFn = &glDeleteVertexArraysOES;
|
||||
glMapBufferFn = &::glMapBufferOES;
|
||||
glUnmapBufferFn = &::glUnmapBufferOES;
|
||||
glMapBufferRangeFn = &::glMapBufferRangeEXT;
|
||||
glFlushMappedBufferRangeFn = &::glFlushMappedBufferRangeEXT;
|
||||
#endif // #if defined(OMIM_OS_MAC)
|
||||
}
|
||||
else if (CurrentApiVersion == dp::ApiVersion::OpenGLES3)
|
||||
{
|
||||
// OpenGL ES3 api is the same for all systems, except WINDOWS.
|
||||
glGenVertexArraysFn = ::glGenVertexArrays;
|
||||
glBindVertexArrayFn = ::glBindVertexArray;
|
||||
glDeleteVertexArrayFn = ::glDeleteVertexArrays;
|
||||
glUnmapBufferFn = ::glUnmapBuffer;
|
||||
glMapBufferRangeFn = ::glMapBufferRange;
|
||||
glFlushMappedBufferRangeFn = ::glFlushMappedBufferRange;
|
||||
glGetStringiFn = ::glGetStringi;
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECK(false, ("Unknown Graphics API"));
|
||||
}
|
||||
// OpenGL ES3 api is the same for all systems, except WINDOWS.
|
||||
glGenVertexArraysFn = ::glGenVertexArrays;
|
||||
glBindVertexArrayFn = ::glBindVertexArray;
|
||||
glDeleteVertexArrayFn = ::glDeleteVertexArrays;
|
||||
glUnmapBufferFn = ::glUnmapBuffer;
|
||||
glMapBufferRangeFn = ::glMapBufferRange;
|
||||
glFlushMappedBufferRangeFn = ::glFlushMappedBufferRange;
|
||||
glGetStringiFn = ::glGetStringi;
|
||||
|
||||
glClearColorFn = LOAD_GL_FUNC(TglClearColorFn, glClearColor);
|
||||
glClearFn = LOAD_GL_FUNC(TglClearFn, glClear);
|
||||
@@ -316,13 +263,9 @@ void GLFunctions::Init(dp::ApiVersion apiVersion)
|
||||
glScissorFn = LOAD_GL_FUNC(TglScissorFn, glScissor);
|
||||
glFlushFn = LOAD_GL_FUNC(TglFlushFn, glFlush);
|
||||
#else // OMIM_OS_WINDOWS
|
||||
if (ExtensionsList.IsSupported(dp::GLExtensionsList::VertexArrayObject))
|
||||
{
|
||||
glGenVertexArraysFn = LOAD_GL_FUNC(TglGenVertexArraysFn, glGenVertexArrays);
|
||||
glBindVertexArrayFn = LOAD_GL_FUNC(TglBindVertexArrayFn, glBindVertexArray);
|
||||
glDeleteVertexArrayFn = LOAD_GL_FUNC(TglDeleteVertexArrayFn, glDeleteVertexArrays);
|
||||
}
|
||||
glMapBufferFn = LOAD_GL_FUNC(TglMapBufferFn, glMapBuffer);
|
||||
glGenVertexArraysFn = LOAD_GL_FUNC(TglGenVertexArraysFn, glGenVertexArrays);
|
||||
glBindVertexArrayFn = LOAD_GL_FUNC(TglBindVertexArrayFn, glBindVertexArray);
|
||||
glDeleteVertexArrayFn = LOAD_GL_FUNC(TglDeleteVertexArrayFn, glDeleteVertexArrays);
|
||||
glUnmapBufferFn = LOAD_GL_FUNC(TglUnmapBufferFn, glUnmapBuffer);
|
||||
glMapBufferRangeFn = LOAD_GL_FUNC(TglMapBufferRangeFn, glMapBufferRange);
|
||||
glFlushMappedBufferRangeFn = LOAD_GL_FUNC(TglFlushMappedBufferRangeFn, glFlushMappedBufferRange);
|
||||
@@ -403,115 +346,94 @@ void GLFunctions::Init(dp::ApiVersion apiVersion)
|
||||
|
||||
bool GLFunctions::glHasExtension(std::string const & name)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
if (CurrentApiVersion == dp::ApiVersion::OpenGLES2)
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGetStringiFn != nullptr, ());
|
||||
GLint n = 0;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
||||
for (GLint i = 0; i < n; i++)
|
||||
{
|
||||
char const * extensions = reinterpret_cast<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(glStencilOpSeparateFn(face, sfail, dpfail, dppass));
|
||||
}
|
||||
|
||||
void GLFunctions::glStencilFuncSeparate(glConst face, glConst func, int ref, uint32_t mask)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(glStencilFuncSeparateFn(face, func, ref, mask));
|
||||
}
|
||||
|
||||
void GLFunctions::glPixelStore(glConst name, uint32_t value)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glPixelStorei(name, value));
|
||||
}
|
||||
|
||||
int32_t GLFunctions::glGetInteger(glConst pname)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLint value;
|
||||
GLCHECK(::glGetIntegerv(pname, &value));
|
||||
return (int32_t)value;
|
||||
@@ -519,7 +441,7 @@ int32_t GLFunctions::glGetInteger(glConst pname)
|
||||
|
||||
std::string GLFunctions::glGetString(glConst pname)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
char const * str = reinterpret_cast<char const *>(::glGetString(pname));
|
||||
GLCHECKCALL();
|
||||
if (str == nullptr)
|
||||
@@ -530,7 +452,7 @@ std::string GLFunctions::glGetString(glConst pname)
|
||||
|
||||
int32_t GLFunctions::glGetMaxLineWidth()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLint range[2];
|
||||
GLCHECK(::glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, range));
|
||||
return std::max(range[0], range[1]);
|
||||
@@ -538,7 +460,7 @@ int32_t GLFunctions::glGetMaxLineWidth()
|
||||
|
||||
int32_t GLFunctions::glGetBufferParameter(glConst target, glConst name)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLint result;
|
||||
ASSERT(glGetBufferParameterFn != nullptr, ());
|
||||
GLCHECK(glGetBufferParameterFn(target, name, &result));
|
||||
@@ -547,19 +469,19 @@ int32_t GLFunctions::glGetBufferParameter(glConst target, glConst name)
|
||||
|
||||
void GLFunctions::glEnable(glConst mode)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glEnable(mode));
|
||||
}
|
||||
|
||||
void GLFunctions::glDisable(glConst mode)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glDisable(mode));
|
||||
}
|
||||
|
||||
void GLFunctions::glClearDepthValue(double depth)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
#if defined(OMIM_OS_IPHONE) || defined(OMIM_OS_ANDROID) || defined(OMIM_OS_LINUX)
|
||||
GLCHECK(::glClearDepthf(static_cast<GLclampf>(depth)));
|
||||
#else
|
||||
@@ -569,32 +491,32 @@ void GLFunctions::glClearDepthValue(double depth)
|
||||
|
||||
void GLFunctions::glDepthMask(bool needWriteToDepthBuffer)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glDepthMask(convert(needWriteToDepthBuffer)));
|
||||
}
|
||||
|
||||
void GLFunctions::glDepthFunc(glConst depthFunc)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glDepthFunc(depthFunc));
|
||||
}
|
||||
|
||||
void GLFunctions::glBlendEquation(glConst function)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glBlendEquationFn != nullptr, ());
|
||||
GLCHECK(glBlendEquationFn(function));
|
||||
}
|
||||
|
||||
void GLFunctions::glBlendFunc(glConst srcFactor, glConst dstFactor)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glBlendFunc(srcFactor, dstFactor));
|
||||
}
|
||||
|
||||
bool GLFunctions::CanEnableDebugMessages()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
if (glDebugMessageCallbackFn == nullptr)
|
||||
return false;
|
||||
if (glDebugMessageControlFn == nullptr)
|
||||
@@ -606,7 +528,7 @@ bool GLFunctions::CanEnableDebugMessages()
|
||||
|
||||
void GLFunctions::glDebugMessageCallback(TglDebugProc messageCallback, void * userParam)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDebugMessageCallbackFn != nullptr, ());
|
||||
GLCHECK(glDebugMessageCallbackFn(reinterpret_cast<GLDEBUGPROC>(messageCallback), userParam));
|
||||
}
|
||||
@@ -614,14 +536,14 @@ void GLFunctions::glDebugMessageCallback(TglDebugProc messageCallback, void * us
|
||||
void GLFunctions::glDebugMessageControl(glConst source, glConst type, glConst severity,
|
||||
int32_t count, uint32_t const * ids, uint8_t enabled)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDebugMessageControlFn != nullptr, ());
|
||||
GLCHECK(glDebugMessageControlFn(source, type, severity, count, ids, enabled));
|
||||
}
|
||||
|
||||
uint32_t GLFunctions::glGenVertexArray()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGenVertexArraysFn != nullptr, ());
|
||||
GLuint result = std::numeric_limits<GLuint>::max();
|
||||
GLCHECK(glGenVertexArraysFn(1, &result));
|
||||
@@ -630,21 +552,21 @@ uint32_t GLFunctions::glGenVertexArray()
|
||||
|
||||
void GLFunctions::glBindVertexArray(uint32_t vao)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glBindVertexArrayFn != nullptr, ());
|
||||
GLCHECK(glBindVertexArrayFn(vao));
|
||||
}
|
||||
|
||||
void GLFunctions::glDeleteVertexArray(uint32_t vao)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDeleteVertexArrayFn != nullptr, ());
|
||||
GLCHECK(glDeleteVertexArrayFn(1, &vao));
|
||||
}
|
||||
|
||||
uint32_t GLFunctions::glGenBuffer()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGenBuffersFn != nullptr, ());
|
||||
GLuint result = std::numeric_limits<GLuint>::max();
|
||||
GLCHECK(glGenBuffersFn(1, &result));
|
||||
@@ -653,7 +575,7 @@ uint32_t GLFunctions::glGenBuffer()
|
||||
|
||||
void GLFunctions::glBindBuffer(uint32_t vbo, uint32_t target)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glBindBufferFn != nullptr, ());
|
||||
#ifdef DEBUG
|
||||
std::lock_guard<std::mutex> guard(g_boundBuffersMutex);
|
||||
@@ -664,7 +586,7 @@ void GLFunctions::glBindBuffer(uint32_t vbo, uint32_t target)
|
||||
|
||||
void GLFunctions::glDeleteBuffer(uint32_t vbo)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDeleteBuffersFn != nullptr, ());
|
||||
#ifdef DEBUG
|
||||
std::lock_guard<std::mutex> guard(g_boundBuffersMutex);
|
||||
@@ -676,21 +598,21 @@ void GLFunctions::glDeleteBuffer(uint32_t vbo)
|
||||
|
||||
void GLFunctions::glBufferData(glConst target, uint32_t size, void const * data, glConst usage)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glBufferDataFn != nullptr, ());
|
||||
GLCHECK(glBufferDataFn(target, size, data, usage));
|
||||
}
|
||||
|
||||
void GLFunctions::glBufferSubData(glConst target, uint32_t size, void const * data, uint32_t offset)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glBufferSubDataFn != nullptr, ());
|
||||
GLCHECK(glBufferSubDataFn(target, offset, size, data));
|
||||
}
|
||||
|
||||
void * GLFunctions::glMapBuffer(glConst target, glConst access)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glMapBufferFn != nullptr, ());
|
||||
void * result = glMapBufferFn(target, access);
|
||||
GLCHECKCALL();
|
||||
@@ -699,7 +621,7 @@ void * GLFunctions::glMapBuffer(glConst target, glConst access)
|
||||
|
||||
void GLFunctions::glUnmapBuffer(glConst target)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUnmapBufferFn != nullptr, ());
|
||||
VERIFY(glUnmapBufferFn(target) == GL_TRUE, ());
|
||||
GLCHECKCALL();
|
||||
@@ -708,7 +630,7 @@ void GLFunctions::glUnmapBuffer(glConst target)
|
||||
void * GLFunctions::glMapBufferRange(glConst target, uint32_t offset, uint32_t length,
|
||||
glConst access)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glMapBufferRangeFn != nullptr, ());
|
||||
void * result = glMapBufferRangeFn(target, offset, length, access);
|
||||
GLCHECKCALL();
|
||||
@@ -717,14 +639,14 @@ void * GLFunctions::glMapBufferRange(glConst target, uint32_t offset, uint32_t l
|
||||
|
||||
void GLFunctions::glFlushMappedBufferRange(glConst target, uint32_t offset, uint32_t length)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glFlushMappedBufferRangeFn != nullptr, ());
|
||||
GLCHECK(glFlushMappedBufferRangeFn(target, offset, length));
|
||||
}
|
||||
|
||||
uint32_t GLFunctions::glCreateShader(glConst type)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glCreateShaderFn != nullptr, ());
|
||||
GLuint result = glCreateShaderFn(type);
|
||||
GLCHECKCALL();
|
||||
@@ -733,7 +655,7 @@ uint32_t GLFunctions::glCreateShader(glConst type)
|
||||
|
||||
void GLFunctions::glShaderSource(uint32_t shaderID, std::string const & src, std::string const & defines)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glShaderSourceFn != nullptr, ());
|
||||
|
||||
std::string fullSrc;
|
||||
@@ -756,7 +678,7 @@ void GLFunctions::glShaderSource(uint32_t shaderID, std::string const & src, std
|
||||
|
||||
bool GLFunctions::glCompileShader(uint32_t shaderID, std::string & errorLog)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glCompileShaderFn != nullptr, ());
|
||||
ASSERT(glGetShaderivFn != nullptr, ());
|
||||
ASSERT(glGetShaderInfoLogFn != nullptr, ());
|
||||
@@ -776,14 +698,14 @@ bool GLFunctions::glCompileShader(uint32_t shaderID, std::string & errorLog)
|
||||
|
||||
void GLFunctions::glDeleteShader(uint32_t shaderID)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDeleteShaderFn != nullptr, ());
|
||||
GLCHECK(glDeleteBuffersFn(1, &shaderID));
|
||||
}
|
||||
|
||||
uint32_t GLFunctions::glCreateProgram()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glCreateProgramFn != nullptr, ());
|
||||
GLuint result = glCreateProgramFn();
|
||||
GLCHECKCALL();
|
||||
@@ -792,21 +714,21 @@ uint32_t GLFunctions::glCreateProgram()
|
||||
|
||||
void GLFunctions::glAttachShader(uint32_t programID, uint32_t shaderID)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glAttachShaderFn != nullptr, ());
|
||||
GLCHECK(glAttachShaderFn(programID, shaderID));
|
||||
}
|
||||
|
||||
void GLFunctions::glDetachShader(uint32_t programID, uint32_t shaderID)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDetachShaderFn != nullptr, ());
|
||||
GLCHECK(glDetachShaderFn(programID, shaderID));
|
||||
}
|
||||
|
||||
bool GLFunctions::glLinkProgram(uint32_t programID, std::string & errorLog)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glLinkProgramFn != nullptr, ());
|
||||
ASSERT(glGetProgramivFn != nullptr, ());
|
||||
ASSERT(glGetProgramInfoLogFn != nullptr, ());
|
||||
@@ -827,21 +749,21 @@ bool GLFunctions::glLinkProgram(uint32_t programID, std::string & errorLog)
|
||||
|
||||
void GLFunctions::glDeleteProgram(uint32_t programID)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDeleteProgramFn != nullptr, ());
|
||||
GLCHECK(glDeleteProgramFn(programID));
|
||||
}
|
||||
|
||||
void GLFunctions::glUseProgram(uint32_t programID)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUseProgramFn != nullptr, ());
|
||||
GLCHECK(glUseProgramFn(programID));
|
||||
}
|
||||
|
||||
int8_t GLFunctions::glGetAttribLocation(uint32_t programID, std::string const & name)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGetAttribLocationFn != nullptr, ());
|
||||
int result = glGetAttribLocationFn(programID, name.c_str());
|
||||
GLCHECKCALL();
|
||||
@@ -851,14 +773,14 @@ int8_t GLFunctions::glGetAttribLocation(uint32_t programID, std::string const &
|
||||
|
||||
void GLFunctions::glBindAttribLocation(uint32_t programID, uint8_t index, std::string const & name)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glBindAttribLocationFn != nullptr, ());
|
||||
GLCHECK(glBindAttribLocationFn(programID, index, name.c_str()));
|
||||
}
|
||||
|
||||
void GLFunctions::glEnableVertexAttribute(int attributeLocation)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glEnableVertexAttributeFn != nullptr, ());
|
||||
GLCHECK(glEnableVertexAttributeFn(attributeLocation));
|
||||
}
|
||||
@@ -866,7 +788,7 @@ void GLFunctions::glEnableVertexAttribute(int attributeLocation)
|
||||
void GLFunctions::glVertexAttributePointer(int attrLocation, uint32_t count, glConst type,
|
||||
bool needNormalize, uint32_t stride, uint32_t offset)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glVertexAttributePointerFn != nullptr, ());
|
||||
GLCHECK(glVertexAttributePointerFn(attrLocation, count, type, convert(needNormalize), stride,
|
||||
reinterpret_cast<void *>(offset)));
|
||||
@@ -875,7 +797,7 @@ void GLFunctions::glVertexAttributePointer(int attrLocation, uint32_t count, glC
|
||||
void GLFunctions::glGetActiveUniform(uint32_t programID, uint32_t uniformIndex,
|
||||
int32_t * uniformSize, glConst * type, std::string & name)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGetActiveUniformFn != nullptr, ());
|
||||
GLchar buff[256];
|
||||
GLCHECK(glGetActiveUniformFn(programID, uniformIndex, ARRAY_SIZE(buff), nullptr, uniformSize,
|
||||
@@ -885,7 +807,7 @@ void GLFunctions::glGetActiveUniform(uint32_t programID, uint32_t uniformIndex,
|
||||
|
||||
int8_t GLFunctions::glGetUniformLocation(uint32_t programID, std::string const & name)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGetUniformLocationFn != nullptr, ());
|
||||
int result = glGetUniformLocationFn(programID, name.c_str());
|
||||
GLCHECKCALL();
|
||||
@@ -895,7 +817,7 @@ int8_t GLFunctions::glGetUniformLocation(uint32_t programID, std::string const &
|
||||
|
||||
void GLFunctions::glUniformValuei(int8_t location, int32_t v)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform1iFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform1iFn(location, v));
|
||||
@@ -903,7 +825,7 @@ void GLFunctions::glUniformValuei(int8_t location, int32_t v)
|
||||
|
||||
void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform2iFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform2iFn(location, v1, v2));
|
||||
@@ -911,7 +833,7 @@ void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2)
|
||||
|
||||
void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2, int32_t v3)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform3iFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform3iFn(location, v1, v2, v3));
|
||||
@@ -919,7 +841,7 @@ void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2, int32
|
||||
|
||||
void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2, int32_t v3, int32_t v4)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform4iFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform4iFn(location, v1, v2, v3, v4));
|
||||
@@ -927,7 +849,7 @@ void GLFunctions::glUniformValuei(int8_t location, int32_t v1, int32_t v2, int32
|
||||
|
||||
void GLFunctions::glUniformValueiv(int8_t location, int32_t * v, uint32_t size)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform1ivFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform1ivFn(location, size, v));
|
||||
@@ -935,7 +857,7 @@ void GLFunctions::glUniformValueiv(int8_t location, int32_t * v, uint32_t size)
|
||||
|
||||
void GLFunctions::glUniformValuef(int8_t location, float v)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform1fFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform1fFn(location, v));
|
||||
@@ -943,7 +865,7 @@ void GLFunctions::glUniformValuef(int8_t location, float v)
|
||||
|
||||
void GLFunctions::glUniformValuef(int8_t location, float v1, float v2)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform2fFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform2fFn(location, v1, v2));
|
||||
@@ -951,7 +873,7 @@ void GLFunctions::glUniformValuef(int8_t location, float v1, float v2)
|
||||
|
||||
void GLFunctions::glUniformValuef(int8_t location, float v1, float v2, float v3)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform3fFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform3fFn(location, v1, v2, v3));
|
||||
@@ -959,7 +881,7 @@ void GLFunctions::glUniformValuef(int8_t location, float v1, float v2, float v3)
|
||||
|
||||
void GLFunctions::glUniformValuef(int8_t location, float v1, float v2, float v3, float v4)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform4fFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform4fFn(location, v1, v2, v3, v4));
|
||||
@@ -967,7 +889,7 @@ void GLFunctions::glUniformValuef(int8_t location, float v1, float v2, float v3,
|
||||
|
||||
void GLFunctions::glUniformValuefv(int8_t location, float * v, uint32_t size)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniform1fvFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniform1fvFn(location, size, v));
|
||||
@@ -975,7 +897,7 @@ void GLFunctions::glUniformValuefv(int8_t location, float * v, uint32_t size)
|
||||
|
||||
void GLFunctions::glUniformMatrix4x4Value(int8_t location, float const * values)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glUniformMatrix4fvFn != nullptr, ());
|
||||
ASSERT(location != -1, ());
|
||||
GLCHECK(glUniformMatrix4fvFn(location, 1, GL_FALSE, values));
|
||||
@@ -983,7 +905,7 @@ void GLFunctions::glUniformMatrix4x4Value(int8_t location, float const * values)
|
||||
|
||||
uint32_t GLFunctions::glGetCurrentProgram()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLint programIndex = 0;
|
||||
GLCHECK(glGetIntegerv(GL_CURRENT_PROGRAM, &programIndex));
|
||||
ASSERT_GREATER_OR_EQUAL(programIndex, 0, ());
|
||||
@@ -992,7 +914,7 @@ uint32_t GLFunctions::glGetCurrentProgram()
|
||||
|
||||
int32_t GLFunctions::glGetProgramiv(uint32_t program, glConst paramName)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGetProgramivFn != nullptr, ());
|
||||
GLint paramValue = 0;
|
||||
GLCHECK(glGetProgramivFn(program, paramName, ¶mValue));
|
||||
@@ -1001,14 +923,14 @@ int32_t GLFunctions::glGetProgramiv(uint32_t program, glConst paramName)
|
||||
|
||||
void GLFunctions::glActiveTexture(glConst texBlock)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glActiveTextureFn != nullptr, ());
|
||||
GLCHECK(glActiveTextureFn(texBlock));
|
||||
}
|
||||
|
||||
uint32_t GLFunctions::glGenTexture()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLuint result = std::numeric_limits<GLuint>::max();
|
||||
GLCHECK(::glGenTextures(1, &result));
|
||||
return result;
|
||||
@@ -1016,20 +938,20 @@ uint32_t GLFunctions::glGenTexture()
|
||||
|
||||
void GLFunctions::glDeleteTexture(uint32_t id)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glDeleteTextures(1, &id));
|
||||
}
|
||||
|
||||
void GLFunctions::glBindTexture(uint32_t textureID)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glBindTexture(GL_TEXTURE_2D, textureID));
|
||||
}
|
||||
|
||||
void GLFunctions::glTexImage2D(int width, int height, glConst layout, glConst pixelType,
|
||||
void const * data)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
// In OpenGL ES3:
|
||||
// - we can't create unsized GL_RED texture, so we use GL_R8;
|
||||
// - we can't create unsized GL_RG texture, so we use GL_RG8;
|
||||
@@ -1068,20 +990,20 @@ void GLFunctions::glTexImage2D(int width, int height, glConst layout, glConst pi
|
||||
void GLFunctions::glTexSubImage2D(int x, int y, int width, int height, glConst layout,
|
||||
glConst pixelType, void const * data)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, layout, pixelType, data));
|
||||
}
|
||||
|
||||
void GLFunctions::glTexParameter(glConst param, glConst value)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glTexParameteri(GL_TEXTURE_2D, param, value));
|
||||
}
|
||||
|
||||
void GLFunctions::glDrawElements(glConst primitive, uint32_t sizeOfIndex, uint32_t indexCount,
|
||||
uint32_t startIndex)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glDrawElements(primitive, indexCount,
|
||||
sizeOfIndex == sizeof(uint32_t) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT,
|
||||
reinterpret_cast<GLvoid *>(startIndex * sizeOfIndex)));
|
||||
@@ -1089,41 +1011,41 @@ void GLFunctions::glDrawElements(glConst primitive, uint32_t sizeOfIndex, uint32
|
||||
|
||||
void GLFunctions::glDrawArrays(glConst mode, int32_t first, uint32_t count)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glDrawArrays(mode, first, count));
|
||||
}
|
||||
|
||||
void GLFunctions::glGenFramebuffer(uint32_t * fbo)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glGenFramebuffersFn != nullptr, ());
|
||||
GLCHECK(glGenFramebuffersFn(1, fbo));
|
||||
}
|
||||
|
||||
void GLFunctions::glDeleteFramebuffer(uint32_t * fbo)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glDeleteFramebuffersFn != nullptr, ());
|
||||
GLCHECK(glDeleteFramebuffersFn(1, fbo));
|
||||
}
|
||||
|
||||
void GLFunctions::glFramebufferTexture2D(glConst attachment, glConst texture)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glFramebufferTexture2DFn != nullptr, ());
|
||||
GLCHECK(glFramebufferTexture2DFn(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, texture, 0));
|
||||
}
|
||||
|
||||
void GLFunctions::glBindFramebuffer(uint32_t fbo)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glBindFramebufferFn != nullptr, ());
|
||||
GLCHECK(glBindFramebufferFn(GL_FRAMEBUFFER, fbo));
|
||||
}
|
||||
|
||||
uint32_t GLFunctions::glCheckFramebufferStatus()
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
ASSERT(glCheckFramebufferStatusFn != nullptr, ());
|
||||
uint32_t const result = glCheckFramebufferStatusFn(GL_FRAMEBUFFER);
|
||||
GLCHECKCALL();
|
||||
@@ -1132,7 +1054,7 @@ uint32_t GLFunctions::glCheckFramebufferStatus()
|
||||
|
||||
void GLFunctions::glLineWidth(uint32_t value)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLCHECK(::glLineWidth(static_cast<float>(value)));
|
||||
}
|
||||
|
||||
@@ -1153,7 +1075,7 @@ std::string GetGLError(GLenum error)
|
||||
|
||||
void CheckGLError(base::SrcPoint const & srcPoint)
|
||||
{
|
||||
ASSERT_NOT_EQUAL(GLFunctions::CurrentApiVersion, dp::ApiVersion::Invalid, ());
|
||||
ASSERT_EQUAL(GLFunctions::CurrentApiVersion, dp::ApiVersion::OpenGLES3, ());
|
||||
GLenum result = glGetError();
|
||||
while (result != GL_NO_ERROR)
|
||||
{
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -176,7 +176,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);
|
||||
|
||||
@@ -139,7 +139,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));
|
||||
|
||||
@@ -184,7 +184,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.
|
||||
@@ -303,7 +303,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.
|
||||
@@ -324,16 +324,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>();
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ VkFormat VulkanFormatUnpacker::Unpack(TextureFormat format)
|
||||
switch (format)
|
||||
{
|
||||
case TextureFormat::RGBA8: return VK_FORMAT_R8G8B8A8_UNORM;
|
||||
case TextureFormat::Alpha: return VK_FORMAT_R8_UNORM;
|
||||
case TextureFormat::Red: return VK_FORMAT_R8_UNORM;
|
||||
case TextureFormat::RedGreen: return VK_FORMAT_R8G8_UNORM;
|
||||
#if defined(OMIM_OS_MAC)
|
||||
case TextureFormat::DepthStencil: return VK_FORMAT_D32_SFLOAT_S8_UINT;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1424,7 +1424,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView, bool activeFram
|
||||
RefreshBgColor();
|
||||
|
||||
uint32_t clearBits = dp::ClearBits::ColorBit | dp::ClearBits::DepthBit;
|
||||
if (m_apiVersion == dp::ApiVersion::OpenGLES2 || m_apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (m_apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
clearBits |= dp::ClearBits::StencilBit;
|
||||
|
||||
uint32_t storeBits = dp::ClearBits::ColorBit;
|
||||
@@ -1522,7 +1522,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView, bool activeFram
|
||||
if (IsValidCurrentZoom())
|
||||
{
|
||||
uint32_t clearBits = dp::ClearBits::DepthBit;
|
||||
if (m_apiVersion == dp::ApiVersion::OpenGLES2 || m_apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
if (m_apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
clearBits |= dp::ClearBits::StencilBit;
|
||||
m_context->Clear(clearBits, dp::kClearBitsStoreAll);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user