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

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

Issue 1231263003: Share SyncPointManager between ipc and in-process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 5 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
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 #if defined(OS_WIN) 5 #if defined(OS_WIN)
6 #include <windows.h> 6 #include <windows.h>
7 #endif 7 #endif
8 8
9 #include "content/common/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // one shot (see constants above). 75 // one shot (see constants above).
76 // - it handles the GpuCommandBufferMsg_InsertSyncPoint message on the IO 76 // - it handles the GpuCommandBufferMsg_InsertSyncPoint message on the IO
77 // thread, generating the sync point ID and responding immediately, and then 77 // thread, generating the sync point ID and responding immediately, and then
78 // posting a task to insert the GpuCommandBufferMsg_RetireSyncPoint message 78 // posting a task to insert the GpuCommandBufferMsg_RetireSyncPoint message
79 // into the channel's queue. 79 // into the channel's queue.
80 // - it generates mailbox names for clients of the GPU process on the IO thread. 80 // - it generates mailbox names for clients of the GPU process on the IO thread.
81 class GpuChannelMessageFilter : public IPC::MessageFilter { 81 class GpuChannelMessageFilter : public IPC::MessageFilter {
82 public: 82 public:
83 GpuChannelMessageFilter( 83 GpuChannelMessageFilter(
84 base::WeakPtr<GpuChannel> gpu_channel, 84 base::WeakPtr<GpuChannel> gpu_channel,
85 scoped_refptr<gpu::SyncPointManager> sync_point_manager, 85 gpu::SyncPointManager* sync_point_manager,
86 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 86 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
87 bool future_sync_points) 87 bool future_sync_points)
88 : preemption_state_(IDLE), 88 : preemption_state_(IDLE),
89 gpu_channel_(gpu_channel), 89 gpu_channel_(gpu_channel),
90 sender_(NULL), 90 sender_(NULL),
91 sync_point_manager_(sync_point_manager), 91 sync_point_manager_(sync_point_manager),
92 task_runner_(task_runner), 92 task_runner_(task_runner),
93 messages_forwarded_to_channel_(0), 93 messages_forwarded_to_channel_(0),
94 a_stub_is_descheduled_(false), 94 a_stub_is_descheduled_(false),
95 future_sync_points_(future_sync_points) {} 95 future_sync_points_(future_sync_points) {}
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 349
350 preemption_state_ = WOULD_PREEMPT_DESCHEDULED; 350 preemption_state_ = WOULD_PREEMPT_DESCHEDULED;
351 preempting_flag_->Reset(); 351 preempting_flag_->Reset();
352 TRACE_COUNTER_ID1("gpu", "GpuChannel::Preempting", this, 0); 352 TRACE_COUNTER_ID1("gpu", "GpuChannel::Preempting", this, 0);
353 353
354 UpdatePreemptionState(); 354 UpdatePreemptionState();
355 } 355 }
356 356
357 static void InsertSyncPointOnMainThread( 357 static void InsertSyncPointOnMainThread(
358 base::WeakPtr<GpuChannel> gpu_channel, 358 base::WeakPtr<GpuChannel> gpu_channel,
359 scoped_refptr<gpu::SyncPointManager> manager, 359 gpu::SyncPointManager* manager,
360 int32 routing_id, 360 int32 routing_id,
361 bool retire, 361 bool retire,
362 uint32 sync_point) { 362 uint32 sync_point) {
363 // This function must ensure that the sync point will be retired. Normally 363 // This function must ensure that the sync point will be retired. Normally
364 // we'll find the stub based on the routing ID, and associate the sync point 364 // we'll find the stub based on the routing ID, and associate the sync point
365 // with it, but if that fails for any reason (channel or stub already 365 // with it, but if that fails for any reason (channel or stub already
366 // deleted, invalid routing id), we need to retire the sync point 366 // deleted, invalid routing id), we need to retire the sync point
367 // immediately. 367 // immediately.
368 if (gpu_channel) { 368 if (gpu_channel) {
369 GpuCommandBufferStub* stub = gpu_channel->LookupCommandBuffer(routing_id); 369 GpuCommandBufferStub* stub = gpu_channel->LookupCommandBuffer(routing_id);
370 if (stub) { 370 if (stub) {
371 stub->AddSyncPoint(sync_point); 371 stub->AddSyncPoint(sync_point);
372 if (retire) { 372 if (retire) {
373 GpuCommandBufferMsg_RetireSyncPoint message(routing_id, sync_point); 373 GpuCommandBufferMsg_RetireSyncPoint message(routing_id, sync_point);
374 gpu_channel->OnMessageReceived(message); 374 gpu_channel->OnMessageReceived(message);
375 } 375 }
376 return; 376 return;
377 } else { 377 } else {
378 gpu_channel->MessageProcessed(); 378 gpu_channel->MessageProcessed();
379 } 379 }
380 } 380 }
381 manager->RetireSyncPoint(sync_point); 381 manager->RetireSyncPoint(sync_point);
382 } 382 }
383 383
384 // NOTE: this weak pointer is never dereferenced on the IO thread, it's only 384 // NOTE: this weak pointer is never dereferenced on the IO thread, it's only
385 // passed through - therefore the WeakPtr assumptions are respected. 385 // passed through - therefore the WeakPtr assumptions are respected.
386 base::WeakPtr<GpuChannel> gpu_channel_; 386 base::WeakPtr<GpuChannel> gpu_channel_;
387 IPC::Sender* sender_; 387 IPC::Sender* sender_;
388 scoped_refptr<gpu::SyncPointManager> sync_point_manager_; 388 gpu::SyncPointManager* sync_point_manager_;
389 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 389 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
390 scoped_refptr<gpu::PreemptionFlag> preempting_flag_; 390 scoped_refptr<gpu::PreemptionFlag> preempting_flag_;
391 391
392 std::queue<PendingMessage> pending_messages_; 392 std::queue<PendingMessage> pending_messages_;
393 393
394 // Count of the number of IPCs forwarded to the GpuChannel. 394 // Count of the number of IPCs forwarded to the GpuChannel.
395 uint64 messages_forwarded_to_channel_; 395 uint64 messages_forwarded_to_channel_;
396 396
397 base::OneShotTimer<GpuChannelMessageFilter> timer_; 397 base::OneShotTimer<GpuChannelMessageFilter> timer_;
398 398
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 pmd->CreateAllocatorDump(base::StringPrintf("gl/%s", dump_name.c_str())); 884 pmd->CreateAllocatorDump(base::StringPrintf("gl/%s", dump_name.c_str()));
885 885
886 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 886 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
887 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 887 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
888 GetMemoryUsage()); 888 GetMemoryUsage());
889 889
890 return true; 890 return true;
891 } 891 }
892 892
893 } // namespace content 893 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698