Commit 93d9a7a4 authored by Dan Sanders's avatar Dan Sanders Committed by Commit Bot

[media] Enable VDAs to request read lock fences, use in VTVDA.

VTVDA binds IOSurfaces to textures, and therefore it is possible for
a GL operation on the IOSurface to still be queued (at the platform
level) after all references to the IOSurface have been dropped.

This CL enables VDAs to request the READ_LOCK_FENCES_ENABLED flag on
their VideoFrames, which ensures that platform operations have
completed before references are dropped.

Bug: 934578
Change-Id: Ia369c66d06100f58f991494b354d00dc628b38c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1487698Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Commit-Queue: Dan Sanders <sandersd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#637946}
parent abc3c6d1
...@@ -687,6 +687,10 @@ void GpuVideoDecoder::PictureReady(const media::Picture& picture) { ...@@ -687,6 +687,10 @@ void GpuVideoDecoder::PictureReady(const media::Picture& picture) {
frame->set_color_space(picture.color_space()); frame->set_color_space(picture.color_space());
if (picture.allow_overlay()) if (picture.allow_overlay())
frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true); frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true);
if (picture.read_lock_fences_enabled()) {
frame->metadata()->SetBoolean(VideoFrameMetadata::READ_LOCK_FENCES_ENABLED,
true);
}
if (picture.texture_owner()) if (picture.texture_owner())
frame->metadata()->SetBoolean(VideoFrameMetadata::TEXTURE_OWNER, true); frame->metadata()->SetBoolean(VideoFrameMetadata::TEXTURE_OWNER, true);
if (picture.wants_promotion_hint()) { if (picture.wants_promotion_hint()) {
......
...@@ -262,6 +262,7 @@ void GpuVideoDecodeAcceleratorHost::OnPictureReady( ...@@ -262,6 +262,7 @@ void GpuVideoDecodeAcceleratorHost::OnPictureReady(
Picture picture(params.picture_buffer_id, params.bitstream_buffer_id, Picture picture(params.picture_buffer_id, params.bitstream_buffer_id,
params.visible_rect, params.color_space, params.visible_rect, params.color_space,
params.allow_overlay); params.allow_overlay);
picture.set_read_lock_fences_enabled(params.read_lock_fences_enabled);
picture.set_size_changed(params.size_changed); picture.set_size_changed(params.size_changed);
picture.set_texture_owner(params.surface_texture); picture.set_texture_owner(params.surface_texture);
picture.set_wants_promotion_hint(params.wants_promotion_hint); picture.set_wants_promotion_hint(params.wants_promotion_hint);
......
...@@ -27,6 +27,7 @@ IPC_STRUCT_BEGIN(AcceleratedVideoDecoderHostMsg_PictureReady_Params) ...@@ -27,6 +27,7 @@ IPC_STRUCT_BEGIN(AcceleratedVideoDecoderHostMsg_PictureReady_Params)
IPC_STRUCT_MEMBER(gfx::Rect, visible_rect) IPC_STRUCT_MEMBER(gfx::Rect, visible_rect)
IPC_STRUCT_MEMBER(gfx::ColorSpace, color_space) IPC_STRUCT_MEMBER(gfx::ColorSpace, color_space)
IPC_STRUCT_MEMBER(bool, allow_overlay) IPC_STRUCT_MEMBER(bool, allow_overlay)
IPC_STRUCT_MEMBER(bool, read_lock_fences_enabled)
IPC_STRUCT_MEMBER(bool, size_changed) IPC_STRUCT_MEMBER(bool, size_changed)
IPC_STRUCT_MEMBER(bool, surface_texture) IPC_STRUCT_MEMBER(bool, surface_texture)
IPC_STRUCT_MEMBER(bool, wants_promotion_hint) IPC_STRUCT_MEMBER(bool, wants_promotion_hint)
......
...@@ -288,6 +288,7 @@ void GpuVideoDecodeAccelerator::PictureReady(const Picture& picture) { ...@@ -288,6 +288,7 @@ void GpuVideoDecodeAccelerator::PictureReady(const Picture& picture) {
params.visible_rect = picture.visible_rect(); params.visible_rect = picture.visible_rect();
params.color_space = picture.color_space(); params.color_space = picture.color_space();
params.allow_overlay = picture.allow_overlay(); params.allow_overlay = picture.allow_overlay();
params.read_lock_fences_enabled = picture.read_lock_fences_enabled();
params.size_changed = picture.size_changed(); params.size_changed = picture.size_changed();
params.surface_texture = picture.texture_owner(); params.surface_texture = picture.texture_owner();
params.wants_promotion_hint = picture.wants_promotion_hint(); params.wants_promotion_hint = picture.wants_promotion_hint();
......
...@@ -220,6 +220,10 @@ class PictureBufferManagerImpl : public PictureBufferManager { ...@@ -220,6 +220,10 @@ class PictureBufferManagerImpl : public PictureBufferManager {
if (picture.allow_overlay()) if (picture.allow_overlay())
frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true); frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true);
if (picture.read_lock_fences_enabled()) {
frame->metadata()->SetBoolean(
VideoFrameMetadata::READ_LOCK_FENCES_ENABLED, true);
}
// TODO(sandersd): Provide an API for VDAs to control this. // TODO(sandersd): Provide an API for VDAs to control this.
frame->metadata()->SetBoolean(VideoFrameMetadata::POWER_EFFICIENT, true); frame->metadata()->SetBoolean(VideoFrameMetadata::POWER_EFFICIENT, true);
......
...@@ -1344,9 +1344,21 @@ bool VTVideoDecodeAccelerator::SendFrame(const Frame& frame) { ...@@ -1344,9 +1344,21 @@ bool VTVideoDecodeAccelerator::SendFrame(const Frame& frame) {
DVLOG(3) << "PictureReady(picture_id=" << picture_id << ", " DVLOG(3) << "PictureReady(picture_id=" << picture_id << ", "
<< "bitstream_id=" << frame.bitstream_id << ")"; << "bitstream_id=" << frame.bitstream_id << ")";
client_->PictureReady(Picture(picture_id, frame.bitstream_id, Picture picture(picture_id, frame.bitstream_id, gfx::Rect(frame.image_size),
gfx::Rect(frame.image_size), color_space, color_space, true);
true)); // The GLImageIOSurface keeps the IOSurface alive as long as it exists, but
// bound textures do not, and they can outlive the GLImageIOSurface if they
// are deleted in the command buffer before they are used by the platform GL
// implementation. (https://crbug.com/930479#c69)
//
// A fence is required whenever a GLImage is bound, but we can't know in
// advance whether that will happen.
//
// TODO(sandersd): Can GLImageIOSurface be responsible for fences, so that
// we don't need to use them when the image is never bound? Bindings are
// typically only created when WebGL is in use.
picture.set_read_lock_fences_enabled(true);
client_->PictureReady(std::move(picture));
return true; return true;
} }
......
...@@ -74,6 +74,7 @@ Picture::Picture(int32_t picture_buffer_id, ...@@ -74,6 +74,7 @@ Picture::Picture(int32_t picture_buffer_id,
visible_rect_(visible_rect), visible_rect_(visible_rect),
color_space_(color_space), color_space_(color_space),
allow_overlay_(allow_overlay), allow_overlay_(allow_overlay),
read_lock_fences_enabled_(false),
size_changed_(false), size_changed_(false),
texture_owner_(false), texture_owner_(false),
wants_promotion_hint_(false) {} wants_promotion_hint_(false) {}
......
...@@ -94,10 +94,6 @@ class MEDIA_EXPORT Picture { ...@@ -94,10 +94,6 @@ class MEDIA_EXPORT Picture {
// Returns the id of the bitstream buffer from which this frame was decoded. // Returns the id of the bitstream buffer from which this frame was decoded.
int32_t bitstream_buffer_id() const { return bitstream_buffer_id_; } int32_t bitstream_buffer_id() const { return bitstream_buffer_id_; }
void set_bitstream_buffer_id(int32_t bitstream_buffer_id) {
bitstream_buffer_id_ = bitstream_buffer_id;
}
// Returns the color space of the picture. // Returns the color space of the picture.
const gfx::ColorSpace& color_space() const { return color_space_; } const gfx::ColorSpace& color_space() const { return color_space_; }
...@@ -108,6 +104,12 @@ class MEDIA_EXPORT Picture { ...@@ -108,6 +104,12 @@ class MEDIA_EXPORT Picture {
bool allow_overlay() const { return allow_overlay_; } bool allow_overlay() const { return allow_overlay_; }
bool read_lock_fences_enabled() const { return read_lock_fences_enabled_; }
void set_read_lock_fences_enabled(bool read_lock_fences_enabled) {
read_lock_fences_enabled_ = read_lock_fences_enabled;
}
// Returns true when the VDA has adjusted the resolution of this Picture // Returns true when the VDA has adjusted the resolution of this Picture
// without requesting new PictureBuffers. GpuVideoDecoder should read this // without requesting new PictureBuffers. GpuVideoDecoder should read this
// as a signal to update the size of the corresponding PicutreBuffer using // as a signal to update the size of the corresponding PicutreBuffer using
...@@ -132,6 +134,7 @@ class MEDIA_EXPORT Picture { ...@@ -132,6 +134,7 @@ class MEDIA_EXPORT Picture {
gfx::Rect visible_rect_; gfx::Rect visible_rect_;
gfx::ColorSpace color_space_; gfx::ColorSpace color_space_;
bool allow_overlay_; bool allow_overlay_;
bool read_lock_fences_enabled_;
bool size_changed_; bool size_changed_;
bool texture_owner_; bool texture_owner_;
bool wants_promotion_hint_; bool wants_promotion_hint_;
......
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