Index: gpu/command_buffer/tests/fuzzer_main.cc |
diff --git a/gpu/command_buffer/tests/fuzzer_main.cc b/gpu/command_buffer/tests/fuzzer_main.cc |
index 4f65a152496ba038f463b15ea22b6dd2e8b678d0..96f0e491fa2855b1ef14d30c8d95febffbb65e1f 100644 |
--- a/gpu/command_buffer/tests/fuzzer_main.cc |
+++ b/gpu/command_buffer/tests/fuzzer_main.cc |
@@ -22,6 +22,7 @@ |
#include "gpu/command_buffer/service/command_executor.h" |
#include "gpu/command_buffer/service/context_group.h" |
#include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
+#include "gpu/command_buffer/service/gpu_switches.h" |
#include "gpu/command_buffer/service/logger.h" |
#include "gpu/command_buffer/service/mailbox_manager_impl.h" |
#include "gpu/command_buffer/service/sync_point_manager.h" |
@@ -96,14 +97,41 @@ class CommandBufferSetup { |
logging::SetMinLogLevel(logging::LOG_FATAL); |
base::CommandLine::Init(0, NULL); |
-#if defined(GPU_FUZZER_USE_ANGLE) |
auto* command_line = base::CommandLine::ForCurrentProcess(); |
+ (void)command_line; |
piman
2017/03/09 18:15:13
nit: ALLOW_UNUSED_LOCAL
Geoff Lang
2017/03/09 19:29:10
Done.
|
+ |
+#if defined(GPU_FUZZER_USE_PASSTHROUGH_CMD_DECODER) |
+ command_line->AppendSwitch(switches::kUsePassthroughCmdDecoder); |
+ gpu_preferences_.use_passthrough_cmd_decoder = true; |
+#endif |
+ |
+#if defined(GPU_FUZZER_USE_ANGLE) |
command_line->AppendSwitchASCII(switches::kUseGL, |
gl::kGLImplementationANGLEName); |
command_line->AppendSwitchASCII(switches::kUseANGLE, |
gl::kANGLEImplementationNullName); |
gl::init::InitializeGLOneOffImplementation(gl::kGLImplementationEGLGLES2, |
false, false, false); |
+#else |
+ gl::GLSurfaceTestSupport::InitializeOneOffWithMockBindings(); |
+#endif |
+ |
+ sync_point_client_ = sync_point_manager_->CreateSyncPointClient( |
+ sync_point_order_data_, CommandBufferNamespace::IN_PROCESS, |
+ command_buffer_id_); |
+ |
+ translator_cache_ = new gles2::ShaderTranslatorCache(gpu_preferences_); |
+ completeness_cache_ = new gles2::FramebufferCompletenessCache; |
+ |
+ InitDecoder(); |
+ } |
+ |
+ void InitDecoder() { |
+ if (decoder_initialized_) { |
+ return; |
+ } |
+ |
+#if defined(GPU_FUZZER_USE_ANGLE) |
surface_ = new gl::PbufferGLSurfaceEGL(gfx::Size()); |
surface_->Initialize(); |
@@ -117,18 +145,8 @@ class CommandBufferSetup { |
context_stub->SetExtensionsString(kExtensions); |
context_stub->SetUseStubApi(true); |
context_ = context_stub; |
- gl::GLSurfaceTestSupport::InitializeOneOffWithMockBindings(); |
#endif |
- sync_point_client_ = sync_point_manager_->CreateSyncPointClient( |
- sync_point_order_data_, CommandBufferNamespace::IN_PROCESS, |
- command_buffer_id_); |
- |
- translator_cache_ = new gles2::ShaderTranslatorCache(gpu_preferences_); |
- completeness_cache_ = new gles2::FramebufferCompletenessCache; |
- } |
- |
- void InitDecoder() { |
context_->MakeCurrent(surface_.get()); |
scoped_refptr<gles2::FeatureInfo> feature_info = |
new gles2::FeatureInfo(); |
@@ -177,15 +195,27 @@ class CommandBufferSetup { |
vertex_translator_ = decoder_->GetTranslator(GL_VERTEX_SHADER); |
fragment_translator_ = decoder_->GetTranslator(GL_FRAGMENT_SHADER); |
} |
+ |
+ decoder_initialized_ = true; |
piman
2017/03/09 18:15:13
Why the need for this? Before this change, we init
Geoff Lang
2017/03/09 19:29:10
I added this due to the comment referenced below.
piman
2017/03/09 22:12:35
Right, the important part is that the ANGLE DLL is
Geoff Lang
2017/03/09 22:22:13
Sounds good, I'll update that when I get back to M
Geoff Lang
2017/03/16 17:22:08
Done, I also updated it to only re-create the cont
|
} |
void ResetDecoder() { |
+ if (!decoder_initialized_) { |
+ return; |
+ } |
+ |
decoder_->Destroy(true); |
decoder_.reset(); |
command_buffer_.reset(); |
+ surface_ = nullptr; |
+ context_->ReleaseCurrent(nullptr); |
+ context_ = nullptr; |
+ |
+ decoder_initialized_ = false; |
} |
~CommandBufferSetup() { |
+ ResetDecoder(); |
sync_point_client_ = nullptr; |
if (sync_point_order_data_) { |
sync_point_order_data_->Destroy(); |
@@ -288,6 +318,8 @@ class CommandBufferSetup { |
scoped_refptr<gl::GLShareGroup> share_group_; |
const gpu::CommandBufferId command_buffer_id_; |
+ bool decoder_initialized_ = false; |
+ |
scoped_refptr<gl::GLSurface> surface_; |
scoped_refptr<gl::GLContext> context_; |