summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliberato <liberato@chromium.org>2016-03-09 13:09:41 -0800
committerCommit bot <commit-bot@chromium.org>2016-03-09 21:11:04 +0000
commit21cddbb0b8e5790fbe390b87844963e47a6e1e9f (patch)
tree1c35e00ec95ac557c1793f66733031fba950eed7
parentcfbc8cb058dcc6cf88f1c4d70c8eb76652c39123 (diff)
downloadchromium_src-21cddbb0b8e5790fbe390b87844963e47a6e1e9f.zip
chromium_src-21cddbb0b8e5790fbe390b87844963e47a6e1e9f.tar.gz
chromium_src-21cddbb0b8e5790fbe390b87844963e47a6e1e9f.tar.bz2
Don't detach SurfaceTexture from GL Context on Mali <= KitKat.
Mali with JB doesn't support SurfaceTexture::DetachFromGLContext, so on those devices we don't defer attaching the SurfaceTexture in AVDA. This may cause additional GL context switches if virtual contexts aren't enabled. We also turn off copying the most recent frame to the PictureBuffer textures, since it also crashes on Mali <= KitKat. BUG=591600,591564 CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win_optional_gpu_tests_rel;tryserver.chromium.mac:mac_optional_gpu_tests_rel Review URL: https://codereview.chromium.org/1760313002 Cr-Commit-Position: refs/heads/master@{#380215}
-rw-r--r--content/common/gpu/media/android_deferred_rendering_backing_strategy.cc58
-rw-r--r--content/common/gpu/media/android_deferred_rendering_backing_strategy.h4
-rw-r--r--gpu/config/gpu_driver_bug_list_json.cc15
-rw-r--r--gpu/config/gpu_driver_bug_workaround_type.h2
4 files changed, 66 insertions, 13 deletions
diff --git a/content/common/gpu/media/android_deferred_rendering_backing_strategy.cc b/content/common/gpu/media/android_deferred_rendering_backing_strategy.cc
index c1e0d2e..a4bfc14 100644
--- a/content/common/gpu/media/android_deferred_rendering_backing_strategy.cc
+++ b/content/common/gpu/media/android_deferred_rendering_backing_strategy.cc
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h"
+
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h"
-
+#include "base/android/build_info.h"
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
@@ -16,6 +17,7 @@
#include "content/common/gpu/media/avda_codec_image.h"
#include "content/common/gpu/media/avda_return_on_failure.h"
#include "content/common/gpu/media/avda_shared_state.h"
+#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/gl_stream_texture_image.h"
#include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
#include "gpu/command_buffer/service/texture_manager.h"
@@ -48,25 +50,32 @@ gfx::ScopedJavaSurface AndroidDeferredRenderingBackingStrategy::Initialize(
int surface_view_id) {
shared_state_ = new AVDASharedState();
+ // Create a texture for the SurfaceTexture to use. We don't attach it here
+ // so that it gets attached in the compositor gl context in the common case.
+ GLuint service_id = 0;
+ glGenTextures(1, &service_id);
+ DCHECK(service_id);
+ shared_state_->set_surface_texture_service_id(service_id);
+
gfx::ScopedJavaSurface surface;
if (surface_view_id != media::VideoDecodeAccelerator::Config::kNoSurfaceID) {
surface =
GpuSurfaceLookup::GetInstance()->AcquireJavaSurface(surface_view_id);
} else {
- // Create a detached SurfaceTexture. Detaching it will silently fail to
- // delete texture 0.
- surface_texture_ = gfx::SurfaceTexture::Create(0);
- surface_texture_->DetachFromGLContext();
+ if (DoesSurfaceTextureDetachWork()) {
+ // Create a detached SurfaceTexture. Detaching it will silently fail to
+ // delete texture 0.
+ surface_texture_ = gfx::SurfaceTexture::Create(0);
+ surface_texture_->DetachFromGLContext();
+ } else {
+ // Detach doesn't work so well on all platforms. Just attach the
+ // SurfaceTexture here, and probably context switch later.
+ surface_texture_ = gfx::SurfaceTexture::Create(service_id);
+ shared_state_->DidAttachSurfaceTexture();
+ }
surface = gfx::ScopedJavaSurface(surface_texture_.get());
}
- // Create a texture for the SurfaceTexture to use. We don't attach it here
- // so that it gets attached in the compositor gl context in the common case.
- GLuint service_id = 0;
- glGenTextures(1, &service_id);
- DCHECK(service_id);
- shared_state_->set_surface_texture_service_id(service_id);
-
return surface;
}
@@ -270,6 +279,11 @@ void AndroidDeferredRenderingBackingStrategy::CopySurfaceTextureToPictures(
if (!gl_decoder)
return;
+ // Mali + <= KitKat crashes when we try to do this. We don't know if it's
+ // due to detaching a surface texture, but it's the same set of devices.
+ if (!DoesSurfaceTextureDetachWork())
+ return;
+
const gfx::Size size = state_provider_->GetSize();
// Create a 2D texture to hold a copy of the SurfaceTexture's front buffer.
@@ -315,6 +329,8 @@ void AndroidDeferredRenderingBackingStrategy::CopySurfaceTextureToPictures(
for (const std::pair<int, media::PictureBuffer>& entry : buffers) {
gpu::gles2::TextureRef* texture_ref = GetTextureForPicture(entry.second);
+ if (!texture_ref)
+ continue;
gfx::ScopedTextureBinder texture_binder(
GL_TEXTURE_EXTERNAL_OES, texture_ref->texture()->service_id());
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_image);
@@ -329,4 +345,20 @@ void AndroidDeferredRenderingBackingStrategy::CopySurfaceTextureToPictures(
}
}
+bool AndroidDeferredRenderingBackingStrategy::DoesSurfaceTextureDetachWork()
+ const {
+ bool surface_texture_detach_works = true;
+ if (gpu::gles2::GLES2Decoder* gl_decoder =
+ state_provider_->GetGlDecoder().get()) {
+ if (gpu::gles2::ContextGroup* group = gl_decoder->GetContextGroup()) {
+ if (gpu::gles2::FeatureInfo* feature_info = group->feature_info()) {
+ surface_texture_detach_works =
+ !feature_info->workarounds().surface_texture_cant_detach;
+ }
+ }
+ }
+
+ return surface_texture_detach_works;
+}
+
} // namespace content
diff --git a/content/common/gpu/media/android_deferred_rendering_backing_strategy.h b/content/common/gpu/media/android_deferred_rendering_backing_strategy.h
index 1cb8bd0..eec5ee0 100644
--- a/content/common/gpu/media/android_deferred_rendering_backing_strategy.h
+++ b/content/common/gpu/media/android_deferred_rendering_backing_strategy.h
@@ -76,6 +76,10 @@ class CONTENT_EXPORT AndroidDeferredRenderingBackingStrategy
void CopySurfaceTextureToPictures(
const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers);
+ // Return true if and only if the surface_texture_cant_detach workaround is
+ // not set.
+ bool DoesSurfaceTextureDetachWork() const;
+
scoped_refptr<AVDASharedState> shared_state_;
AVDAStateProvider* state_provider_;
diff --git a/gpu/config/gpu_driver_bug_list_json.cc b/gpu/config/gpu_driver_bug_list_json.cc
index 325a1e6..a7195b1 100644
--- a/gpu/config/gpu_driver_bug_list_json.cc
+++ b/gpu/config/gpu_driver_bug_list_json.cc
@@ -1765,6 +1765,21 @@ LONG_STRING_CONST(
"features": [
"max_texture_size_limit_4096"
]
+ },
+ {
+ "id": 148,
+ "description": "Mali-4xx GPU on JB doesn't support DetachGLContext",
+ "os": {
+ "type": "android",
+ "version": {
+ "op": "<=",
+ "value": "4.4.4"
+ }
+ },
+ "gl_renderer": ".*Mali-4.*",
+ "features": [
+ "surface_texture_cant_detach"
+ ]
}
]
}
diff --git a/gpu/config/gpu_driver_bug_workaround_type.h b/gpu/config/gpu_driver_bug_workaround_type.h
index d65cdca..71ea843 100644
--- a/gpu/config/gpu_driver_bug_workaround_type.h
+++ b/gpu/config/gpu_driver_bug_workaround_type.h
@@ -120,6 +120,8 @@
set_texture_filter_before_generating_mipmap) \
GPU_OP(SIMULATE_OUT_OF_MEMORY_ON_LARGE_TEXTURES, \
simulate_out_of_memory_on_large_textures) \
+ GPU_OP(SURFACE_TEXTURE_CANT_DETACH, \
+ surface_texture_cant_detach) \
GPU_OP(SWIZZLE_RGBA_FOR_ASYNC_READPIXELS, \
swizzle_rgba_for_async_readpixels) \
GPU_OP(TEXSUBIMAGE_FASTER_THAN_TEXIMAGE, \