Changeset 275097 in webkit
- Timestamp:
- Mar 26, 2021, 8:34:49 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm (modified) (6 diffs)
-
platform/graphics/opengl/GraphicsContextGLOpenGL.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r275092 r275097 1 2021-03-26 Kimmo Kinnunen <kkinnunen@apple.com> 2 3 GraphicsContextGLOpenGL should avoid calling into ANGLE MakeCurrent 4 https://bugs.webkit.org/show_bug.cgi?id=223511 5 6 Reviewed by Kenneth Russell. 7 8 Avoid calling ANGLE MakeCurrent for contexts that are already current. Cache the current context pointer into a 9 global variable. Currently the code adds no locking. For the forseeable future, ANGLE does not support 10 simultaneous access from multiple threads. 11 12 The optimization can be done when run in WebContent process or in GPU process, but not when in WK1. This is because in WK1, 13 the 3rd party client may run arbitrary code in WebKit thread. This includes code that changes EAGL or AGL state. 14 This code might change the current context underneath WebKit. In WK1 mode, we already use "volatile context" feature of 15 ANGLE to reset the platform context on every EGL command. The command we use for this for normal GL commands is EGL_MakeCurrent. 16 Makes in-process WebGL faster in MotionMark triangles by 6300 -> 9800 pts 17 Makes GPU process WebGL faster in MotionMark triangles by 5300 -> 7000 pts 18 19 * platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm: 20 (WebCore::isCurrentContextPredictable): 21 (WebCore::InitializeEGLDisplay): 22 (WebCore::GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL): 23 (WebCore::GraphicsContextGLOpenGL::makeContextCurrent): 24 (WebCore::GraphicsContextGLOpenGL::clearCurrentContext): 25 (WebCore::GraphicsContextGLOpenGL::releaseCurrentContext): 26 (WebCore::GraphicsContextGLOpenGL::checkGPUStatus): 27 * platform/graphics/opengl/GraphicsContextGLOpenGL.h: 28 1 29 2021-03-25 Antoine Quint <graouts@webkit.org> 2 30 -
trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm
r274750 r275097 50 50 namespace WebCore { 51 51 52 // In isCurrentContextPredictable() == true case this variable is accessed in single-threaded manner. 53 // In isCurrentContextPredictable() == false case this variable is accessed from multiple threads but always sequentially 54 // and it always contains nullptr and nullptr is always written to it. 55 static GraphicsContextGLOpenGL* currentContext; 56 57 static bool isCurrentContextPredictable() 58 { 59 static bool value = isInWebProcess() || isInGPUProcess(); 60 return value; 61 } 62 52 63 #if ASSERT_ENABLED 53 64 // Returns true if we have volatile context extension for the particular API or … … 83 94 84 95 // FIXME: This should come in from the GraphicsContextGLAttributes. 85 bool shouldInitializeWithVolatileContextSupport = ! (isInWebProcess() || isInGPUProcess());96 bool shouldInitializeWithVolatileContextSupport = !isCurrentContextPredictable(); 86 97 if (shouldInitializeWithVolatileContextSupport) { 87 98 // For WK1 type APIs we need to set "volatile platform context" for specific … … 374 385 } 375 386 if (m_contextObj) { 376 EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);387 clearCurrentContext(); 377 388 EGL_DestroyContext(m_displayObj, m_contextObj); 378 } 379 389 } else 390 ASSERT(currentContext != this); 380 391 LOG(WebGL, "Destroyed a GraphicsContextGLOpenGL (%p).", this); 381 392 } … … 428 439 if (!m_displayBufferBacking && !getInternalFramebufferSize().isEmpty()) 429 440 return false; 430 // ANGLE has an early out for case where nothing changes. Calling MakeCurrent 431 // is important to set volatile platform context. See InitializeEGLDisplay(). 441 if (currentContext == this) 442 return true; 443 // Calling MakeCurrent is important to set volatile platform context. See InitializeEGLDisplay(). 432 444 if (!EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, m_contextObj)) 433 445 return false; 446 if (isCurrentContextPredictable()) 447 currentContext = this; 434 448 return true; 449 } 450 451 void GraphicsContextGLOpenGL::clearCurrentContext() 452 { 453 EGLBoolean result = EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); 454 ASSERT_UNUSED(result, result); 455 currentContext = nullptr; 435 456 } 436 457 … … 439 460 { 440 461 // At the moment this function is relevant only when web thread lock owns the GraphicsContextGLOpenGL current context. 441 ASSERT(! WebCore::isInWebProcess());462 ASSERT(!isCurrentContextPredictable()); 442 463 443 464 if (!EGL_BindAPI(EGL_OPENGL_ES_API)) … … 477 498 m_failNextStatusCheck = false; 478 499 forceContextLost(); 479 480 EGL_BindAPI(EGL_OPENGL_ES_API); 481 EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); 500 clearCurrentContext(); 482 501 return; 483 502 } -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h
r274557 r275097 537 537 // Called once by all the public entry points of ExtensionsGL that eventually call OpenGL. 538 538 bool makeContextCurrent() WARN_UNUSED_RETURN; 539 void clearCurrentContext(); 539 540 540 541 // Take into account the user's requested context creation attributes,
Note:
See TracChangeset
for help on using the changeset viewer.