diff --git a/src/Graphics/OpenGLContext/GLFunctions.cpp b/src/Graphics/OpenGLContext/GLFunctions.cpp index dbca83b2..3567dda2 100644 --- a/src/Graphics/OpenGLContext/GLFunctions.cpp +++ b/src/Graphics/OpenGLContext/GLFunctions.cpp @@ -93,6 +93,7 @@ PFNGLACTIVETEXTUREPROC ptrActiveTexture; PFNGLBLENDCOLORPROC ptrBlendColor; PFNGLREADBUFFERPROC ptrReadBuffer; PFNGLFINISHPROC ptrFinish; +PFNGLFLUSHPROC ptrFlush; #if defined(OS_ANDROID) PFNEGLGETNATIVECLIENTBUFFERANDROIDPROC ptrGetNativeClientBufferANDROID; #endif @@ -243,6 +244,7 @@ void initGLFunctions() GL_GET_PROC_ADR(PFNGLBLENDCOLORPROC, BlendColor); GL_GET_PROC_ADR(PFNGLREADBUFFERPROC, ReadBuffer); GL_GET_PROC_ADR(PFNGLFINISHPROC, Finish); + GL_GET_PROC_ADR(PFNGLFLUSHPROC, Flush); #if defined(OS_ANDROID) GL_GET_PROC_ADR_EGL(PFNEGLGETNATIVECLIENTBUFFERANDROIDPROC, GetNativeClientBufferANDROID); #endif diff --git a/src/Graphics/OpenGLContext/GLFunctions.h b/src/Graphics/OpenGLContext/GLFunctions.h index 8c138e22..d1456927 100644 --- a/src/Graphics/OpenGLContext/GLFunctions.h +++ b/src/Graphics/OpenGLContext/GLFunctions.h @@ -84,6 +84,8 @@ extern PFNGLACTIVETEXTUREPROC ptrActiveTexture; extern PFNGLBLENDCOLORPROC ptrBlendColor; extern PFNGLREADBUFFERPROC ptrReadBuffer; extern PFNGLFINISHPROC ptrFinish; +extern PFNGLFLUSHPROC ptrFlush; + #if defined(OS_ANDROID) extern PFNEGLGETNATIVECLIENTBUFFERANDROIDPROC ptrGetNativeClientBufferANDROID; #endif @@ -235,6 +237,7 @@ void initGLFunctions(); #define glBlendColor(...) opengl::FunctionWrapper::wrBlendColor(__VA_ARGS__) #define glReadBuffer(...) opengl::FunctionWrapper::wrReadBuffer(__VA_ARGS__) #define glFinish(...) opengl::FunctionWrapper::wrFinish(__VA_ARGS__) +#define glFlush(...) opengl::FunctionWrapper::wrFlush(__VA_ARGS__) #if defined(OS_ANDROID) #define eglGetNativeClientBufferANDROID(...) opengl::FunctionWrapper::ewrGetNativeClientBufferANDROID(__VA_ARGS__) #endif diff --git a/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_WrappedFunctions.h b/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_WrappedFunctions.h index 588e6a36..da2811ac 100644 --- a/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_WrappedFunctions.h +++ b/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_WrappedFunctions.h @@ -4750,6 +4750,34 @@ private: } }; +class GlFlushCommand : public OpenGlCommand +{ +public: + GlFlushCommand() : + OpenGlCommand(true, true, "glFlush") + { + } + + static std::shared_ptr get() + { + static int poolId = OpenGlCommandPool::get().getNextAvailablePool(); + auto ptr = getFromPool(poolId); + ptr->set(); + return ptr; + } + + void commandToExecute() override + { + ptrFlush(); + } + +private: + void set() + { + + } +}; + class GlCopyTexImage2DCommand : public OpenGlCommand { public: diff --git a/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_Wrapper.cpp b/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_Wrapper.cpp index f8b6b40f..952c05e7 100644 --- a/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_Wrapper.cpp +++ b/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_Wrapper.cpp @@ -1371,6 +1371,14 @@ namespace opengl { ptrFinish(); } + void FunctionWrapper::wrFlush() + { + if (m_threaded_wrapper) + executeCommand(GlFlushCommand::get()); + else + ptrFlush(); + } + void FunctionWrapper::wrCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { if (m_threaded_wrapper) diff --git a/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_Wrapper.h b/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_Wrapper.h index a01696d3..27210fa8 100644 --- a/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_Wrapper.h +++ b/src/Graphics/OpenGLContext/ThreadedOpenGl/opengl_Wrapper.h @@ -191,6 +191,7 @@ namespace opengl { static void wrDrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const u16* indices, GLint basevertex); static void wrFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length); static void wrFinish(); + static void wrFlush(); static void wrCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); static void wrDebugMessageCallback(GLDEBUGPROC callback, const void *userParam); static void wrDebugMessageControl(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); diff --git a/src/Graphics/OpenGLContext/opengl_ContextImpl.cpp b/src/Graphics/OpenGLContext/opengl_ContextImpl.cpp index c02e2e52..312fd6c2 100644 --- a/src/Graphics/OpenGLContext/opengl_ContextImpl.cpp +++ b/src/Graphics/OpenGLContext/opengl_ContextImpl.cpp @@ -204,11 +204,6 @@ void ContextImpl::clearDepthBuffer() CachedDepthMask * depthMask = m_cachedFunctions->getCachedDepthMask(); enableScissor->enable(false); - if (m_glInfo.renderer == Renderer::PowerVR) { - depthMask->setDepthMask(false); - glClear(GL_DEPTH_BUFFER_BIT); - } - depthMask->setDepthMask(true); glClear(GL_DEPTH_BUFFER_BIT); diff --git a/src/Graphics/OpenGLContext/opengl_GLInfo.cpp b/src/Graphics/OpenGLContext/opengl_GLInfo.cpp index 18fb8ff9..0c98d0e5 100644 --- a/src/Graphics/OpenGLContext/opengl_GLInfo.cpp +++ b/src/Graphics/OpenGLContext/opengl_GLInfo.cpp @@ -167,6 +167,11 @@ void GLInfo::init() { } } + if (renderer == Renderer::PowerVR) { + config.frameBufferEmulation.forceDepthBufferClear = 1; + config.generalEmulation.enableFragmentDepthWrite = 0; + } + depthTexture = !isGLES2 || Utils::isExtensionSupported(*this, "GL_OES_depth_texture"); noPerspective = Utils::isExtensionSupported(*this, "GL_NV_shader_noperspective_interpolation");