Changeset 247453 in webkit


Ignore:
Timestamp:
Jul 15, 2019 3:27:45 PM (5 years ago)
Author:
dino@apple.com
Message:

[WebGL] Remove software rendering and simplify context creation on macOS
https://bugs.webkit.org/show_bug.cgi?id=199789

Reviewed by Sam Weinig.

Source/WebCore:

We don't ever want to fall-back to the software renderer. We'd be better
off failing to create the context completely.

Also, the number of fall-back attempts we were making before hitting
the software renderer was overkill. All hardware we support should
handle a 32bpp buffer.

Lastly, we don't want to support supersampling - multisampling only.

I lied… there is one more thing - failing to create the context
was causing an ASSERT trying to remove the GC3D from the global list.

  • html/canvas/WebGLRenderingContextBase.cpp:

(WebCore::WebGLRenderingContextBase::create):

  • page/Settings.yaml: Remove forceSoftwareWebGL setting.
  • platform/graphics/GraphicsContext3DAttributes.h:
  • platform/graphics/GraphicsContext3DManager.cpp:

(WebCore::GraphicsContext3DManager::addContext):
(WebCore::GraphicsContext3DManager::removeContext):
(WebCore::GraphicsContext3DManager::removeContextRequiringHighPerformance):

  • platform/graphics/cocoa/GraphicsContext3DCocoa.mm:

(WebCore::GraphicsContext3D::GraphicsContext3D):
(WebCore::setPixelFormat): Deleted.

Source/WebKit:

Remove force software WebGL setting.

  • Shared/WebPreferences.yaml:
  • UIProcess/API/C/WKPreferences.cpp:

(WKPreferencesSetForceSoftwareWebGLRendering): Deleted.
(WKPreferencesGetForceSoftwareWebGLRendering): Deleted.

  • UIProcess/API/C/WKPreferencesRefPrivate.h:

Source/WebKitLegacy/mac:

Remove force software WebGL setting.

  • WebView/WebPreferenceKeysPrivate.h:
  • WebView/WebPreferences.mm:

(+[WebPreferences initialize]):
(-[WebPreferences forceSoftwareWebGLRendering]): Deleted.
(-[WebPreferences setForceSoftwareWebGLRendering:]): Deleted.

  • WebView/WebPreferencesPrivate.h:
  • WebView/WebView.mm:

(-[WebView _preferencesChanged:]):

Location:
trunk/Source
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247452 r247453  
     12019-07-15  Dean Jackson  <dino@apple.com>
     2
     3        [WebGL] Remove software rendering and simplify context creation on macOS
     4        https://bugs.webkit.org/show_bug.cgi?id=199789
     5
     6        Reviewed by Sam Weinig.
     7
     8        We don't ever want to fall-back to the software renderer. We'd be better
     9        off failing to create the context completely.
     10
     11        Also, the number of fall-back attempts we were making before hitting
     12        the software renderer was overkill. All hardware we support should
     13        handle a 32bpp buffer.
     14
     15        Lastly, we don't want to support supersampling - multisampling only.
     16
     17        I lied… there is one more thing - failing to create the context
     18        was causing an ASSERT trying to remove the GC3D from the global list.
     19
     20        * html/canvas/WebGLRenderingContextBase.cpp:
     21        (WebCore::WebGLRenderingContextBase::create):
     22        * page/Settings.yaml: Remove forceSoftwareWebGL setting.
     23        * platform/graphics/GraphicsContext3DAttributes.h:
     24        * platform/graphics/GraphicsContext3DManager.cpp:
     25        (WebCore::GraphicsContext3DManager::addContext):
     26        (WebCore::GraphicsContext3DManager::removeContext):
     27        (WebCore::GraphicsContext3DManager::removeContextRequiringHighPerformance):
     28        * platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
     29        (WebCore::GraphicsContext3D::GraphicsContext3D):
     30        (WebCore::setPixelFormat): Deleted.
     31
    1322019-07-14  Dean Jackson  <dino@apple.com>
    233
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

    r247452 r247453  
    562562            }
    563563        }
    564 
    565         if (frame->settings().forceSoftwareWebGLRendering())
    566             attributes.forceSoftwareRenderer = true;
    567564
    568565        if (frame->settings().forceWebGLUsesLowPower()) {
  • trunk/Source/WebCore/page/Settings.yaml

    r247444 r247453  
    238238unhandledPromiseRejectionToConsoleEnabled:
    239239  initial: true
    240 forceSoftwareWebGLRendering:
    241   initial: false
    242240forceWebGLUsesLowPower:
    243241  initial: false
  • trunk/Source/WebCore/platform/graphics/GraphicsContext3DAttributes.h

    r234380 r247453  
    4747
    4848    // Additional attributes.
    49     bool forceSoftwareRenderer { false };
    5049    bool shareResources { true };
    5150    bool isWebGL2 { false };
  • trunk/Source/WebCore/platform/graphics/GraphicsContext3DManager.cpp

    r246554 r247453  
    161161    if (!context)
    162162        return;
    163    
     163
    164164#if PLATFORM(MAC) && !ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
    165165    if (!m_contexts.size())
     
    174174void GraphicsContext3DManager::removeContext(GraphicsContext3D* context)
    175175{
    176     ASSERT(m_contexts.contains(context));
     176    if (!m_contexts.contains(context))
     177        return;
    177178    m_contexts.removeFirst(context);
    178179    m_contextWindowMap.remove(context);
     
    208209void GraphicsContext3DManager::removeContextRequiringHighPerformance(GraphicsContext3D* context)
    209210{
     211    if (!context)
     212        return;
     213
    210214    if (!m_contextsRequiringHighPerformance.contains(context))
    211215        return;
  • trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm

    r247422 r247453  
    9999};
    100100
    101 #if USE(OPENGL)
    102 
    103 static void setPixelFormat(Vector<CGLPixelFormatAttribute>& attribs, int colorBits, int depthBits, bool accelerated, bool supersample, bool closest, bool antialias, bool isWebGL2, bool allowOfflineRenderers)
    104 {
    105     attribs.clear();
    106    
    107     attribs.append(kCGLPFAColorSize);
    108     attribs.append(static_cast<CGLPixelFormatAttribute>(colorBits));
    109     attribs.append(kCGLPFADepthSize);
    110     attribs.append(static_cast<CGLPixelFormatAttribute>(depthBits));
    111 
    112     // This attribute, while mentioning offline renderers, is actually
    113     // allowing us to request the integrated graphics on a dual GPU
    114     // system, and not force the discrete GPU.
    115     // See https://developer.apple.com/library/mac/technotes/tn2229/_index.html
    116     if (allowOfflineRenderers)
    117         attribs.append(kCGLPFAAllowOfflineRenderers);
    118 
    119     if (accelerated)
    120         attribs.append(kCGLPFAAccelerated);
    121     else {
    122         attribs.append(kCGLPFARendererID);
    123         attribs.append(static_cast<CGLPixelFormatAttribute>(kCGLRendererGenericFloatID));
    124     }
    125        
    126     if (supersample && !antialias)
    127         attribs.append(kCGLPFASupersample);
    128 
    129     if (closest)
    130         attribs.append(kCGLPFAClosestPolicy);
    131 
    132     if (antialias) {
    133         attribs.append(kCGLPFAMultisample);
    134         attribs.append(kCGLPFASampleBuffers);
    135         attribs.append(static_cast<CGLPixelFormatAttribute>(1));
    136         attribs.append(kCGLPFASamples);
    137         attribs.append(static_cast<CGLPixelFormatAttribute>(4));
    138     }
    139 
    140     if (isWebGL2) {
    141         // FIXME: Instead of backing a WebGL2 GraphicsContext3D with a OpenGL 4 context, we should instead back it with ANGLE.
    142         // Use an OpenGL 4 context for now until the ANGLE backend is ready.
    143         attribs.append(kCGLPFAOpenGLProfile);
    144         attribs.append(static_cast<CGLPixelFormatAttribute>(kCGLOGLPVersion_GL4_Core));
    145     }
    146        
    147     attribs.append(static_cast<CGLPixelFormatAttribute>(0));
    148 }
    149 
    150 #endif // USE(OPENGL)
    151 
    152101RefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3DAttributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
    153102{
     
    290239        ::glEnable(GraphicsContext3D::PRIMITIVE_RESTART_FIXED_INDEX);
    291240#elif USE(OPENGL)
    292     Vector<CGLPixelFormatAttribute> attribs;
    293     CGLPixelFormatObj pixelFormatObj = 0;
    294     GLint numPixelFormats = 0;
    295    
     241
    296242#if HAVE(APPLE_GRAPHICS_CONTROL)
    297243    m_powerPreferenceUsedForCreation = (hasLowAndHighPowerGPUs() && attrs.powerPreference == GraphicsContext3DPowerPreference::HighPerformance) ? GraphicsContext3DPowerPreference::HighPerformance : GraphicsContext3DPowerPreference::Default;
     
    300246#endif
    301247
    302     // If we're configured to demand the software renderer, we'll
    303     // do so. We attempt to create contexts in this order:
    304     //
    305     // 1) 32 bit RGBA/32 bit depth/supersampled
    306     // 2) 32 bit RGBA/32 bit depth
    307     // 3) 32 bit RGBA/16 bit depth
    308     //
    309     // If we were not forced into software mode already, our final attempt is
    310     // to try that:
    311     //
    312     // 4) closest to 32 bit RGBA/16 bit depth/software renderer
    313     //
    314     // If none of that works, we fail and leave m_contextObj as nullptr.
    315 
    316248    bool useMultisampling = m_attrs.antialias;
    317249
    318     setPixelFormat(attribs, 32, 32, !attrs.forceSoftwareRenderer, true, false, useMultisampling, attrs.isWebGL2, allowOfflineRenderers());
     250    Vector<CGLPixelFormatAttribute> attribs;
     251    CGLPixelFormatObj pixelFormatObj = 0;
     252    GLint numPixelFormats = 0;
     253
     254    attribs.append(kCGLPFAAccelerated);
     255    attribs.append(kCGLPFAColorSize);
     256    attribs.append(static_cast<CGLPixelFormatAttribute>(32));
     257    attribs.append(kCGLPFADepthSize);
     258    attribs.append(static_cast<CGLPixelFormatAttribute>(32));
     259
     260    // This attribute, while mentioning offline renderers, is actually
     261    // allowing us to request the integrated graphics on a dual GPU
     262    // system, and not force the discrete GPU.
     263    // See https://developer.apple.com/library/mac/technotes/tn2229/_index.html
     264    if (allowOfflineRenderers())
     265        attribs.append(kCGLPFAAllowOfflineRenderers);
     266
     267    if (useMultisampling) {
     268        attribs.append(kCGLPFAMultisample);
     269        attribs.append(kCGLPFASampleBuffers);
     270        attribs.append(static_cast<CGLPixelFormatAttribute>(1));
     271        attribs.append(kCGLPFASamples);
     272        attribs.append(static_cast<CGLPixelFormatAttribute>(4));
     273    }
     274
     275    if (attrs.isWebGL2) {
     276        // FIXME: Instead of backing a WebGL2 GraphicsContext3D with a OpenGL 4 context, we should instead back it with ANGLE.
     277        // Use an OpenGL 4 context for now until the ANGLE backend is ready.
     278        attribs.append(kCGLPFAOpenGLProfile);
     279        attribs.append(static_cast<CGLPixelFormatAttribute>(kCGLOGLPVersion_GL4_Core));
     280    }
     281
     282    attribs.append(static_cast<CGLPixelFormatAttribute>(0));
     283
    319284    CGLChoosePixelFormat(attribs.data(), &pixelFormatObj, &numPixelFormats);
    320 
    321     if (!numPixelFormats) {
    322         setPixelFormat(attribs, 32, 32, !attrs.forceSoftwareRenderer, true, false, useMultisampling, attrs.isWebGL2, allowOfflineRenderers());
    323         CGLChoosePixelFormat(attribs.data(), &pixelFormatObj, &numPixelFormats);
    324 
    325         if (!numPixelFormats) {
    326             setPixelFormat(attribs, 32, 32, !attrs.forceSoftwareRenderer, false, false, useMultisampling, attrs.isWebGL2, allowOfflineRenderers());
    327             CGLChoosePixelFormat(attribs.data(), &pixelFormatObj, &numPixelFormats);
    328 
    329             if (!numPixelFormats) {
    330                 setPixelFormat(attribs, 32, 16, !attrs.forceSoftwareRenderer, false, false, useMultisampling, attrs.isWebGL2, allowOfflineRenderers());
    331                 CGLChoosePixelFormat(attribs.data(), &pixelFormatObj, &numPixelFormats);
    332 
    333                 if (!attrs.forceSoftwareRenderer && !numPixelFormats) {
    334                     setPixelFormat(attribs, 32, 16, false, false, true, false, attrs.isWebGL2, allowOfflineRenderers());
    335                     CGLChoosePixelFormat(attribs.data(), &pixelFormatObj, &numPixelFormats);
    336                     useMultisampling = false;
    337                 }
    338             }
    339         }
    340     }
    341285
    342286    if (!numPixelFormats)
  • trunk/Source/WebKit/ChangeLog

    r247444 r247453  
     12019-07-15  Dean Jackson  <dino@apple.com>
     2
     3        [WebGL] Remove software rendering and simplify context creation on macOS
     4        https://bugs.webkit.org/show_bug.cgi?id=199789
     5
     6        Reviewed by Sam Weinig.
     7
     8        Remove force software WebGL setting.
     9
     10        * Shared/WebPreferences.yaml:
     11        * UIProcess/API/C/WKPreferences.cpp:
     12        (WKPreferencesSetForceSoftwareWebGLRendering): Deleted.
     13        (WKPreferencesGetForceSoftwareWebGLRendering): Deleted.
     14        * UIProcess/API/C/WKPreferencesRefPrivate.h:
     15
    1162019-07-15  Daniel Bates  <dabates@apple.com>
    217
  • trunk/Source/WebKit/Shared/WebPreferences.yaml

    r247388 r247453  
    130130  type: bool
    131131  defaultValue: true
    132 
    133 ForceSoftwareWebGLRendering:
    134   type: bool
    135   defaultValue: false
    136132
    137133Accelerated2dCanvasEnabled:
  • trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp

    r246807 r247453  
    470470}
    471471
    472 void WKPreferencesSetForceSoftwareWebGLRendering(WKPreferencesRef preferencesRef, bool flag)
    473 {
    474     toImpl(preferencesRef)->setForceSoftwareWebGLRendering(flag);
    475 }
    476 
    477 bool WKPreferencesGetForceSoftwareWebGLRendering(WKPreferencesRef preferencesRef)
    478 {
    479     return toImpl(preferencesRef)->forceSoftwareWebGLRendering();
    480 }
    481 
    482472void WKPreferencesSetAccelerated2DCanvasEnabled(WKPreferencesRef preferencesRef, bool flag)
    483473{
  • trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h

    r246444 r247453  
    9292
    9393// Defaults to false.
    94 WK_EXPORT void WKPreferencesSetForceSoftwareWebGLRendering(WKPreferencesRef, bool);
    95 WK_EXPORT bool WKPreferencesGetForceSoftwareWebGLRendering(WKPreferencesRef);
    96 
    97 // Defaults to false.
    9894WK_EXPORT void WKPreferencesSetAccelerated2DCanvasEnabled(WKPreferencesRef, bool);
    9995WK_EXPORT bool WKPreferencesGetAccelerated2DCanvasEnabled(WKPreferencesRef);
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r247416 r247453  
     12019-07-15  Dean Jackson  <dino@apple.com>
     2
     3        [WebGL] Remove software rendering and simplify context creation on macOS
     4        https://bugs.webkit.org/show_bug.cgi?id=199789
     5
     6        Reviewed by Sam Weinig.
     7
     8        Remove force software WebGL setting.
     9
     10        * WebView/WebPreferenceKeysPrivate.h:
     11        * WebView/WebPreferences.mm:
     12        (+[WebPreferences initialize]):
     13        (-[WebPreferences forceSoftwareWebGLRendering]): Deleted.
     14        (-[WebPreferences setForceSoftwareWebGLRendering:]): Deleted.
     15        * WebView/WebPreferencesPrivate.h:
     16        * WebView/WebView.mm:
     17        (-[WebView _preferencesChanged:]):
     18
    1192019-07-13  Zalan Bujtas  <zalan@apple.com>
    220
  • trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h

    r246444 r247453  
    119119#define WebKitWebGL2EnabledPreferenceKey @"WebKitWebGL2Enabled"
    120120#define WebKitWebGPUEnabledPreferenceKey @"WebKitWebGPUEnabled"
    121 #define WebKitForceSoftwareWebGLRenderingPreferenceKey @"WebKitForceSoftwareWebGLRendering"
    122121#define WebKitForceWebGLUsesLowPowerPreferenceKey @"WebKitForceWebGLUsesLowPower"
    123122#define WebKitAccelerated2dCanvasEnabledPreferenceKey @"WebKitAccelerated2dCanvasEnabled"
  • trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm

    r246444 r247453  
    507507        [NSNumber numberWithBool:NO],   WebKitShowRepaintCounterPreferenceKey,
    508508        [NSNumber numberWithBool:YES],  WebKitWebGLEnabledPreferenceKey,
    509         [NSNumber numberWithBool:NO],  WebKitForceSoftwareWebGLRenderingPreferenceKey,
    510509        [NSNumber numberWithBool:YES],   WebKitForceWebGLUsesLowPowerPreferenceKey,
    511510        [NSNumber numberWithBool:NO],   WebKitAccelerated2dCanvasEnabledPreferenceKey,
     
    21452144}
    21462145
    2147 - (BOOL)forceSoftwareWebGLRendering
    2148 {
    2149     return [self _boolValueForKey:WebKitForceSoftwareWebGLRenderingPreferenceKey];
    2150 }
    2151 
    2152 - (void)setForceSoftwareWebGLRendering:(BOOL)forced
    2153 {
    2154     [self _setBoolValue:forced forKey:WebKitForceSoftwareWebGLRenderingPreferenceKey];
    2155 }
    2156 
    21572146- (BOOL)forceLowPowerGPUForWebGL
    21582147{
  • trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h

    r246444 r247453  
    275275- (BOOL)webGL2Enabled;
    276276- (void)setWebGL2Enabled:(BOOL)enabled;
    277 
    278 - (BOOL)forceSoftwareWebGLRendering;
    279 - (void)setForceSoftwareWebGLRendering:(BOOL)forced;
    280277
    281278- (BOOL)forceLowPowerGPUForWebGL;
  • trunk/Source/WebKitLegacy/mac/WebView/WebView.mm

    r247117 r247453  
    29402940    settings.setSubpixelAntialiasedLayerTextEnabled([preferences subpixelAntialiasedLayerTextEnabled]);
    29412941
    2942     settings.setForceSoftwareWebGLRendering([preferences forceSoftwareWebGLRendering]);
    29432942    settings.setForceWebGLUsesLowPower([preferences forceLowPowerGPUForWebGL]);
    29442943    settings.setAccelerated2dCanvasEnabled([preferences accelerated2dCanvasEnabled]);
Note: See TracChangeset for help on using the changeset viewer.