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

Side by Side Diff: content/common/gpu/gpu_channel.cc

Issue 1331843005: Implemented new fence syncs which replaces the old sync points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reverted mojo readme, changed wait() to take a pointer Created 5 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
« no previous file with comments | « content/common/gpu/gpu_channel.h ('k') | content/common/gpu/gpu_command_buffer_stub.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/common/gpu/gpu_channel.h" 5 #include "content/common/gpu/gpu_channel.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const int64 kStopPreemptThresholdMs = kVsyncIntervalMs; 69 const int64 kStopPreemptThresholdMs = kVsyncIntervalMs;
70 70
71 } // anonymous namespace 71 } // anonymous namespace
72 72
73 scoped_refptr<GpuChannelMessageQueue> GpuChannelMessageQueue::Create( 73 scoped_refptr<GpuChannelMessageQueue> GpuChannelMessageQueue::Create(
74 const base::WeakPtr<GpuChannel>& gpu_channel, 74 const base::WeakPtr<GpuChannel>& gpu_channel,
75 base::SingleThreadTaskRunner* task_runner) { 75 base::SingleThreadTaskRunner* task_runner) {
76 return new GpuChannelMessageQueue(gpu_channel, task_runner); 76 return new GpuChannelMessageQueue(gpu_channel, task_runner);
77 } 77 }
78 78
79 scoped_refptr<gpu::SyncPointClientState> 79 scoped_refptr<gpu::SyncPointOrderData>
80 GpuChannelMessageQueue::GetSyncPointClientState() { 80 GpuChannelMessageQueue::GetSyncPointOrderData() {
81 return sync_point_client_state_; 81 return sync_point_order_data_;
82 } 82 }
83 83
84 GpuChannelMessageQueue::GpuChannelMessageQueue( 84 GpuChannelMessageQueue::GpuChannelMessageQueue(
85 const base::WeakPtr<GpuChannel>& gpu_channel, 85 const base::WeakPtr<GpuChannel>& gpu_channel,
86 base::SingleThreadTaskRunner* task_runner) 86 base::SingleThreadTaskRunner* task_runner)
87 : enabled_(true), 87 : enabled_(true),
88 sync_point_client_state_(gpu::SyncPointClientState::Create()), 88 sync_point_order_data_(gpu::SyncPointOrderData::Create()),
89 gpu_channel_(gpu_channel), 89 gpu_channel_(gpu_channel),
90 task_runner_(task_runner) {} 90 task_runner_(task_runner) {}
91 91
92 GpuChannelMessageQueue::~GpuChannelMessageQueue() { 92 GpuChannelMessageQueue::~GpuChannelMessageQueue() {
93 DCHECK(channel_messages_.empty()); 93 DCHECK(channel_messages_.empty());
94 } 94 }
95 95
96 uint32_t GpuChannelMessageQueue::GetUnprocessedOrderNum() const { 96 uint32_t GpuChannelMessageQueue::GetUnprocessedOrderNum() const {
97 return sync_point_client_state_->unprocessed_order_num(); 97 return sync_point_order_data_->unprocessed_order_num();
98 } 98 }
99 99
100 uint32_t GpuChannelMessageQueue::GetProcessedOrderNum() const { 100 uint32_t GpuChannelMessageQueue::GetProcessedOrderNum() const {
101 return sync_point_client_state_->processed_order_num(); 101 return sync_point_order_data_->processed_order_num();
102 } 102 }
103 103
104 void GpuChannelMessageQueue::PushBackMessage( 104 void GpuChannelMessageQueue::PushBackMessage(
105 gpu::SyncPointManager* sync_point_manager, const IPC::Message& message) { 105 gpu::SyncPointManager* sync_point_manager, const IPC::Message& message) {
106 base::AutoLock auto_lock(channel_messages_lock_); 106 base::AutoLock auto_lock(channel_messages_lock_);
107 if (enabled_) { 107 if (enabled_) {
108 PushMessageHelper(sync_point_manager, 108 PushMessageHelper(sync_point_manager,
109 make_scoped_ptr(new GpuChannelMessage(message))); 109 make_scoped_ptr(new GpuChannelMessage(message)));
110 } 110 }
111 } 111 }
(...skipping 28 matching lines...) Expand all
140 base::AutoLock auto_lock(channel_messages_lock_); 140 base::AutoLock auto_lock(channel_messages_lock_);
141 if (!channel_messages_.empty()) 141 if (!channel_messages_.empty())
142 return channel_messages_.front()->time_received; 142 return channel_messages_.front()->time_received;
143 return base::TimeTicks(); 143 return base::TimeTicks();
144 } 144 }
145 145
146 GpuChannelMessage* GpuChannelMessageQueue::GetNextMessage() const { 146 GpuChannelMessage* GpuChannelMessageQueue::GetNextMessage() const {
147 base::AutoLock auto_lock(channel_messages_lock_); 147 base::AutoLock auto_lock(channel_messages_lock_);
148 if (!channel_messages_.empty()) { 148 if (!channel_messages_.empty()) {
149 DCHECK_GT(channel_messages_.front()->order_number, 149 DCHECK_GT(channel_messages_.front()->order_number,
150 sync_point_client_state_->processed_order_num()); 150 sync_point_order_data_->processed_order_num());
151 DCHECK_LE(channel_messages_.front()->order_number, 151 DCHECK_LE(channel_messages_.front()->order_number,
152 sync_point_client_state_->unprocessed_order_num()); 152 sync_point_order_data_->unprocessed_order_num());
153 153
154 return channel_messages_.front(); 154 return channel_messages_.front();
155 } 155 }
156 return nullptr; 156 return nullptr;
157 } 157 }
158 158
159 void GpuChannelMessageQueue::BeginMessageProcessing( 159 void GpuChannelMessageQueue::BeginMessageProcessing(
160 const GpuChannelMessage* msg) { 160 const GpuChannelMessage* msg) {
161 sync_point_client_state_->BeginProcessingOrderNumber(msg->order_number); 161 sync_point_order_data_->BeginProcessingOrderNumber(msg->order_number);
162 } 162 }
163 163
164 bool GpuChannelMessageQueue::MessageProcessed() { 164 bool GpuChannelMessageQueue::MessageProcessed() {
165 base::AutoLock auto_lock(channel_messages_lock_); 165 base::AutoLock auto_lock(channel_messages_lock_);
166 DCHECK(!channel_messages_.empty()); 166 DCHECK(!channel_messages_.empty());
167 scoped_ptr<GpuChannelMessage> msg(channel_messages_.front()); 167 scoped_ptr<GpuChannelMessage> msg(channel_messages_.front());
168 channel_messages_.pop_front(); 168 channel_messages_.pop_front();
169 sync_point_client_state_->FinishProcessingOrderNumber(msg->order_number); 169 sync_point_order_data_->FinishProcessingOrderNumber(msg->order_number);
170 return !channel_messages_.empty(); 170 return !channel_messages_.empty();
171 } 171 }
172 172
173 void GpuChannelMessageQueue::DeleteAndDisableMessages( 173 void GpuChannelMessageQueue::DeleteAndDisableMessages(
174 GpuChannelManager* gpu_channel_manager) { 174 GpuChannelManager* gpu_channel_manager) {
175 { 175 {
176 base::AutoLock auto_lock(channel_messages_lock_); 176 base::AutoLock auto_lock(channel_messages_lock_);
177 DCHECK(enabled_); 177 DCHECK(enabled_);
178 enabled_ = false; 178 enabled_ = false;
179 } 179 }
180 180
181 // We guarantee that the queues will no longer be modified after enabled_ 181 // We guarantee that the queues will no longer be modified after enabled_
182 // is set to false, it is now safe to modify the queue without the lock. 182 // is set to false, it is now safe to modify the queue without the lock.
183 // All public facing modifying functions check enabled_ while all 183 // All public facing modifying functions check enabled_ while all
184 // private modifying functions DCHECK(enabled_) to enforce this. 184 // private modifying functions DCHECK(enabled_) to enforce this.
185 while (!channel_messages_.empty()) { 185 while (!channel_messages_.empty()) {
186 scoped_ptr<GpuChannelMessage> msg(channel_messages_.front()); 186 scoped_ptr<GpuChannelMessage> msg(channel_messages_.front());
187 channel_messages_.pop_front(); 187 channel_messages_.pop_front();
188 // This needs to clean up both GpuCommandBufferMsg_InsertSyncPoint and 188 // This needs to clean up both GpuCommandBufferMsg_InsertSyncPoint and
189 // GpuCommandBufferMsg_RetireSyncPoint messages, safer to just check 189 // GpuCommandBufferMsg_RetireSyncPoint messages, safer to just check
190 // if we have a sync point number here. 190 // if we have a sync point number here.
191 if (msg->sync_point) { 191 if (msg->sync_point) {
192 gpu_channel_manager->sync_point_manager()->RetireSyncPoint( 192 gpu_channel_manager->sync_point_manager()->RetireSyncPoint(
193 msg->sync_point); 193 msg->sync_point);
194 } 194 }
195 } 195 }
196
197 if (sync_point_order_data_) {
198 sync_point_order_data_->Destroy();
199 sync_point_order_data_ = nullptr;
200 }
196 } 201 }
197 202
198 void GpuChannelMessageQueue::ScheduleHandleMessage() { 203 void GpuChannelMessageQueue::ScheduleHandleMessage() {
199 task_runner_->PostTask(FROM_HERE, 204 task_runner_->PostTask(FROM_HERE,
200 base::Bind(&GpuChannel::HandleMessage, gpu_channel_)); 205 base::Bind(&GpuChannel::HandleMessage, gpu_channel_));
201 } 206 }
202 207
203 void GpuChannelMessageQueue::PushMessageHelper( 208 void GpuChannelMessageQueue::PushMessageHelper(
204 gpu::SyncPointManager* sync_point_manager, 209 gpu::SyncPointManager* sync_point_manager,
205 scoped_ptr<GpuChannelMessage> msg) { 210 scoped_ptr<GpuChannelMessage> msg) {
206 channel_messages_lock_.AssertAcquired(); 211 channel_messages_lock_.AssertAcquired();
207 DCHECK(enabled_); 212 DCHECK(enabled_);
208 213
209 msg->order_number = 214 msg->order_number = sync_point_order_data_->GenerateUnprocessedOrderNumber(
210 sync_point_client_state_->GenerateUnprocessedOrderNumber( 215 sync_point_manager);
211 sync_point_manager);
212 msg->time_received = base::TimeTicks::Now(); 216 msg->time_received = base::TimeTicks::Now();
213 217
214 bool had_messages = !channel_messages_.empty(); 218 bool had_messages = !channel_messages_.empty();
215 channel_messages_.push_back(msg.release()); 219 channel_messages_.push_back(msg.release());
216 if (!had_messages) 220 if (!had_messages)
217 ScheduleHandleMessage(); 221 ScheduleHandleMessage();
218 } 222 }
219 223
220 GpuChannelMessageFilter::GpuChannelMessageFilter( 224 GpuChannelMessageFilter::GpuChannelMessageFilter(
221 const base::WeakPtr<GpuChannel>& gpu_channel, 225 const base::WeakPtr<GpuChannel>& gpu_channel,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 298 }
295 299
296 bool GpuChannelMessageFilter::OnMessageReceived(const IPC::Message& message) { 300 bool GpuChannelMessageFilter::OnMessageReceived(const IPC::Message& message) {
297 DCHECK(sender_); 301 DCHECK(sender_);
298 302
299 if (message.should_unblock() || message.is_reply()) { 303 if (message.should_unblock() || message.is_reply()) {
300 DLOG(ERROR) << "Unexpected message type"; 304 DLOG(ERROR) << "Unexpected message type";
301 return true; 305 return true;
302 } 306 }
303 307
308 if (message.type() == GpuChannelMsg_Nop::ID) {
309 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&message);
310 Send(reply);
311 return true;
312 }
313
304 for (scoped_refptr<IPC::MessageFilter>& filter : channel_filters_) { 314 for (scoped_refptr<IPC::MessageFilter>& filter : channel_filters_) {
305 if (filter->OnMessageReceived(message)) { 315 if (filter->OnMessageReceived(message)) {
306 return true; 316 return true;
307 } 317 }
308 } 318 }
309 319
310 bool handled = false; 320 bool handled = false;
311 if ((message.type() == GpuCommandBufferMsg_RetireSyncPoint::ID) && 321 if ((message.type() == GpuCommandBufferMsg_RetireSyncPoint::ID) &&
312 !future_sync_points_) { 322 !future_sync_points_) {
313 DLOG(ERROR) << "Untrusted client should not send " 323 DLOG(ERROR) << "Untrusted client should not send "
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, 791 IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer,
782 OnDestroyCommandBuffer) 792 OnDestroyCommandBuffer)
783 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuMsg_CreateJpegDecoder, 793 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuMsg_CreateJpegDecoder,
784 OnCreateJpegDecoder) 794 OnCreateJpegDecoder)
785 IPC_MESSAGE_UNHANDLED(handled = false) 795 IPC_MESSAGE_UNHANDLED(handled = false)
786 IPC_END_MESSAGE_MAP() 796 IPC_END_MESSAGE_MAP()
787 DCHECK(handled) << msg.type(); 797 DCHECK(handled) << msg.type();
788 return handled; 798 return handled;
789 } 799 }
790 800
791 scoped_refptr<gpu::SyncPointClientState> GpuChannel::GetSyncPointClientState() { 801 scoped_refptr<gpu::SyncPointOrderData> GpuChannel::GetSyncPointOrderData() {
792 return message_queue_->GetSyncPointClientState(); 802 return message_queue_->GetSyncPointOrderData();
793 } 803 }
794 804
795 void GpuChannel::HandleMessage() { 805 void GpuChannel::HandleMessage() {
796 // If we have been preempted by another channel, just post a task to wake up. 806 // If we have been preempted by another channel, just post a task to wake up.
797 if (preempted_flag_ && preempted_flag_->IsSet()) { 807 if (preempted_flag_ && preempted_flag_->IsSet()) {
798 ScheduleHandleMessage(); 808 ScheduleHandleMessage();
799 return; 809 return;
800 } 810 }
801 811
802 GpuChannelMessage* m = message_queue_->GetNextMessage(); 812 GpuChannelMessage* m = message_queue_->GetNextMessage();
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 } 1067 }
1058 } 1068 }
1059 } 1069 }
1060 1070
1061 void GpuChannel::HandleUpdateValueState( 1071 void GpuChannel::HandleUpdateValueState(
1062 unsigned int target, const gpu::ValueState& state) { 1072 unsigned int target, const gpu::ValueState& state) {
1063 pending_valuebuffer_state_->UpdateState(target, state); 1073 pending_valuebuffer_state_->UpdateState(target, state);
1064 } 1074 }
1065 1075
1066 } // namespace content 1076 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel.h ('k') | content/common/gpu/gpu_command_buffer_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698