• yiyix's avatar
    viz: Optimize transform usage in draw occlusion · a4a3af77
    yiyix authored
    The most common transform used in rendering are simple transforms,
    such as translation and scaling. This patch is aimed to optimize the
    usage of these simple transforms.
    
    We used to transform every draw quad to the target space and verify
    that if the draw quad is behind a occlusion region or not. Since these
    simple transforms are invertible, we can transform the occlusion
    region from the target space to the coordinate space so that we can
    do the verification without applying transform on draw quad. The
    traversal speed is increased by 8 times as shown here:
    https://docs.google.com/document/d/1gM4h1ca2jDWdXbYa9yjC53m0sJzaT9skqbPGnfDsdyI/edit#heading=h.7y9syhsnunpw
    
    Before:
    98.26% viz::Display::RemoveOverdrawQuads(CompositorFrame)
      95.58% viz::Display::RemoveOverdrawQuads(CompositorFrame)
      53.17% cc::MathUtil::MapEnclosingClippedRect(gfx::Transform, Rect)
      9.36% cc::ListContainer::viz::DrawQuad::Iterator
      9.07% cc::ListContainer::viz::SharedQuadState::end
      6.77% cc::MathUtil::MapEnclosedRectWith2dAxisAlignedTransform(gfx::Transform, Rect)
      5.20% cc::SimpleEnclosedRegion::Union(gfx::Rect)
      4.46% cc::SimpleEnclosedRegion::Contains(gfx::Rect)
      2.28% cc::ListContainerHelper::PositionInCharAllocator
    
    After applying this patch,
    https://chromium-review.googlesource.com/c/chromium/src/+/783799
    and https://chromium-review.googlesource.com/c/chromium/src/+/782063:
    97.37% viz::Display::RemoveOverdrawQuads(CompositorFrame)
      1.23% cc::LapTimer::NextLap()
      0.48% cc::ListContainer::viz::SharedQuadState::ReverseIterator
      0.21% gfx::Rect::IsEmpty()
      0.17% gfx::Transform(SkMatrix44)
      0.09% cc::LapTimer::HasTimeLimitExpired()
      0.08% cc::ListContainerHelper::PositionInCharAllocator
    
    
    Bug: 
    Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel
    Change-Id: Iee7fb16e44637489a155101e4cc39e128e45acc4
    Reviewed-on: https://chromium-review.googlesource.com/788283
    Commit-Queue: Yi Xu <yiyix@chromium.org>
    Reviewed-by: default avatardanakj <danakj@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#521380}
    a4a3af77
display.cc 23 KB