Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 199443004: gpu: Raise GL_OUT_OF_MEMORY when BeginQueryEXT fails to allocate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: checkmem: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 73d836237c5bc70ab727c91f00141292f5fcd49c..aa779ce558b6d2dc5f81d87e55d021ff09ca672d 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -541,7 +541,8 @@ void GLES2Decoder::EndDecoding() {}
// This class implements GLES2Decoder so we don't have to expose all the GLES2
// cmd stuff to outside this class.
class GLES2DecoderImpl : public GLES2Decoder,
- public FramebufferManager::TextureDetachObserver {
+ public FramebufferManager::TextureDetachObserver,
+ public ErrorStateClient {
public:
explicit GLES2DecoderImpl(ContextGroup* group);
virtual ~GLES2DecoderImpl();
@@ -665,6 +666,9 @@ class GLES2DecoderImpl : public GLES2Decoder,
virtual void OnTextureRefDetachedFromFramebuffer(
TextureRef* texture) OVERRIDE;
+ // Overriden from ErrorStateClient.
+ virtual void OnOutOfMemoryError() OVERRIDE;
+
// Helpers to facilitate calling into compatible extensions.
static void RenderbufferStorageMultisampleHelper(
const FeatureInfo* feature_info,
@@ -1715,6 +1719,9 @@ class GLES2DecoderImpl : public GLES2Decoder,
bool compile_shader_always_succeeds_;
+ // An optional behaviour to lose the context and group when OOM.
+ bool lose_context_when_out_of_memory_;
+
// Log extra info.
bool service_logging_;
@@ -2180,7 +2187,7 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
: GLES2Decoder(),
group_(group),
logger_(&debug_marker_manager_),
- state_(group_->feature_info(), &logger_),
+ state_(group_->feature_info(), this, &logger_),
unpack_flip_y_(false),
unpack_premultiply_alpha_(false),
unpack_unpremultiply_alpha_(false),
@@ -2212,6 +2219,7 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
frag_depth_explicitly_enabled_(false),
draw_buffers_explicitly_enabled_(false),
compile_shader_always_succeeds_(false),
+ lose_context_when_out_of_memory_(false),
service_logging_(CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableGPUServiceLoggingGPU)),
viewport_max_width_(0),
@@ -2285,6 +2293,10 @@ bool GLES2DecoderImpl::Initialize(
if (!attrib_parser.Parse(attribs))
return false;
+ // Save the loseContextWhenOutOfMemory context creation attribute.
+ lose_context_when_out_of_memory_ =
+ attrib_parser.lose_context_when_out_of_memory_ > 0;
+
// If the failIfMajorPerformanceCaveat context creation attribute was true
// and we are using a software renderer, fail.
if (attrib_parser.fail_if_major_perf_caveat_ &&
@@ -10553,6 +10565,13 @@ void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer(
DoDidUseTexImageIfNeeded(texture, texture->target());
}
+void GLES2DecoderImpl::OnOutOfMemoryError() {
+ if (lose_context_when_out_of_memory_) {
+ group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB);
+ LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB);
piman 2014/03/21 21:34:48 nit: we're guilty.
danakj 2014/03/21 22:53:50 Done.
+ }
+}
+
// 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.

Powered by Google App Engine
This is Rietveld 408576698