Changeset 128005 in webkit


Ignore:
Timestamp:
Sep 9, 2012 4:59:41 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Do not delete texture backing structures on the main thread
https://bugs.webkit.org/show_bug.cgi?id=96018

Patch by Christopher Cameron <ccameron@chromium.org> on 2012-09-09
Reviewed by James Robinson.

Do not delete CCPrioritizedTexture::Backing structures on the main
thread. Instead, unlink them from their owning CCPrioritizedTexture
in the main thread, and have the impl thread then delete all unlinked
textures.

This is towards having the main thread not access the m_backings set,
which will allow the impl thread to traverse that set when deleting
resources in response to GPU memory management events.

Tested by existing eviction tests (CCLayerTreeHostTest's
TestEvictTextures, LostContextAfterEvictTextures)

Fix a place where single thread proxy wasn't setting the main thread
blocked state correctly.

  • platform/graphics/chromium/cc/CCLayerTreeHost.cpp:

(WebCore::CCLayerTreeHost::unlinkAllContentTextures):
(WebCore):
(WebCore::CCLayerTreeHost::deleteUnlinkedTextures):

  • platform/graphics/chromium/cc/CCLayerTreeHost.h:

(CCLayerTreeHost):

  • platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp:

(WebCore::CCPrioritizedTextureManager::clearAllMemory):
(WebCore::CCPrioritizedTextureManager::unlinkAllBackings):
(WebCore):
(WebCore::CCPrioritizedTextureManager::deleteAllUnlinkedBackings):

  • platform/graphics/chromium/cc/CCPrioritizedTextureManager.h:

(CCPrioritizedTextureManager):

  • platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:

(WebCore::CCSingleThreadProxy::commitAndComposite):

  • platform/graphics/chromium/cc/CCThreadProxy.cpp:

(WebCore::CCThreadProxy::beginFrame):
(WebCore::CCThreadProxy::beginFrameCompleteOnImplThread):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r128002 r128005  
     12012-09-09  Christopher Cameron  <ccameron@chromium.org>
     2
     3        [chromium] Do not delete texture backing structures on the main thread
     4        https://bugs.webkit.org/show_bug.cgi?id=96018
     5
     6        Reviewed by James Robinson.
     7
     8        Do not delete CCPrioritizedTexture::Backing structures on the main
     9        thread.  Instead, unlink them from their owning CCPrioritizedTexture
     10        in the main thread, and have the impl thread then delete all unlinked
     11        textures.
     12
     13        This is towards having the main thread not access the m_backings set,
     14        which will allow the impl thread to traverse that set when deleting
     15        resources in response to GPU memory management events.
     16
     17        Tested by existing eviction tests (CCLayerTreeHostTest's
     18        TestEvictTextures, LostContextAfterEvictTextures)
     19
     20        Fix a place where single thread proxy wasn't setting the main thread
     21        blocked state correctly.
     22
     23        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
     24        (WebCore::CCLayerTreeHost::unlinkAllContentTextures):
     25        (WebCore):
     26        (WebCore::CCLayerTreeHost::deleteUnlinkedTextures):
     27        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
     28        (CCLayerTreeHost):
     29        * platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp:
     30        (WebCore::CCPrioritizedTextureManager::clearAllMemory):
     31        (WebCore::CCPrioritizedTextureManager::unlinkAllBackings):
     32        (WebCore):
     33        (WebCore::CCPrioritizedTextureManager::deleteAllUnlinkedBackings):
     34        * platform/graphics/chromium/cc/CCPrioritizedTextureManager.h:
     35        (CCPrioritizedTextureManager):
     36        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
     37        (WebCore::CCSingleThreadProxy::commitAndComposite):
     38        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
     39        (WebCore::CCThreadProxy::beginFrame):
     40        (WebCore::CCThreadProxy::beginFrameCompleteOnImplThread):
     41
    1422012-09-09  Andreas Kling  <kling@webkit.org>
    243
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

    r127948 r128005  
    415415}
    416416
    417 void CCLayerTreeHost::evictAllContentTextures()
     417void CCLayerTreeHost::unlinkAllContentTextures()
    418418{
    419419    ASSERT(CCProxy::isMainThread());
    420420    ASSERT(m_contentsTextureManager.get());
    421     m_contentsTextureManager->allBackingTexturesWereDeleted();
     421    m_contentsTextureManager->unlinkAllBackings();
     422}
     423
     424void CCLayerTreeHost::deleteUnlinkedTextures()
     425{
     426    ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
     427    ASSERT(m_contentsTextureManager.get());
     428    m_contentsTextureManager->deleteAllUnlinkedBackings();
    422429}
    423430
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h

    r127948 r128005  
    212212    CCPrioritizedTextureManager* contentsTextureManager() const;
    213213
    214     // This will cause contents texture manager to evict all textures, but
    215     // without deleting them. This happens after all content textures have
    216     // already been deleted on impl, after getting a 0 allocation limit.
    217     // Set during a commit, but before updateLayers.
    218     void evictAllContentTextures();
     214    void unlinkAllContentTextures();
     215    void deleteUnlinkedTextures();
    219216
    220217    bool visible() const { return m_visible; }
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp

    r127880 r128005  
    249249void CCPrioritizedTextureManager::clearAllMemory(CCResourceProvider* resourceProvider)
    250250{
     251    ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
     252    ASSERT(resourceProvider);
    251253    // Unlink and destroy all backing textures.
    252254    while (m_backings.size() > 0) {
     
    258260}
    259261
    260 void CCPrioritizedTextureManager::allBackingTexturesWereDeleted()
    261 {
    262     // Same as clearAllMemory, except all our textures were already
    263     // deleted externally, so we don't delete them. Passing no
    264     // resourceProvider results in leaking the (now invalid) texture ids.
    265     clearAllMemory(0);
     262void CCPrioritizedTextureManager::unlinkAllBackings()
     263{
     264    ASSERT(CCProxy::isMainThread());
     265    for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it)
     266        if ((*it)->owner())
     267            (*it)->owner()->unlink();
     268}
     269
     270void CCPrioritizedTextureManager::deleteAllUnlinkedBackings()
     271{
     272    ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
     273    BackingVector backingsToDelete;
     274    for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it)
     275        if (!(*it)->owner())
     276            backingsToDelete.append((*it));
     277
     278    for (BackingVector::iterator it = backingsToDelete.begin(); it != backingsToDelete.end(); ++it)
     279        destroyBacking((*it), 0);
    266280}
    267281
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h

    r127880 r128005  
    7979    void reduceMemory(CCResourceProvider*);
    8080    void clearAllMemory(CCResourceProvider*);
    81     void allBackingTexturesWereDeleted();
     81    void unlinkAllBackings();
     82    void deleteAllUnlinkedBackings();
    8283
    8384    void acquireBackingTextureIfNeeded(CCPrioritizedTexture*, CCResourceProvider*);
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp

    r127948 r128005  
    155155    bool initialized;
    156156    {
     157        DebugScopedSetMainThreadBlocked mainThreadBlocked;
    157158        DebugScopedSetImplThread impl;
    158159        if (!m_layerTreeHostImpl->contentsTexturesPurged())
     
    297298    ASSERT(CCProxy::isMainThread());
    298299
    299 
    300300    if (!m_layerTreeHost->initializeRendererIfNeeded())
    301301        return false;
    302302
    303     if (m_layerTreeHostImpl->contentsTexturesPurged())
    304         m_layerTreeHost->evictAllContentTextures();
     303    if (m_layerTreeHostImpl->contentsTexturesPurged()) {
     304        m_layerTreeHost->unlinkAllContentTextures();
     305        DebugScopedSetImplThreadAndMainThreadBlocked implAndMainBlocked;
     306        m_layerTreeHost->deleteUnlinkedTextures();
     307    }
    305308
    306309    CCTextureUpdateQueue queue;
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp

    r127948 r128005  
    550550
    551551    if (request->contentsTexturesWereDeleted)
    552         m_layerTreeHost->evictAllContentTextures();
     552        m_layerTreeHost->unlinkAllContentTextures();
    553553
    554554    OwnPtr<CCTextureUpdateQueue> queue = adoptPtr(new CCTextureUpdateQueue);
     
    592592    TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread");
    593593    ASSERT(!m_commitCompletionEventOnImplThread);
    594     ASSERT(isImplThread());
     594    ASSERT(isImplThread() && isMainThreadBlocked());
    595595    ASSERT(m_schedulerOnImplThread);
    596596    ASSERT(m_schedulerOnImplThread->commitPending());
     
    602602    }
    603603
    604     if (!contentsTexturesWereDeleted && m_layerTreeHostImpl->contentsTexturesPurged()) {
     604    if (contentsTexturesWereDeleted) {
     605        ASSERT(m_layerTreeHostImpl->contentsTexturesPurged());
     606        // We unlinked all textures on the main thread, delete them now.
     607        m_layerTreeHost->deleteUnlinkedTextures();
     608        // Mark that we can start drawing again when this commit is complete.
     609        m_resetContentsTexturesPurgedAfterCommitOnImplThread = true;
     610    } else if (m_layerTreeHostImpl->contentsTexturesPurged()) {
    605611        // We purged the content textures on the impl thread between the time we
    606612        // posted the beginFrame task and now, meaning we have a bunch of
     
    609615        queue->clearUploads();
    610616        setNeedsCommitOnImplThread();
    611     } else
    612         m_resetContentsTexturesPurgedAfterCommitOnImplThread = true;
     617    }
    613618
    614619    m_currentTextureUpdateControllerOnImplThread = CCTextureUpdateController::create(CCProxy::implThread(), queue, m_layerTreeHostImpl->resourceProvider(), m_layerTreeHostImpl->renderer()->textureCopier(), m_layerTreeHostImpl->renderer()->textureUploader());
Note: See TracChangeset for help on using the changeset viewer.