From 96ff181779fed2688857b38c02de320cb255eb12 Mon Sep 17 00:00:00 2001 From: ExMix Date: Tue, 22 Oct 2013 16:00:41 +0300 Subject: [PATCH] [note-3 fix] call glFlush only on iOS, where we has multithreaded opengl --- graphics/opengl/buffer_object.cpp | 2 +- graphics/opengl/geometry_renderer.cpp | 4 ++-- graphics/opengl/gl_procedures.inl | 1 + graphics/opengl/opengl.cpp | 1 + graphics/opengl/opengl.hpp | 1 + graphics/opengl/opengl_es2.cpp | 14 ++++++++++++++ graphics/opengl/opengl_ext.cpp | 1 + graphics/opengl/texture.hpp | 4 ++-- 8 files changed, 23 insertions(+), 5 deletions(-) diff --git a/graphics/opengl/buffer_object.cpp b/graphics/opengl/buffer_object.cpp index 6267749b33..2e295f8cbd 100644 --- a/graphics/opengl/buffer_object.cpp +++ b/graphics/opengl/buffer_object.cpp @@ -52,7 +52,7 @@ namespace graphics /// resource update made in one thread to the another thread is /// to call the glFlush in thread, which modifies resource and then rebind /// resource in another threads that is using this resource, if any. - OGLCHECK(glFlush()); + OGLCHECK(glFlushFn()); } } } diff --git a/graphics/opengl/geometry_renderer.cpp b/graphics/opengl/geometry_renderer.cpp index 8a40318220..64c2e8e9c5 100644 --- a/graphics/opengl/geometry_renderer.cpp +++ b/graphics/opengl/geometry_renderer.cpp @@ -126,7 +126,7 @@ namespace graphics /// resource update made in one thread to the another thread is /// to call the glFlush in thread, which modifies resource and then rebind /// resource in another threads that is using this resource, if any. - OGLCHECK(glFlush()); + OGLCHECK(glFlushFn()); static_cast(m_texture.get())->unlock(); } @@ -390,7 +390,7 @@ namespace graphics /// resource update made in one thread to the another thread is /// to call the glFlush in thread, which modifies resource and then rebind /// resource in another threads that is using this resource, if any. - OGLCHECK(glFlush()); + OGLCHECK(glFlushFn()); } else LOG(LDEBUG, ("no storage to unlock")); diff --git a/graphics/opengl/gl_procedures.inl b/graphics/opengl/gl_procedures.inl index 8f13fba3c3..657cc0395d 100644 --- a/graphics/opengl/gl_procedures.inl +++ b/graphics/opengl/gl_procedures.inl @@ -2,6 +2,7 @@ // buffer objects extensions +DEFINE_GL_RPOC("glFlush", glFlushFn); DEFINE_GL_PROC("glActiveTexture", glActiveTextureFn) DEFINE_GL_PROC("glGetAttribLocation", glGetAttribLocationFn) DEFINE_GL_PROC("glGetActiveAttrib", glGetActiveAttribFn) diff --git a/graphics/opengl/opengl.cpp b/graphics/opengl/opengl.cpp index a56bb9991b..9c21566603 100644 --- a/graphics/opengl/opengl.cpp +++ b/graphics/opengl/opengl.cpp @@ -103,6 +103,7 @@ namespace graphics void (OPENGL_CALLING_CONVENTION * glLoadMatrixfFn) (const GLfloat *m); void (OPENGL_CALLING_CONVENTION * glOrthoFn) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); void (OPENGL_CALLING_CONVENTION * glDrawElementsFn) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); + void (OPENGL_CALLING_CONVENTION * glFlushFn)(); bool g_isBufferObjectsSupported = true; bool g_isMapBufferSupported = true; diff --git a/graphics/opengl/opengl.hpp b/graphics/opengl/opengl.hpp index c99c897cf6..69dafad02a 100644 --- a/graphics/opengl/opengl.hpp +++ b/graphics/opengl/opengl.hpp @@ -85,6 +85,7 @@ namespace graphics extern void (OPENGL_CALLING_CONVENTION * glOrthoFn) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); extern void (OPENGL_CALLING_CONVENTION * glDrawElementsFn) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); + extern void (OPENGL_CALLING_CONVENTION * glFlushFn)(); extern const GLenum GL_MODELVIEW_MWM; extern const GLenum GL_PROJECTION_MWM; diff --git a/graphics/opengl/opengl_es2.cpp b/graphics/opengl/opengl_es2.cpp index 1fca434abb..1fb9bfa7e2 100644 --- a/graphics/opengl/opengl_es2.cpp +++ b/graphics/opengl/opengl_es2.cpp @@ -19,6 +19,14 @@ namespace graphics { namespace gl { + +#ifndef OMIM_OS_IPHONE + namespace + { + void emptyFlushFn() {} + } +#endif + const int GL_FRAMEBUFFER_BINDING_MWM = GL_FRAMEBUFFER_BINDING; const int GL_FRAMEBUFFER_MWM = GL_FRAMEBUFFER; const int GL_FRAMEBUFFER_UNSUPPORTED_MWM = GL_FRAMEBUFFER_UNSUPPORTED; @@ -59,6 +67,12 @@ namespace graphics glUnmapBufferFn = &glUnmapBufferOES; #endif +#ifdef OMIM_OS_IPHONE + glFlushFn = &glFlush; +#else + glFlushFn = &emptyFlushFn; +#endif + g_isFramebufferSupported = true; glBindFramebufferFn = &glBindFramebuffer; diff --git a/graphics/opengl/opengl_ext.cpp b/graphics/opengl/opengl_ext.cpp index 71fcc20908..59cc975b1b 100644 --- a/graphics/opengl/opengl_ext.cpp +++ b/graphics/opengl/opengl_ext.cpp @@ -63,6 +63,7 @@ namespace graphics g_isSeparateBlendFuncSupported = HasExtension("GL_EXT_blend_func_separate"); glBlendFuncSeparateFn = &glBlendFuncSeparateEXT; + glFlushFn = &glFlush; glActiveTextureFn = &glActiveTexture; glGetAttribLocationFn = &glGetAttribLocation; diff --git a/graphics/opengl/texture.hpp b/graphics/opengl/texture.hpp index e860cb5fcf..617737a2b9 100644 --- a/graphics/opengl/texture.hpp +++ b/graphics/opengl/texture.hpp @@ -59,7 +59,7 @@ namespace graphics /// resource update made in one thread to the another thread is /// to call the glFlush in thread, which modifies resource and then rebind /// resource in another threads that is using this resource, if any. - OGLCHECK(glFlush()); + OGLCHECK(glFlushFn()); } @@ -238,7 +238,7 @@ namespace graphics /// resource update made in one thread to the another thread is /// to call the glFlush in thread, which modifies resource and then rebind /// resource in another threads that is using this resource, if any. - OGLCHECK(glFlush()); + OGLCHECK(glFlushFn()); } template