Commit 3627adc2 authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

SharedImages/macOS decode: Plumb TEXTURE_RECTANGLE

Video playback fails with the Metal-based command decoder, because
it binds IOSurfaces as TEXTURE_2D, not TEXTURE_RECTANGLE. Plumb
through a flag to specify if TEXTURE_RECTANGLE support is present.

Bug: 1108909
Change-Id: Ib7bccefea54985f052267f51f6b91ce955e30f98
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436311Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811467}
parent b2c4142b
......@@ -199,6 +199,15 @@ class CommandBufferHelperImpl
->is_passthrough_cmd_decoder();
}
bool SupportsTextureRectangle() const override {
if (!stub_)
return false;
return stub_->decoder_context()
->GetFeatureInfo()
->feature_flags()
.arb_texture_rectangle;
}
private:
~CommandBufferHelperImpl() override {
DVLOG(1) << __func__;
......
......@@ -137,6 +137,9 @@ class MEDIA_GPU_EXPORT CommandBufferHelper
// Is the backing command buffer passthrough (versus validating).
virtual bool IsPassthrough() const = 0;
// Does this command buffer support ARB_texture_rectangle.
virtual bool SupportsTextureRectangle() const = 0;
protected:
explicit CommandBufferHelper(
scoped_refptr<base::SequencedTaskRunner> task_runner);
......
......@@ -112,6 +112,9 @@ struct MEDIA_GPU_EXPORT GpuVideoDecodeGLClient {
// Whether or not the command buffer is passthrough.
bool is_passthrough = false;
// Whether or not ARB_texture_rectangle is present.
bool supports_arb_texture_rectangle = false;
};
// Convert vector of VDA::SupportedProfile to vector of
......
......@@ -191,6 +191,10 @@ GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator(
base::BindRepeating(&CreateAbstractTexture, stub_->AsWeakPtr());
gl_client_.is_passthrough =
stub_->decoder_context()->GetFeatureInfo()->is_passthrough_cmd_decoder();
gl_client_.supports_arb_texture_rectangle = stub_->decoder_context()
->GetFeatureInfo()
->feature_flags()
.arb_texture_rectangle;
}
GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() {
......
......@@ -76,6 +76,8 @@ std::unique_ptr<VideoDecodeAccelerator> CreateAndInitializeVda(
&CommandBufferHelper::MakeContextCurrent, command_buffer_helper);
gl_client.bind_image = base::BindRepeating(&BindImage, command_buffer_helper);
gl_client.is_passthrough = command_buffer_helper->IsPassthrough();
gl_client.supports_arb_texture_rectangle =
command_buffer_helper->SupportsTextureRectangle();
std::unique_ptr<GpuVideoDecodeAcceleratorFactory> factory =
GpuVideoDecodeAcceleratorFactory::Create(gl_client);
......
......@@ -1533,7 +1533,10 @@ bool VTVideoDecodeAccelerator::SendFrame(const Frame& frame) {
gpu::Mailbox mailbox = gpu::Mailbox::GenerateForSharedImage();
gpu::SharedImageBackingGLCommon::InitializeGLTextureParams gl_params;
gl_params.target = GL_TEXTURE_RECTANGLE_ARB;
// ANGLE-on-Metal exposes IOSurfaces via GL_TEXTURE_2D. Be robust to that.
gl_params.target = gl_client_.supports_arb_texture_rectangle
? GL_TEXTURE_RECTANGLE_ARB
: GL_TEXTURE_2D;
gl_params.internal_format = gl_format;
gl_params.format = gl_format;
gl_params.type = GL_UNSIGNED_BYTE;
......@@ -1567,7 +1570,7 @@ bool VTVideoDecodeAccelerator::SendFrame(const Frame& frame) {
gpu_task_runner_);
scoped_shared_image = scoped_refptr<Picture::ScopedSharedImage>(
new Picture::ScopedSharedImage(
mailbox, GL_TEXTURE_RECTANGLE_ARB,
mailbox, gl_params.target,
std::move(destroy_shared_image_callback)));
} else {
if (!gl_client_.bind_image.Run(picture_info->client_texture_id,
......
......@@ -168,4 +168,8 @@ bool FakeCommandBufferHelper::IsPassthrough() const {
return false;
}
bool FakeCommandBufferHelper::SupportsTextureRectangle() const {
return false;
}
} // namespace media
......@@ -62,6 +62,7 @@ class FakeCommandBufferHelper : public CommandBufferHelper {
base::OnceClosure done_cb) override;
void SetWillDestroyStubCB(WillDestroyStubCB will_destroy_stub_cb) override;
bool IsPassthrough() const override;
bool SupportsTextureRectangle() const override;
private:
~FakeCommandBufferHelper() override;
......
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