OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 #include <stddef.h> | 4 #include <stddef.h> |
5 #include <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 "GL_OES_texture_float " | 81 "GL_OES_texture_float " |
82 "GL_OES_texture_float_linear " | 82 "GL_OES_texture_float_linear " |
83 "GL_OES_texture_half_float " | 83 "GL_OES_texture_half_float " |
84 "GL_OES_texture_half_float_linear"; | 84 "GL_OES_texture_half_float_linear"; |
85 #endif | 85 #endif |
86 | 86 |
87 class CommandBufferSetup { | 87 class CommandBufferSetup { |
88 public: | 88 public: |
89 CommandBufferSetup() | 89 CommandBufferSetup() |
90 : atexit_manager_(), | 90 : atexit_manager_(), |
91 sync_point_manager_(new SyncPointManager(false)), | 91 sync_point_manager_(new SyncPointManager()), |
92 sync_point_order_data_(SyncPointOrderData::Create()), | 92 sync_point_order_data_(SyncPointOrderData::Create()), |
93 mailbox_manager_(new gles2::MailboxManagerImpl), | 93 mailbox_manager_(new gles2::MailboxManagerImpl), |
94 share_group_(new gl::GLShareGroup), | 94 share_group_(new gl::GLShareGroup), |
95 command_buffer_id_(CommandBufferId::FromUnsafeValue(1)) { | 95 command_buffer_id_(CommandBufferId::FromUnsafeValue(1)) { |
96 logging::SetMinLogLevel(logging::LOG_FATAL); | 96 logging::SetMinLogLevel(logging::LOG_FATAL); |
97 base::CommandLine::Init(0, NULL); | 97 base::CommandLine::Init(0, NULL); |
98 | 98 |
99 #if defined(GPU_FUZZER_USE_ANGLE) | 99 #if defined(GPU_FUZZER_USE_ANGLE) |
100 auto* command_line = base::CommandLine::ForCurrentProcess(); | 100 auto* command_line = base::CommandLine::ForCurrentProcess(); |
101 command_line->AppendSwitchASCII(switches::kUseGL, | 101 command_line->AppendSwitchASCII(switches::kUseGL, |
(...skipping 11 matching lines...) Expand all Loading... |
113 surface_ = new gl::GLSurfaceStub; | 113 surface_ = new gl::GLSurfaceStub; |
114 scoped_refptr<gl::GLContextStub> context_stub = | 114 scoped_refptr<gl::GLContextStub> context_stub = |
115 new gl::GLContextStub(share_group_.get()); | 115 new gl::GLContextStub(share_group_.get()); |
116 context_stub->SetGLVersionString("OpenGL ES 3.1"); | 116 context_stub->SetGLVersionString("OpenGL ES 3.1"); |
117 context_stub->SetExtensionsString(kExtensions); | 117 context_stub->SetExtensionsString(kExtensions); |
118 context_stub->SetUseStubApi(true); | 118 context_stub->SetUseStubApi(true); |
119 context_ = context_stub; | 119 context_ = context_stub; |
120 gl::GLSurfaceTestSupport::InitializeOneOffWithMockBindings(); | 120 gl::GLSurfaceTestSupport::InitializeOneOffWithMockBindings(); |
121 #endif | 121 #endif |
122 | 122 |
123 sync_point_client_ = sync_point_manager_->CreateSyncPointClient( | 123 sync_point_client_ = base::MakeUnique<SyncPointClient>( |
124 sync_point_order_data_, CommandBufferNamespace::IN_PROCESS, | 124 sync_point_manager_.get(), sync_point_order_data_, |
125 command_buffer_id_); | 125 CommandBufferNamespace::IN_PROCESS, command_buffer_id_); |
126 | 126 |
127 translator_cache_ = new gles2::ShaderTranslatorCache(gpu_preferences_); | 127 translator_cache_ = new gles2::ShaderTranslatorCache(gpu_preferences_); |
128 completeness_cache_ = new gles2::FramebufferCompletenessCache; | 128 completeness_cache_ = new gles2::FramebufferCompletenessCache; |
129 } | 129 } |
130 | 130 |
131 void InitDecoder() { | 131 void InitDecoder() { |
132 context_->MakeCurrent(surface_.get()); | 132 context_->MakeCurrent(surface_.get()); |
133 scoped_refptr<gles2::FeatureInfo> feature_info = | 133 scoped_refptr<gles2::FeatureInfo> feature_info = |
134 new gles2::FeatureInfo(); | 134 new gles2::FeatureInfo(); |
135 scoped_refptr<gles2::ContextGroup> context_group = new gles2::ContextGroup( | 135 scoped_refptr<gles2::ContextGroup> context_group = new gles2::ContextGroup( |
136 gpu_preferences_, mailbox_manager_.get(), nullptr, translator_cache_, | 136 gpu_preferences_, mailbox_manager_.get(), nullptr, translator_cache_, |
137 completeness_cache_, feature_info, true /* bind_generates_resource */, | 137 completeness_cache_, feature_info, true /* bind_generates_resource */, |
138 nullptr /* image_factory */, nullptr /* progress_reporter */, | 138 nullptr /* image_factory */, nullptr /* progress_reporter */, |
139 GpuFeatureInfo()); | 139 GpuFeatureInfo()); |
140 command_buffer_.reset( | 140 command_buffer_.reset( |
141 new CommandBufferService(context_group->transfer_buffer_manager())); | 141 new CommandBufferService(context_group->transfer_buffer_manager())); |
142 command_buffer_->SetPutOffsetChangeCallback( | 142 command_buffer_->SetPutOffsetChangeCallback( |
143 base::Bind(&CommandBufferSetup::PumpCommands, base::Unretained(this))); | 143 base::Bind(&CommandBufferSetup::PumpCommands, base::Unretained(this))); |
144 command_buffer_->SetGetBufferChangeCallback(base::Bind( | 144 command_buffer_->SetGetBufferChangeCallback(base::Bind( |
145 &CommandBufferSetup::GetBufferChanged, base::Unretained(this))); | 145 &CommandBufferSetup::GetBufferChanged, base::Unretained(this))); |
146 InitializeInitialCommandBuffer(); | 146 InitializeInitialCommandBuffer(); |
147 | 147 |
148 decoder_.reset(gles2::GLES2Decoder::Create(context_group.get())); | 148 decoder_.reset(gles2::GLES2Decoder::Create(context_group.get())); |
149 executor_.reset(new CommandExecutor(command_buffer_.get(), decoder_.get(), | 149 executor_.reset(new CommandExecutor(command_buffer_.get(), decoder_.get(), |
150 decoder_.get())); | 150 decoder_.get())); |
151 decoder_->set_engine(executor_.get()); | 151 decoder_->set_engine(executor_.get()); |
152 decoder_->SetFenceSyncReleaseCallback(base::Bind( | 152 decoder_->SetFenceSyncReleaseCallback(base::Bind( |
153 &CommandBufferSetup::OnFenceSyncRelease, base::Unretained(this))); | 153 &CommandBufferSetup::OnFenceSyncRelease, base::Unretained(this))); |
154 decoder_->SetWaitFenceSyncCallback(base::Bind( | 154 decoder_->SetWaitSyncTokenCallback(base::Bind( |
155 &CommandBufferSetup::OnWaitFenceSync, base::Unretained(this))); | 155 &CommandBufferSetup::OnWaitSyncToken, base::Unretained(this))); |
156 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); | 156 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); |
157 | 157 |
158 gles2::ContextCreationAttribHelper attrib_helper; | 158 gles2::ContextCreationAttribHelper attrib_helper; |
159 attrib_helper.offscreen_framebuffer_size = gfx::Size(16, 16); | 159 attrib_helper.offscreen_framebuffer_size = gfx::Size(16, 16); |
160 attrib_helper.red_size = 8; | 160 attrib_helper.red_size = 8; |
161 attrib_helper.green_size = 8; | 161 attrib_helper.green_size = 8; |
162 attrib_helper.blue_size = 8; | 162 attrib_helper.blue_size = 8; |
163 attrib_helper.alpha_size = 8; | 163 attrib_helper.alpha_size = 8; |
164 attrib_helper.depth_size = 0; | 164 attrib_helper.depth_size = 0; |
165 attrib_helper.stencil_size = 0; | 165 attrib_helper.stencil_size = 0; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 234 |
235 bool GetBufferChanged(int32_t transfer_buffer_id) { | 235 bool GetBufferChanged(int32_t transfer_buffer_id) { |
236 return executor_->SetGetBuffer(transfer_buffer_id); | 236 return executor_->SetGetBuffer(transfer_buffer_id); |
237 } | 237 } |
238 | 238 |
239 void OnFenceSyncRelease(uint64_t release) { | 239 void OnFenceSyncRelease(uint64_t release) { |
240 CHECK(sync_point_client_); | 240 CHECK(sync_point_client_); |
241 sync_point_client_->ReleaseFenceSync(release); | 241 sync_point_client_->ReleaseFenceSync(release); |
242 } | 242 } |
243 | 243 |
244 bool OnWaitFenceSync(CommandBufferNamespace namespace_id, | 244 bool OnWaitSyncToken(const SyncToken& sync_token) { |
245 CommandBufferId command_buffer_id, | 245 CHECK(sync_point_manager_); |
246 uint64_t release) { | 246 if (sync_point_manager_->IsSyncTokenReleased(sync_token)) |
247 CHECK(sync_point_client_); | 247 return false; |
248 scoped_refptr<gpu::SyncPointClientState> release_state = | |
249 sync_point_manager_->GetSyncPointClientState(namespace_id, | |
250 command_buffer_id); | |
251 if (!release_state) | |
252 return true; | |
253 | |
254 if (release_state->IsFenceSyncReleased(release)) | |
255 return true; | |
256 | |
257 executor_->SetScheduled(false); | 248 executor_->SetScheduled(false); |
258 return false; | 249 return true; |
259 } | 250 } |
260 | 251 |
261 void CreateTransferBuffer(size_t size, int32_t id) { | 252 void CreateTransferBuffer(size_t size, int32_t id) { |
262 scoped_refptr<Buffer> buffer = | 253 scoped_refptr<Buffer> buffer = |
263 command_buffer_->CreateTransferBufferWithId(size, id); | 254 command_buffer_->CreateTransferBufferWithId(size, id); |
264 memset(buffer->memory(), 0, size); | 255 memset(buffer->memory(), 0, size); |
265 } | 256 } |
266 | 257 |
267 void InitializeInitialCommandBuffer() { | 258 void InitializeInitialCommandBuffer() { |
268 buffer_id_ = 1; | 259 buffer_id_ = 1; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 // registered, causing crashes. | 305 // registered, causing crashes. |
315 CommandBufferSetup* g_setup = new CommandBufferSetup(); | 306 CommandBufferSetup* g_setup = new CommandBufferSetup(); |
316 | 307 |
317 } // anonymous namespace | 308 } // anonymous namespace |
318 } // namespace gpu | 309 } // namespace gpu |
319 | 310 |
320 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 311 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
321 gpu::g_setup->RunCommandBuffer(data, size); | 312 gpu::g_setup->RunCommandBuffer(data, size); |
322 return 0; | 313 return 0; |
323 } | 314 } |
OLD | NEW |