Chromium Code Reviews| 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/ipc/service/gpu_command_buffer_stub.h" | 5 #include "gpu/ipc/service/gpu_command_buffer_stub.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/hash.h" | 11 #include "base/hash.h" |
| 12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "gpu/command_buffer/common/constants.h" | 19 #include "gpu/command_buffer/common/constants.h" |
| 20 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" | 20 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" |
| 21 #include "gpu/command_buffer/common/mailbox.h" | 21 #include "gpu/command_buffer/common/mailbox.h" |
| 22 #include "gpu/command_buffer/common/sync_token.h" | 22 #include "gpu/command_buffer/common/sync_token.h" |
| 23 #include "gpu/command_buffer/service/gl_context_virtual.h" | 23 #include "gpu/command_buffer/service/gl_context_virtual.h" |
| 24 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" | 24 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" |
| 25 #include "gpu/command_buffer/service/image_manager.h" | 25 #include "gpu/command_buffer/service/image_manager.h" |
| 26 #include "gpu/command_buffer/service/logger.h" | 26 #include "gpu/command_buffer/service/logger.h" |
| 27 #include "gpu/command_buffer/service/mailbox_manager.h" | 27 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 28 #include "gpu/command_buffer/service/memory_tracking.h" | 28 #include "gpu/command_buffer/service/memory_tracking.h" |
| 29 #include "gpu/command_buffer/service/progress_reporter.h" | |
| 29 #include "gpu/command_buffer/service/query_manager.h" | 30 #include "gpu/command_buffer/service/query_manager.h" |
| 30 #include "gpu/command_buffer/service/sync_point_manager.h" | 31 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 31 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 32 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 32 #include "gpu/ipc/common/gpu_messages.h" | 33 #include "gpu/ipc/common/gpu_messages.h" |
| 33 #include "gpu/ipc/service/gpu_channel.h" | 34 #include "gpu/ipc/service/gpu_channel.h" |
| 34 #include "gpu/ipc/service/gpu_channel_manager.h" | 35 #include "gpu/ipc/service/gpu_channel_manager.h" |
| 35 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" | 36 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" |
| 36 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" | 37 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" |
| 37 #include "gpu/ipc/service/gpu_memory_manager.h" | 38 #include "gpu/ipc/service/gpu_memory_manager.h" |
| 38 #include "gpu/ipc/service/gpu_memory_tracking.h" | 39 #include "gpu/ipc/service/gpu_memory_tracking.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 private: | 99 private: |
| 99 ~GpuCommandBufferMemoryTracker() override {} | 100 ~GpuCommandBufferMemoryTracker() override {} |
| 100 std::unique_ptr<GpuMemoryTrackingGroup> tracking_group_; | 101 std::unique_ptr<GpuMemoryTrackingGroup> tracking_group_; |
| 101 const uint64_t client_tracing_id_; | 102 const uint64_t client_tracing_id_; |
| 102 const int client_id_; | 103 const int client_id_; |
| 103 const uint64_t share_group_tracing_guid_; | 104 const uint64_t share_group_tracing_guid_; |
| 104 | 105 |
| 105 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferMemoryTracker); | 106 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferMemoryTracker); |
| 106 }; | 107 }; |
| 107 | 108 |
| 109 // GpuCommandBufferProgressReporter is used as a bridge between the | |
| 110 // ContextGroup and the GpuChannel's GpuWatchdogThread. | |
| 111 class GpuCommandBufferProgressReporter : public gles2::ProgressReporter { | |
| 112 public: | |
| 113 GpuCommandBufferProgressReporter(GpuChannel* channel) : channel_(channel) {} | |
| 114 | |
| 115 void ReportProgress() override { | |
| 116 if (auto* watchdog = channel_->watchdog()) { | |
| 117 // CheckArmed posts a task. Throttle this so we don't post more than | |
|
vmiura
2016/09/30 18:24:35
Rather than adding throttling here, it seems we co
ericrk
2016/10/01 06:19:27
Good point - I don't want to overload this CL, so
| |
| 118 // one task per second. | |
| 119 base::TimeTicks now = base::TimeTicks::Now(); | |
| 120 if (now < next_check_time_) | |
| 121 return; | |
| 122 | |
| 123 next_check_time_ = now + base::TimeDelta::FromSeconds(kMaxCheckRateS); | |
| 124 watchdog->CheckArmed(); | |
| 125 } | |
| 126 } | |
| 127 | |
| 128 private: | |
| 129 // The max rate at which we will signal the watchdog thread. | |
| 130 static const int kMaxCheckRateS = 1; | |
| 131 | |
| 132 // The GpuChannel always outlives the GpuCommandBufferStub and the | |
| 133 // ContextGroups it creates, so it's safe to hold by raw pointer here. | |
| 134 GpuChannel* channel_; | |
| 135 base::TimeTicks next_check_time_; | |
| 136 }; | |
| 137 | |
| 108 // FastSetActiveURL will shortcut the expensive call to SetActiveURL when the | 138 // FastSetActiveURL will shortcut the expensive call to SetActiveURL when the |
| 109 // url_hash matches. | 139 // url_hash matches. |
| 110 void FastSetActiveURL(const GURL& url, size_t url_hash, GpuChannel* channel) { | 140 void FastSetActiveURL(const GURL& url, size_t url_hash, GpuChannel* channel) { |
| 111 // Leave the previously set URL in the empty case -- empty URLs are given by | 141 // Leave the previously set URL in the empty case -- empty URLs are given by |
| 112 // BlinkPlatformImpl::createOffscreenGraphicsContext3DProvider. Hopefully the | 142 // BlinkPlatformImpl::createOffscreenGraphicsContext3DProvider. Hopefully the |
| 113 // onscreen context URL was set previously and will show up even when a crash | 143 // onscreen context URL was set previously and will show up even when a crash |
| 114 // occurs during offscreen command processing. | 144 // occurs during offscreen command processing. |
| 115 if (url.is_empty()) | 145 if (url.is_empty()) |
| 116 return; | 146 return; |
| 117 static size_t g_last_url_hash = 0; | 147 static size_t g_last_url_hash = 0; |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 new gles2::FeatureInfo(manager->gpu_driver_bug_workarounds()); | 492 new gles2::FeatureInfo(manager->gpu_driver_bug_workarounds()); |
| 463 gpu::GpuMemoryBufferFactory* gmb_factory = | 493 gpu::GpuMemoryBufferFactory* gmb_factory = |
| 464 channel_->gpu_channel_manager()->gpu_memory_buffer_factory(); | 494 channel_->gpu_channel_manager()->gpu_memory_buffer_factory(); |
| 465 context_group_ = new gles2::ContextGroup( | 495 context_group_ = new gles2::ContextGroup( |
| 466 manager->gpu_preferences(), channel_->mailbox_manager(), | 496 manager->gpu_preferences(), channel_->mailbox_manager(), |
| 467 new GpuCommandBufferMemoryTracker(channel_, | 497 new GpuCommandBufferMemoryTracker(channel_, |
| 468 command_buffer_id_.GetUnsafeValue()), | 498 command_buffer_id_.GetUnsafeValue()), |
| 469 manager->shader_translator_cache(), | 499 manager->shader_translator_cache(), |
| 470 manager->framebuffer_completeness_cache(), feature_info, | 500 manager->framebuffer_completeness_cache(), feature_info, |
| 471 init_params.attribs.bind_generates_resource, | 501 init_params.attribs.bind_generates_resource, |
| 472 gmb_factory ? gmb_factory->AsImageFactory() : nullptr); | 502 gmb_factory ? gmb_factory->AsImageFactory() : nullptr, |
| 503 base::MakeUnique<GpuCommandBufferProgressReporter>(channel_)); | |
| 473 } | 504 } |
| 474 | 505 |
| 475 #if defined(OS_MACOSX) | 506 #if defined(OS_MACOSX) |
| 476 // Virtualize PreferIntegratedGpu contexts by default on OS X to prevent | 507 // Virtualize PreferIntegratedGpu contexts by default on OS X to prevent |
| 477 // performance regressions when enabling FCM. | 508 // performance regressions when enabling FCM. |
| 478 // http://crbug.com/180463 | 509 // http://crbug.com/180463 |
| 479 if (init_params.attribs.gpu_preference == gl::PreferIntegratedGpu) | 510 if (init_params.attribs.gpu_preference == gl::PreferIntegratedGpu) |
| 480 use_virtualized_gl_context_ = true; | 511 use_virtualized_gl_context_ = true; |
| 481 #endif | 512 #endif |
| 482 | 513 |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1113 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, params)); | 1144 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, params)); |
| 1114 } | 1145 } |
| 1115 | 1146 |
| 1116 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1147 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
| 1117 base::TimeDelta interval) { | 1148 base::TimeDelta interval) { |
| 1118 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1149 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
| 1119 interval)); | 1150 interval)); |
| 1120 } | 1151 } |
| 1121 | 1152 |
| 1122 } // namespace gpu | 1153 } // namespace gpu |
| OLD | NEW |