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

Side by Side Diff: gpu/command_buffer/service/context_group.cc

Issue 2378583003: Ping watchdog thread during GpuChannel destruction (Closed)
Patch Set: remove throttling Created 4 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "gpu/command_buffer/service/context_group.h" 5 #include "gpu/command_buffer/service/context_group.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <string> 11 #include <string>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "gpu/command_buffer/service/buffer_manager.h" 14 #include "gpu/command_buffer/service/buffer_manager.h"
15 #include "gpu/command_buffer/service/framebuffer_manager.h" 15 #include "gpu/command_buffer/service/framebuffer_manager.h"
16 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" 16 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h"
17 #include "gpu/command_buffer/service/gpu_preferences.h" 17 #include "gpu/command_buffer/service/gpu_preferences.h"
18 #include "gpu/command_buffer/service/mailbox_manager_impl.h" 18 #include "gpu/command_buffer/service/mailbox_manager_impl.h"
19 #include "gpu/command_buffer/service/path_manager.h" 19 #include "gpu/command_buffer/service/path_manager.h"
20 #include "gpu/command_buffer/service/program_manager.h" 20 #include "gpu/command_buffer/service/program_manager.h"
21 #include "gpu/command_buffer/service/progress_reporter.h"
21 #include "gpu/command_buffer/service/renderbuffer_manager.h" 22 #include "gpu/command_buffer/service/renderbuffer_manager.h"
22 #include "gpu/command_buffer/service/sampler_manager.h" 23 #include "gpu/command_buffer/service/sampler_manager.h"
23 #include "gpu/command_buffer/service/shader_manager.h" 24 #include "gpu/command_buffer/service/shader_manager.h"
24 #include "gpu/command_buffer/service/texture_manager.h" 25 #include "gpu/command_buffer/service/texture_manager.h"
25 #include "gpu/command_buffer/service/transfer_buffer_manager.h" 26 #include "gpu/command_buffer/service/transfer_buffer_manager.h"
26 #include "ui/gl/gl_bindings.h" 27 #include "ui/gl/gl_bindings.h"
27 #include "ui/gl/gl_version_info.h" 28 #include "ui/gl/gl_version_info.h"
28 29
29 namespace gpu { 30 namespace gpu {
30 namespace gles2 { 31 namespace gles2 {
(...skipping 27 matching lines...) Expand all
58 59
59 ContextGroup::ContextGroup( 60 ContextGroup::ContextGroup(
60 const GpuPreferences& gpu_preferences, 61 const GpuPreferences& gpu_preferences,
61 const scoped_refptr<MailboxManager>& mailbox_manager, 62 const scoped_refptr<MailboxManager>& mailbox_manager,
62 const scoped_refptr<MemoryTracker>& memory_tracker, 63 const scoped_refptr<MemoryTracker>& memory_tracker,
63 const scoped_refptr<ShaderTranslatorCache>& shader_translator_cache, 64 const scoped_refptr<ShaderTranslatorCache>& shader_translator_cache,
64 const scoped_refptr<FramebufferCompletenessCache>& 65 const scoped_refptr<FramebufferCompletenessCache>&
65 framebuffer_completeness_cache, 66 framebuffer_completeness_cache,
66 const scoped_refptr<FeatureInfo>& feature_info, 67 const scoped_refptr<FeatureInfo>& feature_info,
67 bool bind_generates_resource, 68 bool bind_generates_resource,
68 gpu::ImageFactory* image_factory) 69 gpu::ImageFactory* image_factory,
70 std::unique_ptr<ProgressReporter> progress_reporter)
69 : gpu_preferences_(gpu_preferences), 71 : gpu_preferences_(gpu_preferences),
70 mailbox_manager_(mailbox_manager), 72 mailbox_manager_(mailbox_manager),
71 memory_tracker_(memory_tracker), 73 memory_tracker_(memory_tracker),
72 shader_translator_cache_(shader_translator_cache), 74 shader_translator_cache_(shader_translator_cache),
73 #if defined(OS_MACOSX) 75 #if defined(OS_MACOSX)
74 // Framebuffer completeness is not cacheable on OS X because of dynamic 76 // Framebuffer completeness is not cacheable on OS X because of dynamic
75 // graphics switching. 77 // graphics switching.
76 // http://crbug.com/180876 78 // http://crbug.com/180876
77 // TODO(tobiasjs): determine whether GPU switching is possible 79 // TODO(tobiasjs): determine whether GPU switching is possible
78 // programmatically, rather than just hardcoding this behaviour 80 // programmatically, rather than just hardcoding this behaviour
(...skipping 17 matching lines...) Expand all
96 max_vertex_output_components_(0u), 98 max_vertex_output_components_(0u),
97 max_fragment_input_components_(0u), 99 max_fragment_input_components_(0u),
98 min_program_texel_offset_(0), 100 min_program_texel_offset_(0),
99 max_program_texel_offset_(0), 101 max_program_texel_offset_(0),
100 max_transform_feedback_separate_attribs_(0u), 102 max_transform_feedback_separate_attribs_(0u),
101 max_uniform_buffer_bindings_(0u), 103 max_uniform_buffer_bindings_(0u),
102 uniform_buffer_offset_alignment_(1u), 104 uniform_buffer_offset_alignment_(1u),
103 program_cache_(NULL), 105 program_cache_(NULL),
104 feature_info_(feature_info), 106 feature_info_(feature_info),
105 image_factory_(image_factory), 107 image_factory_(image_factory),
108 progress_reporter_(std::move(progress_reporter)),
106 passthrough_resources_(new PassthroughResources) { 109 passthrough_resources_(new PassthroughResources) {
107 { 110 {
108 DCHECK(feature_info_); 111 DCHECK(feature_info_);
109 if (!mailbox_manager_.get()) 112 if (!mailbox_manager_.get())
110 mailbox_manager_ = new MailboxManagerImpl; 113 mailbox_manager_ = new MailboxManagerImpl;
111 transfer_buffer_manager_ = new TransferBufferManager(memory_tracker_.get()); 114 transfer_buffer_manager_ = new TransferBufferManager(memory_tracker_.get());
112 } 115 }
113 } 116 }
114 117
115 bool ContextGroup::Initialize(GLES2Decoder* decoder, 118 bool ContextGroup::Initialize(GLES2Decoder* decoder,
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 }; 477 };
475 478
476 } // namespace anonymous 479 } // namespace anonymous
477 480
478 bool ContextGroup::HaveContexts() { 481 bool ContextGroup::HaveContexts() {
479 decoders_.erase(std::remove_if(decoders_.begin(), decoders_.end(), IsNull), 482 decoders_.erase(std::remove_if(decoders_.begin(), decoders_.end(), IsNull),
480 decoders_.end()); 483 decoders_.end());
481 return !decoders_.empty(); 484 return !decoders_.empty();
482 } 485 }
483 486
487 void ContextGroup::ReportProgress() {
488 if (progress_reporter_)
danakj 2016/10/05 01:53:48 When is it null? This looks like "null in tests" w
ericrk 2016/10/05 18:07:31 Yeah, makes sense. It's actually null in one other
489 progress_reporter_->ReportProgress();
490 }
491
484 void ContextGroup::Destroy(GLES2Decoder* decoder, bool have_context) { 492 void ContextGroup::Destroy(GLES2Decoder* decoder, bool have_context) {
485 decoders_.erase(std::remove_if(decoders_.begin(), decoders_.end(), 493 decoders_.erase(std::remove_if(decoders_.begin(), decoders_.end(),
486 WeakPtrEquals<gles2::GLES2Decoder>(decoder)), 494 WeakPtrEquals<gles2::GLES2Decoder>(decoder)),
487 decoders_.end()); 495 decoders_.end());
488 // If we still have contexts do nothing. 496 // If we still have contexts do nothing.
489 if (HaveContexts()) { 497 if (HaveContexts()) {
490 return; 498 return;
491 } 499 }
492 500
493 if (buffer_manager_ != nullptr) { 501 if (buffer_manager_ != nullptr) {
494 if (!have_context) { 502 if (!have_context) {
495 buffer_manager_->MarkContextLost(); 503 buffer_manager_->MarkContextLost();
496 } 504 }
497 buffer_manager_->Destroy(); 505 buffer_manager_->Destroy();
498 buffer_manager_.reset(); 506 buffer_manager_.reset();
507 ReportProgress();
499 } 508 }
500 509
501 if (framebuffer_manager_ != NULL) { 510 if (framebuffer_manager_ != NULL) {
502 framebuffer_manager_->Destroy(have_context); 511 framebuffer_manager_->Destroy(have_context);
503 if (texture_manager_) 512 if (texture_manager_)
504 texture_manager_->set_framebuffer_manager(NULL); 513 texture_manager_->set_framebuffer_manager(NULL);
505 framebuffer_manager_.reset(); 514 framebuffer_manager_.reset();
515 ReportProgress();
506 } 516 }
507 517
508 if (renderbuffer_manager_ != NULL) { 518 if (renderbuffer_manager_ != NULL) {
509 renderbuffer_manager_->Destroy(have_context); 519 renderbuffer_manager_->Destroy(have_context);
510 renderbuffer_manager_.reset(); 520 renderbuffer_manager_.reset();
521 ReportProgress();
511 } 522 }
512 523
513 if (texture_manager_ != NULL) { 524 if (texture_manager_ != NULL) {
514 texture_manager_->Destroy(have_context); 525 texture_manager_->Destroy(have_context, progress_reporter_.get());
515 texture_manager_.reset(); 526 texture_manager_.reset();
527 ReportProgress();
516 } 528 }
517 529
518 if (path_manager_ != NULL) { 530 if (path_manager_ != NULL) {
519 path_manager_->Destroy(have_context); 531 path_manager_->Destroy(have_context);
520 path_manager_.reset(); 532 path_manager_.reset();
533 ReportProgress();
521 } 534 }
522 535
523 if (program_manager_ != NULL) { 536 if (program_manager_ != NULL) {
524 program_manager_->Destroy(have_context); 537 program_manager_->Destroy(have_context, progress_reporter_.get());
525 program_manager_.reset(); 538 program_manager_.reset();
539 ReportProgress();
526 } 540 }
527 541
528 if (shader_manager_ != NULL) { 542 if (shader_manager_ != NULL) {
529 shader_manager_->Destroy(have_context); 543 shader_manager_->Destroy(have_context, progress_reporter_.get());
530 shader_manager_.reset(); 544 shader_manager_.reset();
545 ReportProgress();
531 } 546 }
532 547
533 if (sampler_manager_ != NULL) { 548 if (sampler_manager_ != NULL) {
534 sampler_manager_->Destroy(have_context); 549 sampler_manager_->Destroy(have_context);
535 sampler_manager_.reset(); 550 sampler_manager_.reset();
551 ReportProgress();
536 } 552 }
537 553
538 memory_tracker_ = NULL; 554 memory_tracker_ = NULL;
539 555
540 passthrough_resources_->Destroy(have_context); 556 passthrough_resources_->Destroy(have_context);
541 passthrough_resources_.reset(); 557 passthrough_resources_.reset();
558 ReportProgress();
542 } 559 }
543 560
544 uint32_t ContextGroup::GetMemRepresented() const { 561 uint32_t ContextGroup::GetMemRepresented() const {
545 uint32_t total = 0; 562 uint32_t total = 0;
546 if (buffer_manager_.get()) 563 if (buffer_manager_.get())
547 total += buffer_manager_->mem_represented(); 564 total += buffer_manager_->mem_represented();
548 if (renderbuffer_manager_.get()) 565 if (renderbuffer_manager_.get())
549 total += renderbuffer_manager_->mem_represented(); 566 total += renderbuffer_manager_->mem_represented();
550 if (texture_manager_.get()) 567 if (texture_manager_.get())
551 total += texture_manager_->mem_represented(); 568 total += texture_manager_->mem_represented();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 GLuint client_id, GLuint* service_id) const { 624 GLuint client_id, GLuint* service_id) const {
608 Buffer* buffer = buffer_manager_->GetBuffer(client_id); 625 Buffer* buffer = buffer_manager_->GetBuffer(client_id);
609 if (!buffer) 626 if (!buffer)
610 return false; 627 return false;
611 *service_id = buffer->service_id(); 628 *service_id = buffer->service_id();
612 return true; 629 return true;
613 } 630 }
614 631
615 } // namespace gles2 632 } // namespace gles2
616 } // namespace gpu 633 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698