| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/hash.h" | 8 #include "base/hash.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "content/common/gpu/gpu_channel.h" | 14 #include "content/common/gpu/gpu_channel.h" |
| 15 #include "content/common/gpu/gpu_channel_manager.h" | 15 #include "content/common/gpu/gpu_channel_manager.h" |
| 16 #include "content/common/gpu/gpu_command_buffer_stub.h" | 16 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 17 #include "content/common/gpu/gpu_memory_manager.h" | 17 #include "content/common/gpu/gpu_memory_manager.h" |
| 18 #include "content/common/gpu/gpu_memory_tracking.h" | 18 #include "content/common/gpu/gpu_memory_tracking.h" |
| 19 #include "content/common/gpu/gpu_messages.h" | 19 #include "content/common/gpu/gpu_messages.h" |
| 20 #include "content/common/gpu/gpu_watchdog.h" | 20 #include "content/common/gpu/gpu_watchdog.h" |
| 21 #include "content/common/gpu/image_transport_surface.h" | 21 #include "content/common/gpu/image_transport_surface.h" |
| 22 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" | 22 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
| 23 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" | 23 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" |
| 24 #include "content/public/common/content_client.h" | 24 #include "content/public/common/content_client.h" |
| 25 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
| 26 #include "gpu/command_buffer/common/constants.h" | 26 #include "gpu/command_buffer/common/constants.h" |
| 27 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 27 #include "gpu/command_buffer/common/mailbox.h" | 28 #include "gpu/command_buffer/common/mailbox.h" |
| 28 #include "gpu/command_buffer/common/sync_token.h" | |
| 29 #include "gpu/command_buffer/service/gl_context_virtual.h" | 29 #include "gpu/command_buffer/service/gl_context_virtual.h" |
| 30 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" | 30 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" |
| 31 #include "gpu/command_buffer/service/image_factory.h" | 31 #include "gpu/command_buffer/service/image_factory.h" |
| 32 #include "gpu/command_buffer/service/image_manager.h" | 32 #include "gpu/command_buffer/service/image_manager.h" |
| 33 #include "gpu/command_buffer/service/logger.h" | 33 #include "gpu/command_buffer/service/logger.h" |
| 34 #include "gpu/command_buffer/service/mailbox_manager.h" | 34 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 35 #include "gpu/command_buffer/service/memory_tracking.h" | 35 #include "gpu/command_buffer/service/memory_tracking.h" |
| 36 #include "gpu/command_buffer/service/query_manager.h" | 36 #include "gpu/command_buffer/service/query_manager.h" |
| 37 #include "gpu/command_buffer/service/sync_point_manager.h" | 37 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 38 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 38 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 DCHECK(!sync_points_.empty() && sync_points_.front() == sync_point); | 933 DCHECK(!sync_points_.empty() && sync_points_.front() == sync_point); |
| 934 sync_points_.pop_front(); | 934 sync_points_.pop_front(); |
| 935 | 935 |
| 936 gpu::gles2::MailboxManager* mailbox_manager = | 936 gpu::gles2::MailboxManager* mailbox_manager = |
| 937 context_group_->mailbox_manager(); | 937 context_group_->mailbox_manager(); |
| 938 if (mailbox_manager->UsesSync() && MakeCurrent()) { | 938 if (mailbox_manager->UsesSync() && MakeCurrent()) { |
| 939 // Old sync points are global and do not have a command buffer ID, | 939 // Old sync points are global and do not have a command buffer ID, |
| 940 // We can simply use the global sync point number as the release count with | 940 // We can simply use the global sync point number as the release count with |
| 941 // 0 for the command buffer ID (under normal circumstances 0 is invalid so | 941 // 0 for the command buffer ID (under normal circumstances 0 is invalid so |
| 942 // will not be used) until the old sync points are replaced. | 942 // will not be used) until the old sync points are replaced. |
| 943 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, | 943 gpu::gles2::SyncToken sync_token = {gpu::CommandBufferNamespace::GPU_IO, 0, |
| 944 0, | 944 sync_point}; |
| 945 sync_point); | |
| 946 mailbox_manager->PushTextureUpdates(sync_token); | 945 mailbox_manager->PushTextureUpdates(sync_token); |
| 947 } | 946 } |
| 948 | 947 |
| 949 GpuChannelManager* manager = channel_->gpu_channel_manager(); | 948 GpuChannelManager* manager = channel_->gpu_channel_manager(); |
| 950 manager->sync_point_manager()->RetireSyncPoint(sync_point); | 949 manager->sync_point_manager()->RetireSyncPoint(sync_point); |
| 951 } | 950 } |
| 952 | 951 |
| 953 bool GpuCommandBufferStub::OnWaitSyncPoint(uint32 sync_point) { | 952 bool GpuCommandBufferStub::OnWaitSyncPoint(uint32 sync_point) { |
| 954 DCHECK(!waiting_for_sync_point_); | 953 DCHECK(!waiting_for_sync_point_); |
| 955 DCHECK(scheduler_->scheduled()); | 954 DCHECK(scheduler_->scheduled()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 scheduler_->SetScheduled(true); | 991 scheduler_->SetScheduled(true); |
| 993 } | 992 } |
| 994 | 993 |
| 995 void GpuCommandBufferStub::PullTextureUpdates( | 994 void GpuCommandBufferStub::PullTextureUpdates( |
| 996 gpu::CommandBufferNamespace namespace_id, | 995 gpu::CommandBufferNamespace namespace_id, |
| 997 uint64_t command_buffer_id, | 996 uint64_t command_buffer_id, |
| 998 uint32_t release) { | 997 uint32_t release) { |
| 999 gpu::gles2::MailboxManager* mailbox_manager = | 998 gpu::gles2::MailboxManager* mailbox_manager = |
| 1000 context_group_->mailbox_manager(); | 999 context_group_->mailbox_manager(); |
| 1001 if (mailbox_manager->UsesSync() && MakeCurrent()) { | 1000 if (mailbox_manager->UsesSync() && MakeCurrent()) { |
| 1002 gpu::SyncToken sync_token(namespace_id, command_buffer_id, release); | 1001 gpu::gles2::SyncToken sync_token = {namespace_id, command_buffer_id, |
| 1002 release}; |
| 1003 mailbox_manager->PullTextureUpdates(sync_token); | 1003 mailbox_manager->PullTextureUpdates(sync_token); |
| 1004 } | 1004 } |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 void GpuCommandBufferStub::OnSignalSyncPoint(uint32 sync_point, uint32 id) { | 1007 void GpuCommandBufferStub::OnSignalSyncPoint(uint32 sync_point, uint32 id) { |
| 1008 GpuChannelManager* manager = channel_->gpu_channel_manager(); | 1008 GpuChannelManager* manager = channel_->gpu_channel_manager(); |
| 1009 manager->sync_point_manager()->AddSyncPointCallback( | 1009 manager->sync_point_manager()->AddSyncPointCallback( |
| 1010 sync_point, | 1010 sync_point, |
| 1011 base::Bind(&RunOnThread, task_runner_, | 1011 base::Bind(&RunOnThread, task_runner_, |
| 1012 base::Bind(&GpuCommandBufferStub::OnSignalSyncPointAck, | 1012 base::Bind(&GpuCommandBufferStub::OnSignalSyncPointAck, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1038 | 1038 |
| 1039 void GpuCommandBufferStub::OnFenceSyncRelease(uint64_t release) { | 1039 void GpuCommandBufferStub::OnFenceSyncRelease(uint64_t release) { |
| 1040 if (sync_point_client_->client_state()->IsFenceSyncReleased(release)) { | 1040 if (sync_point_client_->client_state()->IsFenceSyncReleased(release)) { |
| 1041 DLOG(ERROR) << "Fence Sync has already been released."; | 1041 DLOG(ERROR) << "Fence Sync has already been released."; |
| 1042 return; | 1042 return; |
| 1043 } | 1043 } |
| 1044 | 1044 |
| 1045 gpu::gles2::MailboxManager* mailbox_manager = | 1045 gpu::gles2::MailboxManager* mailbox_manager = |
| 1046 context_group_->mailbox_manager(); | 1046 context_group_->mailbox_manager(); |
| 1047 if (mailbox_manager->UsesSync() && MakeCurrent()) { | 1047 if (mailbox_manager->UsesSync() && MakeCurrent()) { |
| 1048 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, | 1048 gpu::gles2::SyncToken sync_token = {gpu::CommandBufferNamespace::GPU_IO, |
| 1049 command_buffer_id_, | 1049 command_buffer_id_, release}; |
| 1050 release); | |
| 1051 mailbox_manager->PushTextureUpdates(sync_token); | 1050 mailbox_manager->PushTextureUpdates(sync_token); |
| 1052 } | 1051 } |
| 1053 | 1052 |
| 1054 sync_point_client_->ReleaseFenceSync(release); | 1053 sync_point_client_->ReleaseFenceSync(release); |
| 1055 } | 1054 } |
| 1056 | 1055 |
| 1057 bool GpuCommandBufferStub::OnWaitFenceSync( | 1056 bool GpuCommandBufferStub::OnWaitFenceSync( |
| 1058 gpu::CommandBufferNamespace namespace_id, | 1057 gpu::CommandBufferNamespace namespace_id, |
| 1059 uint64_t command_buffer_id, | 1058 uint64_t command_buffer_id, |
| 1060 uint64_t release) { | 1059 uint64_t release) { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 result)); | 1271 result)); |
| 1273 } | 1272 } |
| 1274 | 1273 |
| 1275 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1274 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
| 1276 base::TimeDelta interval) { | 1275 base::TimeDelta interval) { |
| 1277 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1276 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
| 1278 interval)); | 1277 interval)); |
| 1279 } | 1278 } |
| 1280 | 1279 |
| 1281 } // namespace content | 1280 } // namespace content |
| OLD | NEW |