| 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 "content/common/gpu/gpu_channel.h" | 5 #include "content/common/gpu/gpu_channel.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "base/synchronization/lock.h" | 26 #include "base/synchronization/lock.h" |
| 27 #include "base/thread_task_runner_handle.h" | 27 #include "base/thread_task_runner_handle.h" |
| 28 #include "base/timer/timer.h" | 28 #include "base/timer/timer.h" |
| 29 #include "base/trace_event/memory_dump_manager.h" | 29 #include "base/trace_event/memory_dump_manager.h" |
| 30 #include "base/trace_event/process_memory_dump.h" | 30 #include "base/trace_event/process_memory_dump.h" |
| 31 #include "base/trace_event/trace_event.h" | 31 #include "base/trace_event/trace_event.h" |
| 32 #include "build/build_config.h" | 32 #include "build/build_config.h" |
| 33 #include "content/common/gpu/gpu_channel_manager.h" | 33 #include "content/common/gpu/gpu_channel_manager.h" |
| 34 #include "content/common/gpu/gpu_channel_manager_delegate.h" | 34 #include "content/common/gpu/gpu_channel_manager_delegate.h" |
| 35 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 35 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
| 36 #include "content/common/gpu/gpu_messages.h" | |
| 37 #include "gpu/command_buffer/common/mailbox.h" | 36 #include "gpu/command_buffer/common/mailbox.h" |
| 38 #include "gpu/command_buffer/common/value_state.h" | 37 #include "gpu/command_buffer/common/value_state.h" |
| 39 #include "gpu/command_buffer/service/command_executor.h" | 38 #include "gpu/command_buffer/service/command_executor.h" |
| 40 #include "gpu/command_buffer/service/image_factory.h" | 39 #include "gpu/command_buffer/service/image_factory.h" |
| 41 #include "gpu/command_buffer/service/mailbox_manager.h" | 40 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 42 #include "gpu/command_buffer/service/sync_point_manager.h" | 41 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 43 #include "gpu/command_buffer/service/valuebuffer_manager.h" | 42 #include "gpu/command_buffer/service/valuebuffer_manager.h" |
| 43 #include "gpu/ipc/common/gpu_messages.h" |
| 44 #include "ipc/ipc_channel.h" | 44 #include "ipc/ipc_channel.h" |
| 45 #include "ipc/message_filter.h" | 45 #include "ipc/message_filter.h" |
| 46 #include "ui/gl/gl_context.h" | 46 #include "ui/gl/gl_context.h" |
| 47 #include "ui/gl/gl_image_shared_memory.h" | 47 #include "ui/gl/gl_image_shared_memory.h" |
| 48 #include "ui/gl/gl_surface.h" | 48 #include "ui/gl/gl_surface.h" |
| 49 | 49 |
| 50 #if defined(OS_POSIX) | 50 #if defined(OS_POSIX) |
| 51 #include "ipc/ipc_channel_posix.h" | 51 #include "ipc/ipc_channel_posix.h" |
| 52 #endif | 52 #endif |
| 53 | 53 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 68 const int64_t kMaxPreemptTimeMs = kVsyncIntervalMs; | 68 const int64_t kMaxPreemptTimeMs = kVsyncIntervalMs; |
| 69 | 69 |
| 70 // Stop the preemption once the time for the longest pending IPC drops | 70 // Stop the preemption once the time for the longest pending IPC drops |
| 71 // below this threshold. | 71 // below this threshold. |
| 72 const int64_t kStopPreemptThresholdMs = kVsyncIntervalMs; | 72 const int64_t kStopPreemptThresholdMs = kVsyncIntervalMs; |
| 73 | 73 |
| 74 } // anonymous namespace | 74 } // anonymous namespace |
| 75 | 75 |
| 76 scoped_refptr<GpuChannelMessageQueue> GpuChannelMessageQueue::Create( | 76 scoped_refptr<GpuChannelMessageQueue> GpuChannelMessageQueue::Create( |
| 77 int32_t stream_id, | 77 int32_t stream_id, |
| 78 GpuStreamPriority stream_priority, | 78 gpu::GpuStreamPriority stream_priority, |
| 79 GpuChannel* channel, | 79 GpuChannel* channel, |
| 80 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 80 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
| 81 const scoped_refptr<gpu::PreemptionFlag>& preempting_flag, | 81 const scoped_refptr<gpu::PreemptionFlag>& preempting_flag, |
| 82 const scoped_refptr<gpu::PreemptionFlag>& preempted_flag, | 82 const scoped_refptr<gpu::PreemptionFlag>& preempted_flag, |
| 83 gpu::SyncPointManager* sync_point_manager) { | 83 gpu::SyncPointManager* sync_point_manager) { |
| 84 return new GpuChannelMessageQueue(stream_id, stream_priority, channel, | 84 return new GpuChannelMessageQueue(stream_id, stream_priority, channel, |
| 85 io_task_runner, preempting_flag, | 85 io_task_runner, preempting_flag, |
| 86 preempted_flag, sync_point_manager); | 86 preempted_flag, sync_point_manager); |
| 87 } | 87 } |
| 88 | 88 |
| 89 scoped_refptr<gpu::SyncPointOrderData> | 89 scoped_refptr<gpu::SyncPointOrderData> |
| 90 GpuChannelMessageQueue::GetSyncPointOrderData() { | 90 GpuChannelMessageQueue::GetSyncPointOrderData() { |
| 91 return sync_point_order_data_; | 91 return sync_point_order_data_; |
| 92 } | 92 } |
| 93 | 93 |
| 94 GpuChannelMessageQueue::GpuChannelMessageQueue( | 94 GpuChannelMessageQueue::GpuChannelMessageQueue( |
| 95 int32_t stream_id, | 95 int32_t stream_id, |
| 96 GpuStreamPriority stream_priority, | 96 gpu::GpuStreamPriority stream_priority, |
| 97 GpuChannel* channel, | 97 GpuChannel* channel, |
| 98 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 98 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
| 99 const scoped_refptr<gpu::PreemptionFlag>& preempting_flag, | 99 const scoped_refptr<gpu::PreemptionFlag>& preempting_flag, |
| 100 const scoped_refptr<gpu::PreemptionFlag>& preempted_flag, | 100 const scoped_refptr<gpu::PreemptionFlag>& preempted_flag, |
| 101 gpu::SyncPointManager* sync_point_manager) | 101 gpu::SyncPointManager* sync_point_manager) |
| 102 : stream_id_(stream_id), | 102 : stream_id_(stream_id), |
| 103 stream_priority_(stream_priority), | 103 stream_priority_(stream_priority), |
| 104 enabled_(true), | 104 enabled_(true), |
| 105 scheduled_(true), | 105 scheduled_(true), |
| 106 channel_(channel), | 106 channel_(channel), |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 watchdog_(watchdog), | 607 watchdog_(watchdog), |
| 608 allow_view_command_buffers_(allow_view_command_buffers), | 608 allow_view_command_buffers_(allow_view_command_buffers), |
| 609 allow_real_time_streams_(allow_real_time_streams), | 609 allow_real_time_streams_(allow_real_time_streams), |
| 610 weak_factory_(this) { | 610 weak_factory_(this) { |
| 611 DCHECK(gpu_channel_manager); | 611 DCHECK(gpu_channel_manager); |
| 612 DCHECK(client_id); | 612 DCHECK(client_id); |
| 613 | 613 |
| 614 filter_ = new GpuChannelMessageFilter(); | 614 filter_ = new GpuChannelMessageFilter(); |
| 615 | 615 |
| 616 scoped_refptr<GpuChannelMessageQueue> control_queue = | 616 scoped_refptr<GpuChannelMessageQueue> control_queue = |
| 617 CreateStream(GPU_STREAM_DEFAULT, GpuStreamPriority::HIGH); | 617 CreateStream(gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::HIGH); |
| 618 AddRouteToStream(MSG_ROUTING_CONTROL, GPU_STREAM_DEFAULT); | 618 AddRouteToStream(MSG_ROUTING_CONTROL, gpu::GPU_STREAM_DEFAULT); |
| 619 | 619 |
| 620 subscription_ref_set_->AddObserver(this); | 620 subscription_ref_set_->AddObserver(this); |
| 621 } | 621 } |
| 622 | 622 |
| 623 GpuChannel::~GpuChannel() { | 623 GpuChannel::~GpuChannel() { |
| 624 // Clear stubs first because of dependencies. | 624 // Clear stubs first because of dependencies. |
| 625 stubs_.clear(); | 625 stubs_.clear(); |
| 626 | 626 |
| 627 for (auto& kv : streams_) | 627 for (auto& kv : streams_) |
| 628 kv.second->Disable(); | 628 kv.second->Disable(); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 void GpuChannel::HandleOutOfOrderMessage(const IPC::Message& msg) { | 837 void GpuChannel::HandleOutOfOrderMessage(const IPC::Message& msg) { |
| 838 HandleMessageHelper(msg); | 838 HandleMessageHelper(msg); |
| 839 } | 839 } |
| 840 | 840 |
| 841 void GpuChannel::HandleMessageForTesting(const IPC::Message& msg) { | 841 void GpuChannel::HandleMessageForTesting(const IPC::Message& msg) { |
| 842 HandleMessageHelper(msg); | 842 HandleMessageHelper(msg); |
| 843 } | 843 } |
| 844 | 844 |
| 845 scoped_refptr<GpuChannelMessageQueue> GpuChannel::CreateStream( | 845 scoped_refptr<GpuChannelMessageQueue> GpuChannel::CreateStream( |
| 846 int32_t stream_id, | 846 int32_t stream_id, |
| 847 GpuStreamPriority stream_priority) { | 847 gpu::GpuStreamPriority stream_priority) { |
| 848 DCHECK(streams_.find(stream_id) == streams_.end()); | 848 DCHECK(streams_.find(stream_id) == streams_.end()); |
| 849 scoped_refptr<GpuChannelMessageQueue> queue = GpuChannelMessageQueue::Create( | 849 scoped_refptr<GpuChannelMessageQueue> queue = GpuChannelMessageQueue::Create( |
| 850 stream_id, stream_priority, this, io_task_runner_, | 850 stream_id, stream_priority, this, io_task_runner_, |
| 851 (stream_id == GPU_STREAM_DEFAULT) ? preempting_flag_ : nullptr, | 851 (stream_id == gpu::GPU_STREAM_DEFAULT) ? preempting_flag_ : nullptr, |
| 852 preempted_flag_, sync_point_manager_); | 852 preempted_flag_, sync_point_manager_); |
| 853 streams_.insert(std::make_pair(stream_id, queue)); | 853 streams_.insert(std::make_pair(stream_id, queue)); |
| 854 streams_to_num_routes_.insert(std::make_pair(stream_id, 0)); | 854 streams_to_num_routes_.insert(std::make_pair(stream_id, 0)); |
| 855 return queue; | 855 return queue; |
| 856 } | 856 } |
| 857 | 857 |
| 858 scoped_refptr<GpuChannelMessageQueue> GpuChannel::LookupStream( | 858 scoped_refptr<GpuChannelMessageQueue> GpuChannel::LookupStream( |
| 859 int32_t stream_id) { | 859 int32_t stream_id) { |
| 860 auto stream_it = streams_.find(stream_id); | 860 auto stream_it = streams_.find(stream_id); |
| 861 if (stream_it != streams_.end()) | 861 if (stream_it != streams_.end()) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 return; | 927 return; |
| 928 } | 928 } |
| 929 | 929 |
| 930 int32_t stream_id = init_params.stream_id; | 930 int32_t stream_id = init_params.stream_id; |
| 931 if (share_group && stream_id != share_group->stream_id()) { | 931 if (share_group && stream_id != share_group->stream_id()) { |
| 932 DLOG(ERROR) << "GpuChannel::OnCreateCommandBuffer(): stream id does not " | 932 DLOG(ERROR) << "GpuChannel::OnCreateCommandBuffer(): stream id does not " |
| 933 "match share group stream id"; | 933 "match share group stream id"; |
| 934 return; | 934 return; |
| 935 } | 935 } |
| 936 | 936 |
| 937 GpuStreamPriority stream_priority = init_params.stream_priority; | 937 gpu::GpuStreamPriority stream_priority = init_params.stream_priority; |
| 938 if (!allow_real_time_streams_ && | 938 if (!allow_real_time_streams_ && |
| 939 stream_priority == GpuStreamPriority::REAL_TIME) { | 939 stream_priority == gpu::GpuStreamPriority::REAL_TIME) { |
| 940 DLOG(ERROR) << "GpuChannel::OnCreateCommandBuffer(): real time stream " | 940 DLOG(ERROR) << "GpuChannel::OnCreateCommandBuffer(): real time stream " |
| 941 "priority not allowed"; | 941 "priority not allowed"; |
| 942 return; | 942 return; |
| 943 } | 943 } |
| 944 | 944 |
| 945 scoped_ptr<GpuCommandBufferStub> stub(new GpuCommandBufferStub( | 945 scoped_ptr<GpuCommandBufferStub> stub(new GpuCommandBufferStub( |
| 946 this, sync_point_manager_, task_runner_.get(), share_group, | 946 this, sync_point_manager_, task_runner_.get(), share_group, |
| 947 surface_handle, mailbox_manager_.get(), preempted_flag_.get(), | 947 surface_handle, mailbox_manager_.get(), preempted_flag_.get(), |
| 948 subscription_ref_set_.get(), pending_valuebuffer_state_.get(), size, | 948 subscription_ref_set_.get(), pending_valuebuffer_state_.get(), size, |
| 949 disallowed_features_, init_params.attribs, init_params.gpu_preference, | 949 disallowed_features_, init_params.attribs, init_params.gpu_preference, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 } | 1044 } |
| 1045 } | 1045 } |
| 1046 } | 1046 } |
| 1047 | 1047 |
| 1048 void GpuChannel::HandleUpdateValueState( | 1048 void GpuChannel::HandleUpdateValueState( |
| 1049 unsigned int target, const gpu::ValueState& state) { | 1049 unsigned int target, const gpu::ValueState& state) { |
| 1050 pending_valuebuffer_state_->UpdateState(target, state); | 1050 pending_valuebuffer_state_->UpdateState(target, state); |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 } // namespace content | 1053 } // namespace content |
| OLD | NEW |