Changeset 275463 in webkit


Ignore:
Timestamp:
Apr 5, 2021 5:50:05 PM (3 years ago)
Author:
Fujii Hironori
Message:

[Win][WK2] Implement IPC::Semaphore to run WebGL in GPU process
https://bugs.webkit.org/show_bug.cgi?id=224014

Reviewed by Don Olmstead.

Source/WebCore:

  • platform/graphics/PlatformDisplay.cpp:

(WebCore::PlatformDisplay::sharedDisplay): GPU process calls this
function in IPC thread. Removed the assertion checking the main
thread.

  • platform/graphics/opengl/GraphicsContextGLOpenGL.h:
  • platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp:

(WebCore::GraphicsContextGLOpenGL::createForGPUProcess): Added.

Source/WebKit:

  • GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
  • GPUProcess/graphics/RemoteGraphicsContextGLWin.cpp: Added.

(WebKit::RemoteGraphicsContextGL::create):
(WebKit::RemoteGraphicsContextGLWin::RemoteGraphicsContextGLWin):
(WebKit::RemoteGraphicsContextGLWin::platformWorkQueueInitialize):
(WebKit::RemoteGraphicsContextGL::prepareForDisplay):

  • Platform/IPC/IPCSemaphore.cpp:
  • Platform/IPC/IPCSemaphore.h:
  • Platform/IPC/StreamClientConnection.cpp:

(IPC::StreamClientConnection::setWakeUpSemaphore):
(IPC::StreamClientConnection::wakeUpServer):

  • Platform/IPC/StreamClientConnection.h:

(IPC::StreamClientConnection::tryAcquire):
(IPC::StreamClientConnection::tryAcquireAll):

  • Platform/IPC/StreamConnectionWorkQueue.cpp:

(IPC::StreamConnectionWorkQueue::StreamConnectionWorkQueue):
(IPC::StreamConnectionWorkQueue::removeStreamConnection):
(IPC::StreamConnectionWorkQueue::stop):
(IPC::StreamConnectionWorkQueue::wakeUp):
(IPC::StreamConnectionWorkQueue::wakeUpProcessingThread):

  • Platform/IPC/StreamConnectionWorkQueue.h:
  • Platform/IPC/StreamServerConnection.cpp:

(IPC::StreamServerConnectionBase::release):
(IPC::StreamServerConnectionBase::releaseAll):

  • Platform/IPC/win/IPCSemaphoreWin.cpp: Added.

(IPC::Semaphore::Semaphore):
(IPC::Semaphore::~Semaphore):
(IPC::Semaphore::operator=):
(IPC::Semaphore::signal):
(IPC::Semaphore::wait):
(IPC::Semaphore::waitFor):
(IPC::Semaphore::encode const):
(IPC::Semaphore::decode):
(IPC::Semaphore::destroy):

  • PlatformWin.cmake:
  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::createGraphicsContextGL const):

Location:
trunk/Source
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r275462 r275463  
     12021-04-05  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [Win][WK2] Implement IPC::Semaphore to run WebGL in GPU process
     4        https://bugs.webkit.org/show_bug.cgi?id=224014
     5
     6        Reviewed by Don Olmstead.
     7
     8        * platform/graphics/PlatformDisplay.cpp:
     9        (WebCore::PlatformDisplay::sharedDisplay): GPU process calls this
     10        function in IPC thread. Removed the assertion checking the main
     11        thread.
     12        * platform/graphics/opengl/GraphicsContextGLOpenGL.h:
     13        * platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp:
     14        (WebCore::GraphicsContextGLOpenGL::createForGPUProcess): Added.
     15
    1162021-04-05  Cameron McCormack  <heycam@apple.com>
    217
  • trunk/Source/WebCore/platform/graphics/PlatformDisplay.cpp

    r274273 r275463  
    133133#if PLATFORM(WIN)
    134134    // ANGLE D3D renderer isn't thread-safe. Don't destruct it on non-main threads which calls _exit().
    135     ASSERT(isMainThread());
    136135    static PlatformDisplay* display = createPlatformDisplay().release();
    137136    return *display;
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h

    r275097 r275463  
    113113    static GCGLint EGLDrawingBufferTextureTarget();
    114114#else
     115    static Ref<GraphicsContextGLOpenGL> createForGPUProcess(const GraphicsContextGLAttributes&);
    115116    PlatformLayer* platformLayer() const final;
    116117#endif
  • trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp

    r275373 r275463  
    9797}
    9898
     99Ref<GraphicsContextGLOpenGL> GraphicsContextGLOpenGL::createForGPUProcess(const GraphicsContextGLAttributes& attributes)
     100{
     101    return adoptRef(*new GraphicsContextGLOpenGL(attributes, nullptr));
     102}
     103
    99104#if USE(ANGLE)
    100105GraphicsContextGLOpenGL::GraphicsContextGLOpenGL(GraphicsContextGLAttributes attributes, HostWindow*, GraphicsContextGLOpenGL* sharedContext)
  • trunk/Source/WebKit/ChangeLog

    r275459 r275463  
     12021-04-05  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [Win][WK2] Implement IPC::Semaphore to run WebGL in GPU process
     4        https://bugs.webkit.org/show_bug.cgi?id=224014
     5
     6        Reviewed by Don Olmstead.
     7
     8        * GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
     9        * GPUProcess/graphics/RemoteGraphicsContextGLWin.cpp: Added.
     10        (WebKit::RemoteGraphicsContextGL::create):
     11        (WebKit::RemoteGraphicsContextGLWin::RemoteGraphicsContextGLWin):
     12        (WebKit::RemoteGraphicsContextGLWin::platformWorkQueueInitialize):
     13        (WebKit::RemoteGraphicsContextGL::prepareForDisplay):
     14        * Platform/IPC/IPCSemaphore.cpp:
     15        * Platform/IPC/IPCSemaphore.h:
     16        * Platform/IPC/StreamClientConnection.cpp:
     17        (IPC::StreamClientConnection::setWakeUpSemaphore):
     18        (IPC::StreamClientConnection::wakeUpServer):
     19        * Platform/IPC/StreamClientConnection.h:
     20        (IPC::StreamClientConnection::tryAcquire):
     21        (IPC::StreamClientConnection::tryAcquireAll):
     22        * Platform/IPC/StreamConnectionWorkQueue.cpp:
     23        (IPC::StreamConnectionWorkQueue::StreamConnectionWorkQueue):
     24        (IPC::StreamConnectionWorkQueue::removeStreamConnection):
     25        (IPC::StreamConnectionWorkQueue::stop):
     26        (IPC::StreamConnectionWorkQueue::wakeUp):
     27        (IPC::StreamConnectionWorkQueue::wakeUpProcessingThread):
     28        * Platform/IPC/StreamConnectionWorkQueue.h:
     29        * Platform/IPC/StreamServerConnection.cpp:
     30        (IPC::StreamServerConnectionBase::release):
     31        (IPC::StreamServerConnectionBase::releaseAll):
     32        * Platform/IPC/win/IPCSemaphoreWin.cpp: Added.
     33        (IPC::Semaphore::Semaphore):
     34        (IPC::Semaphore::~Semaphore):
     35        (IPC::Semaphore::operator=):
     36        (IPC::Semaphore::signal):
     37        (IPC::Semaphore::wait):
     38        (IPC::Semaphore::waitFor):
     39        (IPC::Semaphore::encode const):
     40        (IPC::Semaphore::decode):
     41        (IPC::Semaphore::destroy):
     42        * PlatformWin.cmake:
     43        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     44        (WebKit::WebChromeClient::createGraphicsContextGL const):
     45
    1462021-04-05  Myles C. Maxfield  <mmaxfield@apple.com>
    247
  • trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp

    r275403 r275463  
    5353}
    5454
    55 #if !PLATFORM(COCOA)
     55#if !PLATFORM(COCOA) && !PLATFORM(WIN)
    5656Ref<RemoteGraphicsContextGL> RemoteGraphicsContextGL::create(GPUConnectionToWebProcess& gpuConnectionToWebProcess, GraphicsContextGLAttributes&& attributes, GraphicsContextGLIdentifier graphicsContextGLIdentifier, RemoteRenderingBackend& renderingBackend, IPC::StreamConnectionBuffer&& stream)
    5757{
     
    152152}
    153153
    154 #if !PLATFORM(COCOA)
     154#if !PLATFORM(COCOA) && !PLATFORM(WIN)
    155155void RemoteGraphicsContextGL::prepareForDisplay(CompletionHandler<void()>&& completionHandler)
    156156{
  • trunk/Source/WebKit/Platform/IPC/IPCSemaphore.cpp

    r272382 r275463  
    2727#include "IPCSemaphore.h"
    2828
    29 #if !OS(DARWIN)
     29#if !OS(DARWIN) && !OS(WINDOWS)
    3030
    3131namespace IPC {
  • trunk/Source/WebKit/Platform/IPC/IPCSemaphore.h

    r275180 r275463  
    3434#include <mach/semaphore.h>
    3535#include <wtf/MachSendRight.h>
     36#elif OS(WINDOWS)
     37#include <windows.h>
    3638#endif
    3739
     
    5355    static Optional<Semaphore> decode(Decoder&);
    5456
     57    void signal();
     58    void wait();
     59    bool waitFor(Timeout);
     60
    5561#if OS(DARWIN)
    5662    explicit Semaphore(MachSendRight&&);
    5763
    58     void signal();
    59     void wait();
    60     bool waitFor(Timeout);
    6164    MachSendRight createSendRight() const;
    6265    explicit operator bool() const { return m_sendRight || m_semaphore != SEMAPHORE_NULL; }
     66#elif OS(WINDOWS)
     67    explicit Semaphore(HANDLE);
    6368#else
    6469    explicit operator bool() const { return true; }
     
    6671
    6772private:
     73    void destroy();
    6874#if OS(DARWIN)
    69     void destroy();
    7075    MachSendRight m_sendRight;
    7176    semaphore_t m_semaphore { SEMAPHORE_NULL };
     77#elif OS(WINDOWS)
     78    HANDLE m_semaphoreHandle { nullptr };
    7279#endif
    7380};
  • trunk/Source/WebKit/Platform/IPC/StreamClientConnection.cpp

    r274066 r275463  
    4141void StreamClientConnection::setWakeUpSemaphore(IPC::Semaphore&& semaphore)
    4242{
    43 #if PLATFORM(COCOA)
     43#if PLATFORM(COCOA) || PLATFORM(WIN)
    4444    m_wakeUpSemaphore = WTFMove(semaphore);
    4545#endif
     
    4949void StreamClientConnection::wakeUpServer()
    5050{
    51 #if PLATFORM(COCOA)
     51#if PLATFORM(COCOA) || PLATFORM(WIN)
    5252    if (m_wakeUpSemaphore)
    5353        m_wakeUpSemaphore->signal();
  • trunk/Source/WebKit/Platform/IPC/StreamClientConnection.h

    r274433 r275463  
    103103    size_t m_clientOffset { 0 };
    104104    StreamConnectionBuffer m_buffer;
    105 #if PLATFORM(COCOA)
     105#if PLATFORM(COCOA) || PLATFORM(WIN)
    106106    Optional<Semaphore> m_wakeUpSemaphore;
    107107#endif
     
    241241        if (timeout.didTimeOut())
    242242            break;
    243 #if PLATFORM(COCOA)
     243#if PLATFORM(COCOA) || PLATFORM(WIN)
    244244        ClientLimit oldClientLimit = sharedClientLimit().compareExchangeStrong(clientLimit, ClientLimit::clientIsWaitingTag, std::memory_order_acq_rel, std::memory_order_acq_rel);
    245245        if (clientLimit == oldClientLimit) {
     
    274274
    275275    for (;;) {
    276 #if PLATFORM(COCOA)
     276#if PLATFORM(COCOA) || PLATFORM(WIN)
    277277        ClientLimit clientLimit = sharedClientLimit().exchange(ClientLimit::clientIsWaitingTag, std::memory_order_acq_rel);
    278278        ClientOffset clientOffset = sharedClientOffset().load(std::memory_order_acquire);
     
    284284            break;
    285285
    286 #if PLATFORM(COCOA)
     286#if PLATFORM(COCOA) || PLATFORM(WIN)
    287287        m_buffer.clientWaitSemaphore().waitFor(timeout);
    288288#else
     
    292292            return WTF::nullopt;
    293293    }
    294 #if PLATFORM(COCOA)
     294#if PLATFORM(COCOA) || PLATFORM(WIN)
    295295    // In case the transaction was cancelled, undo the transaction marker.
    296296    sharedClientLimit().store(static_cast<ClientLimit>(0), std::memory_order_release);
  • trunk/Source/WebKit/Platform/IPC/StreamConnectionWorkQueue.cpp

    r274386 r275463  
    3030
    3131StreamConnectionWorkQueue::StreamConnectionWorkQueue(const char* name)
    32 #if PLATFORM(COCOA)
     32#if PLATFORM(COCOA) || PLATFORM(WIN)
    3333    : m_name(name)
    3434#endif
     
    6464        ASSERT(!m_shouldQuit); // Re-entering during shutdown not supported.
    6565    }
    66 #if PLATFORM(COCOA)
     66#if PLATFORM(COCOA) || PLATFORM(WIN)
    6767    m_wakeUpSemaphore.signal();
    6868#endif
     
    7272{
    7373    m_shouldQuit = true;
    74 #if PLATFORM(COCOA)
     74#if PLATFORM(COCOA) || PLATFORM(WIN)
    7575    if (!m_processingThread)
    7676        return;
     
    8383void StreamConnectionWorkQueue::wakeUp()
    8484{
    85 #if PLATFORM(COCOA)
     85#if PLATFORM(COCOA) || PLATFORM(WIN)
    8686    m_wakeUpSemaphore.signal();
    8787#endif
     
    9595void StreamConnectionWorkQueue::wakeUpProcessingThread()
    9696{
    97 #if PLATFORM(COCOA)
     97#if PLATFORM(COCOA) || PLATFORM(WIN)
    9898    if (m_processingThread) {
    9999        m_wakeUpSemaphore.signal();
  • trunk/Source/WebKit/Platform/IPC/StreamConnectionWorkQueue.h

    r274386 r275463  
    5454    void processStreams();
    5555
    56 #if PLATFORM(COCOA)
     56#if PLATFORM(COCOA) || PLATFORM(WIN)
    5757    const char* const m_name;
    5858#endif
  • trunk/Source/WebKit/Platform/IPC/StreamServerConnection.cpp

    r274433 r275463  
    8989    ServerOffset serverOffset = static_cast<ServerOffset>(wrapOffset(alignOffset(m_serverOffset) + readSize));
    9090
    91 #if PLATFORM(COCOA)
     91#if PLATFORM(COCOA) || PLATFORM(WIN)
    9292    ServerOffset oldServerOffset = sharedServerOffset().exchange(serverOffset, std::memory_order_acq_rel);
    9393    // If the client wrote over serverOffset, it means the client is waiting.
     
    107107{
    108108    sharedServerLimit().store(static_cast<ServerLimit>(0), std::memory_order_release);
    109 #if PLATFORM(COCOA)
     109#if PLATFORM(COCOA) || PLATFORM(WIN)
    110110    ServerOffset oldServerOffset = sharedServerOffset().exchange(static_cast<ServerOffset>(0), std::memory_order_acq_rel);
    111111    // If the client wrote over serverOffset, it means the client is waiting.
  • trunk/Source/WebKit/PlatformWin.cmake

    r274912 r275463  
    1010
    1111list(APPEND WebKit_SOURCES
     12    GPUProcess/graphics/RemoteGraphicsContextGLWin.cpp
     13
    1214    GPUProcess/media/win/RemoteMediaPlayerProxyWin.cpp
    1315
     
    2325    Platform/IPC/win/AttachmentWin.cpp
    2426    Platform/IPC/win/ConnectionWin.cpp
     27    Platform/IPC/win/IPCSemaphoreWin.cpp
    2528
    2629    Platform/classifier/ResourceLoadStatisticsClassifier.cpp
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r274929 r275463  
    112112#endif
    113113
    114 #if PLATFORM(COCOA)
     114#if PLATFORM(COCOA) || PLATFORM(WIN)
    115115#include "RemoteGraphicsContextGLProxy.h"
    116116#endif
     
    939939        return nullptr;
    940940    UNUSED_VARIABLE(hostWindowDisplayID);
    941 #if PLATFORM(COCOA)
     941#if PLATFORM(COCOA) || PLATFORM(WIN)
    942942    return RemoteGraphicsContextGLProxy::create(attributes, m_page.ensureRemoteRenderingBackendProxy().renderingBackendIdentifier());
    943943#else
Note: See TracChangeset for help on using the changeset viewer.