summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorkbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-13 22:49:17 +0000
committerkbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-13 22:49:17 +0000
commit35d90072e5c73f4091eeb12f26e6c5015e7597c0 (patch)
treecf74f45c43b911d3356b4e7cf387da6916703ddb /content
parentde6ea3ae3c0444d4f0a9f65bb57dbacb8846ce5b (diff)
downloadchromium_src-35d90072e5c73f4091eeb12f26e6c5015e7597c0.zip
chromium_src-35d90072e5c73f4091eeb12f26e6c5015e7597c0.tar.gz
chromium_src-35d90072e5c73f4091eeb12f26e6c5015e7597c0.tar.bz2
Revert 92429 - Detect and expose loss of OpenGL context using GL_ARB_robustness. (Regressed static initalizer size on Linux -- will need to reexamine code to understand why.)
This initial patch changes the Linux port to use GLX_ARB_create_context_robustness when available, and tests periodically whether the context has been lost after each draw call and when making the context current. The detection of context loss also works with EGL and ANGLE, although it always reports an unknown reset status. WebKit changes will follow which test the reset status and determine what to do in response; for example, the policy might be to never restore a WebGL context which was lost (due to a GPU reset) and which was determined to be the guilty context. Tested manually with WebGL stress tests and verified on Linux and Windows that in at least some situations it is possible to detect guilty contexts and shut down the associated WebGL application. Some precision of this detection was recently lost and will need to be fixed in following CLs. Also updated and ran GPU unit tests. BUG=88106 TEST=none (tested manually; try servers) Review URL: http://codereview.chromium.org/7331020 TBR=kbr@chromium.org Review URL: http://codereview.chromium.org/7346032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc4
-rw-r--r--content/common/gpu/gpu_messages.h5
-rw-r--r--content/renderer/gpu/command_buffer_proxy.cc11
-rw-r--r--content/renderer/gpu/command_buffer_proxy.h3
-rw-r--r--content/renderer/gpu/renderer_gl_context.cc31
-rw-r--r--content/renderer/gpu/renderer_gl_context.h16
-rw-r--r--content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc35
-rw-r--r--content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h4
-rw-r--r--content/renderer/render_widget_fullscreen_pepper.cc4
-rw-r--r--content/renderer/render_widget_fullscreen_pepper.h5
10 files changed, 18 insertions, 100 deletions
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index 8034372..0b2d23b 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -242,9 +242,7 @@ void GpuCommandBufferStub::OnGetState(IPC::Message* reply_message) {
void GpuCommandBufferStub::OnParseError() {
TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnParseError");
- gpu::CommandBuffer::State state = command_buffer_->GetState();
- IPC::Message* msg = new GpuCommandBufferMsg_Destroyed(
- route_id_, state.context_lost_reason);
+ IPC::Message* msg = new GpuCommandBufferMsg_Destroyed(route_id_);
msg->set_unblock(true);
Send(msg);
// If an error occurs, the remaining commands will not be processed.
diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h
index 8f7c926..b30ab98 100644
--- a/content/common/gpu/gpu_messages.h
+++ b/content/common/gpu/gpu_messages.h
@@ -13,7 +13,6 @@
#include "content/common/gpu/gpu_info.h"
#include "content/common/gpu/gpu_process_launch_causes.h"
#include "gpu/command_buffer/common/command_buffer.h"
-#include "gpu/command_buffer/common/constants.h"
#include "gpu/ipc/gpu_command_buffer_traits.h"
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_message_macros.h"
@@ -106,7 +105,6 @@ IPC_STRUCT_TRAITS_BEGIN(gpu::ReadWriteTokens)
IPC_STRUCT_TRAITS_END()
IPC_ENUM_TRAITS(content::CauseForGpuLaunch)
-IPC_ENUM_TRAITS(gpu::error::ContextLostReason)
//------------------------------------------------------------------------------
// GPU Messages
@@ -419,8 +417,7 @@ IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SetWindowSize,
// Tells the proxy that there was an error and the command buffer had to be
// destroyed for some reason.
-IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_Destroyed,
- gpu::error::ContextLostReason /* reason */)
+IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_Destroyed)
// --------------------------------------------------------------------------
// TransportTexture messages
diff --git a/content/renderer/gpu/command_buffer_proxy.cc b/content/renderer/gpu/command_buffer_proxy.cc
index 42949b6..ae81bf5 100644
--- a/content/renderer/gpu/command_buffer_proxy.cc
+++ b/content/renderer/gpu/command_buffer_proxy.cc
@@ -59,17 +59,16 @@ bool CommandBufferProxy::OnMessageReceived(const IPC::Message& message) {
void CommandBufferProxy::OnChannelError() {
video_decoder_host_->OnChannelError();
- OnDestroyed(gpu::error::kUnknown);
+ OnDestroyed();
}
-void CommandBufferProxy::OnDestroyed(gpu::error::ContextLostReason reason) {
+void CommandBufferProxy::OnDestroyed() {
// Prevent any further messages from being sent.
channel_ = NULL;
// When the client sees that the context is lost, they should delete this
// CommandBufferProxy and create a new one.
last_state_.error = gpu::error::kLostContext;
- last_state_.context_lost_reason = reason;
if (channel_error_callback_.get()) {
channel_error_callback_->Run();
@@ -333,12 +332,6 @@ void CommandBufferProxy::SetParseError(
NOTREACHED();
}
-void CommandBufferProxy::SetContextLostReason(
- gpu::error::ContextLostReason reason) {
- // Not implemented in proxy.
- NOTREACHED();
-}
-
void CommandBufferProxy::OnSwapBuffers() {
if (swap_buffers_callback_.get())
swap_buffers_callback_->Run();
diff --git a/content/renderer/gpu/command_buffer_proxy.h b/content/renderer/gpu/command_buffer_proxy.h
index 9879169..2aabf9a 100644
--- a/content/renderer/gpu/command_buffer_proxy.h
+++ b/content/renderer/gpu/command_buffer_proxy.h
@@ -60,7 +60,6 @@ class CommandBufferProxy : public gpu::CommandBuffer,
virtual gpu::Buffer GetTransferBuffer(int32 handle);
virtual void SetToken(int32 token);
virtual void SetParseError(gpu::error::Error error);
- virtual void SetContextLostReason(gpu::error::ContextLostReason reason);
virtual void OnSwapBuffers();
// Reparent a command buffer. TODO(apatrick): going forward, the notion of
@@ -114,7 +113,7 @@ class CommandBufferProxy : public gpu::CommandBuffer,
// Message handlers:
void OnUpdateState(const gpu::CommandBuffer::State& state);
void OnNotifyRepaint();
- void OnDestroyed(gpu::error::ContextLostReason reason);
+ void OnDestroyed();
// As with the service, the client takes ownership of the ring buffer.
int32 num_entries_;
diff --git a/content/renderer/gpu/renderer_gl_context.cc b/content/renderer/gpu/renderer_gl_context.cc
index bf2d100..210fd1f 100644
--- a/content/renderer/gpu/renderer_gl_context.cc
+++ b/content/renderer/gpu/renderer_gl_context.cc
@@ -145,24 +145,6 @@ bool LatchAllocator::FreeLatch(uint32 latch_id) {
static base::LazyInstance<GLES2Initializer> g_gles2_initializer(
base::LINKER_INITIALIZED);
-////////////////////////////////////////////////////////////////////////////////
-
-#if defined(ENABLE_GPU)
-RendererGLContext::ContextLostReason ConvertReason(
- gpu::error::ContextLostReason reason) {
- switch (reason) {
- case gpu::error::kGuilty:
- return RendererGLContext::kGuilty;
- case gpu::error::kInnocent:
- return RendererGLContext::kInnocent;
- case gpu::error::kUnknown:
- return RendererGLContext::kUnknown;
- }
- NOTREACHED();
- return RendererGLContext::kUnknown;
-}
-#endif
-
} // namespace anonymous
RendererGLContext::~RendererGLContext() {
@@ -326,8 +308,7 @@ void RendererGLContext::SetSwapBuffersCallback(Callback0::Type* callback) {
swap_buffers_callback_.reset(callback);
}
-void RendererGLContext::SetContextLostCallback(
- Callback1<ContextLostReason>::Type* callback) {
+void RendererGLContext::SetContextLostCallback(Callback0::Type* callback) {
context_lost_callback_.reset(callback);
}
@@ -596,14 +577,8 @@ void RendererGLContext::OnSwapBuffers() {
}
void RendererGLContext::OnContextLost() {
- if (context_lost_callback_.get()) {
- RendererGLContext::ContextLostReason reason = kUnknown;
- if (command_buffer_) {
- reason = ConvertReason(
- command_buffer_->GetLastState().context_lost_reason);
- }
- context_lost_callback_->Run(reason);
- }
+ if (context_lost_callback_.get())
+ context_lost_callback_->Run();
}
bool RendererGLContext::CreateLatch(uint32* ret_latch) {
diff --git a/content/renderer/gpu/renderer_gl_context.h b/content/renderer/gpu/renderer_gl_context.h
index 1c0280e..eb1096c 100644
--- a/content/renderer/gpu/renderer_gl_context.h
+++ b/content/renderer/gpu/renderer_gl_context.h
@@ -56,18 +56,6 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> {
NONE = 0x3038 // Attrib list = terminator
};
- // Reasons that a lost context might have been provoked.
- enum ContextLostReason {
- // This context definitely provoked the loss of context.
- kGuilty,
-
- // This context definitely did not provoke the loss of context.
- kInnocent,
-
- // It is unknown whether this context provoked the loss of context.
- kUnknown
- };
-
// Initialize the library. This must have completed before any other
// functions are invoked.
static bool Initialize();
@@ -151,7 +139,7 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> {
// service side.
void SetSwapBuffersCallback(Callback0::Type* callback);
- void SetContextLostCallback(Callback1<ContextLostReason>::Type* callback);
+ void SetContextLostCallback(Callback0::Type* callback);
// Set the current RendererGLContext for the calling thread.
static bool MakeCurrent(RendererGLContext* context);
@@ -213,7 +201,7 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> {
scoped_refptr<GpuChannelHost> channel_;
base::WeakPtr<RendererGLContext> parent_;
scoped_ptr<Callback0::Type> swap_buffers_callback_;
- scoped_ptr<Callback1<ContextLostReason>::Type> context_lost_callback_;
+ scoped_ptr<Callback0::Type> context_lost_callback_;
uint32 parent_texture_id_;
uint32 child_to_parent_latch_;
uint32 parent_to_child_latch_;
diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc
index 2d825b9..73153bc 100644
--- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc
+++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc
@@ -38,7 +38,6 @@ WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl()
plugin_handle_(NULL),
#endif // defined(OS_MACOSX)
context_lost_callback_(0),
- context_lost_reason_(GL_NO_ERROR),
cached_width_(0),
cached_height_(0),
bound_fbo_(0) {
@@ -686,8 +685,7 @@ WGC3Denum WebGraphicsContext3DCommandBufferImpl::getError() {
}
bool WebGraphicsContext3DCommandBufferImpl::isContextLost() {
- return context_->IsCommandBufferContextLost() ||
- context_lost_reason_ != GL_NO_ERROR;
+ return context_->IsCommandBufferContextLost();
}
DELEGATE_TO_GL_2(getFloatv, GetFloatv, WGC3Denum, WGC3Dfloat*)
@@ -1033,36 +1031,7 @@ void WebGraphicsContext3DCommandBufferImpl::setContextLostCallback(
context_lost_callback_ = cb;
}
-WGC3Denum WebGraphicsContext3DCommandBufferImpl::getGraphicsResetStatusARB() {
- if (context_->IsCommandBufferContextLost() &&
- context_lost_reason_ == GL_NO_ERROR) {
- return GL_UNKNOWN_CONTEXT_RESET_ARB;
- }
-
- return context_lost_reason_;
-}
-
-namespace {
-
-WGC3Denum convertReason(RendererGLContext::ContextLostReason reason) {
- switch (reason) {
- case RendererGLContext::kGuilty:
- return GL_GUILTY_CONTEXT_RESET_ARB;
- case RendererGLContext::kInnocent:
- return GL_INNOCENT_CONTEXT_RESET_ARB;
- case RendererGLContext::kUnknown:
- return GL_UNKNOWN_CONTEXT_RESET_ARB;
- }
-
- NOTREACHED();
- return GL_UNKNOWN_CONTEXT_RESET_ARB;
-}
-
-} // anonymous namespace
-
-void WebGraphicsContext3DCommandBufferImpl::OnContextLost(
- RendererGLContext::ContextLostReason reason) {
- context_lost_reason_ = convertReason(reason);
+void WebGraphicsContext3DCommandBufferImpl::OnContextLost() {
if (context_lost_callback_) {
context_lost_callback_->onContextLost();
}
diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h
index 5411502..c9eabeb 100644
--- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h
+++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h
@@ -425,12 +425,11 @@ class WebGraphicsContext3DCommandBufferImpl
virtual void setContextLostCallback(
WebGraphicsContext3D::WebGraphicsContextLostCallback* callback);
- virtual WGC3Denum getGraphicsResetStatusARB();
private:
// SwapBuffers callback.
void OnSwapBuffersComplete();
- virtual void OnContextLost(RendererGLContext::ContextLostReason reason);
+ virtual void OnContextLost();
// The context we use for OpenGL rendering.
RendererGLContext* context_;
@@ -444,7 +443,6 @@ class WebGraphicsContext3DCommandBufferImpl
gfx::PluginWindowHandle plugin_handle_;
#endif
WebGraphicsContext3D::WebGraphicsContextLostCallback* context_lost_callback_;
- WGC3Denum context_lost_reason_;
WebKit::WebGraphicsContext3D::Attributes attributes_;
int cached_width_, cached_height_;
diff --git a/content/renderer/render_widget_fullscreen_pepper.cc b/content/renderer/render_widget_fullscreen_pepper.cc
index e18a1c63..ed4a5e8 100644
--- a/content/renderer/render_widget_fullscreen_pepper.cc
+++ b/content/renderer/render_widget_fullscreen_pepper.cc
@@ -6,6 +6,7 @@
#include "base/message_loop.h"
#include "content/common/view_messages.h"
+#include "content/renderer/gpu/renderer_gl_context.h"
#include "content/renderer/gpu/gpu_channel_host.h"
#include "content/renderer/pepper_platform_context_3d_impl.h"
#include "content/renderer/render_thread.h"
@@ -470,8 +471,7 @@ void RenderWidgetFullscreenPepper::SwapBuffers() {
context_->SwapBuffers();
}
-void RenderWidgetFullscreenPepper::OnLostContext(
- RendererGLContext::ContextLostReason) {
+void RenderWidgetFullscreenPepper::OnLostContext() {
if (!context_)
return;
// Destroy the context later, in case we got called from InitContext for
diff --git a/content/renderer/render_widget_fullscreen_pepper.h b/content/renderer/render_widget_fullscreen_pepper.h
index 1664034..d22b418 100644
--- a/content/renderer/render_widget_fullscreen_pepper.h
+++ b/content/renderer/render_widget_fullscreen_pepper.h
@@ -6,7 +6,6 @@
#define CONTENT_RENDERER_RENDER_WIDGET_FULLSCREEN_PEPPER_H_
#include "content/renderer/render_widget_fullscreen.h"
-#include "content/renderer/gpu/renderer_gl_context.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h"
#include "webkit/plugins/ppapi/fullscreen_container.h"
@@ -18,6 +17,8 @@ class PluginInstance;
} // namespace ppapi
} // namespace webkit
+class RendererGLContext;
+
// A RenderWidget that hosts a fullscreen pepper plugin. This provides a
// FullscreenContainer that the plugin instance can callback into to e.g.
// invalidate rects.
@@ -76,7 +77,7 @@ class RenderWidgetFullscreenPepper : public RenderWidgetFullscreen,
bool CheckCompositing();
// Called when the compositing context gets lost.
- void OnLostContext(RendererGLContext::ContextLostReason);
+ void OnLostContext();
// Binding of RendererGLContext swapbuffers callback to
// RenderWidget::OnSwapBuffersCompleted.