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 "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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 | 259 |
260 bool put_offset_changed = last_put_offset_ != put_offset; | 260 bool put_offset_changed = last_put_offset_ != put_offset; |
261 last_put_offset_ = put_offset; | 261 last_put_offset_ = put_offset; |
262 last_barrier_put_offset_ = put_offset; | 262 last_barrier_put_offset_ = put_offset; |
263 | 263 |
264 if (channel_) { | 264 if (channel_) { |
265 uint32_t highest_verified_flush_id; | 265 uint32_t highest_verified_flush_id; |
266 const uint32_t flush_id = channel_->OrderingBarrier( | 266 const uint32_t flush_id = channel_->OrderingBarrier( |
267 route_id_, stream_id_, put_offset, ++flush_count_, latency_info_, | 267 route_id_, stream_id_, put_offset, ++flush_count_, latency_info_, |
268 put_offset_changed, true, &highest_verified_flush_id); | 268 put_offset_changed, true, &highest_verified_flush_id); |
269 UpdateVerifiedReleases(highest_verified_flush_id); | |
270 if (put_offset_changed) { | 269 if (put_offset_changed) { |
271 DCHECK(flush_id); | 270 DCHECK(flush_id); |
272 const uint64_t fence_sync_release = next_fence_sync_release_ - 1; | 271 const uint64_t fence_sync_release = next_fence_sync_release_ - 1; |
273 if (fence_sync_release > flushed_fence_sync_release_) { | 272 if (fence_sync_release > flushed_fence_sync_release_) { |
274 flushed_fence_sync_release_ = fence_sync_release; | 273 flushed_fence_sync_release_ = fence_sync_release; |
275 flushed_release_flush_id_.push( | 274 flushed_release_flush_id_.push( |
276 std::make_pair(fence_sync_release, flush_id)); | 275 std::make_pair(fence_sync_release, flush_id)); |
277 } | 276 } |
277 CleanupFlushedReleases(highest_verified_flush_id); | |
piman
2016/09/07 23:49:10
nit: any reason to only do that when put_offset_ch
| |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 if (put_offset_changed) | 281 if (put_offset_changed) |
282 latency_info_.clear(); | 282 latency_info_.clear(); |
283 } | 283 } |
284 | 284 |
285 void CommandBufferProxyImpl::OrderingBarrier(int32_t put_offset) { | 285 void CommandBufferProxyImpl::OrderingBarrier(int32_t put_offset) { |
286 CheckLock(); | 286 CheckLock(); |
287 if (last_state_.error != gpu::error::kNoError) | 287 if (last_state_.error != gpu::error::kNoError) |
288 return; | 288 return; |
289 | 289 |
290 TRACE_EVENT1("gpu", "CommandBufferProxyImpl::OrderingBarrier", "put_offset", | 290 TRACE_EVENT1("gpu", "CommandBufferProxyImpl::OrderingBarrier", "put_offset", |
291 put_offset); | 291 put_offset); |
292 | 292 |
293 bool put_offset_changed = last_barrier_put_offset_ != put_offset; | 293 bool put_offset_changed = last_barrier_put_offset_ != put_offset; |
294 last_barrier_put_offset_ = put_offset; | 294 last_barrier_put_offset_ = put_offset; |
295 | 295 |
296 if (channel_) { | 296 if (channel_) { |
297 uint32_t highest_verified_flush_id; | 297 uint32_t highest_verified_flush_id; |
298 const uint32_t flush_id = channel_->OrderingBarrier( | 298 const uint32_t flush_id = channel_->OrderingBarrier( |
299 route_id_, stream_id_, put_offset, ++flush_count_, latency_info_, | 299 route_id_, stream_id_, put_offset, ++flush_count_, latency_info_, |
300 put_offset_changed, false, &highest_verified_flush_id); | 300 put_offset_changed, false, &highest_verified_flush_id); |
301 UpdateVerifiedReleases(highest_verified_flush_id); | |
302 | 301 |
303 if (put_offset_changed) { | 302 if (put_offset_changed) { |
304 DCHECK(flush_id); | 303 DCHECK(flush_id); |
305 const uint64_t fence_sync_release = next_fence_sync_release_ - 1; | 304 const uint64_t fence_sync_release = next_fence_sync_release_ - 1; |
306 if (fence_sync_release > flushed_fence_sync_release_) { | 305 if (fence_sync_release > flushed_fence_sync_release_) { |
307 flushed_fence_sync_release_ = fence_sync_release; | 306 flushed_fence_sync_release_ = fence_sync_release; |
308 flushed_release_flush_id_.push( | 307 flushed_release_flush_id_.push( |
309 std::make_pair(fence_sync_release, flush_id)); | 308 std::make_pair(fence_sync_release, flush_id)); |
310 } | 309 } |
310 CleanupFlushedReleases(highest_verified_flush_id); | |
311 } | 311 } |
312 } | 312 } |
313 | 313 |
314 if (put_offset_changed) | 314 if (put_offset_changed) |
315 latency_info_.clear(); | 315 latency_info_.clear(); |
316 } | 316 } |
317 | 317 |
318 void CommandBufferProxyImpl::SetLatencyInfo( | 318 void CommandBufferProxyImpl::SetLatencyInfo( |
319 const std::vector<ui::LatencyInfo>& latency_info) { | 319 const std::vector<ui::LatencyInfo>& latency_info) { |
320 CheckLock(); | 320 CheckLock(); |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
739 while (!flushed_release_flush_id_.empty()) { | 739 while (!flushed_release_flush_id_.empty()) { |
740 const std::pair<uint64_t, uint32_t>& front_item = | 740 const std::pair<uint64_t, uint32_t>& front_item = |
741 flushed_release_flush_id_.front(); | 741 flushed_release_flush_id_.front(); |
742 if (front_item.second > verified_flush) | 742 if (front_item.second > verified_flush) |
743 break; | 743 break; |
744 verified_fence_sync_release_ = front_item.first; | 744 verified_fence_sync_release_ = front_item.first; |
745 flushed_release_flush_id_.pop(); | 745 flushed_release_flush_id_.pop(); |
746 } | 746 } |
747 } | 747 } |
748 | 748 |
749 void CommandBufferProxyImpl::CleanupFlushedReleases( | |
750 uint32_t highest_verified_flush_id) { | |
751 DCHECK(channel_); | |
752 static const uint32_t kMaxUnverifiedFlushes = 1000; | |
753 if (flushed_release_flush_id_.size() > kMaxUnverifiedFlushes) { | |
754 // Prevent list of unverified flushes from growing indefinitely. | |
755 highest_verified_flush_id = | |
756 channel_->ValidateFlushIDReachedServer(stream_id_, false); | |
757 } | |
758 UpdateVerifiedReleases(highest_verified_flush_id); | |
759 } | |
760 | |
749 gpu::CommandBufferSharedState* CommandBufferProxyImpl::shared_state() const { | 761 gpu::CommandBufferSharedState* CommandBufferProxyImpl::shared_state() const { |
750 return reinterpret_cast<gpu::CommandBufferSharedState*>( | 762 return reinterpret_cast<gpu::CommandBufferSharedState*>( |
751 shared_state_shm_->memory()); | 763 shared_state_shm_->memory()); |
752 } | 764 } |
753 | 765 |
754 void CommandBufferProxyImpl::OnSwapBuffersCompleted( | 766 void CommandBufferProxyImpl::OnSwapBuffersCompleted( |
755 const GpuCommandBufferMsg_SwapBuffersCompleted_Params& params) { | 767 const GpuCommandBufferMsg_SwapBuffersCompleted_Params& params) { |
756 #if defined(OS_MACOSX) | 768 #if defined(OS_MACOSX) |
757 gpu::GpuProcessHostedCALayerTreeParamsMac params_mac; | 769 gpu::GpuProcessHostedCALayerTreeParamsMac params_mac; |
758 params_mac.surface_handle = params.surface_handle; | 770 params_mac.surface_handle = params.surface_handle; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 return; | 868 return; |
857 channel_->FlushPendingStream(stream_id_); | 869 channel_->FlushPendingStream(stream_id_); |
858 channel_->Send(new GpuChannelMsg_DestroyCommandBuffer(route_id_)); | 870 channel_->Send(new GpuChannelMsg_DestroyCommandBuffer(route_id_)); |
859 channel_->RemoveRoute(route_id_); | 871 channel_->RemoveRoute(route_id_); |
860 channel_ = nullptr; | 872 channel_ = nullptr; |
861 if (gpu_control_client_) | 873 if (gpu_control_client_) |
862 gpu_control_client_->OnGpuControlLostContext(); | 874 gpu_control_client_->OnGpuControlLostContext(); |
863 } | 875 } |
864 | 876 |
865 } // namespace gpu | 877 } // namespace gpu |
OLD | NEW |