Changeset 127820 in webkit


Ignore:
Timestamp:
Sep 6, 2012 9:39:50 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-06
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)

  • 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

    r127819 r127820  
     12012-09-06  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        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
     21        (WebCore::CCLayerTreeHost::unlinkAllContentTextures):
     22        (WebCore):
     23        (WebCore::CCLayerTreeHost::deleteUnlinkedTextures):
     24        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
     25        (CCLayerTreeHost):
     26        * platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp:
     27        (WebCore::CCPrioritizedTextureManager::clearAllMemory):
     28        (WebCore::CCPrioritizedTextureManager::unlinkAllBackings):
     29        (WebCore):
     30        (WebCore::CCPrioritizedTextureManager::deleteAllUnlinkedBackings):
     31        * platform/graphics/chromium/cc/CCPrioritizedTextureManager.h:
     32        (CCPrioritizedTextureManager):
     33        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
     34        (WebCore::CCSingleThreadProxy::commitAndComposite):
     35        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
     36        (WebCore::CCThreadProxy::beginFrame):
     37        (WebCore::CCThreadProxy::beginFrameCompleteOnImplThread):
     38
    1392012-09-06  Simon Hausmann  <simon.hausmann@nokia.com>
    240
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

    r127789 r127820  
    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

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

    r127317 r127820  
    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

    r124093 r127820  
    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

    r126540 r127820  
    298298    ASSERT(CCProxy::isMainThread());
    299299
    300 
    301300    if (!m_layerTreeHost->initializeRendererIfNeeded())
    302301        return false;
    303302
    304     if (m_layerTreeHostImpl->contentsTexturesPurged())
    305         m_layerTreeHost->evictAllContentTextures();
     303    if (m_layerTreeHostImpl->contentsTexturesPurged()) {
     304        m_layerTreeHost->unlinkAllContentTextures();
     305        DebugScopedSetImplThreadAndMainThreadBlocked implAndMainBlocked;
     306        m_layerTreeHost->deleteUnlinkedTextures();
     307    }
    306308
    307309    CCTextureUpdateQueue queue;
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp

    r127556 r127820  
    556556
    557557    if (request->contentsTexturesWereDeleted)
    558         m_layerTreeHost->evictAllContentTextures();
     558        m_layerTreeHost->unlinkAllContentTextures();
    559559
    560560    OwnPtr<CCTextureUpdateQueue> queue = adoptPtr(new CCTextureUpdateQueue);
     
    598598    TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread");
    599599    ASSERT(!m_commitCompletionEventOnImplThread);
    600     ASSERT(isImplThread());
     600    ASSERT(isImplThread() && isMainThreadBlocked());
    601601    ASSERT(m_schedulerOnImplThread);
    602602    ASSERT(m_schedulerOnImplThread->commitPending());
     
    608608    }
    609609
    610     if (!contentsTexturesWereDeleted && m_layerTreeHostImpl->contentsTexturesPurged()) {
     610    if (contentsTexturesWereDeleted) {
     611        ASSERT(m_layerTreeHostImpl->contentsTexturesPurged());
     612        // We unlinked all textures on the main thread, delete them now.
     613        m_layerTreeHost->deleteUnlinkedTextures();
     614        // Mark that we can start drawing again when this commit is complete.
     615        m_resetContentsTexturesPurgedAfterCommitOnImplThread = true;
     616    } else if (m_layerTreeHostImpl->contentsTexturesPurged()) {
    611617        // We purged the content textures on the impl thread between the time we
    612618        // posted the beginFrame task and now, meaning we have a bunch of
     
    615621        queue->clearUploads();
    616622        setNeedsCommitOnImplThread();
    617     } else
    618         m_resetContentsTexturesPurgedAfterCommitOnImplThread = true;
     623    }
    619624
    620625    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.