Changeset 180609 in webkit


Ignore:
Timestamp:
Feb 24, 2015 8:19:30 PM (9 years ago)
Author:
roger_fong@apple.com
Message:

WebGL: Destroy the GLContext if a GPU restart has been detected.
https://bugs.webkit.org/show_bug.cgi?id=141567.
<rdar://problem/18507496>
Reviewed by Dean Jackson.

  • html/canvas/WebGLRenderingContextBase.cpp:

(WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase):

  • platform/graphics/GraphicsContext3D.h:

(WebCore::GraphicsContext3D::setWebGLContext):
Keep track of which WebGLRenderingContext is associated with the current GraphicsContext3D.

  • platform/graphics/mac/GraphicsContext3DMac.mm:

(WebCore::GraphicsContext3D::checkGPUStatusIfNecessary): Helper method to check GPU status.
(WebCore::GraphicsContext3D::GraphicsContext3D):
Don’t immediately abort the GPU process when the restart status is kCGLCPGPURestartStatusBlacklisted.

  • platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:

(WebCore::GraphicsContext3D::forceContextLost):
Force the WebGLRenderingContext to be lost.
(WebCore::GraphicsContext3D::drawArrays): Check GPU status after calling drawArrays.
(WebCore::GraphicsContext3D::drawElements): Check GPU status after calling drawElements.

  • WebCore.xcodeproj/project.pbxproj: Add SPI header for iOS.
  • platform/spi/ios/OpenGLESSPI.h: Added.
Location:
trunk/Source/WebCore
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r180608 r180609  
     12015-02-19  Roger Fong  <roger_fong@apple.com>
     2
     3        WebGL: Destroy the GLContext if a GPU restart has been detected.
     4        https://bugs.webkit.org/show_bug.cgi?id=141567.
     5        <rdar://problem/18507496>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * html/canvas/WebGLRenderingContextBase.cpp:
     10        (WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase):
     11        * platform/graphics/GraphicsContext3D.h:
     12        (WebCore::GraphicsContext3D::setWebGLContext):
     13        Keep track of which WebGLRenderingContext is associated with the current GraphicsContext3D.
     14        * platform/graphics/mac/GraphicsContext3DMac.mm:
     15        (WebCore::GraphicsContext3D::checkGPUStatusIfNecessary): Helper method to check GPU status.
     16        (WebCore::GraphicsContext3D::GraphicsContext3D):
     17        Don’t immediately abort the GPU process when the restart status is kCGLCPGPURestartStatusBlacklisted.
     18        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
     19        (WebCore::GraphicsContext3D::forceContextLost):
     20        Force the WebGLRenderingContext to be lost.
     21        (WebCore::GraphicsContext3D::drawArrays): Check GPU status after calling drawArrays.
     22        (WebCore::GraphicsContext3D::drawElements): Check GPU status after calling drawElements.
     23        * WebCore.xcodeproj/project.pbxproj: Add SPI header for iOS.
     24        * platform/spi/ios/OpenGLESSPI.h: Added.
     25
    1262015-02-24  Stephanie Lewis  <slewis@apple.com>
    227
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r180601 r180609  
    94999499                6F995A2F1A70833700A735F4 /* JSWebGLVertexArrayObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLVertexArrayObject.cpp; sourceTree = "<group>"; };
    95009500                6F995A301A70833700A735F4 /* JSWebGLVertexArrayObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLVertexArrayObject.h; sourceTree = "<group>"; };
     9501                6FAD4A561A9D0FAE009F7D3C /* OpenGLESSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OpenGLESSPI.h; path = ios/OpenGLESSPI.h; sourceTree = "<group>"; };
    95019502                7117445614BC34E200EE5FC8 /* SVGTextMetricsBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTextMetricsBuilder.cpp; sourceTree = "<group>"; };
    95029503                7117445714BC34E200EE5FC8 /* SVGTextMetricsBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTextMetricsBuilder.h; sourceTree = "<group>"; };
     
    1857118572                                CE1252401A16B1B600864480 /* MediaPlayerSPI.h */,
    1857218573                                CE1252381A166FA000864480 /* QuickLookSPI.h */,
     18574                                6FAD4A561A9D0FAE009F7D3C /* OpenGLESSPI.h */,
    1857318575                        );
    1857418576                        name = ios;
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

    r180285 r180609  
    464464    m_contextGroup = WebGLContextGroup::create();
    465465    m_contextGroup->addContext(this);
     466   
     467    m_context->setWebGLContext(this);
    466468
    467469    m_maxViewportDims[0] = m_maxViewportDims[1] = 0;
  • trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h

    r179842 r180609  
    9999class IntRect;
    100100class IntSize;
     101class WebGLRenderingContextBase;
    101102#if USE(CAIRO)
    102103class PlatformContextCairo;
     
    781782
    782783    bool makeContextCurrent();
     784    void setWebGLContext(WebGLRenderingContextBase* base) { m_webglContext = base; }
    783785
    784786    // With multisampling on, blit from multisampleFBO to regular FBO.
     
    11291131    void markLayerComposited();
    11301132    bool layerComposited() const;
     1133    void forceContextLost();
    11311134
    11321135    void paintRenderingResultsToCanvas(ImageBuffer*, DrawingBuffer*);
     
    12571260    GraphicsContext3D(Attributes, HostWindow*, RenderStyle = RenderOffscreen);
    12581261    static int numActiveContexts;
     1262    static int GPUCheckCounter;
    12591263
    12601264    // Helper for packImageData/extractImageData/extractTextureData which implement packing of pixel
     
    12711275    void validateDepthStencil(const char* packedDepthStencilExtension);
    12721276    void validateAttributes();
     1277   
     1278    // Call to make during draw calls to check on the GPU's status.
     1279    void checkGPUStatusIfNecessary();
    12731280
    12741281    // Read rendering results into a pixel array with the same format as the
     
    14391446    friend class GraphicsContext3DPrivate;
    14401447    std::unique_ptr<GraphicsContext3DPrivate> m_private;
     1448   
     1449    WebGLRenderingContextBase* m_webglContext;
    14411450};
    14421451
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp

    r179398 r180609  
    283283}
    284284
     285void GraphicsContext3D::checkGPUStatusIfNecessary()
     286{
     287}
     288
    285289PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
    286290{
  • trunk/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp

    r173112 r180609  
    184184}
    185185
     186void GraphicsContext3D::checkGPUStatusIfNecessary()
     187{
     188}
     189
    186190bool GraphicsContext3D::isGLES2Compliant() const
    187191{
  • trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm

    r178166 r180609  
    4343#include "ImageBuffer.h"
    4444#if PLATFORM(IOS)
     45#import "OpenGLESSPI.h"
    4546#import <OpenGLES/ES2/glext.h>
    4647#import <OpenGLES/EAGL.h>
     
    5354#include "WebGLLayer.h"
    5455#include "WebGLObject.h"
     56#include "WebGLRenderingContextBase.h"
    5557#include <runtime/ArrayBuffer.h>
    5658#include <runtime/ArrayBufferView.h>
     
    6466const int maxActiveContexts = 64;
    6567int GraphicsContext3D::numActiveContexts = 0;
    66 
     68const int GPUStatusCheckThreshold = 5;
     69int GraphicsContext3D::GPUCheckCounter = 0;
     70   
    6771// FIXME: This class is currently empty on Mac, but will get populated as
    6872// the restructuring in https://bugs.webkit.org/show_bug.cgi?id=66903 is done
     
    146150    , m_multisampleColorBuffer(0)
    147151    , m_private(std::make_unique<GraphicsContext3DPrivate>(this))
     152    , m_webglContext(0)
    148153{
    149154    UNUSED_PARAM(hostWindow);
     
    197202
    198203    CGLError err = CGLCreateContext(pixelFormatObj, 0, &m_contextObj);
     204#if ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000) || PLATFORM(IOS))
     205    GLint abortOnBlacklist = 0;
     206#if PLATFORM(MAC)
     207    CGLSetParameter(m_contextObj, kCGLCPAbortOnGPURestartStatusBlacklisted, &abortOnBlacklist);
     208#elif PLATFORM(IOS)
     209    CGLSetParameter(m_contextObj, kEAGLCPAbortOnGPURestartStatusBlacklisted, &abortOnBlacklist);
     210#endif
     211#endif
     212
    199213    CGLDestroyPixelFormat(pixelFormatObj);
    200214   
     
    354368}
    355369
     370void GraphicsContext3D::checkGPUStatusIfNecessary()
     371{
     372#if ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000) || PLATFORM(IOS))
     373    GPUCheckCounter = (GPUCheckCounter + 1) % GPUStatusCheckThreshold;
     374    if (GPUCheckCounter)
     375        return;
     376#if PLATFORM(MAC)
     377    GLint restartStatus = 0;
     378    CGLGetParameter(platformGraphicsContext3D(), kCGLCPGPURestartStatus, &restartStatus);
     379    if (restartStatus == kCGLCPGPURestartStatusCaused || restartStatus == kCGLCPGPURestartStatusBlacklisted) {
     380        CGLSetCurrentContext(0);
     381        CGLDestroyContext(platformGraphicsContext3D());
     382        forceContextLost();
     383    }
     384#elif PLATFORM(IOS)
     385    GLint restartStatus = 0;
     386    EAGLContext* currentContext = static_cast<EAGLContext*>(PlatformGraphicsContext3D());
     387    [currentContext getParameter:kEAGLCPGPURestartStatus to:&restartStatus];
     388    if (restartStatus == kEAGLCPGPURestartStatusCaused || restartStatus == kEAGLCPGPURestartStatusBlacklisted) {
     389        [EAGLContext setCurrentContext:0];
     390        [static_cast<EAGLContext*>(currentContext) release];
     391        forceContextLost();
     392    }
     393#endif
     394#endif
     395}
     396
    356397#if PLATFORM(IOS)
    357398void GraphicsContext3D::endPaint()
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp

    r179530 r180609  
    4949#include "Logging.h"
    5050#include "TemporaryOpenGLSetting.h"
     51#include "WebGLRenderingContextBase.h"
    5152#include <cstring>
    5253#include <runtime/ArrayBuffer.h>
     
    7576#endif
    7677#endif
     78
    7779
    7880namespace WebCore {
     
    684686    makeContextCurrent();
    685687    ::glDrawArrays(mode, first, count);
     688    checkGPUStatusIfNecessary();
    686689}
    687690
     
    690693    makeContextCurrent();
    691694    ::glDrawElements(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)));
     695    checkGPUStatusIfNecessary();
    692696}
    693697
     
    17641768}
    17651769
     1770void GraphicsContext3D::forceContextLost()
     1771{
     1772    if (m_webglContext)
     1773        m_webglContext->forceLostContext(WebGLRenderingContextBase::RealLostContext);
     1774}
     1775
    17661776void GraphicsContext3D::texImage2DDirect(GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type, const void* pixels)
    17671777{
  • trunk/Source/WebCore/platform/graphics/win/GraphicsContext3DWin.cpp

    r178166 r180609  
    179179}
    180180
     181void GraphicsContext3D::checkGPUStatusIfNecessary()
     182{
     183}
     184
    181185PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D()
    182186{
Note: See TracChangeset for help on using the changeset viewer.