| 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 |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 DCHECK_EQ(fence_sync - 1, flushed_fence_sync_release_); | 699 DCHECK_EQ(fence_sync - 1, flushed_fence_sync_release_); |
| 700 } | 700 } |
| 701 | 701 |
| 702 QueueTask(base::Bind(&InProcessCommandBuffer::CreateImageOnGpuThread, | 702 QueueTask(base::Bind(&InProcessCommandBuffer::CreateImageOnGpuThread, |
| 703 base::Unretained(this), new_id, handle, | 703 base::Unretained(this), new_id, handle, |
| 704 gfx::Size(width, height), gpu_memory_buffer->GetFormat(), | 704 gfx::Size(width, height), gpu_memory_buffer->GetFormat(), |
| 705 internalformat, order_num, fence_sync)); | 705 internalformat, order_num, fence_sync)); |
| 706 | 706 |
| 707 if (fence_sync) { | 707 if (fence_sync) { |
| 708 flushed_fence_sync_release_ = fence_sync; | 708 flushed_fence_sync_release_ = fence_sync; |
| 709 SyncToken sync_token(GetNamespaceID(), GetCommandBufferID(), fence_sync); | 709 SyncToken sync_token(GetNamespaceID(), GetExtraCommandBufferData(), |
| 710 GetCommandBufferID(), fence_sync); |
| 710 sync_token.SetVerifyFlush(); | 711 sync_token.SetVerifyFlush(); |
| 711 gpu_memory_buffer_manager_->SetDestructionSyncToken(gpu_memory_buffer, | 712 gpu_memory_buffer_manager_->SetDestructionSyncToken(gpu_memory_buffer, |
| 712 sync_token); | 713 sync_token); |
| 713 } | 714 } |
| 714 | 715 |
| 715 return new_id; | 716 return new_id; |
| 716 } | 717 } |
| 717 | 718 |
| 718 void InProcessCommandBuffer::CreateImageOnGpuThread( | 719 void InProcessCommandBuffer::CreateImageOnGpuThread( |
| 719 int32 id, | 720 int32 id, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 bool make_current_success = false; | 846 bool make_current_success = false; |
| 846 { | 847 { |
| 847 base::AutoLock lock(command_buffer_lock_); | 848 base::AutoLock lock(command_buffer_lock_); |
| 848 make_current_success = MakeCurrent(); | 849 make_current_success = MakeCurrent(); |
| 849 } | 850 } |
| 850 if (make_current_success) { | 851 if (make_current_success) { |
| 851 // Old sync points are global and do not have a command buffer ID, | 852 // Old sync points are global and do not have a command buffer ID, |
| 852 // We can simply use the GPUIO namespace with 0 for the command buffer ID | 853 // We can simply use the GPUIO namespace with 0 for the command buffer ID |
| 853 // (under normal circumstances 0 is invalid so will not be used) until | 854 // (under normal circumstances 0 is invalid so will not be used) until |
| 854 // the old sync points are replaced. | 855 // the old sync points are replaced. |
| 855 SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, sync_point); | 856 SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 0, |
| 857 sync_point); |
| 856 mailbox_manager->PushTextureUpdates(sync_token); | 858 mailbox_manager->PushTextureUpdates(sync_token); |
| 857 } | 859 } |
| 858 } | 860 } |
| 859 service_->sync_point_manager()->RetireSyncPoint(sync_point); | 861 service_->sync_point_manager()->RetireSyncPoint(sync_point); |
| 860 } | 862 } |
| 861 | 863 |
| 862 void InProcessCommandBuffer::SignalSyncPoint(unsigned sync_point, | 864 void InProcessCommandBuffer::SignalSyncPoint(unsigned sync_point, |
| 863 const base::Closure& callback) { | 865 const base::Closure& callback) { |
| 864 service_->sync_point_manager()->AddSyncPointCallback(sync_point, | 866 service_->sync_point_manager()->AddSyncPointCallback(sync_point, |
| 865 WrapCallback(callback)); | 867 WrapCallback(callback)); |
| 866 } | 868 } |
| 867 | 869 |
| 868 bool InProcessCommandBuffer::WaitSyncPointOnGpuThread(unsigned sync_point) { | 870 bool InProcessCommandBuffer::WaitSyncPointOnGpuThread(unsigned sync_point) { |
| 869 service_->sync_point_manager()->WaitSyncPoint(sync_point); | 871 service_->sync_point_manager()->WaitSyncPoint(sync_point); |
| 870 gles2::MailboxManager* mailbox_manager = | 872 gles2::MailboxManager* mailbox_manager = |
| 871 decoder_->GetContextGroup()->mailbox_manager(); | 873 decoder_->GetContextGroup()->mailbox_manager(); |
| 872 // Old sync points are global and do not have a command buffer ID, | 874 // Old sync points are global and do not have a command buffer ID, |
| 873 // We can simply use the GPUIO namespace with 0 for the command buffer ID | 875 // We can simply use the GPUIO namespace with 0 for the command buffer ID |
| 874 // (under normal circumstances 0 is invalid so will not be used) until | 876 // (under normal circumstances 0 is invalid so will not be used) until |
| 875 // the old sync points are replaced. | 877 // the old sync points are replaced. |
| 876 SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, sync_point); | 878 SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, 0, 0, sync_point); |
| 877 mailbox_manager->PullTextureUpdates(sync_token); | 879 mailbox_manager->PullTextureUpdates(sync_token); |
| 878 return true; | 880 return true; |
| 879 } | 881 } |
| 880 | 882 |
| 881 void InProcessCommandBuffer::FenceSyncReleaseOnGpuThread(uint64_t release) { | 883 void InProcessCommandBuffer::FenceSyncReleaseOnGpuThread(uint64_t release) { |
| 882 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release)); | 884 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release)); |
| 883 gles2::MailboxManager* mailbox_manager = | 885 gles2::MailboxManager* mailbox_manager = |
| 884 decoder_->GetContextGroup()->mailbox_manager(); | 886 decoder_->GetContextGroup()->mailbox_manager(); |
| 885 if (mailbox_manager->UsesSync()) { | 887 if (mailbox_manager->UsesSync()) { |
| 886 bool make_current_success = false; | 888 bool make_current_success = false; |
| 887 { | 889 { |
| 888 base::AutoLock lock(command_buffer_lock_); | 890 base::AutoLock lock(command_buffer_lock_); |
| 889 make_current_success = MakeCurrent(); | 891 make_current_success = MakeCurrent(); |
| 890 } | 892 } |
| 891 if (make_current_success) { | 893 if (make_current_success) { |
| 892 SyncToken sync_token(GetNamespaceID(), GetCommandBufferID(), release); | 894 SyncToken sync_token(GetNamespaceID(), GetExtraCommandBufferData(), |
| 895 GetCommandBufferID(), release); |
| 893 mailbox_manager->PushTextureUpdates(sync_token); | 896 mailbox_manager->PushTextureUpdates(sync_token); |
| 894 } | 897 } |
| 895 } | 898 } |
| 896 | 899 |
| 897 sync_point_client_->ReleaseFenceSync(release); | 900 sync_point_client_->ReleaseFenceSync(release); |
| 898 } | 901 } |
| 899 | 902 |
| 900 bool InProcessCommandBuffer::WaitFenceSyncOnGpuThread( | 903 bool InProcessCommandBuffer::WaitFenceSyncOnGpuThread( |
| 901 gpu::CommandBufferNamespace namespace_id, | 904 gpu::CommandBufferNamespace namespace_id, |
| 902 uint64_t command_buffer_id, | 905 uint64_t command_buffer_id, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 915 // Use waitable event which is signalled when the release fence is released. | 918 // Use waitable event which is signalled when the release fence is released. |
| 916 sync_point_client_->Wait( | 919 sync_point_client_->Wait( |
| 917 release_state.get(), release, | 920 release_state.get(), release, |
| 918 base::Bind(&base::WaitableEvent::Signal, | 921 base::Bind(&base::WaitableEvent::Signal, |
| 919 base::Unretained(&fence_sync_wait_event_))); | 922 base::Unretained(&fence_sync_wait_event_))); |
| 920 fence_sync_wait_event_.Wait(); | 923 fence_sync_wait_event_.Wait(); |
| 921 } | 924 } |
| 922 | 925 |
| 923 gles2::MailboxManager* mailbox_manager = | 926 gles2::MailboxManager* mailbox_manager = |
| 924 decoder_->GetContextGroup()->mailbox_manager(); | 927 decoder_->GetContextGroup()->mailbox_manager(); |
| 925 SyncToken sync_token(namespace_id, command_buffer_id, release); | 928 SyncToken sync_token(namespace_id, 0, command_buffer_id, release); |
| 926 mailbox_manager->PullTextureUpdates(sync_token); | 929 mailbox_manager->PullTextureUpdates(sync_token); |
| 927 return true; | 930 return true; |
| 928 } | 931 } |
| 929 | 932 |
| 930 void InProcessCommandBuffer::SignalSyncTokenOnGpuThread( | 933 void InProcessCommandBuffer::SignalSyncTokenOnGpuThread( |
| 931 const SyncToken& sync_token, const base::Closure& callback) { | 934 const SyncToken& sync_token, const base::Closure& callback) { |
| 932 gpu::SyncPointManager* sync_point_manager = service_->sync_point_manager(); | 935 gpu::SyncPointManager* sync_point_manager = service_->sync_point_manager(); |
| 933 DCHECK(sync_point_manager); | 936 DCHECK(sync_point_manager); |
| 934 | 937 |
| 935 scoped_refptr<gpu::SyncPointClientState> release_state = | 938 scoped_refptr<gpu::SyncPointClientState> release_state = |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 } | 982 } |
| 980 | 983 |
| 981 CommandBufferNamespace InProcessCommandBuffer::GetNamespaceID() const { | 984 CommandBufferNamespace InProcessCommandBuffer::GetNamespaceID() const { |
| 982 return CommandBufferNamespace::IN_PROCESS; | 985 return CommandBufferNamespace::IN_PROCESS; |
| 983 } | 986 } |
| 984 | 987 |
| 985 uint64_t InProcessCommandBuffer::GetCommandBufferID() const { | 988 uint64_t InProcessCommandBuffer::GetCommandBufferID() const { |
| 986 return command_buffer_id_; | 989 return command_buffer_id_; |
| 987 } | 990 } |
| 988 | 991 |
| 992 int32_t InProcessCommandBuffer::GetExtraCommandBufferData() const { |
| 993 return 0; |
| 994 } |
| 995 |
| 989 uint64_t InProcessCommandBuffer::GenerateFenceSyncRelease() { | 996 uint64_t InProcessCommandBuffer::GenerateFenceSyncRelease() { |
| 990 return next_fence_sync_release_++; | 997 return next_fence_sync_release_++; |
| 991 } | 998 } |
| 992 | 999 |
| 993 bool InProcessCommandBuffer::IsFenceSyncRelease(uint64_t release) { | 1000 bool InProcessCommandBuffer::IsFenceSyncRelease(uint64_t release) { |
| 994 return release != 0 && release < next_fence_sync_release_; | 1001 return release != 0 && release < next_fence_sync_release_; |
| 995 } | 1002 } |
| 996 | 1003 |
| 997 bool InProcessCommandBuffer::IsFenceSyncFlushed(uint64_t release) { | 1004 bool InProcessCommandBuffer::IsFenceSyncFlushed(uint64_t release) { |
| 998 return release <= flushed_fence_sync_release_; | 1005 return release <= flushed_fence_sync_release_; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 framebuffer_completeness_cache_ = | 1142 framebuffer_completeness_cache_ = |
| 1136 new gpu::gles2::FramebufferCompletenessCache; | 1143 new gpu::gles2::FramebufferCompletenessCache; |
| 1137 return framebuffer_completeness_cache_; | 1144 return framebuffer_completeness_cache_; |
| 1138 } | 1145 } |
| 1139 | 1146 |
| 1140 SyncPointManager* GpuInProcessThread::sync_point_manager() { | 1147 SyncPointManager* GpuInProcessThread::sync_point_manager() { |
| 1141 return sync_point_manager_; | 1148 return sync_point_manager_; |
| 1142 } | 1149 } |
| 1143 | 1150 |
| 1144 } // namespace gpu | 1151 } // namespace gpu |
| OLD | NEW |