summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorkbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-14 00:38:43 +0000
committerkbr@chromium.org <kbr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-14 00:38:43 +0000
commit38d139d7410c8e42e731c5c58fab23d8d07b2721 (patch)
treefc3b1dba6528b6685354480990c4e11be03200e2 /gpu
parent2c812ba0ee1bf617c72a8bcd1a26b3a8418b0b5f (diff)
downloadchromium_src-38d139d7410c8e42e731c5c58fab23d8d07b2721.zip
chromium_src-38d139d7410c8e42e731c5c58fab23d8d07b2721.tar.gz
chromium_src-38d139d7410c8e42e731c5c58fab23d8d07b2721.tar.bz2
Detect and expose loss of OpenGL context using GL_ARB_robustness.
(This CL was originally reviewed under http://codereview.chromium.org/7331020/ . The only difference is the removal of an #include from command_buffer.h that was accidentally left in and which caused a significant increase in the number of files containing static initializers, presumably because of the dependent #include of <iostream>.) 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) R=gman,apatrick,piman Review URL: http://codereview.chromium.org/7362005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92453 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/GLES2/gl2ext.h20
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py5
-rw-r--r--gpu/command_buffer/client/gles2_implementation.h1
-rw-r--r--gpu/command_buffer/client/gles2_implementation_autogen.h2
-rw-r--r--gpu/command_buffer/client/gles2_implementation_unittest.cc5
-rw-r--r--gpu/command_buffer/common/cmd_buffer_common.cc15
-rw-r--r--gpu/command_buffer/common/command_buffer.h15
-rw-r--r--gpu/command_buffer/common/command_buffer_mock.h2
-rw-r--r--gpu/command_buffer/common/constants.h12
-rw-r--r--gpu/command_buffer/common/gl_mock.h2
-rw-r--r--gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h3
-rw-r--r--gpu/command_buffer/service/command_buffer_service.cc6
-rw-r--r--gpu/command_buffer/service/command_buffer_service.h2
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc152
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.h3
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_autogen.h17
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_mock.h1
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h1
-rw-r--r--gpu/command_buffer/service/gpu_scheduler.cc2
-rw-r--r--gpu/command_buffer/service/gpu_scheduler_unittest.cc2
20 files changed, 204 insertions, 64 deletions
diff --git a/gpu/GLES2/gl2ext.h b/gpu/GLES2/gl2ext.h
index 7ad5ef1..1afb408 100644
--- a/gpu/GLES2/gl2ext.h
+++ b/gpu/GLES2/gl2ext.h
@@ -1010,6 +1010,26 @@ typedef void (GL_APIENTRYP PFNGLGETPROGRAMINFOCHROMIUM) ();
#endif
#endif
+/* GL_ARB_robustness */
+/* This extension is subsetted for the moment, incorporating only the
+ * enums necessary to describe the reasons that we might encounter for
+ * losing the context. The entry point querying the reset status is
+ * not yet incorporated; to do so, a spec will be needed of a GLES2
+ * subset of GL_ARB_robustness.
+ */
+#ifndef GL_ARB_robustness
+#define GL_ARB_robustness 1
+#ifndef GL_GUILTY_CONTEXT_RESET_ARB
+#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253
+#endif
+#ifndef GL_INNOCENT_CONTEXT_RESET_ARB
+#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254
+#endif
+#ifndef GL_UNKNOWN_CONTEXT_RESET_ARB
+#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255
+#endif
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index e2bf5aa..91df3e2 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -1219,9 +1219,8 @@ _FUNCTION_INFO = {
'impl_decl': False,
},
'DrawArrays': {
- 'decoder_func': 'DoDrawArrays',
- 'unit_test': False,
- 'impl_decl': False,
+ 'type': 'Manual',
+ 'cmd_args': 'GLenum mode, GLint first, GLsizei count',
},
'DrawElements': {
'type': 'Manual',
diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h
index cf555bd..d7b955e 100644
--- a/gpu/command_buffer/client/gles2_implementation.h
+++ b/gpu/command_buffer/client/gles2_implementation.h
@@ -171,7 +171,6 @@ class GLES2Implementation {
#include "../client/gles2_implementation_autogen.h"
void DisableVertexAttribArray(GLuint index);
- void DrawArrays(GLenum mode, GLint first, GLsizei count);
void EnableVertexAttribArray(GLuint index);
void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params);
void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params);
diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h
index edcb5da..270d303 100644
--- a/gpu/command_buffer/client/gles2_implementation_autogen.h
+++ b/gpu/command_buffer/client/gles2_implementation_autogen.h
@@ -324,6 +324,8 @@ void Disable(GLenum cap) {
helper_->Disable(cap);
}
+void DrawArrays(GLenum mode, GLint first, GLsizei count);
+
void DrawElements(
GLenum mode, GLsizei count, GLenum type, const void* indices);
diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc
index 9643b55..eb003a5 100644
--- a/gpu/command_buffer/client/gles2_implementation_unittest.cc
+++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc
@@ -95,6 +95,11 @@ class GLES2MockCommandBufferHelper : public CommandBuffer {
state_.error = error;
}
+ virtual void SetContextLostReason(error::ContextLostReason reason) {
+ GPU_NOTREACHED();
+ state_.context_lost_reason = reason;
+ }
+
virtual void OnFlush(void* transfer_buffer) = 0;
private:
diff --git a/gpu/command_buffer/common/cmd_buffer_common.cc b/gpu/command_buffer/common/cmd_buffer_common.cc
index abfdc93..a9113b2 100644
--- a/gpu/command_buffer/common/cmd_buffer_common.cc
+++ b/gpu/command_buffer/common/cmd_buffer_common.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,6 +6,8 @@
// command buffer commands.
#include "../common/cmd_buffer_common.h"
+#include "../common/command_buffer.h"
+#include "../common/logging.h"
namespace gpu {
#if !defined(_WIN32)
@@ -28,6 +30,17 @@ const char* GetCommandName(CommandId command_id) {
}
} // namespace cmd
+
+// TODO(kbr): this method body is here instead of command_buffer.cc
+// because NaCl currently compiles in this file but not the other.
+// Remove this method body and the includes of command_buffer.h and
+// logging.h above once NaCl defines SetContextLostReason() in its
+// CommandBuffer subclass and has been rolled forward. See
+// http://crbug.com/89127 .
+void CommandBuffer::SetContextLostReason(error::ContextLostReason) {
+ GPU_NOTREACHED();
+}
+
} // namespace gpu
diff --git a/gpu/command_buffer/common/command_buffer.h b/gpu/command_buffer/common/command_buffer.h
index d5fb24d..539098b 100644
--- a/gpu/command_buffer/common/command_buffer.h
+++ b/gpu/command_buffer/common/command_buffer.h
@@ -28,6 +28,7 @@ class CommandBuffer {
put_offset(0),
token(-1),
error(error::kNoError),
+ context_lost_reason(error::kUnknown),
generation(0) {
}
@@ -50,6 +51,9 @@ class CommandBuffer {
// Error status.
error::Error error;
+ // Lost context detail information.
+ error::ContextLostReason context_lost_reason;
+
// Generation index of this state. The generation index is incremented every
// time a new state is retrieved from the command processor, so that
// consistency can be kept even if IPC messages are processed out-of-order.
@@ -119,6 +123,17 @@ class CommandBuffer {
// Allows the reader to set the current parse error.
virtual void SetParseError(error::Error) = 0;
+ // Allows the reader to set the current context lost reason.
+ // NOTE: if calling this in conjunction with SetParseError,
+ // call this first.
+ //
+ // TODO(kbr): this temporarily has a definition (i.e., is not pure
+ // virtual) to work around a difficult interdependency with the NaCl
+ // build. Make this pure virtual and remove the body once this is
+ // defined in CommandBufferNaCl and NaCl has rolled forward. See
+ // http://crbug.com/89127 .
+ virtual void SetContextLostReason(error::ContextLostReason);
+
private:
DISALLOW_COPY_AND_ASSIGN(CommandBuffer);
};
diff --git a/gpu/command_buffer/common/command_buffer_mock.h b/gpu/command_buffer/common/command_buffer_mock.h
index 4da8e82..3243d17 100644
--- a/gpu/command_buffer/common/command_buffer_mock.h
+++ b/gpu/command_buffer/common/command_buffer_mock.h
@@ -36,6 +36,8 @@ class MockCommandBuffer : public CommandBuffer {
int32 id_request));
MOCK_METHOD1(SetToken, void(int32 token));
MOCK_METHOD1(SetParseError, void(error::Error error));
+ MOCK_METHOD1(SetContextLostReason,
+ void(error::ContextLostReason context_lost_reason));
private:
DISALLOW_COPY_AND_ASSIGN(MockCommandBuffer);
diff --git a/gpu/command_buffer/common/constants.h b/gpu/command_buffer/common/constants.h
index 873dfa0..c204e87 100644
--- a/gpu/command_buffer/common/constants.h
+++ b/gpu/command_buffer/common/constants.h
@@ -44,6 +44,18 @@ namespace error {
return true;
}
}
+
+ // Provides finer grained information about why the context was lost.
+ 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
+ };
}
// Invalid shared memory Id, returned by RegisterSharedMemory in case of
diff --git a/gpu/command_buffer/common/gl_mock.h b/gpu/command_buffer/common/gl_mock.h
index 43e877b..ed39af4 100644
--- a/gpu/command_buffer/common/gl_mock.h
+++ b/gpu/command_buffer/common/gl_mock.h
@@ -431,6 +431,8 @@ class MockGLInterface : public GLInterface {
MOCK_METHOD3(GetFenceivNV, void(GLuint fence, GLenum pname, GLint *params));
MOCK_METHOD1(SetSurfaceCHROMIUM, void(GLuint));
+
+ MOCK_METHOD0(GetGraphicsResetStatusARB, GLenum());
};
} // namespace gfx
diff --git a/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h b/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h
index 37bf93e..1988472 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h
@@ -341,6 +341,7 @@ static GLES2Util::EnumToString enum_to_string_table[] = {
{ 0x2600, "GL_NEAREST", },
{ 0x84C4, "GL_TEXTURE4", },
{ 0x85B5, "GL_VERTEX_ARRAY_BINDING_OES", },
+ { 0x8253, "GL_GUILTY_CONTEXT_RESET_ARB", },
{ 0x00200000, "GL_STENCIL_BUFFER_BIT5_QCOM", },
{ 0x8D61, "GL_HALF_FLOAT_OES", },
{ 0x8D62, "GL_RGB565", },
@@ -418,6 +419,8 @@ static GLES2Util::EnumToString enum_to_string_table[] = {
{ 0x8625, "GL_VERTEX_ATTRIB_ARRAY_TYPE", },
{ 0x8622, "GL_VERTEX_ATTRIB_ARRAY_ENABLED", },
{ 0x8623, "GL_VERTEX_ATTRIB_ARRAY_SIZE", },
+ { 0x8255, "GL_UNKNOWN_CONTEXT_RESET_ARB", },
+ { 0x8254, "GL_INNOCENT_CONTEXT_RESET_ARB", },
{ 0x1100, "GL_DONT_CARE", },
{ 0x1101, "GL_FASTEST", },
{ 0x1102, "GL_NICEST", },
diff --git a/gpu/command_buffer/service/command_buffer_service.cc b/gpu/command_buffer/service/command_buffer_service.cc
index b042a23..064341d 100644
--- a/gpu/command_buffer/service/command_buffer_service.cc
+++ b/gpu/command_buffer/service/command_buffer_service.cc
@@ -98,6 +98,7 @@ CommandBufferService::State CommandBufferService::GetState() {
state.put_offset = put_offset_;
state.token = token_;
state.error = error_;
+ state.context_lost_reason = context_lost_reason_;
state.generation = ++generation_;
return state;
@@ -254,6 +255,11 @@ void CommandBufferService::SetParseError(error::Error error) {
}
}
+void CommandBufferService::SetContextLostReason(
+ error::ContextLostReason reason) {
+ context_lost_reason_ = reason;
+}
+
void CommandBufferService::SetPutOffsetChangeCallback(
Callback1<bool>::Type* callback) {
put_offset_change_callback_.reset(callback);
diff --git a/gpu/command_buffer/service/command_buffer_service.h b/gpu/command_buffer/service/command_buffer_service.h
index cffef5f..9c52531 100644
--- a/gpu/command_buffer/service/command_buffer_service.h
+++ b/gpu/command_buffer/service/command_buffer_service.h
@@ -40,6 +40,7 @@ class CommandBufferService : public CommandBuffer {
virtual Buffer GetTransferBuffer(int32 handle);
virtual void SetToken(int32 token);
virtual void SetParseError(error::Error error);
+ virtual void SetContextLostReason(error::ContextLostReason);
// Sets a callback that is called whenever the put offset is changed. When
// called with sync==true, the callback must not return until some progress
@@ -64,6 +65,7 @@ class CommandBufferService : public CommandBuffer {
int32 token_;
uint32 generation_;
error::Error error_;
+ error::ContextLostReason context_lost_reason_;
};
} // namespace gpu
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 045dfc3..e989af6 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -496,6 +496,8 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
bool BoundFramebufferHasDepthAttachment();
bool BoundFramebufferHasStencilAttachment();
+ virtual error::ContextLostReason GetContextLostReason();
+
private:
friend class ScopedGLErrorSuppressor;
friend class ScopedResolvedFrameBufferBinder;
@@ -888,9 +890,6 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
// Wrapper for glDetachShader
void DoDetachShader(GLuint client_program_id, GLint client_shader_id);
- // Wrapper for glDrawArrays.
- void DoDrawArrays(GLenum mode, GLint first, GLsizei count);
-
// Wrapper for glDisable
void DoDisable(GLenum cap);
@@ -1134,6 +1133,9 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
error::Error* error, GLuint* service_id, void** result,
GLenum* result_type);
+ // Returns true if the context was just lost due to e.g. GL_ARB_robustness.
+ bool WasContextLost();
+
// Generate a member function prototype for each command in an automated and
// typesafe way.
#define GLES2_CMD_OP(name) \
@@ -1301,6 +1303,9 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
int frame_number_;
+ bool has_arb_robustness_;
+ GLenum reset_status_;
+
DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl);
};
@@ -1637,7 +1642,9 @@ GLES2DecoderImpl::GLES2DecoderImpl(SurfaceManager* surface_manager,
validators_(group_->feature_info()->validators()),
feature_info_(group_->feature_info()),
tex_image_2d_failed_(false),
- frame_number_(0) {
+ frame_number_(0),
+ has_arb_robustness_(false),
+ reset_status_(GL_NO_ERROR) {
attrib_0_value_.v[0] = 0.0f;
attrib_0_value_.v[1] = 0.0f;
attrib_0_value_.v[2] = 0.0f;
@@ -1885,6 +1892,8 @@ bool GLES2DecoderImpl::Initialize(
glEnable(GL_POINT_SPRITE);
}
+ has_arb_robustness_ = context->HasExtension("GL_ARB_robustness");
+
if (!InitializeShaderTranslator()) {
return false;
}
@@ -2064,7 +2073,13 @@ void GLES2DecoderImpl::DeleteTexturesHelper(
// } // anonymous namespace
bool GLES2DecoderImpl::MakeCurrent() {
- return context_.get() ? context_->MakeCurrent(surface_.get()) : false;
+ bool result = context_.get() ? context_->MakeCurrent(surface_.get()) : false;
+ if (result && WasContextLost()) {
+ LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent.";
+ result = false;
+ }
+
+ return result;
}
void GLES2DecoderImpl::RestoreCurrentRenderbufferBindings() {
@@ -3361,43 +3376,6 @@ void GLES2DecoderImpl::DoClear(GLbitfield mask) {
}
}
-void GLES2DecoderImpl::DoDrawArrays(
- GLenum mode, GLint first, GLsizei count) {
- if (!CheckFramebufferComplete("glDrawArrays")) {
- return;
- }
- // We have to check this here because the prototype for glDrawArrays
- // is GLint not GLsizei.
- if (first < 0) {
- SetGLError(GL_INVALID_VALUE, "glDrawArrays: first < 0");
- return;
- }
-
- if (count == 0) {
- return;
- }
-
- GLuint max_vertex_accessed = first + count - 1;
- if (IsDrawValid(max_vertex_accessed)) {
- bool simulated_attrib_0 = SimulateAttrib0(max_vertex_accessed);
- bool simulated_fixed_attribs = false;
- if (SimulateFixedAttribs(max_vertex_accessed, &simulated_fixed_attribs)) {
- bool textures_set = SetBlackTextureForNonRenderableTextures();
- ApplyDirtyState();
- glDrawArrays(mode, first, count);
- if (textures_set) {
- RestoreStateForNonRenderableTextures();
- }
- if (simulated_fixed_attribs) {
- RestoreStateForSimulatedFixedAttribs();
- }
- }
- if (simulated_attrib_0) {
- RestoreStateForSimulatedAttrib0();
- }
- }
-}
-
void GLES2DecoderImpl::DoFramebufferRenderbuffer(
GLenum target, GLenum attachment, GLenum renderbuffertarget,
GLuint client_renderbuffer_id) {
@@ -4371,6 +4349,59 @@ void GLES2DecoderImpl::RestoreStateForSimulatedFixedAttribs() {
bound_array_buffer_ ? bound_array_buffer_->service_id() : 0);
}
+error::Error GLES2DecoderImpl::HandleDrawArrays(
+ uint32 immediate_data_size, const gles2::DrawArrays& c) {
+ GLenum mode = static_cast<GLenum>(c.mode);
+ GLint first = static_cast<GLint>(c.first);
+ GLsizei count = static_cast<GLsizei>(c.count);
+ if (!validators_->draw_mode.IsValid(mode)) {
+ SetGLError(GL_INVALID_ENUM, "glDrawArrays: mode GL_INVALID_ENUM");
+ return error::kNoError;
+ }
+ if (count < 0) {
+ SetGLError(GL_INVALID_VALUE, "glDrawArrays: count < 0");
+ return error::kNoError;
+ }
+ if (!CheckFramebufferComplete("glDrawArrays")) {
+ return error::kNoError;
+ }
+ // We have to check this here because the prototype for glDrawArrays
+ // is GLint not GLsizei.
+ if (first < 0) {
+ SetGLError(GL_INVALID_VALUE, "glDrawArrays: first < 0");
+ return error::kNoError;
+ }
+
+ if (count == 0) {
+ return error::kNoError;
+ }
+
+ GLuint max_vertex_accessed = first + count - 1;
+ if (IsDrawValid(max_vertex_accessed)) {
+ bool simulated_attrib_0 = SimulateAttrib0(max_vertex_accessed);
+ bool simulated_fixed_attribs = false;
+ if (SimulateFixedAttribs(max_vertex_accessed, &simulated_fixed_attribs)) {
+ bool textures_set = SetBlackTextureForNonRenderableTextures();
+ ApplyDirtyState();
+ glDrawArrays(mode, first, count);
+ if (textures_set) {
+ RestoreStateForNonRenderableTextures();
+ }
+ if (simulated_fixed_attribs) {
+ RestoreStateForSimulatedFixedAttribs();
+ }
+ }
+ if (simulated_attrib_0) {
+ RestoreStateForSimulatedAttrib0();
+ }
+ if (WasContextLost()) {
+ LOG(ERROR) << " GLES2DecoderImpl: Context lost during DrawArrays.";
+ return error::kLostContext;
+ }
+ }
+ return error::kNoError;
+}
+
error::Error GLES2DecoderImpl::HandleDrawElements(
uint32 immediate_data_size, const gles2::DrawElements& c) {
if (!bound_element_array_buffer_ ||
@@ -4435,6 +4466,10 @@ error::Error GLES2DecoderImpl::HandleDrawElements(
if (simulated_attrib_0) {
RestoreStateForSimulatedAttrib0();
}
+ if (WasContextLost()) {
+ LOG(ERROR) << " GLES2DecoderImpl: Context lost during DrawElements.";
+ return error::kLostContext;
+ }
}
return error::kNoError;
}
@@ -6730,6 +6765,39 @@ error::Error GLES2DecoderImpl::HandleGetProgramInfoCHROMIUM(
return error::kNoError;
}
+error::ContextLostReason GLES2DecoderImpl::GetContextLostReason() {
+ switch (reset_status_) {
+ case GL_NO_ERROR:
+ // TODO(kbr): improve the precision of the error code in this case.
+ // Consider delegating to context for error code if MakeCurrent fails.
+ return error::kUnknown;
+ case GL_GUILTY_CONTEXT_RESET_ARB:
+ return error::kGuilty;
+ case GL_INNOCENT_CONTEXT_RESET_ARB:
+ return error::kInnocent;
+ case GL_UNKNOWN_CONTEXT_RESET_ARB:
+ return error::kUnknown;
+ }
+
+ NOTREACHED();
+ return error::kUnknown;
+}
+
+bool GLES2DecoderImpl::WasContextLost() {
+ if (context_->WasAllocatedUsingARBRobustness() && has_arb_robustness_) {
+ GLenum status = glGetGraphicsResetStatusARB();
+ if (status != GL_NO_ERROR) {
+ // The graphics card was reset. Signal a lost context to the application.
+ reset_status_ = status;
+ LOG(ERROR) << (surface_->IsOffscreen() ? "Offscreen" : "Onscreen")
+ << " context lost via ARB_robustness. Reset status = 0x"
+ << std::hex << status << std::dec;
+ return true;
+ }
+ }
+ return false;
+}
+
// Include the auto-generated part of this file. We split this because it means
// we can easily edit the non-auto generated parts right here in this file
// instead of having to edit some template or the code generator.
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h
index 0551e5a..abd2b85 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.h
@@ -120,6 +120,9 @@ class GLES2Decoder : public CommonDecoder {
virtual bool GetServiceTextureId(uint32 client_texture_id,
uint32* service_texture_id);
+ // Provides detail about a lost context if one occurred.
+ virtual error::ContextLostReason GetContextLostReason() = 0;
+
protected:
GLES2Decoder();
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
index 89cf621..44cba0b 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
@@ -630,23 +630,6 @@ error::Error GLES2DecoderImpl::HandleDisableVertexAttribArray(
return error::kNoError;
}
-error::Error GLES2DecoderImpl::HandleDrawArrays(
- uint32 immediate_data_size, const gles2::DrawArrays& c) {
- GLenum mode = static_cast<GLenum>(c.mode);
- GLint first = static_cast<GLint>(c.first);
- GLsizei count = static_cast<GLsizei>(c.count);
- if (!validators_->draw_mode.IsValid(mode)) {
- SetGLError(GL_INVALID_ENUM, "glDrawArrays: mode GL_INVALID_ENUM");
- return error::kNoError;
- }
- if (count < 0) {
- SetGLError(GL_INVALID_VALUE, "glDrawArrays: count < 0");
- return error::kNoError;
- }
- DoDrawArrays(mode, first, count);
- return error::kNoError;
-}
-
error::Error GLES2DecoderImpl::HandleEnable(
uint32 immediate_data_size, const gles2::Enable& c) {
GLenum cap = static_cast<GLenum>(c.cap);
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
index 0a44ecf..2f1275c 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
@@ -54,6 +54,7 @@ class MockGLES2Decoder : public GLES2Decoder {
const void* cmd_data));
MOCK_METHOD2(GetServiceTextureId, bool(uint32 client_texture_id,
uint32* service_texture_id));
+ MOCK_METHOD0(GetContextLostReason, error::ContextLostReason());
MOCK_CONST_METHOD1(GetCommandName, const char*(unsigned int command_id));
DISALLOW_COPY_AND_ASSIGN(MockGLES2Decoder);
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h
index fe90c47..209f259 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h
@@ -704,6 +704,7 @@ TEST_F(GLES2DecoderTest1, DisableVertexAttribArrayValidArgs) {
EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
// TODO(gman): DrawArrays
+
// TODO(gman): DrawElements
diff --git a/gpu/command_buffer/service/gpu_scheduler.cc b/gpu/command_buffer/service/gpu_scheduler.cc
index 0a7d1dd..9365118 100644
--- a/gpu/command_buffer/service/gpu_scheduler.cc
+++ b/gpu/command_buffer/service/gpu_scheduler.cc
@@ -170,6 +170,7 @@ void GpuScheduler::ProcessCommands() {
if (decoder_.get()) {
if (!decoder_->MakeCurrent()) {
LOG(ERROR) << "Context lost because MakeCurrent failed.";
+ command_buffer_->SetContextLostReason(decoder_->GetContextLostReason());
command_buffer_->SetParseError(error::kLostContext);
return;
}
@@ -213,6 +214,7 @@ void GpuScheduler::ProcessCommands() {
is_break = true;
break;
} else if (error::IsError(error)) {
+ command_buffer_->SetContextLostReason(decoder_->GetContextLostReason());
command_buffer_->SetParseError(error);
return;
}
diff --git a/gpu/command_buffer/service/gpu_scheduler_unittest.cc b/gpu/command_buffer/service/gpu_scheduler_unittest.cc
index 8cdb361..3d21f90 100644
--- a/gpu/command_buffer/service/gpu_scheduler_unittest.cc
+++ b/gpu/command_buffer/service/gpu_scheduler_unittest.cc
@@ -217,6 +217,8 @@ TEST_F(GpuSchedulerTest, SetsErrorCodeOnCommandBuffer) {
error::kUnknownCommand));
EXPECT_CALL(*command_buffer_, SetGetOffset(1));
+ EXPECT_CALL(*decoder_, GetContextLostReason())
+ .WillOnce(Return(error::kUnknown));
EXPECT_CALL(*command_buffer_,
SetParseError(error::kUnknownCommand));