| OLD | NEW |
| 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 Loading... |
| 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 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 Loading... |
| 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), |
| 106 passthrough_resources_(new PassthroughResources) { | 108 passthrough_resources_(new PassthroughResources), |
| 109 progress_reporter_(progress_reporter) { |
| 107 { | 110 { |
| 108 DCHECK(feature_info_); | 111 DCHECK(feature_info_); |
| 112 DCHECK(progress_reporter_); |
| 109 if (!mailbox_manager_.get()) | 113 if (!mailbox_manager_.get()) |
| 110 mailbox_manager_ = new MailboxManagerImpl; | 114 mailbox_manager_ = new MailboxManagerImpl; |
| 111 transfer_buffer_manager_ = new TransferBufferManager(memory_tracker_.get()); | 115 transfer_buffer_manager_ = new TransferBufferManager(memory_tracker_.get()); |
| 112 } | 116 } |
| 113 } | 117 } |
| 114 | 118 |
| 115 bool ContextGroup::Initialize(GLES2Decoder* decoder, | 119 bool ContextGroup::Initialize(GLES2Decoder* decoder, |
| 116 ContextType context_type, | 120 ContextType context_type, |
| 117 const DisallowedFeatures& disallowed_features) { | 121 const DisallowedFeatures& disallowed_features) { |
| 118 if (HaveContexts()) { | 122 if (HaveContexts()) { |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 if (HaveContexts()) { | 493 if (HaveContexts()) { |
| 490 return; | 494 return; |
| 491 } | 495 } |
| 492 | 496 |
| 493 if (buffer_manager_ != nullptr) { | 497 if (buffer_manager_ != nullptr) { |
| 494 if (!have_context) { | 498 if (!have_context) { |
| 495 buffer_manager_->MarkContextLost(); | 499 buffer_manager_->MarkContextLost(); |
| 496 } | 500 } |
| 497 buffer_manager_->Destroy(); | 501 buffer_manager_->Destroy(); |
| 498 buffer_manager_.reset(); | 502 buffer_manager_.reset(); |
| 503 progress_reporter_->ReportProgress(); |
| 499 } | 504 } |
| 500 | 505 |
| 501 if (framebuffer_manager_ != NULL) { | 506 if (framebuffer_manager_ != NULL) { |
| 502 framebuffer_manager_->Destroy(have_context); | 507 framebuffer_manager_->Destroy(have_context); |
| 503 if (texture_manager_) | 508 if (texture_manager_) |
| 504 texture_manager_->set_framebuffer_manager(NULL); | 509 texture_manager_->set_framebuffer_manager(NULL); |
| 505 framebuffer_manager_.reset(); | 510 framebuffer_manager_.reset(); |
| 511 progress_reporter_->ReportProgress(); |
| 506 } | 512 } |
| 507 | 513 |
| 508 if (renderbuffer_manager_ != NULL) { | 514 if (renderbuffer_manager_ != NULL) { |
| 509 renderbuffer_manager_->Destroy(have_context); | 515 renderbuffer_manager_->Destroy(have_context); |
| 510 renderbuffer_manager_.reset(); | 516 renderbuffer_manager_.reset(); |
| 517 progress_reporter_->ReportProgress(); |
| 511 } | 518 } |
| 512 | 519 |
| 513 if (texture_manager_ != NULL) { | 520 if (texture_manager_ != NULL) { |
| 514 texture_manager_->Destroy(have_context); | 521 texture_manager_->Destroy(have_context, progress_reporter_); |
| 515 texture_manager_.reset(); | 522 texture_manager_.reset(); |
| 523 progress_reporter_->ReportProgress(); |
| 516 } | 524 } |
| 517 | 525 |
| 518 if (path_manager_ != NULL) { | 526 if (path_manager_ != NULL) { |
| 519 path_manager_->Destroy(have_context); | 527 path_manager_->Destroy(have_context); |
| 520 path_manager_.reset(); | 528 path_manager_.reset(); |
| 529 progress_reporter_->ReportProgress(); |
| 521 } | 530 } |
| 522 | 531 |
| 523 if (program_manager_ != NULL) { | 532 if (program_manager_ != NULL) { |
| 524 program_manager_->Destroy(have_context); | 533 program_manager_->Destroy(have_context, progress_reporter_); |
| 525 program_manager_.reset(); | 534 program_manager_.reset(); |
| 535 progress_reporter_->ReportProgress(); |
| 526 } | 536 } |
| 527 | 537 |
| 528 if (shader_manager_ != NULL) { | 538 if (shader_manager_ != NULL) { |
| 529 shader_manager_->Destroy(have_context); | 539 shader_manager_->Destroy(have_context, progress_reporter_); |
| 530 shader_manager_.reset(); | 540 shader_manager_.reset(); |
| 541 progress_reporter_->ReportProgress(); |
| 531 } | 542 } |
| 532 | 543 |
| 533 if (sampler_manager_ != NULL) { | 544 if (sampler_manager_ != NULL) { |
| 534 sampler_manager_->Destroy(have_context); | 545 sampler_manager_->Destroy(have_context); |
| 535 sampler_manager_.reset(); | 546 sampler_manager_.reset(); |
| 547 progress_reporter_->ReportProgress(); |
| 536 } | 548 } |
| 537 | 549 |
| 538 memory_tracker_ = NULL; | 550 memory_tracker_ = NULL; |
| 539 | 551 |
| 540 passthrough_resources_->Destroy(have_context); | 552 passthrough_resources_->Destroy(have_context); |
| 541 passthrough_resources_.reset(); | 553 passthrough_resources_.reset(); |
| 554 progress_reporter_->ReportProgress(); |
| 542 } | 555 } |
| 543 | 556 |
| 544 uint32_t ContextGroup::GetMemRepresented() const { | 557 uint32_t ContextGroup::GetMemRepresented() const { |
| 545 uint32_t total = 0; | 558 uint32_t total = 0; |
| 546 if (buffer_manager_.get()) | 559 if (buffer_manager_.get()) |
| 547 total += buffer_manager_->mem_represented(); | 560 total += buffer_manager_->mem_represented(); |
| 548 if (renderbuffer_manager_.get()) | 561 if (renderbuffer_manager_.get()) |
| 549 total += renderbuffer_manager_->mem_represented(); | 562 total += renderbuffer_manager_->mem_represented(); |
| 550 if (texture_manager_.get()) | 563 if (texture_manager_.get()) |
| 551 total += texture_manager_->mem_represented(); | 564 total += texture_manager_->mem_represented(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 GLuint client_id, GLuint* service_id) const { | 620 GLuint client_id, GLuint* service_id) const { |
| 608 Buffer* buffer = buffer_manager_->GetBuffer(client_id); | 621 Buffer* buffer = buffer_manager_->GetBuffer(client_id); |
| 609 if (!buffer) | 622 if (!buffer) |
| 610 return false; | 623 return false; |
| 611 *service_id = buffer->service_id(); | 624 *service_id = buffer->service_id(); |
| 612 return true; | 625 return true; |
| 613 } | 626 } |
| 614 | 627 |
| 615 } // namespace gles2 | 628 } // namespace gles2 |
| 616 } // namespace gpu | 629 } // namespace gpu |
| OLD | NEW |