From ba222f72b8d074f00d63d72897b293d3409f9db3 Mon Sep 17 00:00:00 2001 From: Jeff Gilbert Date: Thu, 8 Nov 2018 17:19:02 +0000 Subject: [PATCH] Bug 1492580 - Limit glGetError flush loop and handle CONTEXT_LOST. r=lsalzman Differential Revision: https://phabricator.services.mozilla.com/D11270 --HG-- extra : moz-landing-system : lando --- gfx/gl/GLContext.cpp | 24 ++++++++++++++++++++++++ gfx/gl/GLContext.h | 13 +------------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp index 6363a4b7c60b..5a083fafc6ff 100644 --- a/gfx/gl/GLContext.cpp +++ b/gfx/gl/GLContext.cpp @@ -2058,6 +2058,30 @@ GLContext::MarkDestroyed() mSymbols = {}; } +// - + +GLenum +GLContext::RawGetErrorAndClear() const +{ + const GLenum ret = mSymbols.fGetError(); + + auto flushedErr = ret; + uint32_t i = 1; + while (flushedErr && flushedErr != LOCAL_GL_CONTEXT_LOST) { + if (i == 100) { + gfxCriticalError() << "Flushing glGetError still " << gfx::hexa(flushedErr) + << " after " << i << " calls."; + break; + } + flushedErr = mSymbols.fGetError(); + i += 1; + } + + return ret; +} + +// - + #ifdef MOZ_GL_DEBUG /* static */ void GLContext::AssertNotPassingStackBufferToTheGL(const void* ptr) diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h index c0f5d2d191c1..ae299422b6fc 100644 --- a/gfx/gl/GLContext.h +++ b/gfx/gl/GLContext.h @@ -579,18 +579,7 @@ public: private: mutable GLenum mTopError = 0; - GLenum RawGetError() const { - return mSymbols.fGetError(); - } - - GLenum RawGetErrorAndClear() const { - GLenum err = RawGetError(); - - if (err) - while (RawGetError()) {} - - return err; - } + GLenum RawGetErrorAndClear() const; GLenum FlushErrors() const { GLenum err = RawGetErrorAndClear();