Commit 8057b678 authored by Antoine Labour's avatar Antoine Labour Committed by Commit Bot

Implement SwiftShader fuzzer

Simply reuses the existing command buffer fuzzer, but with a SwiftShader backend.

Bug: swiftshader:51
Cq-Include-Trybots: 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: I40f595c830f82c791033383d68f4b2802a35b8b2
Reviewed-on: https://chromium-review.googlesource.com/514246Reviewed-by: default avatarGeoff Lang <geofflang@chromium.org>
Commit-Queue: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#478790}
parent 2d50b3d7
......@@ -471,4 +471,24 @@ if (is_linux) {
libfuzzer_options = [ "max_len=16384" ]
}
fuzzer_test("gpu_swiftshader_fuzzer") {
sources = [
"command_buffer/tests/fuzzer_main.cc",
]
defines = [ "GPU_FUZZER_USE_SWIFTSHADER" ]
deps = [
":gpu",
"//base",
"//base/third_party/dynamic_annotations",
"//gpu/command_buffer/common:gles2_utils",
"//ui/gfx/geometry",
"//ui/gl",
"//ui/gl:test_support",
]
libfuzzer_options = [ "max_len=16384" ]
}
}
......@@ -49,7 +49,11 @@ const size_t kTransferBufferSize = 16384;
const size_t kSmallTransferBufferSize = 16;
const size_t kTinyTransferBufferSize = 3;
#if !defined(GPU_FUZZER_USE_ANGLE)
#if !defined(GPU_FUZZER_USE_ANGLE) && !defined(GPU_FUZZER_USE_SWIFTSHADER)
#define GPU_FUZZER_USE_STUB
#endif
#if defined(GPU_FUZZER_USE_STUB)
static const char kExtensions[] =
"GL_AMD_compressed_ATC_texture "
"GL_ANGLE_texture_compression_dxt3 "
......@@ -109,19 +113,26 @@ class CommandBufferSetup {
gl::kGLImplementationANGLEName);
command_line->AppendSwitchASCII(switches::kUseANGLE,
gl::kANGLEImplementationNullName);
gl::init::InitializeGLOneOffImplementation(gl::kGLImplementationEGLGLES2,
false, false, false);
CHECK(gl::init::InitializeGLOneOffImplementation(
gl::kGLImplementationEGLGLES2, false, false, false));
#elif defined(GPU_FUZZER_USE_SWIFTSHADER)
command_line->AppendSwitchASCII(switches::kUseGL,
gl::kGLImplementationSwiftShaderName);
CHECK(gl::init::InitializeGLOneOffImplementation(
gl::kGLImplementationSwiftShaderGL, false, false, false));
#endif
#if !defined(GPU_FUZZER_USE_STUB)
surface_ = new gl::PbufferGLSurfaceEGL(gfx::Size());
surface_->Initialize();
if (!recreate_context_) {
InitContext();
}
#else
#else // defined(GPU_FUZZER_USE_STUB)
surface_ = new gl::GLSurfaceStub;
InitContext();
gl::GLSurfaceTestSupport::InitializeOneOffWithMockBindings();
#endif
#endif // defined(GPU_FUZZER_USE_STUB)
translator_cache_ = new gles2::ShaderTranslatorCache(gpu_preferences_);
completeness_cache_ = new gles2::FramebufferCompletenessCache;
......@@ -161,7 +172,11 @@ class CommandBufferSetup {
attrib_helper.alpha_size = 8;
attrib_helper.depth_size = 0;
attrib_helper.stencil_size = 0;
#if defined(GPU_FUZZER_USE_SWIFTSHADER)
attrib_helper.context_type = gles2::CONTEXT_TYPE_OPENGLES2;
#else
attrib_helper.context_type = gles2::CONTEXT_TYPE_OPENGLES3;
#endif
bool result =
decoder_->Initialize(surface_.get(), context_.get(), true,
......@@ -232,7 +247,7 @@ class CommandBufferSetup {
}
void InitContext() {
#if defined(GPU_FUZZER_USE_ANGLE)
#if !defined(GPU_FUZZER_USE_STUB)
context_ = new gl::GLContextEGL(share_group_.get());
context_->Initialize(surface_.get(), gl::GLContextAttribs());
#else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment