Report fatal vs transient errors when initializing contexts
Currently context creation and initialization reports back just true/false
for if the process succeeded. This expands that information to a tri-state
of success, fatal error, transient error. In the latter case, the client
should retry making the context as it may succeed next time. This happens
when, for instance, another client crashes the gpu process at the same
time the context is being constructed. In the case of a fatal error, the
context can not be made given the current inputs so either the gpu is not
usable, or the client has a bug and is requesting an invalid context of
some sort, but it will not make progress by retrying. So in this case the
client should not retry and just fail back to a non-gpu mode.
This information will allow us to remove the retry count when making the
compositor context for the display compositor, removing the state machine
in that code (as retry becomes a local decision from the result).
TBR=raymes
Bug: 772574
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ic3574de9fccae42ac34ff8a5755d4cfa5f0dd2b0
Reviewed-on: https://chromium-review.googlesource.com/717548
Reviewed-by: danakj <[email protected]>
Reviewed-by: Sadrul Chowdhury <[email protected]>
Reviewed-by: Ken Buchanan <[email protected]>
Reviewed-by: Antoine Labour <[email protected]>
Commit-Queue: danakj <[email protected]>
Cr-Commit-Position: refs/heads/master@{#509836}
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.cc b/gpu/command_buffer/client/cmd_buffer_helper.cc
index f29f744..6e172ec9 100644
--- a/gpu/command_buffer/client/cmd_buffer_helper.cc
+++ b/gpu/command_buffer/client/cmd_buffer_helper.cc
@@ -150,9 +150,14 @@
}
}
-bool CommandBufferHelper::Initialize(int32_t ring_buffer_size) {
+gpu::ContextResult CommandBufferHelper::Initialize(int32_t ring_buffer_size) {
ring_buffer_size_ = ring_buffer_size;
- return AllocateRingBuffer();
+ if (!AllocateRingBuffer()) {
+ // This would fail if CreateTransferBuffer fails, which will not fail for
+ // transient reasons such as context loss. See http://crrev.com/c/720269
+ return gpu::ContextResult::kFatalFailure;
+ }
+ return gpu::ContextResult::kSuccess;
}
CommandBufferHelper::~CommandBufferHelper() {
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.h b/gpu/command_buffer/client/cmd_buffer_helper.h
index 5c38d0e..a7fbbc9 100644
--- a/gpu/command_buffer/client/cmd_buffer_helper.h
+++ b/gpu/command_buffer/client/cmd_buffer_helper.h
@@ -19,6 +19,7 @@
#include "build/build_config.h"
#include "gpu/command_buffer/common/cmd_buffer_common.h"
#include "gpu/command_buffer/common/command_buffer.h"
+#include "gpu/command_buffer/common/context_result.h"
#include "gpu/gpu_export.h"
namespace gpu {
@@ -60,7 +61,7 @@
// Parameters:
// ring_buffer_size: The size of the ring buffer portion of the command
// buffer.
- bool Initialize(int32_t ring_buffer_size);
+ gpu::ContextResult Initialize(int32_t ring_buffer_size);
// Sets whether the command buffer should automatically flush periodically
// to try to increase performance. Defaults to true.
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index 9d63f5f..f87129f6 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -192,7 +192,8 @@
memset(&reserved_ids_, 0, sizeof(reserved_ids_));
}
-bool GLES2Implementation::Initialize(const SharedMemoryLimits& limits) {
+gpu::ContextResult GLES2Implementation::Initialize(
+ const SharedMemoryLimits& limits) {
TRACE_EVENT0("gpu", "GLES2Implementation::Initialize");
DCHECK_GE(limits.start_transfer_buffer_size, limits.min_transfer_buffer_size);
DCHECK_LE(limits.start_transfer_buffer_size, limits.max_transfer_buffer_size);
@@ -204,12 +205,14 @@
limits.start_transfer_buffer_size, kStartingOffset,
limits.min_transfer_buffer_size, limits.max_transfer_buffer_size,
kAlignment, kSizeToFlush)) {
- return false;
+ // TransferBuffer::Initialize doesn't fail for transient reasons such as if
+ // the context was lost. See http://crrev.com/c/720269
+ return gpu::ContextResult::kFatalFailure;
}
max_extra_transfer_buffer_size_ = limits.max_mapped_memory_for_texture_upload;
- mapped_memory_.reset(
- new MappedMemoryManager(helper_, limits.mapped_memory_reclaim_limit));
+ mapped_memory_ = std::make_unique<MappedMemoryManager>(
+ helper_, limits.mapped_memory_reclaim_limit);
mapped_memory_->set_chunk_size_multiple(limits.mapped_memory_chunk_size);
GLStaticState::ShaderPrecisionMap* shader_precisions =
@@ -226,11 +229,11 @@
capabilities_.num_compressed_texture_formats);
util_.set_num_shader_binary_formats(capabilities_.num_shader_binary_formats);
- texture_units_.reset(
- new TextureUnit[capabilities_.max_combined_texture_image_units]);
+ texture_units_ = std::make_unique<TextureUnit[]>(
+ capabilities_.max_combined_texture_image_units);
- query_tracker_.reset(new QueryTracker(mapped_memory_.get()));
- buffer_tracker_.reset(new BufferTracker(mapped_memory_.get()));
+ query_tracker_ = std::make_unique<QueryTracker>(mapped_memory_.get());
+ buffer_tracker_ = std::make_unique<BufferTracker>(mapped_memory_.get());
for (int i = 0; i < static_cast<int>(IdNamespaces::kNumIdNamespaces); ++i)
id_allocators_[i].reset(new IdAllocator());
@@ -252,10 +255,10 @@
SetGLError(GL_INVALID_OPERATION,
"Initialize",
"Service bind_generates_resource mismatch.");
- return false;
+ return gpu::ContextResult::kFatalFailure;
}
- return true;
+ return gpu::ContextResult::kSuccess;
}
GLES2Implementation::~GLES2Implementation() {
diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h
index 8ce0179..9002b3d 100644
--- a/gpu/command_buffer/client/gles2_implementation.h
+++ b/gpu/command_buffer/client/gles2_implementation.h
@@ -31,6 +31,7 @@
#include "gpu/command_buffer/client/ref_counted.h"
#include "gpu/command_buffer/client/share_group.h"
#include "gpu/command_buffer/common/capabilities.h"
+#include "gpu/command_buffer/common/context_result.h"
#include "gpu/command_buffer/common/debug_marker_manager.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
@@ -171,7 +172,7 @@
~GLES2Implementation() override;
- bool Initialize(const SharedMemoryLimits& limits);
+ gpu::ContextResult Initialize(const SharedMemoryLimits& limits);
// The GLES2CmdHelper being used by this GLES2Implementation. You can use
// this to issue cmds at a lower level for certain kinds of optimization.
diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc
index d724023c..656354a9 100644
--- a/gpu/command_buffer/client/gles2_implementation_unittest.cc
+++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc
@@ -499,7 +499,7 @@
// The client should be set to something non-null.
EXPECT_CALL(*gpu_control_, SetGpuControlClient(gl_.get())).Times(1);
- if (!gl_->Initialize(limits))
+ if (gl_->Initialize(limits) != gpu::ContextResult::kSuccess)
return false;
helper_->CommandBufferHelper::Finish();
diff --git a/gpu/command_buffer/client/transfer_buffer.cc b/gpu/command_buffer/client/transfer_buffer.cc
index 76afc59f..76dde81 100644
--- a/gpu/command_buffer/client/transfer_buffer.cc
+++ b/gpu/command_buffer/client/transfer_buffer.cc
@@ -117,12 +117,9 @@
if (id != -1) {
DCHECK(buffer.get());
buffer_ = buffer;
- ring_buffer_.reset(new RingBuffer(
- alignment_,
- result_size_,
- buffer_->size() - result_size_,
- helper_,
- static_cast<char*>(buffer_->memory()) + result_size_));
+ ring_buffer_ = std::make_unique<RingBuffer>(
+ alignment_, result_size_, buffer_->size() - result_size_, helper_,
+ static_cast<char*>(buffer_->memory()) + result_size_);
buffer_id_ = id;
result_buffer_ = buffer_->memory();
result_shm_offset_ = 0;
diff --git a/gpu/command_buffer/client/transfer_buffer_unittest.cc b/gpu/command_buffer/client/transfer_buffer_unittest.cc
index c83e1d3e..595798a 100644
--- a/gpu/command_buffer/client/transfer_buffer_unittest.cc
+++ b/gpu/command_buffer/client/transfer_buffer_unittest.cc
@@ -68,7 +68,8 @@
command_buffer_.reset(new StrictMock<MockClientCommandBufferMockFlush>());
helper_.reset(new CommandBufferHelper(command_buffer()));
- ASSERT_TRUE(helper_->Initialize(kCommandBufferSizeBytes));
+ ASSERT_EQ(helper_->Initialize(kCommandBufferSizeBytes),
+ gpu::ContextResult::kSuccess);
transfer_buffer_id_ = command_buffer()->GetNextFreeTransferBufferId();
@@ -308,7 +309,8 @@
.RetiresOnSaturation();
helper_.reset(new CommandBufferHelper(command_buffer()));
- ASSERT_TRUE(helper_->Initialize(kCommandBufferSizeBytes));
+ ASSERT_EQ(helper_->Initialize(kCommandBufferSizeBytes),
+ gpu::ContextResult::kSuccess);
transfer_buffer_id_ = command_buffer()->GetNextFreeTransferBufferId();
diff --git a/gpu/command_buffer/common/BUILD.gn b/gpu/command_buffer/common/BUILD.gn
index 061318b..b7b3dc6 100644
--- a/gpu/command_buffer/common/BUILD.gn
+++ b/gpu/command_buffer/common/BUILD.gn
@@ -35,6 +35,7 @@
"command_buffer.h",
"command_buffer_id.h",
"constants.h",
+ "context_result.h",
"debug_marker_manager.cc",
"debug_marker_manager.h",
"discardable_handle.cc",
diff --git a/gpu/command_buffer/common/context_result.h b/gpu/command_buffer/common/context_result.h
new file mode 100644
index 0000000..db59266
--- /dev/null
+++ b/gpu/command_buffer/common/context_result.h
@@ -0,0 +1,28 @@
+// Copyright 2017 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.
+
+#ifndef GPU_COMMAND_BUFFER_COMMON_CONTEXT_RESULT_H_
+#define GPU_COMMAND_BUFFER_COMMON_CONTEXT_RESULT_H_
+
+namespace gpu {
+
+// The result of trying to create a gpu context. Also the result of intermediate
+// steps which bubble up to the final result. If any fatal error occurs, the
+// entire result should be fatal - as any attempt to retry is expected to get
+// the same fatal result.
+enum class ContextResult {
+ // The context was created and initialized successfully.
+ kSuccess,
+ // A failure occured that prevented the context from being initialized,
+ // but it can be retried and expect to make progress.
+ kTransientFailure,
+ // An error occured that will recur in future attempts too with the
+ // same inputs, retrying would not be productive.
+ kFatalFailure,
+ kLastContextResult = kFatalFailure
+};
+
+} // namespace gpu
+
+#endif // GPU_COMMAND_BUFFER_COMMON_CONTEXT_RESULT_H_
diff --git a/gpu/command_buffer/service/context_group.cc b/gpu/command_buffer/service/context_group.cc
index f43e913..68da0c7 100644
--- a/gpu/command_buffer/service/context_group.cc
+++ b/gpu/command_buffer/service/context_group.cc
@@ -125,15 +125,16 @@
gpu_preferences_.use_passthrough_cmd_decoder;
}
-bool ContextGroup::Initialize(GLES2Decoder* decoder,
- ContextType context_type,
- const DisallowedFeatures& disallowed_features) {
+gpu::ContextResult ContextGroup::Initialize(
+ GLES2Decoder* decoder,
+ ContextType context_type,
+ const DisallowedFeatures& disallowed_features) {
switch (context_type) {
case CONTEXT_TYPE_WEBGL1:
if (kGpuFeatureStatusBlacklisted ==
gpu_feature_info_.status_values[GPU_FEATURE_TYPE_ACCELERATED_WEBGL]) {
DLOG(ERROR) << "ContextGroup::Initialize failed: WebGL1 baclklisted";
- return false;
+ return gpu::ContextResult::kFatalFailure;
}
break;
case CONTEXT_TYPE_WEBGL2:
@@ -141,7 +142,7 @@
gpu_feature_info_
.status_values[GPU_FEATURE_TYPE_ACCELERATED_WEBGL2]) {
DLOG(ERROR) << "ContextGroup::Initialize failed: WebGL2 blacklisted";
- return false;
+ return gpu::ContextResult::kFatalFailure;
}
break;
default:
@@ -151,21 +152,17 @@
if (context_type != feature_info_->context_type()) {
DLOG(ERROR) << "ContextGroup::Initialize failed because the type of "
<< "the context does not fit with the group.";
- return false;
+ return gpu::ContextResult::kFatalFailure;
}
// If we've already initialized the group just add the context.
decoders_.push_back(decoder->AsWeakPtr());
- return true;
+ return gpu::ContextResult::kSuccess;
}
DisallowedFeatures adjusted_disallowed_features =
AdjustDisallowedFeatures(context_type, disallowed_features);
- if (!feature_info_->Initialize(context_type, adjusted_disallowed_features)) {
- DLOG(ERROR) << "ContextGroup::Initialize failed because FeatureInfo "
- << "initialization failed.";
- return false;
- }
+ feature_info_->Initialize(context_type, adjusted_disallowed_features);
const GLint kMinRenderbufferSize = 512; // GL says 1 pixel!
GLint max_renderbuffer_size = 0;
@@ -175,7 +172,9 @@
DLOG(ERROR) << "ContextGroup::Initialize failed because maximum "
<< "renderbuffer size too small (" << max_renderbuffer_size
<< ", should be " << kMinRenderbufferSize << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
GLint max_samples = 0;
if (feature_info_->feature_flags().chromium_framebuffer_multisample ||
@@ -217,7 +216,9 @@
<< "transform feedback separate attribs is too small ("
<< max_transform_feedback_separate_attribs_ << ", should be "
<< kMinTransformFeedbackSeparateAttribs << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
const GLint kMinUniformBufferBindings = 24;
@@ -228,7 +229,9 @@
<< "uniform buffer bindings is too small ("
<< max_uniform_buffer_bindings_ << ", should be "
<< kMinUniformBufferBindings << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
// TODO(zmo): Should we check max UNIFORM_BUFFER_OFFSET_ALIGNMENT is 256?
@@ -252,7 +255,9 @@
DLOG(ERROR) << "ContextGroup::Initialize failed because too few "
<< "vertex attributes supported (" << max_vertex_attribs_
<< ", should be " << kGLES2RequiredMinimumVertexAttribs << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
const GLuint kGLES2RequiredMinimumTextureUnits = 8u;
@@ -262,7 +267,9 @@
DLOG(ERROR) << "ContextGroup::Initialize failed because too few "
<< "texture units supported (" << max_texture_units_
<< ", should be " << kGLES2RequiredMinimumTextureUnits << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
GLint max_texture_size = 0;
@@ -282,7 +289,9 @@
DLOG(ERROR) << "ContextGroup::Initialize failed because maximum "
<< "2d texture size is too small (" << max_texture_size
<< ", should be " << kMinTextureSize << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
if (!QueryGLFeature(GL_MAX_CUBE_MAP_TEXTURE_SIZE, kMinCubeMapSize,
&max_cube_map_texture_size)) {
@@ -290,7 +299,9 @@
<< "cube texture size is too small ("
<< max_cube_map_texture_size << ", should be "
<< kMinCubeMapSize << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
if (feature_info_->gl_version_info().is_es3_capable &&
!QueryGLFeature(GL_MAX_3D_TEXTURE_SIZE, kMin3DTextureSize,
@@ -298,7 +309,9 @@
DLOG(ERROR) << "ContextGroup::Initialize failed because maximum "
<< "3d texture size is too small (" << max_3d_texture_size
<< ", should be " << kMin3DTextureSize << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
if (feature_info_->gl_version_info().is_es3_capable &&
!QueryGLFeature(GL_MAX_ARRAY_TEXTURE_LAYERS, kMinArrayTextureLayers,
@@ -307,7 +320,9 @@
<< "array texture layers is too small ("
<< max_array_texture_layers
<< ", should be " << kMinArrayTextureLayers << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
if (feature_info_->feature_flags().arb_texture_rectangle &&
!QueryGLFeature(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB,
@@ -316,7 +331,9 @@
<< "rectangle texture size is too small ("
<< max_rectangle_texture_size << ", should be "
<< kMinRectangleTextureSize << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
if (feature_info_->workarounds().max_texture_size) {
@@ -342,6 +359,9 @@
<< "texture image units supported ("
<< max_texture_image_units_
<< ", should be " << kMinTextureImageUnits << ").";
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
if (!QueryGLFeatureU(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS,
kMinVertexTextureImageUnits,
@@ -350,7 +370,9 @@
<< "vertex texture image units supported ("
<< max_vertex_texture_image_units_ << ", should be "
<< kMinTextureImageUnits << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
if (feature_info_->gl_version_info().BehavesLikeGLES()) {
@@ -378,7 +400,9 @@
kMinVertexUniformVectors, &max_vertex_uniform_vectors_)) {
DLOG(ERROR) << "ContextGroup::Initialize failed because too few "
<< "uniforms or varyings supported.";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
// Some shaders in Skia need more than the min available vertex and
@@ -416,7 +440,9 @@
<< "vertex output components is too small ("
<< max_vertex_output_components_ << ", should be "
<< kMinVertexOutputComponents << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
if (!QueryGLFeatureU(GL_MAX_FRAGMENT_INPUT_COMPONENTS,
kMinFragmentInputComponents,
@@ -425,7 +451,9 @@
<< "fragment input components is too small ("
<< max_fragment_input_components_ << ", should be "
<< kMinFragmentInputComponents << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
if (!QueryGLFeature(GL_MAX_PROGRAM_TEXEL_OFFSET, kMin_MaxProgramTexelOffset,
&max_program_texel_offset_)) {
@@ -433,7 +461,9 @@
<< "program texel offset is too small ("
<< max_program_texel_offset_ << ", should be "
<< kMin_MaxProgramTexelOffset << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
glGetIntegerv(GL_MIN_PROGRAM_TEXEL_OFFSET, &min_program_texel_offset_);
if (enforce_gl_minimums_) {
@@ -445,7 +475,9 @@
<< "program texel offset is too big ("
<< min_program_texel_offset_ << ", should be "
<< kMax_MinProgramTexelOffset << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
const GLint kES3MinCubeMapSize = 2048;
@@ -454,7 +486,9 @@
<< "cube texture size is too small ("
<< max_cube_map_texture_size << ", should be "
<< kES3MinCubeMapSize << ").";
- return false;
+ bool was_lost = decoder->CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
}
@@ -465,14 +499,10 @@
max_dual_source_draw_buffers_, max_vertex_attribs_, gpu_preferences_,
feature_info_.get(), progress_reporter_));
- if (!texture_manager_->Initialize()) {
- DLOG(ERROR) << "Context::Group::Initialize failed because texture manager "
- << "failed to initialize.";
- return false;
- }
+ texture_manager_->Initialize();
decoders_.push_back(decoder->AsWeakPtr());
- return true;
+ return gpu::ContextResult::kSuccess;
}
namespace {
diff --git a/gpu/command_buffer/service/context_group.h b/gpu/command_buffer/service/context_group.h
index b072dbe93..d467f8b 100644
--- a/gpu/command_buffer/service/context_group.h
+++ b/gpu/command_buffer/service/context_group.h
@@ -73,10 +73,9 @@
// This should only be called by GLES2Decoder. This must be paired with a
// call to destroy if it succeeds.
- bool Initialize(
- GLES2Decoder* decoder,
- ContextType context_type,
- const DisallowedFeatures& disallowed_features);
+ gpu::ContextResult Initialize(GLES2Decoder* decoder,
+ ContextType context_type,
+ const DisallowedFeatures& disallowed_features);
// Destroys all the resources when called for the last context in the group.
// It should only be called by GLES2Decoder.
diff --git a/gpu/command_buffer/service/context_group_unittest.cc b/gpu/command_buffer/service/context_group_unittest.cc
index 0cb5098..58c5951 100644
--- a/gpu/command_buffer/service/context_group_unittest.cc
+++ b/gpu/command_buffer/service/context_group_unittest.cc
@@ -124,16 +124,21 @@
TestHelper::SetupContextGroupInitExpectations(
gl_.get(), DisallowedFeatures(), "", "",
CONTEXT_TYPE_OPENGLES2, kBindGeneratesResource);
- EXPECT_TRUE(group_->Initialize(decoder_.get(), CONTEXT_TYPE_OPENGLES2,
- DisallowedFeatures()));
- EXPECT_FALSE(group_->Initialize(decoder2_.get(), CONTEXT_TYPE_WEBGL1,
- DisallowedFeatures()));
- EXPECT_FALSE(group_->Initialize(decoder2_.get(), CONTEXT_TYPE_WEBGL2,
- DisallowedFeatures()));
- EXPECT_FALSE(group_->Initialize(decoder2_.get(), CONTEXT_TYPE_OPENGLES3,
- DisallowedFeatures()));
- EXPECT_TRUE(group_->Initialize(decoder2_.get(), CONTEXT_TYPE_OPENGLES2,
- DisallowedFeatures()));
+ EXPECT_EQ(group_->Initialize(decoder_.get(), CONTEXT_TYPE_OPENGLES2,
+ DisallowedFeatures()),
+ gpu::ContextResult::kSuccess);
+ EXPECT_EQ(group_->Initialize(decoder2_.get(), CONTEXT_TYPE_WEBGL1,
+ DisallowedFeatures()),
+ gpu::ContextResult::kFatalFailure);
+ EXPECT_EQ(group_->Initialize(decoder2_.get(), CONTEXT_TYPE_WEBGL2,
+ DisallowedFeatures()),
+ gpu::ContextResult::kFatalFailure);
+ EXPECT_EQ(group_->Initialize(decoder2_.get(), CONTEXT_TYPE_OPENGLES3,
+ DisallowedFeatures()),
+ gpu::ContextResult::kFatalFailure);
+ EXPECT_EQ(group_->Initialize(decoder2_.get(), CONTEXT_TYPE_OPENGLES2,
+ DisallowedFeatures()),
+ gpu::ContextResult::kSuccess);
EXPECT_TRUE(group_->buffer_manager() != NULL);
EXPECT_TRUE(group_->renderbuffer_manager() != NULL);
diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc
index a1fdad7..8c42775 100644
--- a/gpu/command_buffer/service/feature_info.cc
+++ b/gpu/command_buffer/service/feature_info.cc
@@ -250,25 +250,24 @@
command_line->HasSwitch(switches::kDisableGLSLTranslator);
}
-bool FeatureInfo::Initialize(ContextType context_type,
+void FeatureInfo::Initialize(ContextType context_type,
const DisallowedFeatures& disallowed_features) {
disallowed_features_ = disallowed_features;
context_type_ = context_type;
InitializeFeatures();
- return true;
}
-bool FeatureInfo::InitializeForTesting(
+void FeatureInfo::InitializeForTesting(
const DisallowedFeatures& disallowed_features) {
- return Initialize(CONTEXT_TYPE_OPENGLES2, disallowed_features);
+ Initialize(CONTEXT_TYPE_OPENGLES2, disallowed_features);
}
-bool FeatureInfo::InitializeForTesting() {
- return Initialize(CONTEXT_TYPE_OPENGLES2, DisallowedFeatures());
+void FeatureInfo::InitializeForTesting() {
+ Initialize(CONTEXT_TYPE_OPENGLES2, DisallowedFeatures());
}
-bool FeatureInfo::InitializeForTesting(ContextType context_type) {
- return Initialize(context_type, DisallowedFeatures());
+void FeatureInfo::InitializeForTesting(ContextType context_type) {
+ Initialize(context_type, DisallowedFeatures());
}
bool IsGL_REDSupportedOnFBOs() {
diff --git a/gpu/command_buffer/service/feature_info.h b/gpu/command_buffer/service/feature_info.h
index 05fb1cb..578ec82 100644
--- a/gpu/command_buffer/service/feature_info.h
+++ b/gpu/command_buffer/service/feature_info.h
@@ -132,15 +132,15 @@
const GpuDriverBugWorkarounds& gpu_driver_bug_workarounds);
// Initializes the feature information. Needs a current GL context.
- bool Initialize(ContextType context_type,
+ void Initialize(ContextType context_type,
const DisallowedFeatures& disallowed_features);
// Helper that defaults to no disallowed features and a GLES2 context.
- bool InitializeForTesting();
+ void InitializeForTesting();
// Helper that defaults to no disallowed Features.
- bool InitializeForTesting(ContextType context_type);
+ void InitializeForTesting(ContextType context_type);
// Helper that defaults to a GLES2 context.
- bool InitializeForTesting(const DisallowedFeatures& disallowed_features);
+ void InitializeForTesting(const DisallowedFeatures& disallowed_features);
const Validators* validators() const {
return &validators_;
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 5dc8721..27c756d8 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -536,11 +536,12 @@
// Overridden from GLES2Decoder.
base::WeakPtr<GLES2Decoder> AsWeakPtr() override;
- bool Initialize(const scoped_refptr<gl::GLSurface>& surface,
- const scoped_refptr<gl::GLContext>& context,
- bool offscreen,
- const DisallowedFeatures& disallowed_features,
- const ContextCreationAttribHelper& attrib_helper) override;
+ gpu::ContextResult Initialize(
+ const scoped_refptr<gl::GLSurface>& surface,
+ const scoped_refptr<gl::GLContext>& context,
+ bool offscreen,
+ const DisallowedFeatures& disallowed_features,
+ const ContextCreationAttribHelper& attrib_helper) override;
void Destroy(bool have_context) override;
void SetSurface(const scoped_refptr<gl::GLSurface>& surface) override;
void ReleaseSurface() override;
@@ -2069,7 +2070,7 @@
bool WasContextLost() const override;
bool WasContextLostByRobustnessExtension() const override;
void MarkContextLost(error::ContextLostReason reason) override;
- bool CheckResetStatus();
+ bool CheckResetStatus() override;
bool GetCompressedTexSizeInBytes(
const char* function_name, GLsizei width, GLsizei height, GLsizei depth,
@@ -3188,7 +3189,7 @@
return weak_ptr_factory_.GetWeakPtr();
}
-bool GLES2DecoderImpl::Initialize(
+gpu::ContextResult GLES2DecoderImpl::Initialize(
const scoped_refptr<gl::GLSurface>& surface,
const scoped_refptr<gl::GLContext>& context,
bool offscreen,
@@ -3240,14 +3241,15 @@
feature_info_->feature_flags().is_swiftshader_for_webgl) {
group_ = NULL; // Must not destroy ContextGroup if it is not initialized.
Destroy(true);
- return false;
+ return gpu::ContextResult::kFatalFailure;
}
- if (!group_->Initialize(this, attrib_helper.context_type,
- disallowed_features)) {
+ auto result =
+ group_->Initialize(this, attrib_helper.context_type, disallowed_features);
+ if (result != gpu::ContextResult::kSuccess) {
group_ = NULL; // Must not destroy ContextGroup if it is not initialized.
Destroy(true);
- return false;
+ return result;
}
CHECK_GL_ERROR();
@@ -3274,7 +3276,7 @@
if (!supported) {
Destroy(true);
- return false;
+ return gpu::ContextResult::kFatalFailure;
}
}
@@ -3289,7 +3291,7 @@
if (!feature_info_->IsES3Capable()) {
LOG(ERROR) << "ES3 is blacklisted/disabled/unsupported by driver.";
Destroy(true);
- return false;
+ return gpu::ContextResult::kFatalFailure;
}
feature_info_->EnableES3Validators();
@@ -3625,7 +3627,7 @@
gfx::Size(state_.viewport_width, state_.viewport_height))) {
LOG(ERROR) << "Could not allocate offscreen buffer storage.";
Destroy(true);
- return false;
+ return gpu::ContextResult::kFatalFailure;
}
if (!offscreen_single_buffer_) {
// Allocate the offscreen saved color texture.
@@ -3638,8 +3640,10 @@
if (offscreen_saved_frame_buffer_->CheckStatus() !=
GL_FRAMEBUFFER_COMPLETE) {
LOG(ERROR) << "Offscreen saved FBO was incomplete.";
+ bool was_lost = CheckResetStatus();
Destroy(true);
- return false;
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
}
}
@@ -3705,7 +3709,7 @@
LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glClearWorkaroundInit");
clear_framebuffer_blit_.reset(new ClearFramebufferResourceManager(this));
if (LOCAL_PEEK_GL_ERROR("glClearWorkaroundInit") != GL_NO_ERROR)
- return false;
+ return gpu::ContextResult::kFatalFailure;
}
if (group_->gpu_preferences().enable_gpu_driver_debug_logging &&
@@ -3720,21 +3724,23 @@
if (attrib_helper.enable_oop_rasterization) {
if (!features().chromium_raster_transport)
- return false;
+ return gpu::ContextResult::kFatalFailure;
sk_sp<const GrGLInterface> interface(
CreateGrGLInterface(gl_version_info()));
// TODO(enne): if this or gr_context creation below fails in practice for
// different reasons than the ones the renderer would fail on for gpu
// raster, expose this in gpu::Capabilities so the renderer can handle it.
if (!interface)
- return false;
+ return gpu::ContextResult::kFatalFailure;
gr_context_ = sk_sp<GrContext>(
GrContext::Create(kOpenGL_GrBackend,
reinterpret_cast<GrBackendContext>(interface.get())));
if (!gr_context_) {
LOG(ERROR) << "Could not create GrContext";
- return false;
+ bool was_lost = CheckResetStatus();
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
// TODO(enne): this cache is for this decoder only and each decoder has
@@ -3748,7 +3754,7 @@
kMaxGaneshResourceCacheBytes);
}
- return true;
+ return gpu::ContextResult::kSuccess;
}
Capabilities GLES2DecoderImpl::GetCapabilities() {
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h
index b7a07e3..f860d390 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.h
@@ -21,6 +21,7 @@
#include "gpu/command_buffer/common/capabilities.h"
#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/constants.h"
+#include "gpu/command_buffer/common/context_result.h"
#include "gpu/command_buffer/service/common_decoder.h"
#include "gpu/gpu_export.h"
@@ -175,11 +176,12 @@
// offscreen_size: the size if the GL context is offscreen.
// Returns:
// true if successful.
- virtual bool Initialize(const scoped_refptr<gl::GLSurface>& surface,
- const scoped_refptr<gl::GLContext>& context,
- bool offscreen,
- const DisallowedFeatures& disallowed_features,
- const ContextCreationAttribHelper& attrib_helper) = 0;
+ virtual gpu::ContextResult Initialize(
+ const scoped_refptr<gl::GLSurface>& surface,
+ const scoped_refptr<gl::GLContext>& context,
+ bool offscreen,
+ const DisallowedFeatures& disallowed_features,
+ const ContextCreationAttribHelper& attrib_helper) = 0;
// Destroys the graphics context.
virtual void Destroy(bool have_context) = 0;
@@ -331,6 +333,13 @@
// Lose this context.
virtual void MarkContextLost(error::ContextLostReason reason) = 0;
+ // Updates context lost state and returns true if lost. Most callers can use
+ // WasContextLost() as the GLES2Decoder will update the state internally. But
+ // if making GL calls directly, to the context then this state would not be
+ // updated and the caller can use this to determine if their calls failed due
+ // to context loss.
+ virtual bool CheckResetStatus() = 0;
+
virtual Logger* GetLogger() = 0;
void BeginDecoding() override;
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
index 5a85501..07d0504 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
@@ -42,12 +42,13 @@
base::WeakPtr<GLES2Decoder> AsWeakPtr() override;
- MOCK_METHOD5(Initialize,
- bool(const scoped_refptr<gl::GLSurface>& surface,
- const scoped_refptr<gl::GLContext>& context,
- bool offscreen,
- const DisallowedFeatures& disallowed_features,
- const ContextCreationAttribHelper& attrib_helper));
+ MOCK_METHOD5(
+ Initialize,
+ gpu::ContextResult(const scoped_refptr<gl::GLSurface>& surface,
+ const scoped_refptr<gl::GLContext>& context,
+ bool offscreen,
+ const DisallowedFeatures& disallowed_features,
+ const ContextCreationAttribHelper& attrib_helper));
MOCK_METHOD1(Destroy, void(bool have_context));
MOCK_METHOD1(SetSurface, void(const scoped_refptr<gl::GLSurface>& surface));
MOCK_METHOD0(ReleaseSurface, void());
@@ -145,6 +146,7 @@
MOCK_CONST_METHOD0(WasContextLost, bool());
MOCK_CONST_METHOD0(WasContextLostByRobustnessExtension, bool());
MOCK_METHOD1(MarkContextLost, void(gpu::error::ContextLostReason reason));
+ MOCK_METHOD0(CheckResetStatus, bool());
MOCK_METHOD4(BindImage,
void(uint32_t client_texture_id,
uint32_t texture_target,
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc
index 4d427bec..92cac07 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc
@@ -204,11 +204,10 @@
GLES2DecoderPassthroughImpl::EmulatedColorBuffer::~EmulatedColorBuffer() =
default;
-bool GLES2DecoderPassthroughImpl::EmulatedColorBuffer::Resize(
+void GLES2DecoderPassthroughImpl::EmulatedColorBuffer::Resize(
const gfx::Size& new_size) {
- if (size == new_size) {
- return true;
- }
+ if (size == new_size)
+ return;
size = new_size;
ScopedTexture2DBindingReset scoped_texture_reset;
@@ -220,8 +219,6 @@
glTexImage2D(texture->target(), 0, format.color_texture_internal_format,
size.width(), size.height(), 0, format.color_texture_format,
format.color_texture_type, nullptr);
-
- return true;
}
void GLES2DecoderPassthroughImpl::EmulatedColorBuffer::Destroy(
@@ -344,11 +341,8 @@
ResizeRenderbuffer(color_buffer_service_id, size, format.samples,
format.color_renderbuffer_internal_format, feature_info);
}
- if (color_texture) {
- if (!color_texture->Resize(size)) {
- return false;
- }
- }
+ if (color_texture)
+ color_texture->Resize(size);
if (depth_stencil_buffer_service_id != 0) {
ResizeRenderbuffer(depth_stencil_buffer_service_id, size, format.samples,
format.depth_stencil_internal_format, feature_info);
@@ -547,7 +541,7 @@
return weak_ptr_factory_.GetWeakPtr();
}
-bool GLES2DecoderPassthroughImpl::Initialize(
+gpu::ContextResult GLES2DecoderPassthroughImpl::Initialize(
const scoped_refptr<gl::GLSurface>& surface,
const scoped_refptr<gl::GLContext>& context,
bool offscreen,
@@ -562,11 +556,13 @@
// Create GPU Tracer for timing values.
gpu_tracer_.reset(new GPUTracer(this));
- if (!group_->Initialize(this, attrib_helper.context_type,
- disallowed_features)) {
- group_ = NULL; // Must not destroy ContextGroup if it is not initialized.
+ auto result =
+ group_->Initialize(this, attrib_helper.context_type, disallowed_features);
+ if (result != gpu::ContextResult::kSuccess) {
+ // Must not destroy ContextGroup if it is not initialized.
+ group_ = nullptr;
Destroy(true);
- return false;
+ return result;
}
// Extensions that are enabled via emulation on the client side or needed for
@@ -627,11 +623,7 @@
// Each context initializes its own feature info because some extensions may
// be enabled dynamically. Don't disallow any features, leave it up to ANGLE
// to dynamically enable extensions.
- if (!feature_info_->Initialize(attrib_helper.context_type,
- DisallowedFeatures())) {
- Destroy(true);
- return false;
- }
+ feature_info_->Initialize(attrib_helper.context_type, DisallowedFeatures());
// Check for required extensions
// TODO(geofflang): verify
@@ -646,12 +638,12 @@
IsWebGLContextType(attrib_helper.context_type) ||
!feature_info_->feature_flags().angle_request_extension) {
Destroy(true);
- return false;
+ return gpu::ContextResult::kFatalFailure;
}
if (attrib_helper.enable_oop_rasterization) {
Destroy(true);
- return false;
+ return gpu::ContextResult::kFatalFailure;
}
bind_generates_resource_ = group_->bind_generates_resource();
@@ -772,19 +764,22 @@
}
FlushErrors();
- emulated_back_buffer_.reset(new EmulatedDefaultFramebuffer(
- emulated_default_framebuffer_format_, feature_info_.get()));
+ emulated_back_buffer_ = std::make_unique<EmulatedDefaultFramebuffer>(
+ emulated_default_framebuffer_format_, feature_info_.get());
if (!emulated_back_buffer_->Resize(attrib_helper.offscreen_framebuffer_size,
feature_info_.get())) {
+ bool was_lost = CheckResetStatus();
Destroy(true);
- return false;
+ return was_lost ? gpu::ContextResult::kTransientFailure
+ : gpu::ContextResult::kFatalFailure;
}
if (FlushErrors()) {
LOG(ERROR) << "Creation of the offscreen framebuffer failed because "
"errors were generated.";
Destroy(true);
- return false;
+ // Errors are considered fatal, including OOM.
+ return gpu::ContextResult::kFatalFailure;
}
framebuffer_id_map_.SetIDMapping(
@@ -798,7 +793,7 @@
}
set_initialized();
- return true;
+ return gpu::ContextResult::kSuccess;
}
void GLES2DecoderPassthroughImpl::Destroy(bool have_context) {
@@ -912,7 +907,7 @@
return;
}
- if (!emulated_front_buffer_.get()) {
+ if (!emulated_front_buffer_) {
DLOG(ERROR) << "Called TakeFrontBuffer on a non-offscreen context";
return;
}
@@ -924,12 +919,9 @@
if (available_color_textures_.empty()) {
// Create a new color texture to use as the front buffer
- emulated_front_buffer_.reset(
- new EmulatedColorBuffer(emulated_default_framebuffer_format_));
- if (!emulated_front_buffer_->Resize(emulated_back_buffer_->size)) {
- DLOG(ERROR) << "Failed to create a new emulated front buffer texture.";
- return;
- }
+ emulated_front_buffer_ = std::make_unique<EmulatedColorBuffer>(
+ emulated_default_framebuffer_format_);
+ emulated_front_buffer_->Resize(emulated_back_buffer_->size);
create_color_buffer_count_for_test_++;
} else {
emulated_front_buffer_ = std::move(available_color_textures_.back());
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h
index 8b20928..d54b40a 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h
@@ -124,11 +124,12 @@
base::WeakPtr<GLES2Decoder> AsWeakPtr() override;
- bool Initialize(const scoped_refptr<gl::GLSurface>& surface,
- const scoped_refptr<gl::GLContext>& context,
- bool offscreen,
- const DisallowedFeatures& disallowed_features,
- const ContextCreationAttribHelper& attrib_helper) override;
+ gpu::ContextResult Initialize(
+ const scoped_refptr<gl::GLSurface>& surface,
+ const scoped_refptr<gl::GLContext>& context,
+ bool offscreen,
+ const DisallowedFeatures& disallowed_features,
+ const ContextCreationAttribHelper& attrib_helper) override;
// Destroys the graphics context.
void Destroy(bool have_context) override;
@@ -275,6 +276,10 @@
// Lose this context.
void MarkContextLost(error::ContextLostReason reason) override;
+ // Update lost context state for use when making calls to the GL context
+ // directly, and needing to know if they failed due to loss.
+ bool CheckResetStatus() override;
+
Logger* GetLogger() override;
void BeginDecoding() override;
@@ -348,7 +353,6 @@
// call to glGetError
void InjectDriverError(GLenum error);
- bool CheckResetStatus();
bool IsRobustnessSupported();
bool IsEmulatedQueryTarget(GLenum target) const;
@@ -525,7 +529,7 @@
const EmulatedDefaultFramebufferFormat& format_in);
~EmulatedColorBuffer();
- bool Resize(const gfx::Size& new_size);
+ void Resize(const gfx::Size& new_size);
void Destroy(bool have_context);
scoped_refptr<TexturePassthrough> texture;
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc
index 194bffa..9d34393 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc
@@ -3141,13 +3141,9 @@
emulated_front_buffer_ = std::move(available_color_textures_.back());
available_color_textures_.pop_back();
} else {
- emulated_front_buffer_.reset(
- new EmulatedColorBuffer(emulated_default_framebuffer_format_));
- if (!emulated_front_buffer_->Resize(emulated_back_buffer_->size)) {
- DLOG(ERROR)
- << "Failed to create a new emulated front buffer texture.";
- return error::kLostContext;
- }
+ emulated_front_buffer_ = std::make_unique<EmulatedColorBuffer>(
+ emulated_default_framebuffer_format_);
+ emulated_front_buffer_->Resize(emulated_back_buffer_->size);
}
}
@@ -3371,10 +3367,8 @@
// Make sure newly enabled extensions are exposed and usable.
context_->ReinitializeDynamicBindings();
- if (!feature_info_->Initialize(feature_info_->context_type(),
- feature_info_->disallowed_features())) {
- return error::kLostContext;
- }
+ feature_info_->Initialize(feature_info_->context_type(),
+ feature_info_->disallowed_features());
return error::kNoError;
}
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
index 5fdc10d..1960215 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
@@ -246,8 +246,9 @@
mock_decoder_.reset(
new MockGLES2Decoder(command_buffer_service_.get(), &outputter_));
- EXPECT_TRUE(group_->Initialize(mock_decoder_.get(), init.context_type,
- DisallowedFeatures()));
+ EXPECT_EQ(group_->Initialize(mock_decoder_.get(), init.context_type,
+ DisallowedFeatures()),
+ gpu::ContextResult::kSuccess);
if (init.context_type == CONTEXT_TYPE_WEBGL2 ||
init.context_type == CONTEXT_TYPE_OPENGLES3) {
@@ -490,8 +491,9 @@
&outputter_, group_.get()));
decoder_->SetIgnoreCachedStateForTest(ignore_cached_state_for_test_);
decoder_->GetLogger()->set_log_synthesized_gl_errors(false);
- ASSERT_TRUE(decoder_->Initialize(surface_, context_, false,
- DisallowedFeatures(), attribs));
+ ASSERT_EQ(decoder_->Initialize(surface_, context_, false,
+ DisallowedFeatures(), attribs),
+ gpu::ContextResult::kSuccess);
EXPECT_CALL(*context_, MakeCurrent(surface_.get())).WillOnce(Return(true));
if (context_->WasAllocatedUsingRobustnessExtension()) {
@@ -2273,12 +2275,14 @@
decoder_.reset(new GLES2DecoderPassthroughImpl(
this, command_buffer_service_.get(), &outputter_, group_.get()));
- ASSERT_TRUE(group_->Initialize(decoder_.get(),
- context_creation_attribs_.context_type,
- DisallowedFeatures()));
- ASSERT_TRUE(decoder_->Initialize(surface_, context_, false,
- DisallowedFeatures(),
- context_creation_attribs_));
+ ASSERT_EQ(
+ group_->Initialize(decoder_.get(), context_creation_attribs_.context_type,
+ DisallowedFeatures()),
+ gpu::ContextResult::kSuccess);
+ ASSERT_EQ(
+ decoder_->Initialize(surface_, context_, false, DisallowedFeatures(),
+ context_creation_attribs_),
+ gpu::ContextResult::kSuccess);
scoped_refptr<gpu::Buffer> buffer =
command_buffer_service_->CreateTransferBufferHelper(kSharedBufferSize,
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc
index 9dafeea..c1b4475 100644
--- a/gpu/command_buffer/service/texture_manager.cc
+++ b/gpu/command_buffer/service/texture_manager.cc
@@ -2009,7 +2009,7 @@
NOTREACHED();
}
-bool TextureManager::Initialize() {
+void TextureManager::Initialize() {
// Reset PIXEL_UNPACK_BUFFER to avoid unrelated GL error on some GL drivers.
if (feature_info_->gl_version_info().is_es3_capable) {
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
@@ -2048,8 +2048,6 @@
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
this, "gpu::TextureManager", base::ThreadTaskRunnerHandle::Get());
}
-
- return true;
}
scoped_refptr<TextureRef>
diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h
index 77b7e7f..776d528 100644
--- a/gpu/command_buffer/service/texture_manager.h
+++ b/gpu/command_buffer/service/texture_manager.h
@@ -771,7 +771,7 @@
void RemoveFramebufferManager(FramebufferManager* framebuffer_manager);
// Init the texture manager.
- bool Initialize();
+ void Initialize();
// Must call before destruction.
void Destroy(bool have_context);
diff --git a/gpu/command_buffer/tests/fuzzer_main.cc b/gpu/command_buffer/tests/fuzzer_main.cc
index 4f9d6ef..f6863b4 100644
--- a/gpu/command_buffer/tests/fuzzer_main.cc
+++ b/gpu/command_buffer/tests/fuzzer_main.cc
@@ -184,10 +184,10 @@
attrib_helper.context_type = gles2::CONTEXT_TYPE_OPENGLES3;
#endif
- bool result =
+ auto result =
decoder_->Initialize(surface_.get(), context_.get(), true,
gles2::DisallowedFeatures(), attrib_helper);
- CHECK(result);
+ CHECK_EQ(result, gpu::ContextResult::kSuccess);
decoder_->set_max_bucket_size(8 << 20);
context_group->buffer_manager()->set_max_buffer_size(8 << 20);
if (!vertex_translator_) {
diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc
index 23c1fbb..f66bc55 100644
--- a/gpu/command_buffer/tests/gl_manager.cc
+++ b/gpu/command_buffer/tests/gl_manager.cc
@@ -369,17 +369,19 @@
ASSERT_TRUE(context_->MakeCurrent(surface_.get()));
- if (!decoder_->Initialize(surface_.get(), context_.get(), true,
- ::gpu::gles2::DisallowedFeatures(), attribs)) {
+ auto result =
+ decoder_->Initialize(surface_.get(), context_.get(), true,
+ ::gpu::gles2::DisallowedFeatures(), attribs);
+ if (result != gpu::ContextResult::kSuccess)
return;
- }
// Client side Capabilities queries return reference, service side return
// value. Here two sides are joined together.
capabilities_ = decoder_->GetCapabilities();
// Create the GLES2 helper, which writes the command buffer protocol.
gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get()));
- ASSERT_TRUE(gles2_helper_->Initialize(limits.command_buffer_size));
+ ASSERT_EQ(gles2_helper_->Initialize(limits.command_buffer_size),
+ gpu::ContextResult::kSuccess);
// Create a transfer buffer.
transfer_buffer_.reset(new TransferBuffer(gles2_helper_.get()));
@@ -392,7 +394,8 @@
options.lose_context_when_out_of_memory, support_client_side_arrays,
this));
- ASSERT_TRUE(gles2_implementation_->Initialize(limits))
+ ASSERT_EQ(gles2_implementation_->Initialize(limits),
+ gpu::ContextResult::kSuccess)
<< "Could not init GLES2Implementation";
MakeCurrent();
diff --git a/gpu/command_buffer/tests/gl_unittest.cc b/gpu/command_buffer/tests/gl_unittest.cc
index 344e888..7acc5e9 100644
--- a/gpu/command_buffer/tests/gl_unittest.cc
+++ b/gpu/command_buffer/tests/gl_unittest.cc
@@ -104,7 +104,7 @@
TEST_F(GLTest, FeatureFlagsMatchCapabilities) {
scoped_refptr<gles2::FeatureInfo> features =
new gles2::FeatureInfo(gl_.workarounds());
- EXPECT_TRUE(features->InitializeForTesting());
+ features->InitializeForTesting();
const auto& caps = gl_.GetCapabilities();
const auto& flags = features->feature_flags();
EXPECT_EQ(caps.egl_image_external, flags.oes_egl_image_external);