Commit 3518a663 authored by Miguel Casas's avatar Miguel Casas Committed by Commit Bot

media/gpu/vaapi: split some encoding-related TRACEs in VaapiWrapper

Encoding for Vaapi has 4 parts: (1) copying the video frame contents,
(2) submitting some buffers, (3) executing the encode, and finally
(4) downloading the encoded chunk.

During crrev.com/c/2344526 I was taking a look at the chrome traces
for it and reckoned it'd be good to split out some of them, namely this
CL adds more targeted metrics for:
- In part 1, for the libyuv copy-conversion that takes the majority of
the time.
- In part 4, for the SyncSurface (largest part), with a smaller share
taken by copying the encoded chunk out.

No new functionality intended.

Bug: b/166646505
Change-Id: Id0f6dbcb4c119e2692c2fa7ab999100e1cac77b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2427069Reviewed-by: default avatarAndres Calderon Jaramillo <andrescj@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810574}
parent bc8f2928
...@@ -1934,12 +1934,11 @@ bool VaapiWrapper::UploadVideoFrameToSurface(const VideoFrame& frame, ...@@ -1934,12 +1934,11 @@ bool VaapiWrapper::UploadVideoFrameToSurface(const VideoFrame& frame,
} }
const gfx::Size visible_size = frame.visible_rect().size(); const gfx::Size visible_size = frame.visible_rect().size();
bool va_create_put_fallback = false; bool needs_va_put_image = false;
VAImage image; VAImage image;
VAStatus va_res = vaDeriveImage(va_display_, va_surface_id, &image); VAStatus va_res = vaDeriveImage(va_display_, va_surface_id, &image);
if (va_res == VA_STATUS_ERROR_OPERATION_FAILED) { if (va_res == VA_STATUS_ERROR_OPERATION_FAILED) {
DVLOG(4) << "vaDeriveImage failed and fallback to Create_PutImage"; DVLOG(4) << "vaDeriveImage failed and fallback to Create_PutImage";
va_create_put_fallback = true;
constexpr VAImageFormat kImageFormatNV12{.fourcc = VA_FOURCC_NV12, constexpr VAImageFormat kImageFormatNV12{.fourcc = VA_FOURCC_NV12,
.byte_order = VA_LSB_FIRST, .byte_order = VA_LSB_FIRST,
.bits_per_pixel = 12}; .bits_per_pixel = 12};
...@@ -1948,6 +1947,7 @@ bool VaapiWrapper::UploadVideoFrameToSurface(const VideoFrame& frame, ...@@ -1948,6 +1947,7 @@ bool VaapiWrapper::UploadVideoFrameToSurface(const VideoFrame& frame,
va_res = vaCreateImage(va_display_, &image_format, va_surface_size.width(), va_res = vaCreateImage(va_display_, &image_format, va_surface_size.width(),
va_surface_size.height(), &image); va_surface_size.height(), &image);
VA_SUCCESS_OR_RETURN(va_res, VaapiFunctions::kVACreateImage, false); VA_SUCCESS_OR_RETURN(va_res, VaapiFunctions::kVACreateImage, false);
needs_va_put_image = true;
} }
base::ScopedClosureRunner vaimage_deleter( base::ScopedClosureRunner vaimage_deleter(
base::Bind(&DestroyVAImage, va_display_, image)); base::Bind(&DestroyVAImage, va_display_, image));
...@@ -1980,6 +1980,8 @@ bool VaapiWrapper::UploadVideoFrameToSurface(const VideoFrame& frame, ...@@ -1980,6 +1980,8 @@ bool VaapiWrapper::UploadVideoFrameToSurface(const VideoFrame& frame,
int ret = 0; int ret = 0;
{ {
TRACE_EVENT0("media,gpu", "VaapiWrapper::UploadVideoFrameToSurface_copy");
base::AutoUnlock auto_unlock(*va_lock_); base::AutoUnlock auto_unlock(*va_lock_);
switch (frame.format()) { switch (frame.format()) {
case PIXEL_FORMAT_I420: case PIXEL_FORMAT_I420:
...@@ -2019,10 +2021,11 @@ bool VaapiWrapper::UploadVideoFrameToSurface(const VideoFrame& frame, ...@@ -2019,10 +2021,11 @@ bool VaapiWrapper::UploadVideoFrameToSurface(const VideoFrame& frame,
return false; return false;
} }
} }
if (va_create_put_fallback) { if (needs_va_put_image) {
va_res = vaPutImage(va_display_, va_surface_id, image.image_id, 0, 0, const VAStatus va_res =
visible_size.width(), visible_size.height(), 0, 0, vaPutImage(va_display_, va_surface_id, image.image_id, 0, 0,
visible_size.width(), visible_size.height()); visible_size.width(), visible_size.height(), 0, 0,
visible_size.width(), visible_size.height());
VA_SUCCESS_OR_RETURN(va_res, VaapiFunctions::kVAPutImage, false); VA_SUCCESS_OR_RETURN(va_res, VaapiFunctions::kVAPutImage, false);
} }
return ret == 0; return ret == 0;
...@@ -2070,8 +2073,11 @@ bool VaapiWrapper::DownloadFromVABuffer(VABufferID buffer_id, ...@@ -2070,8 +2073,11 @@ bool VaapiWrapper::DownloadFromVABuffer(VABufferID buffer_id,
base::AutoLock auto_lock(*va_lock_); base::AutoLock auto_lock(*va_lock_);
TRACE_EVENT0("media,gpu", "VaapiWrapper::DownloadFromVABufferLocked"); TRACE_EVENT0("media,gpu", "VaapiWrapper::DownloadFromVABufferLocked");
VAStatus va_res = vaSyncSurface(va_display_, sync_surface_id); {
VA_SUCCESS_OR_RETURN(va_res, VaapiFunctions::kVASyncSurface, false); TRACE_EVENT0("media,gpu", "VaapiWrapper::DownloadFromVABuffer_SyncSurface");
const VAStatus va_res = vaSyncSurface(va_display_, sync_surface_id);
VA_SUCCESS_OR_RETURN(va_res, VaapiFunctions::kVASyncSurface, false);
}
ScopedVABufferMapping mapping(va_lock_, va_display_, buffer_id); ScopedVABufferMapping mapping(va_lock_, va_display_, buffer_id);
if (!mapping.IsValid()) if (!mapping.IsValid())
...@@ -2083,7 +2089,7 @@ bool VaapiWrapper::DownloadFromVABuffer(VABufferID buffer_id, ...@@ -2083,7 +2089,7 @@ bool VaapiWrapper::DownloadFromVABuffer(VABufferID buffer_id,
// cause another thread to acquire the lock and we'd have to wait delaying the // cause another thread to acquire the lock and we'd have to wait delaying the
// notification that the encode is done. // notification that the encode is done.
{ {
TRACE_EVENT0("media,gpu", "VaapiWrapper::DownloadFromVABufferCopyEncoded"); TRACE_EVENT0("media,gpu", "VaapiWrapper::DownloadFromVABuffer_copy");
*coded_data_size = 0; *coded_data_size = 0;
while (buffer_segment) { while (buffer_segment) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment