Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Side by Side Diff: gpu/command_buffer/tests/fuzzer_main.cc

Issue 2752393002: gpu: Add SequenceId for identifying sync point sequences. (Closed)
Patch Set: piman's review 3 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
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()), 91 sync_point_manager_(new SyncPointManager()),
92 sync_point_order_data_(SyncPointOrderData::Create()), 92 sync_point_order_data_(sync_point_manager_->CreateSyncPointOrderData()),
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,
102 gl::kGLImplementationANGLEName); 102 gl::kGLImplementationANGLEName);
(...skipping 10 matching lines...) Expand all
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_ = base::MakeUnique<SyncPointClient>( 123 sync_point_client_state_ = sync_point_manager_->CreateSyncPointClientState(
124 sync_point_manager_.get(), sync_point_order_data_, 124 CommandBufferNamespace::IN_PROCESS, command_buffer_id_,
125 CommandBufferNamespace::IN_PROCESS, command_buffer_id_); 125 sync_point_order_data_->sequence_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(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 } 181 }
182 182
183 void ResetDecoder() { 183 void ResetDecoder() {
184 decoder_->Destroy(true); 184 decoder_->Destroy(true);
185 decoder_.reset(); 185 decoder_.reset();
186 command_buffer_.reset(); 186 command_buffer_.reset();
187 } 187 }
188 188
189 ~CommandBufferSetup() { 189 ~CommandBufferSetup() {
190 sync_point_client_ = nullptr;
191 if (sync_point_order_data_) { 190 if (sync_point_order_data_) {
192 sync_point_order_data_->Destroy(); 191 sync_point_order_data_->Destroy();
193 sync_point_order_data_ = nullptr; 192 sync_point_order_data_ = nullptr;
194 } 193 }
194 if (sync_point_client_state_) {
195 sync_point_client_state_->Destroy();
196 sync_point_client_state_ = nullptr;
197 }
195 } 198 }
196 199
197 void RunCommandBuffer(const uint8_t* data, size_t size) { 200 void RunCommandBuffer(const uint8_t* data, size_t size) {
198 // The commands are flushed at a uint32_t granularity. If the data is not 201 // The commands are flushed at a uint32_t granularity. If the data is not
199 // a full command, we zero-pad it. 202 // a full command, we zero-pad it.
200 size_t padded_size = (size + 3) & ~3; 203 size_t padded_size = (size + 3) & ~3;
201 // crbug.com/638836 The -max_len argument is sometimes not respected, so the 204 // crbug.com/638836 The -max_len argument is sometimes not respected, so the
202 // fuzzer may give us too much data. Bail ASAP in that case. 205 // fuzzer may give us too much data. Bail ASAP in that case.
203 if (padded_size > kCommandBufferSize) 206 if (padded_size > kCommandBufferSize)
204 return; 207 return;
(...skipping 11 matching lines...) Expand all
216 } 219 }
217 220
218 private: 221 private:
219 void PumpCommands() { 222 void PumpCommands() {
220 if (!decoder_->MakeCurrent()) { 223 if (!decoder_->MakeCurrent()) {
221 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); 224 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason());
222 command_buffer_->SetParseError(::gpu::error::kLostContext); 225 command_buffer_->SetParseError(::gpu::error::kLostContext);
223 return; 226 return;
224 } 227 }
225 228
226 uint32_t order_num = sync_point_order_data_->GenerateUnprocessedOrderNumber( 229 uint32_t order_num =
227 sync_point_manager_.get()); 230 sync_point_order_data_->GenerateUnprocessedOrderNumber();
228 sync_point_order_data_->BeginProcessingOrderNumber(order_num); 231 sync_point_order_data_->BeginProcessingOrderNumber(order_num);
229 232
230 executor_->PutChanged(); 233 executor_->PutChanged();
231 234
232 sync_point_order_data_->FinishProcessingOrderNumber(order_num); 235 sync_point_order_data_->FinishProcessingOrderNumber(order_num);
233 } 236 }
234 237
235 bool GetBufferChanged(int32_t transfer_buffer_id) { 238 bool GetBufferChanged(int32_t transfer_buffer_id) {
236 return executor_->SetGetBuffer(transfer_buffer_id); 239 return executor_->SetGetBuffer(transfer_buffer_id);
237 } 240 }
238 241
239 void OnFenceSyncRelease(uint64_t release) { 242 void OnFenceSyncRelease(uint64_t release) {
240 CHECK(sync_point_client_); 243 CHECK(sync_point_client_state_);
241 sync_point_client_->ReleaseFenceSync(release); 244 sync_point_client_state_->ReleaseFenceSync(release);
242 } 245 }
243 246
244 bool OnWaitSyncToken(const SyncToken& sync_token) { 247 bool OnWaitSyncToken(const SyncToken& sync_token) {
245 CHECK(sync_point_manager_); 248 CHECK(sync_point_manager_);
246 if (sync_point_manager_->IsSyncTokenReleased(sync_token)) 249 if (sync_point_manager_->IsSyncTokenReleased(sync_token))
247 return false; 250 return false;
248 executor_->SetScheduled(false); 251 executor_->SetScheduled(false);
249 return true; 252 return true;
250 } 253 }
251 254
(...skipping 16 matching lines...) Expand all
268 CreateTransferBuffer(kTransferBufferSize, 4); 271 CreateTransferBuffer(kTransferBufferSize, 4);
269 CreateTransferBuffer(kTinyTransferBufferSize, 5); 272 CreateTransferBuffer(kTinyTransferBufferSize, 5);
270 } 273 }
271 274
272 base::AtExitManager atexit_manager_; 275 base::AtExitManager atexit_manager_;
273 276
274 GpuPreferences gpu_preferences_; 277 GpuPreferences gpu_preferences_;
275 278
276 std::unique_ptr<SyncPointManager> sync_point_manager_; 279 std::unique_ptr<SyncPointManager> sync_point_manager_;
277 scoped_refptr<SyncPointOrderData> sync_point_order_data_; 280 scoped_refptr<SyncPointOrderData> sync_point_order_data_;
278 std::unique_ptr<SyncPointClient> sync_point_client_; 281 scoped_refptr<SyncPointClientState> sync_point_client_state_;
279 scoped_refptr<gles2::MailboxManager> mailbox_manager_; 282 scoped_refptr<gles2::MailboxManager> mailbox_manager_;
280 scoped_refptr<gl::GLShareGroup> share_group_; 283 scoped_refptr<gl::GLShareGroup> share_group_;
281 const gpu::CommandBufferId command_buffer_id_; 284 const gpu::CommandBufferId command_buffer_id_;
282 285
283 scoped_refptr<gl::GLSurface> surface_; 286 scoped_refptr<gl::GLSurface> surface_;
284 scoped_refptr<gl::GLContext> context_; 287 scoped_refptr<gl::GLContext> context_;
285 288
286 scoped_refptr<gles2::ShaderTranslatorCache> translator_cache_; 289 scoped_refptr<gles2::ShaderTranslatorCache> translator_cache_;
287 scoped_refptr<gles2::FramebufferCompletenessCache> completeness_cache_; 290 scoped_refptr<gles2::FramebufferCompletenessCache> completeness_cache_;
288 291
(...skipping 16 matching lines...) Expand all
305 // registered, causing crashes. 308 // registered, causing crashes.
306 CommandBufferSetup* g_setup = new CommandBufferSetup(); 309 CommandBufferSetup* g_setup = new CommandBufferSetup();
307 310
308 } // anonymous namespace 311 } // anonymous namespace
309 } // namespace gpu 312 } // namespace gpu
310 313
311 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 314 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
312 gpu::g_setup->RunCommandBuffer(data, size); 315 gpu::g_setup->RunCommandBuffer(data, size);
313 return 0; 316 return 0;
314 } 317 }
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/sync_point_manager_unittest.cc ('k') | gpu/command_buffer/tests/gl_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698