| 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 #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 Loading... |
| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 360 |
| 361 preemption_state_ = WOULD_PREEMPT_DESCHEDULED; | 361 preemption_state_ = WOULD_PREEMPT_DESCHEDULED; |
| 362 preempting_flag_->Reset(); | 362 preempting_flag_->Reset(); |
| 363 TRACE_COUNTER_ID1("gpu", "GpuChannel::Preempting", this, 0); | 363 TRACE_COUNTER_ID1("gpu", "GpuChannel::Preempting", this, 0); |
| 364 | 364 |
| 365 UpdatePreemptionState(); | 365 UpdatePreemptionState(); |
| 366 } | 366 } |
| 367 | 367 |
| 368 static void InsertSyncPointOnMainThread( | 368 static void InsertSyncPointOnMainThread( |
| 369 base::WeakPtr<GpuChannel> gpu_channel, | 369 base::WeakPtr<GpuChannel> gpu_channel, |
| 370 scoped_refptr<gpu::SyncPointManager> manager, | 370 gpu::SyncPointManager* manager, |
| 371 int32 routing_id, | 371 int32 routing_id, |
| 372 bool retire, | 372 bool retire, |
| 373 uint32 sync_point) { | 373 uint32 sync_point) { |
| 374 // This function must ensure that the sync point will be retired. Normally | 374 // This function must ensure that the sync point will be retired. Normally |
| 375 // we'll find the stub based on the routing ID, and associate the sync point | 375 // we'll find the stub based on the routing ID, and associate the sync point |
| 376 // with it, but if that fails for any reason (channel or stub already | 376 // with it, but if that fails for any reason (channel or stub already |
| 377 // deleted, invalid routing id), we need to retire the sync point | 377 // deleted, invalid routing id), we need to retire the sync point |
| 378 // immediately. | 378 // immediately. |
| 379 if (gpu_channel) { | 379 if (gpu_channel) { |
| 380 GpuCommandBufferStub* stub = gpu_channel->LookupCommandBuffer(routing_id); | 380 GpuCommandBufferStub* stub = gpu_channel->LookupCommandBuffer(routing_id); |
| 381 if (stub) { | 381 if (stub) { |
| 382 stub->AddSyncPoint(sync_point); | 382 stub->AddSyncPoint(sync_point); |
| 383 if (retire) { | 383 if (retire) { |
| 384 GpuCommandBufferMsg_RetireSyncPoint message(routing_id, sync_point); | 384 GpuCommandBufferMsg_RetireSyncPoint message(routing_id, sync_point); |
| 385 gpu_channel->OnMessageReceived(message); | 385 gpu_channel->OnMessageReceived(message); |
| 386 } | 386 } |
| 387 return; | 387 return; |
| 388 } else { | 388 } else { |
| 389 gpu_channel->MessageProcessed(); | 389 gpu_channel->MessageProcessed(); |
| 390 } | 390 } |
| 391 } | 391 } |
| 392 manager->RetireSyncPoint(sync_point); | 392 manager->RetireSyncPoint(sync_point); |
| 393 } | 393 } |
| 394 | 394 |
| 395 // NOTE: this weak pointer is never dereferenced on the IO thread, it's only | 395 // NOTE: this weak pointer is never dereferenced on the IO thread, it's only |
| 396 // passed through - therefore the WeakPtr assumptions are respected. | 396 // passed through - therefore the WeakPtr assumptions are respected. |
| 397 base::WeakPtr<GpuChannel> gpu_channel_; | 397 base::WeakPtr<GpuChannel> gpu_channel_; |
| 398 IPC::Sender* sender_; | 398 IPC::Sender* sender_; |
| 399 scoped_refptr<gpu::SyncPointManager> sync_point_manager_; | 399 gpu::SyncPointManager* sync_point_manager_; |
| 400 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 400 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 401 scoped_refptr<gpu::PreemptionFlag> preempting_flag_; | 401 scoped_refptr<gpu::PreemptionFlag> preempting_flag_; |
| 402 | 402 |
| 403 std::queue<PendingMessage> pending_messages_; | 403 std::queue<PendingMessage> pending_messages_; |
| 404 | 404 |
| 405 // Count of the number of IPCs forwarded to the GpuChannel. | 405 // Count of the number of IPCs forwarded to the GpuChannel. |
| 406 uint64 messages_forwarded_to_channel_; | 406 uint64 messages_forwarded_to_channel_; |
| 407 | 407 |
| 408 base::OneShotTimer<GpuChannelMessageFilter> timer_; | 408 base::OneShotTimer<GpuChannelMessageFilter> timer_; |
| 409 | 409 |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 pmd->CreateAllocatorDump(base::StringPrintf("gl/%s", dump_name.c_str())); | 895 pmd->CreateAllocatorDump(base::StringPrintf("gl/%s", dump_name.c_str())); |
| 896 | 896 |
| 897 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 897 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 898 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 898 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 899 GetMemoryUsage()); | 899 GetMemoryUsage()); |
| 900 | 900 |
| 901 return true; | 901 return true; |
| 902 } | 902 } |
| 903 | 903 |
| 904 } // namespace content | 904 } // namespace content |
| OLD | NEW |