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

Side by Side Diff: gpu/ipc/client/command_buffer_proxy_impl.cc

Issue 2383753002: gpu: Add GpuFence framework.
Patch Set: rebase Created 4 years, 1 month 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 #include "gpu/ipc/client/command_buffer_proxy_impl.h" 5 #include "gpu/ipc/client/command_buffer_proxy_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 // catches upwith the command buffer. 657 // catches upwith the command buffer.
658 // A malicious caller trying to create a collision by making next_signal_id 658 // A malicious caller trying to create a collision by making next_signal_id
659 // would have to make calls at an astounding rate (300B/s) and even if they 659 // would have to make calls at an astounding rate (300B/s) and even if they
660 // could do that, all they would do is to prevent some callbacks from getting 660 // could do that, all they would do is to prevent some callbacks from getting
661 // called, leading to stalled threads and/or memory leaks. 661 // called, leading to stalled threads and/or memory leaks.
662 uint32_t signal_id = next_signal_id_++; 662 uint32_t signal_id = next_signal_id_++;
663 Send(new GpuCommandBufferMsg_SignalQuery(route_id_, query, signal_id)); 663 Send(new GpuCommandBufferMsg_SignalQuery(route_id_, query, signal_id));
664 signal_tasks_.insert(std::make_pair(signal_id, callback)); 664 signal_tasks_.insert(std::make_pair(signal_id, callback));
665 } 665 }
666 666
667 int32_t CommandBufferProxyImpl::CreateFence(ClientFence fence) {
668 CheckLock();
669 if (last_state_.error != gpu::error::kNoError)
670 return -1;
671
672 int32_t new_id = channel_->ReserveFenceId();
673
674 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager =
675 channel_->gpu_memory_buffer_manager();
676 gfx::GpuFence* gpu_fence =
677 gpu_memory_buffer_manager->GpuFenceFromClientFence(fence);
678 DCHECK(gpu_fence);
679
680 // This handle is owned by the GPU process and must be passed to it or it
681 // will leak. In otherwords, do not early out on error between here and the
682 // sending of the CreateFence IPC below.
683 gfx::GpuFenceHandle handle =
684 channel_->ShareGpuFenceToGpuProcess(gpu_fence->GetHandle());
685
686 GpuCommandBufferMsg_CreateFence_Params params;
687 params.id = new_id;
688 params.gpu_fence = handle;
689
690 Send(new GpuCommandBufferMsg_CreateFence(route_id_, params));
691
692 return new_id;
693 }
694
695 void CommandBufferProxyImpl::DestroyFence(int32_t id) {
696 CheckLock();
697 if (last_state_.error != gpu::error::kNoError)
698 return;
699
700 Send(new GpuCommandBufferMsg_DestroyFence(route_id_, id));
701 }
702
667 void CommandBufferProxyImpl::TakeFrontBuffer(const gpu::Mailbox& mailbox) { 703 void CommandBufferProxyImpl::TakeFrontBuffer(const gpu::Mailbox& mailbox) {
668 CheckLock(); 704 CheckLock();
669 if (last_state_.error != gpu::error::kNoError) 705 if (last_state_.error != gpu::error::kNoError)
670 return; 706 return;
671 707
672 Send(new GpuCommandBufferMsg_TakeFrontBuffer(route_id_, mailbox)); 708 Send(new GpuCommandBufferMsg_TakeFrontBuffer(route_id_, mailbox));
673 } 709 }
674 710
675 void CommandBufferProxyImpl::ReturnFrontBuffer(const gpu::Mailbox& mailbox, 711 void CommandBufferProxyImpl::ReturnFrontBuffer(const gpu::Mailbox& mailbox,
676 const gpu::SyncToken& sync_token, 712 const gpu::SyncToken& sync_token,
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 return; 902 return;
867 channel_->FlushPendingStream(stream_id_); 903 channel_->FlushPendingStream(stream_id_);
868 channel_->Send(new GpuChannelMsg_DestroyCommandBuffer(route_id_)); 904 channel_->Send(new GpuChannelMsg_DestroyCommandBuffer(route_id_));
869 channel_->RemoveRoute(route_id_); 905 channel_->RemoveRoute(route_id_);
870 channel_ = nullptr; 906 channel_ = nullptr;
871 if (gpu_control_client_) 907 if (gpu_control_client_)
872 gpu_control_client_->OnGpuControlLostContext(); 908 gpu_control_client_->OnGpuControlLostContext();
873 } 909 }
874 910
875 } // namespace gpu 911 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698