| 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 9049dff2ddf98279cd5f856b00e435a4bc18fcbc..26e9163fa1910468d832ce47a56f00d9dc46733b 100644
|
| --- a/gpu/command_buffer/tests/fuzzer_main.cc
|
| +++ b/gpu/command_buffer/tests/fuzzer_main.cc
|
| @@ -11,6 +11,7 @@
|
| #include "base/bind.h"
|
| #include "base/command_line.h"
|
| #include "base/logging.h"
|
| +#include "base/memory/ptr_util.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "build/build_config.h"
|
| #include "gpu/command_buffer/common/constants.h"
|
| @@ -27,11 +28,13 @@
|
| #include "gpu/command_buffer/service/transfer_buffer_manager.h"
|
| #include "ui/gfx/geometry/size.h"
|
| #include "ui/gl/gl_context.h"
|
| +#include "ui/gl/gl_context_egl.h"
|
| #include "ui/gl/gl_context_stub_with_extensions.h"
|
| #include "ui/gl/gl_image_ref_counted_memory.h"
|
| #include "ui/gl/gl_share_group.h"
|
| #include "ui/gl/gl_stub_api.h"
|
| #include "ui/gl/gl_surface.h"
|
| +#include "ui/gl/gl_surface_egl.h"
|
| #include "ui/gl/gl_surface_stub.h"
|
| #include "ui/gl/init/gl_factory.h"
|
| #include "ui/gl/test/gl_surface_test_support.h"
|
| @@ -44,6 +47,7 @@ const size_t kTransferBufferSize = 16384;
|
| const size_t kSmallTransferBufferSize = 16;
|
| const size_t kTinyTransferBufferSize = 3;
|
|
|
| +#if !defined(GPU_FUZZER_USE_ANGLE)
|
| static const char kExtensions[] =
|
| "GL_AMD_compressed_ATC_texture "
|
| "GL_ANGLE_texture_compression_dxt3 "
|
| @@ -78,6 +82,7 @@ static const char kExtensions[] =
|
| "GL_OES_texture_float_linear "
|
| "GL_OES_texture_half_float "
|
| "GL_OES_texture_half_float_linear";
|
| +#endif
|
|
|
| class CommandBufferSetup {
|
| public:
|
| @@ -87,17 +92,33 @@ class CommandBufferSetup {
|
| sync_point_order_data_(SyncPointOrderData::Create()),
|
| mailbox_manager_(new gles2::MailboxManagerImpl),
|
| share_group_(new gl::GLShareGroup),
|
| - surface_(new gl::GLSurfaceStub),
|
| - context_(new gl::GLContextStub(share_group_.get())),
|
| command_buffer_id_(CommandBufferId::FromUnsafeValue(1)) {
|
| logging::SetMinLogLevel(logging::LOG_FATAL);
|
| base::CommandLine::Init(0, NULL);
|
|
|
| +#if defined(GPU_FUZZER_USE_ANGLE)
|
| + auto* command_line = base::CommandLine::ForCurrentProcess();
|
| + command_line->AppendSwitchASCII(switches::kUseGL,
|
| + gl::kGLImplementationANGLEName);
|
| + command_line->AppendSwitchASCII(switches::kUseANGLE,
|
| + gl::kANGLEImplementationNullName);
|
| + gl::init::InitializeGLOneOffImplementation(gl::kGLImplementationEGLGLES2,
|
| + false, false, false);
|
| + surface_ = new gl::PbufferGLSurfaceEGL(gfx::Size());
|
| + surface_->Initialize();
|
| +
|
| + context_ = new gl::GLContextEGL(share_group_.get());
|
| + context_->Initialize(surface_.get(), gl::GLContextAttribs());
|
| +#else
|
| + surface_ = new gl::GLSurfaceStub;
|
| + context_ = new gl::GLContextStub(share_group_.get());
|
| gl::GLSurfaceTestSupport::InitializeOneOffWithMockBindings();
|
|
|
| - api_.set_version("OpenGL ES 3.1");
|
| - api_.set_extensions(kExtensions);
|
| - gl::SetStubGLApi(&api_);
|
| + api_ = base::MakeUnique<gl::GLStubApi>();
|
| + api_->set_version("OpenGL ES 3.1");
|
| + api_->set_extensions(kExtensions);
|
| + gl::SetStubGLApi(api_.get());
|
| +#endif
|
|
|
| sync_point_client_ = sync_point_manager_->CreateSyncPointClient(
|
| sync_point_order_data_, CommandBufferNamespace::IN_PROCESS,
|
| @@ -258,7 +279,6 @@ class CommandBufferSetup {
|
|
|
| base::AtExitManager atexit_manager_;
|
|
|
| - gl::GLStubApi api_;
|
| GpuPreferences gpu_preferences_;
|
|
|
| std::unique_ptr<SyncPointManager> sync_point_manager_;
|
| @@ -266,9 +286,13 @@ class CommandBufferSetup {
|
| std::unique_ptr<SyncPointClient> sync_point_client_;
|
| scoped_refptr<gles2::MailboxManager> mailbox_manager_;
|
| scoped_refptr<gl::GLShareGroup> share_group_;
|
| + const gpu::CommandBufferId command_buffer_id_;
|
| +
|
| scoped_refptr<gl::GLSurface> surface_;
|
| scoped_refptr<gl::GLContext> context_;
|
| - const gpu::CommandBufferId command_buffer_id_;
|
| +#if !defined(GPU_FUZZER_USE_ANGLE)
|
| + std::unique_ptr<gl::GLStubApi> api_;
|
| +#endif
|
|
|
| scoped_refptr<gles2::ShaderTranslatorCache> translator_cache_;
|
| scoped_refptr<gles2::FramebufferCompletenessCache> completeness_cache_;
|
| @@ -285,16 +309,14 @@ class CommandBufferSetup {
|
| int32_t buffer_id_ = 0;
|
| };
|
|
|
| +// Intentionally leaked because asan tries to exit cleanly after a crash, but
|
| +// the decoder is usually in a bad state at that point.
|
| +CommandBufferSetup* g_setup = new CommandBufferSetup();
|
| +
|
| } // anonymous namespace
|
| } // namespace gpu
|
|
|
| -
|
| -static gpu::CommandBufferSetup& GetSetup() {
|
| - static gpu::CommandBufferSetup setup;
|
| - return setup;
|
| -}
|
| -
|
| extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
| - GetSetup().RunCommandBuffer(data, size);
|
| + gpu::g_setup->RunCommandBuffer(data, size);
|
| return 0;
|
| }
|
|
|