• Miguel Casas's avatar
    RELAND 2: media/gpu/vaapi_video_decoder: keep allocated VASurfaces alive · 02aec841
    Miguel Casas authored
    The relanded CL was reverted due to crashes when used from ARC++:
    Video Frames coming from this path are not GpuMemoryBuffers, so there's
    a DCHECK not verified, and then a crash. This CL addresses that
    situation, fixing `video_decode_accelerator_tests --use_vd_vda`:
    see crrev.com/c/2359734/1..3.
    
    Bug: b:163920993
    
    Original RELAND description -------------------------------------------
    
    The original CL was reverted due to crashes in betty initialization:
    betty is a VM which doesn't support VA, so the VideoDecoderPipeline
    constructed-destructed a VaapiVideoDecoder, hitting an unprotected
    nullptr |vaapi_wrapper_| in dtor. Fix in crrev.com/c/2339494/2..3.
    
    TBR=andrescj@chromium.org
    
    Original CL description -----------------------------------------------
    
    Certain platforms and codecs suffer from horrible artifacts (Intel BYT,
    H264) or crashes (Intel BSW/BDW, VP9). This was traced to some kind of
    error in the tracking of the VASurfaces lifetime in the driver: every
    time we get a new resource from the pool to decode onto, this is
    imported into libva as a VASurface: this works fine almost everywhere
    but doesn't play well in these old platforms (see CreateSurface() body).
    
    This CL adds a map that keeps the ref-counted VASurfaces alive and
    indexed by the unique GpuMemoryBufferId until the VA Context is
    destroyed. In so doing, we're basically observing the "contract" of
    va.h vaDestroySurfaces() [1] "Surfaces can only be destroyed after all
    contexts using these surfaces have been destroyed".
    
    [1] https://github.com/intel/libva/blob/libva-2.0.0/va/va.h#L1134
    
    Bug: b:142019786 b:143323596
    Change-Id: I16e74eb2b483b892961eca27aed30112240aa8ba
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2339494Reviewed-by: default avatarMiguel Casas <mcasas@chromium.org>
    Commit-Queue: Miguel Casas <mcasas@chromium.org>
    Cr-Original-Commit-Position: refs/heads/master@{#795026}
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359734Reviewed-by: default avatarAndres Calderon Jaramillo <andrescj@chromium.org>
    Commit-Queue: Andres Calderon Jaramillo <andrescj@chromium.org>
    Auto-Submit: Miguel Casas <mcasas@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#798931}
    02aec841
vaapi_video_decoder.cc 23.4 KB