OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "gpu/command_buffer/service/in_process_command_buffer.h" | 5 #include "gpu/command_buffer/service/in_process_command_buffer.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/sequence_checker.h" | 18 #include "base/sequence_checker.h" |
19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
20 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
21 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 21 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
22 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 22 #include "gpu/command_buffer/common/sync_token.h" |
23 #include "gpu/command_buffer/common/value_state.h" | 23 #include "gpu/command_buffer/common/value_state.h" |
24 #include "gpu/command_buffer/service/command_buffer_service.h" | 24 #include "gpu/command_buffer/service/command_buffer_service.h" |
25 #include "gpu/command_buffer/service/context_group.h" | 25 #include "gpu/command_buffer/service/context_group.h" |
26 #include "gpu/command_buffer/service/gl_context_virtual.h" | 26 #include "gpu/command_buffer/service/gl_context_virtual.h" |
27 #include "gpu/command_buffer/service/gpu_scheduler.h" | 27 #include "gpu/command_buffer/service/gpu_scheduler.h" |
28 #include "gpu/command_buffer/service/gpu_switches.h" | 28 #include "gpu/command_buffer/service/gpu_switches.h" |
29 #include "gpu/command_buffer/service/image_factory.h" | 29 #include "gpu/command_buffer/service/image_factory.h" |
30 #include "gpu/command_buffer/service/image_manager.h" | 30 #include "gpu/command_buffer/service/image_manager.h" |
31 #include "gpu/command_buffer/service/mailbox_manager.h" | 31 #include "gpu/command_buffer/service/mailbox_manager.h" |
32 #include "gpu/command_buffer/service/memory_program_cache.h" | 32 #include "gpu/command_buffer/service/memory_program_cache.h" |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 bool make_current_success = false; | 810 bool make_current_success = false; |
811 { | 811 { |
812 base::AutoLock lock(command_buffer_lock_); | 812 base::AutoLock lock(command_buffer_lock_); |
813 make_current_success = MakeCurrent(); | 813 make_current_success = MakeCurrent(); |
814 } | 814 } |
815 if (make_current_success) { | 815 if (make_current_success) { |
816 // Old sync points are global and do not have a command buffer ID, | 816 // Old sync points are global and do not have a command buffer ID, |
817 // We can simply use the GPUIO namespace with 0 for the command buffer ID | 817 // We can simply use the GPUIO namespace with 0 for the command buffer ID |
818 // (under normal circumstances 0 is invalid so will not be used) until | 818 // (under normal circumstances 0 is invalid so will not be used) until |
819 // the old sync points are replaced. | 819 // the old sync points are replaced. |
820 gles2::SyncToken sync_token = {gpu::CommandBufferNamespace::GPU_IO, 0, | 820 SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, sync_point); |
821 sync_point}; | |
822 mailbox_manager->PushTextureUpdates(sync_token); | 821 mailbox_manager->PushTextureUpdates(sync_token); |
823 } | 822 } |
824 } | 823 } |
825 service_->sync_point_manager()->RetireSyncPoint(sync_point); | 824 service_->sync_point_manager()->RetireSyncPoint(sync_point); |
826 } | 825 } |
827 | 826 |
828 void InProcessCommandBuffer::SignalSyncPoint(unsigned sync_point, | 827 void InProcessCommandBuffer::SignalSyncPoint(unsigned sync_point, |
829 const base::Closure& callback) { | 828 const base::Closure& callback) { |
830 CheckSequencedThread(); | 829 CheckSequencedThread(); |
831 QueueTask(base::Bind(&InProcessCommandBuffer::SignalSyncPointOnGpuThread, | 830 QueueTask(base::Bind(&InProcessCommandBuffer::SignalSyncPointOnGpuThread, |
832 base::Unretained(this), | 831 base::Unretained(this), |
833 sync_point, | 832 sync_point, |
834 WrapCallback(callback))); | 833 WrapCallback(callback))); |
835 } | 834 } |
836 | 835 |
837 bool InProcessCommandBuffer::WaitSyncPointOnGpuThread(unsigned sync_point) { | 836 bool InProcessCommandBuffer::WaitSyncPointOnGpuThread(unsigned sync_point) { |
838 service_->sync_point_manager()->WaitSyncPoint(sync_point); | 837 service_->sync_point_manager()->WaitSyncPoint(sync_point); |
839 gles2::MailboxManager* mailbox_manager = | 838 gles2::MailboxManager* mailbox_manager = |
840 decoder_->GetContextGroup()->mailbox_manager(); | 839 decoder_->GetContextGroup()->mailbox_manager(); |
841 // Old sync points are global and do not have a command buffer ID, | 840 // Old sync points are global and do not have a command buffer ID, |
842 // We can simply use the GPUIO namespace with 0 for the command buffer ID | 841 // We can simply use the GPUIO namespace with 0 for the command buffer ID |
843 // (under normal circumstances 0 is invalid so will not be used) until | 842 // (under normal circumstances 0 is invalid so will not be used) until |
844 // the old sync points are replaced. | 843 // the old sync points are replaced. |
845 gles2::SyncToken sync_token = {gpu::CommandBufferNamespace::GPU_IO, 0, | 844 SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, sync_point); |
846 sync_point}; | |
847 mailbox_manager->PullTextureUpdates(sync_token); | 845 mailbox_manager->PullTextureUpdates(sync_token); |
848 return true; | 846 return true; |
849 } | 847 } |
850 | 848 |
851 void InProcessCommandBuffer::FenceSyncReleaseOnGpuThread(uint64_t release) { | 849 void InProcessCommandBuffer::FenceSyncReleaseOnGpuThread(uint64_t release) { |
852 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release)); | 850 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release)); |
853 gles2::MailboxManager* mailbox_manager = | 851 gles2::MailboxManager* mailbox_manager = |
854 decoder_->GetContextGroup()->mailbox_manager(); | 852 decoder_->GetContextGroup()->mailbox_manager(); |
855 if (mailbox_manager->UsesSync()) { | 853 if (mailbox_manager->UsesSync()) { |
856 bool make_current_success = false; | 854 bool make_current_success = false; |
857 { | 855 { |
858 base::AutoLock lock(command_buffer_lock_); | 856 base::AutoLock lock(command_buffer_lock_); |
859 make_current_success = MakeCurrent(); | 857 make_current_success = MakeCurrent(); |
860 } | 858 } |
861 if (make_current_success) { | 859 if (make_current_success) { |
862 gles2::SyncToken sync_token = {GetNamespaceID(), GetCommandBufferID(), | 860 SyncToken sync_token(GetNamespaceID(), GetCommandBufferID(), release); |
863 release}; | |
864 mailbox_manager->PushTextureUpdates(sync_token); | 861 mailbox_manager->PushTextureUpdates(sync_token); |
865 } | 862 } |
866 } | 863 } |
867 | 864 |
868 sync_point_client_->ReleaseFenceSync(release); | 865 sync_point_client_->ReleaseFenceSync(release); |
869 } | 866 } |
870 | 867 |
871 bool InProcessCommandBuffer::WaitFenceSyncOnGpuThread( | 868 bool InProcessCommandBuffer::WaitFenceSyncOnGpuThread( |
872 gpu::CommandBufferNamespace namespace_id, | 869 gpu::CommandBufferNamespace namespace_id, |
873 uint64_t command_buffer_id, | 870 uint64_t command_buffer_id, |
(...skipping 12 matching lines...) Expand all Loading... |
886 // Use waitable event which is signalled when the release fence is released. | 883 // Use waitable event which is signalled when the release fence is released. |
887 sync_point_client_->Wait( | 884 sync_point_client_->Wait( |
888 release_state.get(), release, | 885 release_state.get(), release, |
889 base::Bind(&base::WaitableEvent::Signal, | 886 base::Bind(&base::WaitableEvent::Signal, |
890 base::Unretained(&fence_sync_wait_event_))); | 887 base::Unretained(&fence_sync_wait_event_))); |
891 fence_sync_wait_event_.Wait(); | 888 fence_sync_wait_event_.Wait(); |
892 } | 889 } |
893 | 890 |
894 gles2::MailboxManager* mailbox_manager = | 891 gles2::MailboxManager* mailbox_manager = |
895 decoder_->GetContextGroup()->mailbox_manager(); | 892 decoder_->GetContextGroup()->mailbox_manager(); |
896 gles2::SyncToken sync_token = {namespace_id, command_buffer_id, release}; | 893 SyncToken sync_token(namespace_id, command_buffer_id, release); |
897 mailbox_manager->PullTextureUpdates(sync_token); | 894 mailbox_manager->PullTextureUpdates(sync_token); |
898 return true; | 895 return true; |
899 } | 896 } |
900 | 897 |
901 void InProcessCommandBuffer::SignalSyncPointOnGpuThread( | 898 void InProcessCommandBuffer::SignalSyncPointOnGpuThread( |
902 unsigned sync_point, | 899 unsigned sync_point, |
903 const base::Closure& callback) { | 900 const base::Closure& callback) { |
904 service_->sync_point_manager()->AddSyncPointCallback(sync_point, callback); | 901 service_->sync_point_manager()->AddSyncPointCallback(sync_point, callback); |
905 } | 902 } |
906 | 903 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 framebuffer_completeness_cache_ = | 1074 framebuffer_completeness_cache_ = |
1078 new gpu::gles2::FramebufferCompletenessCache; | 1075 new gpu::gles2::FramebufferCompletenessCache; |
1079 return framebuffer_completeness_cache_; | 1076 return framebuffer_completeness_cache_; |
1080 } | 1077 } |
1081 | 1078 |
1082 SyncPointManager* GpuInProcessThread::sync_point_manager() { | 1079 SyncPointManager* GpuInProcessThread::sync_point_manager() { |
1083 return sync_point_manager_; | 1080 return sync_point_manager_; |
1084 } | 1081 } |
1085 | 1082 |
1086 } // namespace gpu | 1083 } // namespace gpu |
OLD | NEW |