Commit 5bdf2fe5 authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Commit Bot

media/gpu/v4l2ip: allocate as many buffers as possible in DMABUF mode

If we are operating in DMABUF mode, then we will try to keep the same
frame assigned to the same V4L2 buffer. The number of buffers requested
by the client is indicative of the real load, but there is no hard
guarantee that we will not receive more frames than that, thus resulting
in sub-optimal affinity tracking.

Try to prevent this by allocating as many buffers as allowed by the V4L2
API (32) when operating in DMABUF mode. Since these buffers won't have
backing memory unless we attach a DMABUF to them, they are virtually
free if unused.

BUG=b:159688625
TEST=video.DecodeAccel.h264 passes on Kukui.

Change-Id: Ibc9ea18835acd4b8d3bc6ffc7393bf0d5d97d04d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2415908
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarFritz Koenig <frkoenig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813110}
parent 788bc9da
...@@ -96,13 +96,23 @@ void FillV4L2BufferByGpuMemoryBufferHandle( ...@@ -96,13 +96,23 @@ void FillV4L2BufferByGpuMemoryBufferHandle(
} }
bool AllocateV4L2Buffers(V4L2Queue* queue, bool AllocateV4L2Buffers(V4L2Queue* queue,
size_t num_buffers, const size_t num_buffers,
v4l2_memory memory_type) { v4l2_memory memory_type) {
DCHECK(queue); DCHECK(queue);
if (queue->AllocateBuffers(num_buffers, memory_type) == 0u)
size_t requested_buffers = num_buffers;
// If we are using DMABUFs, then we will try to keep using the same V4L2
// buffer for a given input or output frame. In that case, allocate as many
// V4L2 buffers as we can to avoid running out of them. Unused buffers won't
// use backed memory and are thus virtually free.
if (memory_type == V4L2_MEMORY_DMABUF)
requested_buffers = VIDEO_MAX_FRAME;
if (queue->AllocateBuffers(requested_buffers, memory_type) == 0u)
return false; return false;
if (queue->AllocatedBuffersCount() != num_buffers) { if (queue->AllocatedBuffersCount() < num_buffers) {
VLOGF(1) << "Failed to allocate buffers. Allocated number=" VLOGF(1) << "Failed to allocate buffers. Allocated number="
<< queue->AllocatedBuffersCount() << queue->AllocatedBuffersCount()
<< ", Requested number=" << num_buffers; << ", Requested number=" << num_buffers;
......
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