Commit 42a63f2b authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Commit Bot

media/gpu/v4l2vda: Assign output_fds earlier

When using import mode, we used to assign output_fds last, during
the call to AssignEGLImage(). However this can also be done ahead of
time in ImportBufferForPictureTask(). Doing so allows us to stop passing
the DMABUF FDs as an argument to AssignEGLImage(), simplifying its
interface as well as the code in ImportBufferForPictureTask().

BUG=792790
TEST=Checked that VDA unittest was passing on Hana, in import and
non-import mode, with rendering enabled or not.

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: I95b66f7b3b4ee31147b2eb34a19499c39ad4efa8
Reviewed-on: https://chromium-review.googlesource.com/c/1288497Reviewed-by: default avatarPawel Osciak <posciak@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601882}
parent 9f335772
...@@ -481,17 +481,14 @@ void V4L2VideoDecodeAccelerator::CreateEGLImageFor( ...@@ -481,17 +481,14 @@ void V4L2VideoDecodeAccelerator::CreateEGLImageFor(
} }
decoder_thread_.task_runner()->PostTask( decoder_thread_.task_runner()->PostTask(
FROM_HERE, FROM_HERE, base::Bind(&V4L2VideoDecodeAccelerator::AssignEGLImage,
base::Bind(&V4L2VideoDecodeAccelerator::AssignEGLImage, base::Unretained(this), buffer_index,
base::Unretained(this), buffer_index, picture_buffer_id, picture_buffer_id, egl_image));
egl_image, base::Passed(&dmabuf_fds)));
} }
void V4L2VideoDecodeAccelerator::AssignEGLImage( void V4L2VideoDecodeAccelerator::AssignEGLImage(size_t buffer_index,
size_t buffer_index, int32_t picture_buffer_id,
int32_t picture_buffer_id, EGLImageKHR egl_image) {
EGLImageKHR egl_image,
std::vector<base::ScopedFD> dmabuf_fds) {
DVLOGF(3) << "index=" << buffer_index << ", picture_id=" << picture_buffer_id; DVLOGF(3) << "index=" << buffer_index << ", picture_id=" << picture_buffer_id;
DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
...@@ -521,10 +518,6 @@ void V4L2VideoDecodeAccelerator::AssignEGLImage( ...@@ -521,10 +518,6 @@ void V4L2VideoDecodeAccelerator::AssignEGLImage(
DCHECK_EQ(output_record.state, kFree); DCHECK_EQ(output_record.state, kFree);
output_record.egl_image = egl_image; output_record.egl_image = egl_image;
if (output_mode_ == Config::OutputMode::IMPORT) {
DCHECK(output_record.output_fds.empty());
output_record.output_fds.swap(dmabuf_fds);
}
// Drop our reference so the buffer returns to the queue and can be reused. // Drop our reference so the buffer returns to the queue and can be reused.
output_wait_map_.erase(picture_buffer_id); output_wait_map_.erase(picture_buffer_id);
...@@ -645,7 +638,11 @@ void V4L2VideoDecodeAccelerator::ImportBufferForPictureTask( ...@@ -645,7 +638,11 @@ void V4L2VideoDecodeAccelerator::ImportBufferForPictureTask(
DVLOGF(3) << "Change state to kDecoding"; DVLOGF(3) << "Change state to kDecoding";
} }
size_t index = iter - output_buffer_map_.begin(); if (output_mode_ == Config::OutputMode::IMPORT) {
DCHECK_EQ(egl_image_planes_count_, dmabuf_fds.size());
DCHECK(iter->output_fds.empty());
iter->output_fds = DuplicateFDs(dmabuf_fds);
}
iter->state = kFree; iter->state = kFree;
if (iter->texture_id != 0) { if (iter->texture_id != 0) {
...@@ -656,6 +653,7 @@ void V4L2VideoDecodeAccelerator::ImportBufferForPictureTask( ...@@ -656,6 +653,7 @@ void V4L2VideoDecodeAccelerator::ImportBufferForPictureTask(
egl_display_, iter->egl_image)); egl_display_, iter->egl_image));
} }
size_t index = iter - output_buffer_map_.begin();
child_task_runner_->PostTask( child_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&V4L2VideoDecodeAccelerator::CreateEGLImageFor, base::BindOnce(&V4L2VideoDecodeAccelerator::CreateEGLImageFor,
...@@ -664,10 +662,6 @@ void V4L2VideoDecodeAccelerator::ImportBufferForPictureTask( ...@@ -664,10 +662,6 @@ void V4L2VideoDecodeAccelerator::ImportBufferForPictureTask(
egl_image_size_, egl_image_format_fourcc_)); egl_image_size_, egl_image_format_fourcc_));
} else { } else {
// No need for an EGLImage, start using this buffer now. // No need for an EGLImage, start using this buffer now.
DCHECK_EQ(egl_image_planes_count_, dmabuf_fds.size());
iter->output_fds.swap(dmabuf_fds);
// If this was the first import, release the reference to the buffer
// so it can be used.
output_wait_map_.erase(picture_buffer_id); output_wait_map_.erase(picture_buffer_id);
if (decoder_state_ != kChangingResolution) { if (decoder_state_ != kChangingResolution) {
Enqueue(); Enqueue();
......
...@@ -256,12 +256,10 @@ class MEDIA_GPU_EXPORT V4L2VideoDecodeAccelerator ...@@ -256,12 +256,10 @@ class MEDIA_GPU_EXPORT V4L2VideoDecodeAccelerator
uint32_t fourcc); uint32_t fourcc);
// Take the EGLImage |egl_image|, created for |picture_buffer_id|, and use it // Take the EGLImage |egl_image|, created for |picture_buffer_id|, and use it
// for OutputRecord at |buffer_index|. The buffer is backed by // for OutputRecord at |buffer_index|.
// |passed_dmabuf_fds|, and the OutputRecord takes ownership of them.
void AssignEGLImage(size_t buffer_index, void AssignEGLImage(size_t buffer_index,
int32_t picture_buffer_id, int32_t picture_buffer_id,
EGLImageKHR egl_image, EGLImageKHR egl_image);
std::vector<base::ScopedFD> dmabuf_fds);
// Service I/O on the V4L2 devices. This task should only be scheduled from // Service I/O on the V4L2 devices. This task should only be scheduled from
// DevicePollTask(). If |event_pending| is true, one or more events // DevicePollTask(). If |event_pending| is true, one or more events
......
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