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()) { | |
|
danakj
2016/10/05 01:53:48
when is it null?
ericrk
2016/10/05 18:07:32
added stub and removed.
| |
| 117 watchdog->CheckArmed(); | |
| 118 } | |
| 119 } | |
| 120 | |
| 121 private: | |
| 122 // The GpuChannel always outlives the GpuCommandBufferStub and the | |
| 123 // ContextGroups it creates, so it's safe to hold by raw pointer here. | |
| 124 GpuChannel* channel_; | |
| 125 }; | |
| 126 | |
| 108 // FastSetActiveURL will shortcut the expensive call to SetActiveURL when the | 127 // FastSetActiveURL will shortcut the expensive call to SetActiveURL when the |
| 109 // url_hash matches. | 128 // url_hash matches. |
| 110 void FastSetActiveURL(const GURL& url, size_t url_hash, GpuChannel* channel) { | 129 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 | 130 // Leave the previously set URL in the empty case -- empty URLs are given by |
| 112 // BlinkPlatformImpl::createOffscreenGraphicsContext3DProvider. Hopefully the | 131 // BlinkPlatformImpl::createOffscreenGraphicsContext3DProvider. Hopefully the |
| 113 // onscreen context URL was set previously and will show up even when a crash | 132 // onscreen context URL was set previously and will show up even when a crash |
| 114 // occurs during offscreen command processing. | 133 // occurs during offscreen command processing. |
| 115 if (url.is_empty()) | 134 if (url.is_empty()) |
| 116 return; | 135 return; |
| 117 static size_t g_last_url_hash = 0; | 136 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()); | 481 new gles2::FeatureInfo(manager->gpu_driver_bug_workarounds()); |
| 463 gpu::GpuMemoryBufferFactory* gmb_factory = | 482 gpu::GpuMemoryBufferFactory* gmb_factory = |
| 464 channel_->gpu_channel_manager()->gpu_memory_buffer_factory(); | 483 channel_->gpu_channel_manager()->gpu_memory_buffer_factory(); |
| 465 context_group_ = new gles2::ContextGroup( | 484 context_group_ = new gles2::ContextGroup( |
| 466 manager->gpu_preferences(), channel_->mailbox_manager(), | 485 manager->gpu_preferences(), channel_->mailbox_manager(), |
| 467 new GpuCommandBufferMemoryTracker(channel_, | 486 new GpuCommandBufferMemoryTracker(channel_, |
| 468 command_buffer_id_.GetUnsafeValue()), | 487 command_buffer_id_.GetUnsafeValue()), |
| 469 manager->shader_translator_cache(), | 488 manager->shader_translator_cache(), |
| 470 manager->framebuffer_completeness_cache(), feature_info, | 489 manager->framebuffer_completeness_cache(), feature_info, |
| 471 init_params.attribs.bind_generates_resource, | 490 init_params.attribs.bind_generates_resource, |
| 472 gmb_factory ? gmb_factory->AsImageFactory() : nullptr); | 491 gmb_factory ? gmb_factory->AsImageFactory() : nullptr, |
| 492 base::MakeUnique<GpuCommandBufferProgressReporter>(channel_)); | |
|
danakj
2016/10/05 01:53:48
I was surprised at the ownership model here. I wou
ericrk
2016/10/05 18:07:31
I agree, this was a weird decision - I was origina
| |
| 473 } | 493 } |
| 474 | 494 |
| 475 #if defined(OS_MACOSX) | 495 #if defined(OS_MACOSX) |
| 476 // Virtualize PreferIntegratedGpu contexts by default on OS X to prevent | 496 // Virtualize PreferIntegratedGpu contexts by default on OS X to prevent |
| 477 // performance regressions when enabling FCM. | 497 // performance regressions when enabling FCM. |
| 478 // http://crbug.com/180463 | 498 // http://crbug.com/180463 |
| 479 if (init_params.attribs.gpu_preference == gl::PreferIntegratedGpu) | 499 if (init_params.attribs.gpu_preference == gl::PreferIntegratedGpu) |
| 480 use_virtualized_gl_context_ = true; | 500 use_virtualized_gl_context_ = true; |
| 481 #endif | 501 #endif |
| 482 | 502 |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1113 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, params)); | 1133 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, params)); |
| 1114 } | 1134 } |
| 1115 | 1135 |
| 1116 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1136 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
| 1117 base::TimeDelta interval) { | 1137 base::TimeDelta interval) { |
| 1118 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1138 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
| 1119 interval)); | 1139 interval)); |
| 1120 } | 1140 } |
| 1121 | 1141 |
| 1122 } // namespace gpu | 1142 } // namespace gpu |
| OLD | NEW |