• Miguel Casas's avatar
    vaapi: decode on client NativePixmaps · c1ee5625
    Miguel Casas authored
    This CL teaches VaVDA to use client VASurfaceIDs to decode onto, saving
    a buffer copy and removing a costly blit (DownloadFromSurface) on the
    GPU Main thread.  Three groups of changes:
    
    1. In AssignPictureBuffers(): if |vaapi_picture_factory_| Create()s a
     VaapiPicture with a VASurfaceID, we use those to decode onto and set a new
     flag: |decode_using_client_picture_buffers_|
    
    2. When the decoder calls CreateVASurface(), instead of giving it the first
     |available_va_surfaces_|, we need to figure out the first VASurfaceID in
     this |available_va_surfaces_| such that the corresponding VaapiPicture in
     |pictures_| is available (i.e. in |available_picture_buffers_|).
     Reason: libva holds on to some VASurfaceIDs, there's no simple one-to-one
     correspondence like on ToT.
    
    3. When we're ready to OutputPicture() to |client_|, instead of using the first
     |available_picture_buffers_|, we find the corresponding one for the
     passed |va_surface_id| (we could search all over |pictures_| but there's
     always less |available_picture_buffers_|.
    
    Some other notable developments:
    
    - s/output_buffers_/available_picture_buffers_/
    - OutputPicture() loses a parameter.
    - |decode_using_client_picture_buffers_| is still false for e.g. VP9 Profile 2
     or the ImportBufferForPicture() path.
    - Pictures is made a base::small_map. (Originally from crrev.com/c/988512).
    
    Bug: 822346, 717265
    Test: v_d_a_unittest vp8/vp9/h264 passing on eve, running crosvideo changing
    resolutions for a long time. No hickups, no dropped frames.
    
    Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
    Change-Id: I3d5a4d3c83002c8d0977702c9b97ffec52b1db23
    Reviewed-on: https://chromium-review.googlesource.com/1021675Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
    Reviewed-by: default avatarKristian H. Kristensen <hoegsberg@chromium.org>
    Commit-Queue: Miguel Casas <mcasas@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#568880}
    c1ee5625
vaapi_picture.cc 1.23 KB