Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8566d855663a3dadd06c1562746e95344fb5af18
      
https://github.com/WebKit/WebKit/commit/8566d855663a3dadd06c1562746e95344fb5af18
  Author: Nikolas Zimmermann <[email protected]>
  Date:   2024-11-25 (Mon, 25 Nov 2024)

  Changed paths:
    M LayoutTests/css3/masking/mask-base64.html
    M LayoutTests/css3/masking/mask-luminance-svg.html
    M LayoutTests/svg/filters/filter-on-root-tile-boundary.html
    M LayoutTests/svg/repaint/buffered-rendering-static-image.html
    M Source/WebCore/platform/Skia.cmake
    M Source/WebCore/platform/SourcesSkia.txt
    M Source/WebCore/platform/graphics/ImageBuffer.cpp
    M Source/WebCore/platform/graphics/ImageBuffer.h
    M Source/WebCore/platform/graphics/ImageBufferBackend.cpp
    M Source/WebCore/platform/graphics/ImageBufferBackend.h
    M Source/WebCore/platform/graphics/NativeImage.h
    M Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
    M Source/WebCore/platform/graphics/skia/GraphicsContextSkia.h
    M 
Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.cpp
    M Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.h
    M Source/WebCore/platform/graphics/skia/NativeImageSkia.cpp
    A Source/WebCore/platform/graphics/skia/SkiaPaintingEngine.cpp
    A Source/WebCore/platform/graphics/skia/SkiaPaintingEngine.h
    R Source/WebCore/platform/graphics/skia/SkiaThreadedPaintingPool.cpp
    R Source/WebCore/platform/graphics/skia/SkiaThreadedPaintingPool.h
    M 
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
    M 
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayerSkia.cpp
    M 
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTileBuffer.cpp
    M 
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTileBuffer.h
    M Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp
    M Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h

  Log Message:
  -----------
  [GTK][WPE][Skia] Introduce threaded GPU painting mode
https://bugs.webkit.org/show_bug.cgi?id=280677

Reviewed by Carlos Garcia Campos.

This patch introduces a threaded rendering mode also for the GPU
accelerated rendering, and activates it by default. The change aims to
free the main thread: currently accelerated rendering in the
Gtk/WPE ports blocks the main thread -- move to a DisplayList
record & replay approach, to make the GPU tile painting asynchronous,
which has proven to work successfully for CPU rendering already.

In GPU rendering mode we previously didn't use any threading, and thus
painted tile after tile, without any parallelization. GPU painting does
requires a non-neglible amount of CPU work, to prepare the GPU painting
(computing vertex data, etc.). This slowed down the current GPU
rendering architecture so much, that threaded CPU rendering on embedded
devices was usually faster than GPU rendering. However CPU rendering is
not per-se faster, it's just the naive implementation we're currently
using that makes the GPU rendering appear slower than the CPU rendering.

A considerable amount of time was spent to adapt the ImageBuffer and
NativeImage rendering code to cope with threaded GPU painting: we cannot
re-use the SkSurface/SkImages produced on main thread directly on the
worker threads -- instead we have to extract the underlying
GrBackendRenderTarget/GrBackendTexture, and re-wrap them in
SkSurfaces/SkImages on the worker thread.

The SkiaThreadedPaintingPool class was renamed to SkiaPaintingEngine,
since it now takes care of both unaccelerated & accelerated rendering,
either in multi-threaded, or main thread mode.

The environment variable WEBKIT_SKIA_PAINTING_THREADS was renamed to
WEBKIT_SKIA_CPU_PAINTING_THREADS, since it only controls the amount
of CPU rendering threads that are used (default: nCores/2).

Introduce WEBKIT_SKIA_GPU_PAINTING_THREADS (default: 1), to control
the amount of GPU worker threads.

The different painting modes can be selected at runtime:

1) GPU-accelerated multi-threaded rendering: (now default!)
   - WEBKIT_SKIA_GPU_PAINTING_THREADS>0
     (or unset, then default 1 is used)
   - WEBKIT_SKIA_ENABLE_CPU_RENDERING unset

2) GPU-accelerated main thread rendering: (previous default)
   - WEBKIT_SKIA_GPU_PAINTING_THREADS=0
   - WEBKIT_SKIA_ENABLE_CPU_RENDERING unset

3) CPU multi-threaded rendering:
   - WEBKIT_SKIA_CPU_PAINTING_THREADS>0
     (or unset, then default nCores/2 is used)
   - WEBKIT_SKIA_ENABLE_CPU_RENDERING=1

4) CPU main thread rendering:
   - WEBKIT_SKIA_CPU_PAINTING_THREADS=0
   - WEBKIT_SKIA_ENABLE_CPU_RENDERING=1

Covered by existing tests.

* LayoutTests/css3/masking/mask-base64.html:
* LayoutTests/css3/masking/mask-luminance-svg.html:
* LayoutTests/svg/filters/filter-on-root-tile-boundary.html:
* LayoutTests/svg/repaint/buffered-rendering-static-image.html:
* Source/WebCore/platform/Skia.cmake:
* Source/WebCore/platform/SourcesSkia.txt:
* Source/WebCore/platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::skiaGrContext const):
(WebCore::ImageBuffer::copyAcceleratedImageBufferBorrowingBackendRenderTarget 
const):
* Source/WebCore/platform/graphics/ImageBuffer.h:
(WebCore::ImageBuffer::backendInfo const):
(WebCore::ImageBuffer::backendInfo): Deleted.
* Source/WebCore/platform/graphics/ImageBufferBackend.cpp:
(WebCore::ImageBufferBackend::copyAcceleratedImageBufferBorrowingBackendRenderTarget
 const):
* Source/WebCore/platform/graphics/ImageBufferBackend.h:
(WebCore::ImageBufferBackend::skiaGrContext const):
(WebCore::ImageBufferBackend::parameters const):
(WebCore::ImageBufferBackend::parameters): Deleted.
* Source/WebCore/platform/graphics/NativeImage.h:
(WebCore::NativeImageBackend::skiaGrContext const):
(WebCore::NativeImageBackend::copyAcceleratedNativeImageBorrowingBackendTexture 
const):
* Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContextSkia::drawSkiaImage):
(WebCore::GraphicsContextSkia::drawNativeImageInternal):
(WebCore::GraphicsContextSkia::drawFilteredImageBuffer):
(WebCore::GraphicsContextSkia::drawSkiaPattern):
(WebCore::GraphicsContextSkia::drawPattern):
* Source/WebCore/platform/graphics/skia/GraphicsContextSkia.h:
* Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.cpp:
(WebCore::ImageBufferSkiaAcceleratedBackend::create):
(WebCore::ImageBufferSkiaAcceleratedBackend::ImageBufferSkiaAcceleratedBackend):
(WebCore::ImageBufferSkiaAcceleratedBackend::finishAcceleratedRenderingAndCreateFence):
(WebCore::ImageBufferSkiaAcceleratedBackend::waitForAcceleratedRenderingFenceCompletion):
(WebCore::ImageBufferSkiaAcceleratedBackend::copyAcceleratedImageBufferBorrowingBackendRenderTarget
 const):
* Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.h:
* Source/WebCore/platform/graphics/skia/NativeImageSkia.cpp:
(WebCore::PlatformImageNativeImageBackend::finishAcceleratedRenderingAndCreateFence):
(WebCore::PlatformImageNativeImageBackend::waitForAcceleratedRenderingFenceCompletion):
(WebCore::PlatformImageNativeImageBackend::skiaGrContext const):
(WebCore::PlatformImageNativeImageBackend::copyAcceleratedNativeImageBorrowingBackendTexture
 const):
* Source/WebCore/platform/graphics/skia/SkiaPaintingEngine.cpp: Added.
(WebCore::SkiaPaintingEngine::SkiaPaintingEngine):
(WebCore::SkiaPaintingEngine::create):
(WebCore::SkiaPaintingEngine::recordDisplayList const):
(WebCore::SkiaPaintingEngine::paintIntoGraphicsContext const):
(WebCore::SkiaPaintingEngine::paintDisplayListIntoBuffer):
(WebCore::SkiaPaintingEngine::paintGraphicsLayerIntoBuffer const):
(WebCore::canPerformAcceleratedRendering):
(WebCore::SkiaPaintingEngine::renderingMode const):
(WebCore::SkiaPaintingEngine::threadedRenderingMode const):
(WebCore::SkiaPaintingEngine::createBuffer const):
(WebCore::SkiaPaintingEngine::paintLayer):
(WebCore::SkiaPaintingEngine::postPaintingTask):
(WebCore::SkiaPaintingEngine::performPaintingTask):
(WebCore::SkiaPaintingEngine::numberOfCPUPaintingThreads):
(WebCore::SkiaPaintingEngine::numberOfGPUPaintingThreads):
* Source/WebCore/platform/graphics/skia/SkiaPaintingEngine.h: Renamed from 
Source/WebCore/platform/graphics/skia/SkiaThreadedPaintingPool.h.
* Source/WebCore/platform/graphics/skia/SkiaThreadedPaintingPool.cpp: Removed.
* 
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
* 
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayerSkia.cpp:
(WebCore::CoordinatedGraphicsLayer::paintTile):
(WebCore::CoordinatedGraphicsLayer::paintIntoGraphicsContext const): Deleted.
* Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTileBuffer.cpp:
(WebCore::CoordinatedTileBuffer::beginPainting):
(WebCore::CoordinatedTileBuffer::completePainting):
(WebCore::CoordinatedTileBuffer::waitUntilPaintingComplete):
(WebCore::CoordinatedAcceleratedTileBuffer::completePainting):
(WebCore::CoordinatedAcceleratedTileBuffer::waitUntilPaintingComplete):
(WebCore::CoordinatedUnacceleratedTileBuffer::beginPainting): Deleted.
(WebCore::CoordinatedUnacceleratedTileBuffer::completePainting): Deleted.
(WebCore::CoordinatedUnacceleratedTileBuffer::waitUntilPaintingComplete): 
Deleted.
* Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedTileBuffer.h:
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
(WebKit::LayerTreeHost::LayerTreeHost):
(WebKit::LayerTreeHost::~LayerTreeHost):
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h:

Canonical link: https://commits.webkit.org/287060@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to