Commit ec777f5e authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

Let VideoDecodeAccelerator indicate SharedImage support

Add a method to media::VideoDecodeAccelerator to indicate whether
SharedImage-backed picture buffers are supported. Make this return
true only for the VTVideoDecodeAccelerator.

Add a parameter to media::PictureBufferManager::CreatePictureBuffers
to indicate if SharedImage-backed PictureBuffers are desired.

Hook the two of these together in the ProvidePictureBuffersAsync
method of media::VdaVideoDecoder. Leave this disabled for now.

Bug: 1108909
Change-Id: I539f03bdca232fe32969ab5e92b6aea34c6d99f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436313Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811766}
parent 8e741e35
......@@ -27,11 +27,6 @@ int32_t NextID(int32_t* counter) {
return value;
}
bool UseSharedImage() {
// TODO(https://crbug.com/1108909): Enable shared image use on macOS.
return false;
}
class PictureBufferManagerImpl : public PictureBufferManager {
public:
explicit PictureBufferManagerImpl(
......@@ -79,7 +74,8 @@ class PictureBufferManagerImpl : public PictureBufferManager {
VideoPixelFormat pixel_format,
uint32_t planes,
gfx::Size texture_size,
uint32_t texture_target) override {
uint32_t texture_target,
bool use_shared_image) override {
DVLOG(2) << __func__;
DCHECK(gpu_task_runner_);
DCHECK(gpu_task_runner_->BelongsToCurrentThread());
......@@ -87,7 +83,7 @@ class PictureBufferManagerImpl : public PictureBufferManager {
DCHECK(planes);
DCHECK_LE(planes, static_cast<uint32_t>(VideoFrame::kMaxPlanes));
if (!UseSharedImage()) {
if (!use_shared_image) {
// TODO(sandersd): Consider requiring that CreatePictureBuffers() is
// called with the context current.
if (!command_buffer_helper_->MakeContextCurrent()) {
......@@ -98,9 +94,10 @@ class PictureBufferManagerImpl : public PictureBufferManager {
std::vector<PictureBuffer> picture_buffers;
for (uint32_t i = 0; i < count; i++) {
PictureBufferData picture_data = {pixel_format, texture_size};
PictureBufferData picture_data = {pixel_format, texture_size,
use_shared_image};
if (!UseSharedImage()) {
if (!use_shared_image) {
for (uint32_t j = 0; j < planes; j++) {
// Create a texture for this plane.
GLuint service_id = command_buffer_helper_->CreateTexture(
......@@ -219,7 +216,8 @@ class PictureBufferManagerImpl : public PictureBufferManager {
// If this |picture| has a SharedImage, then keep a reference to the
// SharedImage in |picture_buffer_data| and update the gpu::MailboxHolder.
DCHECK_EQ(UseSharedImage(), !!picture.scoped_shared_image());
DCHECK_EQ(picture_buffer_data.use_shared_image,
!!picture.scoped_shared_image());
if (auto scoped_shared_image = picture.scoped_shared_image()) {
picture_buffer_data.scoped_shared_image = scoped_shared_image;
picture_buffer_data.mailbox_holders[0] =
......@@ -350,6 +348,7 @@ class PictureBufferManagerImpl : public PictureBufferManager {
struct PictureBufferData {
VideoPixelFormat pixel_format;
gfx::Size texture_size;
bool use_shared_image = false;
std::vector<GLuint> service_ids;
gpu::MailboxHolder mailbox_holders[VideoFrame::kMaxPlanes];
scoped_refptr<Picture::ScopedSharedImage> scoped_shared_image;
......
......@@ -62,6 +62,7 @@ class PictureBufferManager
// |planes|: Number of image planes (textures) in the picture.
// |texture_size|: Size of textures to create.
// |texture_target|: Type of textures to create.
// |use_shared_image|: True if the created buffers should use shared images.
//
// Must be called on the GPU thread.
//
......@@ -77,7 +78,8 @@ class PictureBufferManager
VideoPixelFormat pixel_format,
uint32_t planes,
gfx::Size texture_size,
uint32_t texture_target) = 0;
uint32_t texture_target,
bool use_shared_image) = 0;
// Dismisses a picture buffer from the pool.
//
......
......@@ -41,7 +41,8 @@ class PictureBufferManagerImplTest : public testing::Test {
std::vector<PictureBuffer> CreateARGBPictureBuffers(uint32_t count) {
return pbm_->CreatePictureBuffers(count, PIXEL_FORMAT_ARGB, 1,
gfx::Size(320, 240), GL_TEXTURE_2D);
gfx::Size(320, 240), GL_TEXTURE_2D,
false /* use_shared_image */);
}
PictureBuffer CreateARGBPictureBuffer() {
......
......@@ -541,7 +541,8 @@ void VdaVideoDecoder::ProvidePictureBuffersAsync(uint32_t count,
std::vector<PictureBuffer> picture_buffers =
picture_buffer_manager_->CreatePictureBuffers(
count, pixel_format, planes, texture_size, texture_target);
count, pixel_format, planes, texture_size, texture_target,
vda_->SupportsSharedImagePictureBuffers());
if (picture_buffers.empty()) {
parent_task_runner_->PostTask(
FROM_HERE,
......
......@@ -1690,6 +1690,11 @@ bool VTVideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread(
return false;
}
bool VTVideoDecodeAccelerator::SupportsSharedImagePictureBuffers() const {
// TODO(https://crbug.com/1108909): Enable shared image use on macOS.
return false;
}
// static
VideoDecodeAccelerator::SupportedProfiles
VTVideoDecodeAccelerator::GetSupportedProfiles() {
......
......@@ -63,6 +63,7 @@ class VTVideoDecodeAccelerator : public VideoDecodeAccelerator,
const base::WeakPtr<Client>& decode_client,
const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner)
override;
bool SupportsSharedImagePictureBuffers() const override;
// MemoryDumpProvider implementation.
bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
......
......@@ -101,6 +101,10 @@ GLenum VideoDecodeAccelerator::GetSurfaceInternalFormat() const {
return GL_RGBA;
}
bool VideoDecodeAccelerator::SupportsSharedImagePictureBuffers() const {
return false;
}
VideoDecodeAccelerator::SupportedProfile::SupportedProfile()
: profile(media::VIDEO_CODEC_PROFILE_UNKNOWN), encrypted_only(false) {}
......
......@@ -414,6 +414,10 @@ class MEDIA_EXPORT VideoDecodeAccelerator {
// TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691
virtual GLenum GetSurfaceInternalFormat() const;
// Returns true if the decoder supports SharedImage backed picture buffers.
// May be called on any thread at any time.
virtual bool SupportsSharedImagePictureBuffers() const;
protected:
// Do not delete directly; use Destroy() or own it with a scoped_ptr, which
// will Destroy() it properly by default.
......
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