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

Side by Side Diff: content/common/gpu/client/context_provider_command_buffer.cc

Issue 2550583002: gpu: Thread-safe command buffer state lookup. (Closed)
Patch Set: state_lock_ -> last_state_lock_ Created 4 years 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 4
5 #include "content/common/gpu/client/context_provider_command_buffer.h" 5 #include "content/common/gpu/client/context_provider_command_buffer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 attributes_.lose_context_when_out_of_memory, support_client_side_arrays, 285 attributes_.lose_context_when_out_of_memory, support_client_side_arrays,
286 command_buffer_.get())); 286 command_buffer_.get()));
287 if (!gles2_impl_->Initialize(memory_limits_.start_transfer_buffer_size, 287 if (!gles2_impl_->Initialize(memory_limits_.start_transfer_buffer_size,
288 memory_limits_.min_transfer_buffer_size, 288 memory_limits_.min_transfer_buffer_size,
289 memory_limits_.max_transfer_buffer_size, 289 memory_limits_.max_transfer_buffer_size,
290 memory_limits_.mapped_memory_reclaim_limit)) { 290 memory_limits_.mapped_memory_reclaim_limit)) {
291 DLOG(ERROR) << "Failed to initialize GLES2Implementation."; 291 DLOG(ERROR) << "Failed to initialize GLES2Implementation.";
292 return false; 292 return false;
293 } 293 }
294 294
295 if (command_buffer_->GetLastError() != gpu::error::kNoError) { 295 if (command_buffer_->GetLastState().error != gpu::error::kNoError) {
296 DLOG(ERROR) << "Context dead on arrival. Last error: " 296 DLOG(ERROR) << "Context dead on arrival. Last error: "
297 << command_buffer_->GetLastError(); 297 << command_buffer_->GetLastState().error;
298 return false; 298 return false;
299 } 299 }
300 300
301 // If any context in the share group has been lost, then abort and don't 301 // If any context in the share group has been lost, then abort and don't
302 // continue since we need to go back to the caller of the constructor to 302 // continue since we need to go back to the caller of the constructor to
303 // find the correct share group. 303 // find the correct share group.
304 // This may happen in between the share group being chosen at the 304 // This may happen in between the share group being chosen at the
305 // constructor, and getting to run this BindToCurrentThread method which 305 // constructor, and getting to run this BindToCurrentThread method which
306 // can be on some other thread. 306 // can be on some other thread.
307 // We intentionally call this *after* creating the command buffer via the 307 // We intentionally call this *after* creating the command buffer via the
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 const base::trace_event::MemoryDumpArgs& args, 447 const base::trace_event::MemoryDumpArgs& args,
448 base::trace_event::ProcessMemoryDump* pmd) { 448 base::trace_event::ProcessMemoryDump* pmd) {
449 DCHECK(bind_succeeded_); 449 DCHECK(bind_succeeded_);
450 if (!gr_context_) 450 if (!gr_context_)
451 return false; 451 return false;
452 452
453 base::Optional<base::AutoLock> hold; 453 base::Optional<base::AutoLock> hold;
454 if (support_locking_) 454 if (support_locking_)
455 hold.emplace(context_lock_); 455 hold.emplace(context_lock_);
456 456
457 gles2_impl_->OnMemoryDump(args, pmd);
ericrk 2016/12/08 01:59:39 Seems like this will fix crbug.com/638862, can you
458
457 context_thread_checker_.DetachFromThread(); 459 context_thread_checker_.DetachFromThread();
458 SkiaGpuTraceMemoryDump trace_memory_dump( 460 SkiaGpuTraceMemoryDump trace_memory_dump(
459 pmd, gles2_impl_->ShareGroupTracingGUID()); 461 pmd, gles2_impl_->ShareGroupTracingGUID());
460 gr_context_->get()->dumpMemoryStatistics(&trace_memory_dump); 462 gr_context_->get()->dumpMemoryStatistics(&trace_memory_dump);
461 context_thread_checker_.DetachFromThread(); 463 context_thread_checker_.DetachFromThread();
462 return true; 464 return true;
463 } 465 }
464 466
465 } // namespace content 467 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698