• Miguel Casas's avatar
    Reland "RELAND 2: media/gpu/vaapi_video_decoder: keep allocated VASurfaces alive" · 49422e89
    Miguel Casas authored
    This is a reland of 02aec841
    
    Speculative revert was incorrect
    
    Original change's description:
    > RELAND 2: media/gpu/vaapi_video_decoder: keep allocated VASurfaces alive
    >
    > 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/+/2339494
    > Reviewed-by: Miguel 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/+/2359734
    > Reviewed-by: Andres 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}
    
    TBR=mcasas@chromium.org,andrescj@chromium.org
    
    Bug: b:163920993
    Bug: b:142019786 b:143323596
    No-Presubmit: true
    No-Tree-Checks: true
    No-Try: true
    Change-Id: I6124e960d93f6985dbf9a546bc9d34372815e002
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359975Reviewed-by: default avatarFergus Dall <sidereal@google.com>
    Commit-Queue: Fergus Dall <sidereal@google.com>
    Cr-Commit-Position: refs/heads/master@{#798968}
    49422e89
vaapi_video_decoder.h 6.98 KB