summaryrefslogtreecommitdiffstats
path: root/content/common
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-02 14:43:13 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-02 14:43:13 +0000
commit828a3933dbfe452718e6602d1afaa2db4d80ab76 (patch)
tree56af77629470fae86de042bc0f9922e57bd5fafe /content/common
parentf3cad76934b9282f7a8d795b27862210ad9f488a (diff)
downloadchromium_src-828a3933dbfe452718e6602d1afaa2db4d80ab76.zip
chromium_src-828a3933dbfe452718e6602d1afaa2db4d80ab76.tar.gz
chromium_src-828a3933dbfe452718e6602d1afaa2db4d80ab76.tar.bz2
gpu: Lose context when BeginQueryEXT fails to allocate.
Instead of crashes, raise a GL_OUT_OF_MEMORY error. Since compositor does not want to deal with these errors and it would leave it in a bad state, add the ability to lose the context when GL_OUT_OF_MEMORY occurs. R=dmichael@chromium.org, jamesr@chromium.org, piman@chromium.org, piman BUG=351587 Review URL: https://codereview.chromium.org/199443004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261120 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common')
-rw-r--r--content/common/gpu/client/context_provider_command_buffer_browsertest.cc2
-rw-r--r--content/common/gpu/client/gl_helper_benchmark.cc3
-rw-r--r--content/common/gpu/client/gl_helper_unittest.cc3
-rw-r--r--content/common/gpu/client/gpu_in_process_context_tests.cc6
-rw-r--r--content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc35
-rw-r--r--content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h32
6 files changed, 50 insertions, 31 deletions
diff --git a/content/common/gpu/client/context_provider_command_buffer_browsertest.cc b/content/common/gpu/client/context_provider_command_buffer_browsertest.cc
index d6378ad..7588571 100644
--- a/content/common/gpu/client/context_provider_command_buffer_browsertest.cc
+++ b/content/common/gpu/client/context_provider_command_buffer_browsertest.cc
@@ -30,6 +30,7 @@ class ContextProviderCommandBufferBrowserTest : public ContentBrowserTest {
}
scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext3d() {
+ bool lose_context_when_out_of_memory = false;
scoped_refptr<GpuChannelHost> gpu_channel_host(
GetFactory()->EstablishGpuChannelSync(
CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE));
@@ -37,6 +38,7 @@ class ContextProviderCommandBufferBrowserTest : public ContentBrowserTest {
WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
gpu_channel_host.get(),
blink::WebGraphicsContext3D::Attributes(),
+ lose_context_when_out_of_memory,
GURL("chrome://gpu/ContextProviderCommandBufferTest"),
WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(),
NULL));
diff --git a/content/common/gpu/client/gl_helper_benchmark.cc b/content/common/gpu/client/gl_helper_benchmark.cc
index 06b4206..b55ae1f 100644
--- a/content/common/gpu/client/gl_helper_benchmark.cc
+++ b/content/common/gpu/client/gl_helper_benchmark.cc
@@ -62,8 +62,9 @@ class GLHelperTest : public testing::Test {
protected:
virtual void SetUp() {
WebGraphicsContext3D::Attributes attributes;
+ bool lose_context_when_out_of_memory = false;
context_ = webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl::
- CreateOffscreenContext(attributes);
+ CreateOffscreenContext(attributes, lose_context_when_out_of_memory);
context_->makeContextCurrent();
helper_.reset(
diff --git a/content/common/gpu/client/gl_helper_unittest.cc b/content/common/gpu/client/gl_helper_unittest.cc
index 028777b..38b45ce 100644
--- a/content/common/gpu/client/gl_helper_unittest.cc
+++ b/content/common/gpu/client/gl_helper_unittest.cc
@@ -60,9 +60,10 @@ class GLHelperTest : public testing::Test {
protected:
virtual void SetUp() {
WebGraphicsContext3D::Attributes attributes;
+ bool lose_context_when_out_of_memory = false;
context_ =
WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
- attributes);
+ attributes, lose_context_when_out_of_memory);
context_->makeContextCurrent();
context_support_ = context_->GetContextSupport();
helper_.reset(
diff --git a/content/common/gpu/client/gpu_in_process_context_tests.cc b/content/common/gpu/client/gpu_in_process_context_tests.cc
index 7be7890..8288237 100644
--- a/content/common/gpu/client/gpu_in_process_context_tests.cc
+++ b/content/common/gpu/client/gpu_in_process_context_tests.cc
@@ -20,8 +20,10 @@ class ContextTestBase : public testing::Test {
public:
virtual void SetUp() {
blink::WebGraphicsContext3D::Attributes attributes;
- context_ = WebGraphicsContext3DInProcessCommandBufferImpl::
- CreateOffscreenContext(attributes);
+ bool lose_context_when_out_of_memory = false;
+ typedef WebGraphicsContext3DInProcessCommandBufferImpl WGC3DIPCBI;
+ context_ = WGC3DIPCBI::CreateOffscreenContext(
+ attributes, lose_context_when_out_of_memory);
context_->makeContextCurrent();
context_support_ = context_->GetContextSupport();
}
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
index 4b91c42..425990c 100644
--- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
+++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
@@ -230,6 +230,7 @@ WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl(
GpuChannelHost* host,
const Attributes& attributes,
bool bind_generates_resources,
+ bool lose_context_when_out_of_memory,
const SharedMemoryLimits& limits,
WebGraphicsContext3DCommandBufferImpl* share_context)
: initialize_failed_(false),
@@ -247,6 +248,7 @@ WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl(
initialized_(false),
gl_(NULL),
bind_generates_resources_(bind_generates_resources),
+ lose_context_when_out_of_memory_(lose_context_when_out_of_memory),
mem_limits_(limits),
flush_id_(0) {
if (share_context) {
@@ -350,6 +352,8 @@ bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer(
attribs.push_back(attributes_.antialias ? 1 : 0);
attribs.push_back(FAIL_IF_MAJOR_PERF_CAVEAT);
attribs.push_back(attributes_.failIfMajorPerformanceCaveat ? 1 : 0);
+ attribs.push_back(LOSE_CONTEXT_WHEN_OUT_OF_MEMORY);
+ attribs.push_back(lose_context_when_out_of_memory_ ? 1 : 0);
attribs.push_back(NONE);
// Create a proxy to a command buffer in the GPU process.
@@ -424,12 +428,13 @@ bool WebGraphicsContext3DCommandBufferImpl::CreateContext(bool onscreen) {
DCHECK(host_.get());
// Create the object exposing the OpenGL API.
- real_gl_.reset(new gpu::gles2::GLES2Implementation(
- gles2_helper_.get(),
- gles2_share_group,
- transfer_buffer_.get(),
- bind_generates_resources_,
- command_buffer_.get()));
+ real_gl_.reset(
+ new gpu::gles2::GLES2Implementation(gles2_helper_.get(),
+ gles2_share_group,
+ transfer_buffer_.get(),
+ bind_generates_resources_,
+ lose_context_when_out_of_memory_,
+ command_buffer_.get()));
gl_ = real_gl_.get();
if (!real_gl_->Initialize(
@@ -1191,6 +1196,7 @@ WebGraphicsContext3DCommandBufferImpl*
WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
GpuChannelHost* host,
const WebGraphicsContext3D::Attributes& attributes,
+ bool lose_context_when_out_of_memory,
const GURL& active_url,
const SharedMemoryLimits& limits,
WebGraphicsContext3DCommandBufferImpl* share_context) {
@@ -1200,13 +1206,16 @@ WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
if (share_context && share_context->IsCommandBufferContextLost())
return NULL;
- return new WebGraphicsContext3DCommandBufferImpl(0,
- active_url,
- host,
- attributes,
- false,
- limits,
- share_context);
+ bool bind_generates_resources = false;
+ return new WebGraphicsContext3DCommandBufferImpl(
+ 0,
+ active_url,
+ host,
+ attributes,
+ bind_generates_resources,
+ lose_context_when_out_of_memory,
+ limits,
+ share_context);
}
DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM, TexImageIOSurface2DCHROMIUM,
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h
index 2ff411b..dd65b76 100644
--- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h
+++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h
@@ -124,6 +124,7 @@ class WebGraphicsContext3DCommandBufferImpl
GpuChannelHost* host,
const Attributes& attributes,
bool bind_generates_resources,
+ bool lose_context_when_out_of_memory,
const SharedMemoryLimits& limits,
WebGraphicsContext3DCommandBufferImpl* share_context);
@@ -149,6 +150,7 @@ class WebGraphicsContext3DCommandBufferImpl
CreateOffscreenContext(
GpuChannelHost* host,
const WebGraphicsContext3D::Attributes& attributes,
+ bool lose_context_when_out_of_memory,
const GURL& active_url,
const SharedMemoryLimits& limits,
WebGraphicsContext3DCommandBufferImpl* share_context);
@@ -687,20 +689,21 @@ class WebGraphicsContext3DCommandBufferImpl
// gpu/command_buffer/common/gles2_cmd_utils.cc and to
// gpu/command_buffer/client/gl_in_process_context.cc
enum Attribute {
- ALPHA_SIZE = 0x3021,
- BLUE_SIZE = 0x3022,
- GREEN_SIZE = 0x3023,
- RED_SIZE = 0x3024,
- DEPTH_SIZE = 0x3025,
- STENCIL_SIZE = 0x3026,
- SAMPLES = 0x3031,
- SAMPLE_BUFFERS = 0x3032,
- HEIGHT = 0x3056,
- WIDTH = 0x3057,
- NONE = 0x3038, // Attrib list = terminator
- SHARE_RESOURCES = 0x10000,
- BIND_GENERATES_RESOURCES = 0x10001,
- FAIL_IF_MAJOR_PERF_CAVEAT = 0x10002
+ ALPHA_SIZE = 0x3021,
+ BLUE_SIZE = 0x3022,
+ GREEN_SIZE = 0x3023,
+ RED_SIZE = 0x3024,
+ DEPTH_SIZE = 0x3025,
+ STENCIL_SIZE = 0x3026,
+ SAMPLES = 0x3031,
+ SAMPLE_BUFFERS = 0x3032,
+ HEIGHT = 0x3056,
+ WIDTH = 0x3057,
+ NONE = 0x3038, // Attrib list = terminator
+ SHARE_RESOURCES = 0x10000,
+ BIND_GENERATES_RESOURCES = 0x10001,
+ FAIL_IF_MAJOR_PERF_CAVEAT = 0x10002,
+ LOSE_CONTEXT_WHEN_OUT_OF_MEMORY = 0x10003,
};
friend class WebGraphicsContext3DErrorMessageCallback;
@@ -767,6 +770,7 @@ class WebGraphicsContext3DCommandBufferImpl
scoped_ptr<gpu::gles2::GLES2Interface> trace_gl_;
Error last_error_;
bool bind_generates_resources_;
+ bool lose_context_when_out_of_memory_;
SharedMemoryLimits mem_limits_;
uint32_t flush_id_;