Changeset 279497 in webkit


Ignore:
Timestamp:
Jul 1, 2021, 11:01:51 PM (4 years ago)
Author:
Ben Nham
Message:

Unreviewed, reverting r279172.

Broke WebGL context construction on some devices.

Reverted changeset:

"rAF driven WebGL submits excessive amount of GPU work when frames are slow"
https://bugs.webkit.org/show_bug.cgi?id=227059
https://commits.webkit.org/r279172

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/ThirdParty/ANGLE/ChangeLog

    r279466 r279497  
     12021-07-01  Ben Nham  <nham@apple.com>
     2
     3        Unreviewed, reverting r279172.
     4
     5        Broke WebGL context construction on some devices.
     6
     7        Reverted changeset:
     8
     9        "rAF driven WebGL submits excessive amount of GPU work when frames are slow"
     10        https://bugs.webkit.org/show_bug.cgi?id=227059
     11        https://commits.webkit.org/r279172
     12
    1132021-07-01  Kyle Piddington  <kpiddington@apple.com>
    214
  • trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/DisplayMtl.mm

    r279327 r279497  
    885885        // GL_OES_EGL_sync
    886886        mNativeExtensions.eglSyncOES = true;
    887 
    888         // GL_ARB_sync
    889         mNativeExtensions.glSyncARB = true;
    890887    }
    891888}
  • trunk/Source/WebCore/ChangeLog

    r279492 r279497  
     12021-07-01  Ben Nham  <nham@apple.com>
     2
     3        Unreviewed, reverting r279172.
     4
     5        Broke WebGL context construction on some devices.
     6
     7        Reverted changeset:
     8
     9        "rAF driven WebGL submits excessive amount of GPU work when frames are slow"
     10        https://bugs.webkit.org/show_bug.cgi?id=227059
     11        https://commits.webkit.org/r279172
     12
    1132021-07-01  Jean-Yves Avenard  <jya@apple.com>
    214
  • trunk/Source/WebCore/Headers.cmake

    r279355 r279497  
    13311331    platform/graphics/angle/ANGLEHeaders.h
    13321332    platform/graphics/angle/ExtensionsGLANGLE.h
    1333     platform/graphics/angle/GraphicsContextGLANGLEUtilities.h
    13341333
    13351334    platform/graphics/displaylists/DisplayList.h
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r279451 r279497  
    716716                26F9A83818A046AC00AEB88A /* ViewportConfiguration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F9A83618A046AC00AEB88A /* ViewportConfiguration.cpp */; };
    717717                26F9A83918A046AC00AEB88A /* ViewportConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 26F9A83718A046AC00AEB88A /* ViewportConfiguration.h */; settings = {ATTRIBUTES = (Private, ); }; };
    718                 27E3C808257F5E6E00C986AB /* ANGLEHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 27E3C806257F5E6E00C986AB /* ANGLEHeaders.h */; settings = {ATTRIBUTES = (Private, ); }; };
     718                27E3C808257F5E6E00C986AB /* ANGLEHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 27E3C806257F5E6E00C986AB /* ANGLEHeaders.h */; };
    719719                2914E3081CAB5A440049966F /* AccessibilityAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 2914E3061CAB5A440049966F /* AccessibilityAttachment.h */; };
    720720                2936BF5C21D69E4B004A8FC9 /* AccessibilityObjectInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 2936BF5A21D6999E004A8FC9 /* AccessibilityObjectInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    23242324                7B7311FB25C092B7003B2796 /* ScopedHighPerformanceGPURequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B7311FA25C092B7003B2796 /* ScopedHighPerformanceGPURequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
    23252325                7B90417025501142006EEB8C /* RemoteGraphicsContextGLProxyBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B90416E25501109006EEB8C /* RemoteGraphicsContextGLProxyBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
    2326                 7BB34A1725345CB200029D08 /* GraphicsContextGLANGLEUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A1625345CB200029D08 /* GraphicsContextGLANGLEUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2326                7BB34A1725345CB200029D08 /* GraphicsContextGLANGLEUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A1625345CB200029D08 /* GraphicsContextGLANGLEUtilities.h */; };
    23272327                7BB34A48253776CA00029D08 /* GraphicsContextGLImageExtractor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB34A45253776C600029D08 /* GraphicsContextGLImageExtractor.h */; settings = {ATTRIBUTES = (Private, ); }; };
    23282328                7BB680BA25BA1BE4002B8738 /* GraphicsChecksMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BB680B825BA1BE4002B8738 /* GraphicsChecksMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
  • trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp

    r279172 r279497  
    4545#include <cstring>
    4646#include <wtf/HexNumber.h>
    47 #include <wtf/Seconds.h>
    4847#include <wtf/ThreadSpecific.h>
    4948#include <wtf/text/CString.h>
     
    6362static const char* packedDepthStencilExtensionName = "GL_OES_packed_depth_stencil";
    6463
    65 static Seconds maxFrameDuration = 5_s;
     64namespace {
     65
     66
     67} // namespace anonymous
    6668
    6769#if PLATFORM(MAC) || PLATFORM(IOS_FAMILY)
     
    28452847#endif
    28462848
    2847 bool GraphicsContextGLOpenGL::waitAndUpdateOldestFrame()
    2848 {
    2849     size_t oldestFrameCompletionFence = m_oldestFrameCompletionFence++ % maxPendingFrames;
    2850     bool success = true;
    2851     if (ScopedGLFence fence = WTFMove(m_frameCompletionFences[oldestFrameCompletionFence])) {
    2852         // Wait so that rendering does not get more than maxPendingFrames frames ahead.
    2853         GLbitfield flags = GL_SYNC_FLUSH_COMMANDS_BIT;
    2854 #if PLATFORM(COCOA)
    2855         // Avoid using the GL_SYNC_FLUSH_COMMANDS_BIT because each each frame is ended with a flush
    2856         // due to external IOSurface access. This particular fence is maxPendingFrames behind.
    2857         // This means the creation of this fence has already been flushed.
    2858         flags = 0;
    2859 #endif
    2860         GLenum result = gl::ClientWaitSync(fence, flags, maxFrameDuration.nanosecondsAs<GLuint64>());
    2861         ASSERT(result != GL_WAIT_FAILED);
    2862         success = result != GL_WAIT_FAILED && result != GL_TIMEOUT_EXPIRED;
    2863     }
    2864     m_frameCompletionFences[oldestFrameCompletionFence].fenceSync();
    2865     return success;
    2866 }
    2867 
    28682849}
    28692850
  • trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLEUtilities.h

    r279172 r279497  
    205205};
    206206
    207 class ScopedGLFence {
    208     WTF_MAKE_NONCOPYABLE(ScopedGLFence);
    209 public:
    210     ScopedGLFence() = default;
    211     ScopedGLFence(ScopedGLFence&& other)
    212         : m_object(std::exchange(other.m_object, { }))
    213     {
    214     }
    215     ~ScopedGLFence() { reset(); }
    216     ScopedGLFence& operator=(ScopedGLFence&& other)
    217     {
    218         if (this != &other) {
    219             reset();
    220             m_object = std::exchange(other.m_object, { });
    221         }
    222         return *this;
    223     }
    224     void reset()
    225     {
    226         if (m_object) {
    227             gl::DeleteSync(m_object);
    228             m_object = { };
    229         }
    230     }
    231     void abandon() { m_object = { }; }
    232     void fenceSync()
    233     {
    234         reset();
    235         m_object = gl::FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
    236     }
    237     operator GLsync() const { return m_object; }
    238     operator bool() const { return m_object; }
    239 private:
    240     GLsync m_object { };
    241 };
    242 
    243207}
    244208
  • trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm

    r279308 r279497  
    117117        displayAttributes.append(EGL_TRUE);
    118118    }
    119     if (attrs.useMetal) {
     119    bool canUseMetal = platformSupportsMetal();
     120    if (attrs.useMetal && canUseMetal) {
    120121        displayAttributes.append(EGL_PLATFORM_ANGLE_TYPE_ANGLE);
    121122        displayAttributes.append(EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE);
    122123    }
    123     LOG(WebGL, "Attempting to use ANGLE's %s backend.\n", attrs.useMetal ? "Metal" : "OpenGL");
     124
     125    LOG(WebGL, "Attempting to use ANGLE's %s backend.\n", attrs.useMetal && canUseMetal ? "Metal" : "OpenGL");
    124126    if (attrs.powerPreference != GraphicsContextGLAttributes::PowerPreference::Default) {
    125127        displayAttributes.append(EGL_POWER_PREFERENCE_ANGLE);
     
    131133        }
    132134    }
     135
    133136    displayAttributes.append(EGL_NONE);
    134137    display = EGL_GetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, reinterpret_cast<void*>(EGL_DEFAULT_DISPLAY), displayAttributes.data());
     
    208211{
    209212    m_isForWebGL2 = attrs.webGLVersion == GraphicsContextGLWebGLVersion::WebGL2;
    210     if (attrs.useMetal && !platformSupportsMetal()) {
    211         attrs.useMetal = false;
    212         setContextAttributes(attrs);
    213     }
    214213
    215214    m_displayObj = InitializeEGLDisplay(attrs);
     
    298297        // For WebGL 2.0 occlusion queries to work.
    299298        requiredExtensions.append("GL_EXT_occlusion_query_boolean"_s);
    300     } else {
    301         if (contextAttributes().useMetal) {
    302             // The implementation uses GLsync objects. Enable the functionality for WebGL 1.0 contexts
    303             // that use OpenGL ES 2.0.
    304             requiredExtensions.append("GL_ARB_sync"_s);
    305         }
    306299    }
    307300#if PLATFORM(MAC) || PLATFORM(MACCATALYST)
     
    311304        // For creating the EGL surface from an IOSurface.
    312305        requiredExtensions.append("GL_EXT_texture_format_BGRA8888"_s);
    313     }
     306            }
     307
    314308#endif // PLATFORM(MAC) || PLATFORM(MACCATALYST)
    315309    ExtensionsGL& extensions = getExtensions();
     
    402396        if (m_preserveDrawingBufferFBO)
    403397            gl::DeleteFramebuffers(1, &m_preserveDrawingBufferFBO);
    404         for (auto& fence : m_frameCompletionFences)
    405             fence.reset();
    406     } else {
    407         for (auto& fence : m_frameCompletionFences)
    408             fence.abandon();
    409398    }
    410399    if (m_displayBufferPbuffer) {
     
    789778    if (!hasNewBacking)
    790779        allocateAndBindDisplayBufferBacking();
     780
    791781    markLayerComposited();
    792 
    793     if (contextAttributes().useMetal) {
    794         // OpenGL sync objects are not signaling upon completion on Catalina-era drivers.
    795         // OpenGL drivers typically implement some sort of internal throttling.
    796         bool success = waitAndUpdateOldestFrame();
    797         UNUSED_VARIABLE(success); // FIXME: implement context lost.
    798     }
    799782}
    800783
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h

    r279308 r279497  
    4646#endif
    4747
    48 #if USE(ANGLE)
    49 #include "GraphicsContextGLANGLEUtilities.h"
    50 #else
     48#if !USE(ANGLE)
    5149#include "ANGLEWebKitBridge.h"
    5250#include "ExtensionsGLOpenGLCommon.h"
    53 #endif
    54 
    55 #if PLATFORM(MAC)
    56 #include "ScopedHighPerformanceGPURequest.h"
    5751#endif
    5852
     
    7771class GCGLLayer;
    7872}
     73#endif
     74
     75#if PLATFORM(MAC)
     76#include "ScopedHighPerformanceGPURequest.h"
    7977#endif
    8078
     
    581579    bool bindDisplayBufferBacking(std::unique_ptr<IOSurface> backing, void* pbuffer);
    582580#endif
    583 #if USE(ANGLE)
    584     // Returns false if context should be lost due to timeout.
    585     bool waitAndUpdateOldestFrame() WARN_UNUSED_RETURN;
    586 #endif
    587581
    588582#if PLATFORM(COCOA)
     
    798792    std::unique_ptr<GraphicsContextGLCV> m_cv;
    799793#endif
    800 #if USE(ANGLE)
    801     static constexpr size_t maxPendingFrames = 3;
    802     size_t m_oldestFrameCompletionFence { 0 };
    803     ScopedGLFence m_frameCompletionFences[maxPendingFrames];
    804 #endif
    805794};
    806795
Note: See TracChangeset for help on using the changeset viewer.