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

Side by Side Diff: content/common/gpu/client/command_buffer_proxy_impl.cc

Issue 1331843005: Implemented new fence syncs which replaces the old sync points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Forgot to remove cmd buffer helper functios and replace with gpu control ones Created 5 years, 2 months 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 "content/common/gpu/client/command_buffer_proxy_impl.h" 5 #include "content/common/gpu/client/command_buffer_proxy_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 28 matching lines...) Expand all
39 int32 route_id, 39 int32 route_id,
40 int32 stream_id) 40 int32 stream_id)
41 : lock_(nullptr), 41 : lock_(nullptr),
42 channel_(channel), 42 channel_(channel),
43 command_buffer_id_(CommandBufferProxyID(channel->channel_id(), route_id)), 43 command_buffer_id_(CommandBufferProxyID(channel->channel_id(), route_id)),
44 route_id_(route_id), 44 route_id_(route_id),
45 stream_id_(stream_id), 45 stream_id_(stream_id),
46 flush_count_(0), 46 flush_count_(0),
47 last_put_offset_(-1), 47 last_put_offset_(-1),
48 last_barrier_put_offset_(-1), 48 last_barrier_put_offset_(-1),
49 next_fence_sync_release_(1),
50 flushed_fence_sync_release_(0),
51 verified_fence_sync_release_(0),
49 next_signal_id_(0) { 52 next_signal_id_(0) {
50 DCHECK(channel); 53 DCHECK(channel);
51 } 54 }
52 55
53 CommandBufferProxyImpl::~CommandBufferProxyImpl() { 56 CommandBufferProxyImpl::~CommandBufferProxyImpl() {
54 FOR_EACH_OBSERVER(DeletionObserver, 57 FOR_EACH_OBSERVER(DeletionObserver,
55 deletion_observers_, 58 deletion_observers_,
56 OnWillDeleteImpl()); 59 OnWillDeleteImpl());
57 if (channel_) { 60 if (channel_) {
58 channel_->DestroyCommandBuffer(this); 61 channel_->DestroyCommandBuffer(this);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 TRACE_EVENT1("gpu", 227 TRACE_EVENT1("gpu",
225 "CommandBufferProxyImpl::Flush", 228 "CommandBufferProxyImpl::Flush",
226 "put_offset", 229 "put_offset",
227 put_offset); 230 put_offset);
228 231
229 bool put_offset_changed = last_put_offset_ != put_offset; 232 bool put_offset_changed = last_put_offset_ != put_offset;
230 last_put_offset_ = put_offset; 233 last_put_offset_ = put_offset;
231 last_barrier_put_offset_ = put_offset; 234 last_barrier_put_offset_ = put_offset;
232 235
233 if (channel_) { 236 if (channel_) {
234 channel_->OrderingBarrier(route_id_, stream_id_, put_offset, ++flush_count_, 237 const uint32_t flush_id =
235 latency_info_, put_offset_changed, true); 238 channel_->OrderingBarrier(route_id_, stream_id_, put_offset,
239 ++flush_count_, latency_info_,
240 put_offset_changed, true);
241 if (put_offset_changed) {
242 DCHECK(flush_id);
243 const uint32_t fence_sync_release = next_fence_sync_release_ - 1;
244 if (fence_sync_release > flushed_fence_sync_release_) {
245 flushed_fence_sync_release_ = fence_sync_release;
246 flushed_release_flush_id_.push(std::make_pair(fence_sync_release,
247 flush_id));
piman 2015/09/26 00:09:51 TBH all this tracking seems costly, and most of it
David Yen 2015/09/26 00:24:56 None of these variables are atomic so there is not
248 }
249 }
236 } 250 }
237 251
238 if (put_offset_changed) 252 if (put_offset_changed)
239 latency_info_.clear(); 253 latency_info_.clear();
240 } 254 }
241 255
242 void CommandBufferProxyImpl::OrderingBarrier(int32 put_offset) { 256 void CommandBufferProxyImpl::OrderingBarrier(int32 put_offset) {
243 if (last_state_.error != gpu::error::kNoError) 257 if (last_state_.error != gpu::error::kNoError)
244 return; 258 return;
245 259
246 TRACE_EVENT1("gpu", "CommandBufferProxyImpl::OrderingBarrier", "put_offset", 260 TRACE_EVENT1("gpu", "CommandBufferProxyImpl::OrderingBarrier", "put_offset",
247 put_offset); 261 put_offset);
248 262
249 bool put_offset_changed = last_barrier_put_offset_ != put_offset; 263 bool put_offset_changed = last_barrier_put_offset_ != put_offset;
250 last_barrier_put_offset_ = put_offset; 264 last_barrier_put_offset_ = put_offset;
251 265
252 if (channel_) { 266 if (channel_) {
253 channel_->OrderingBarrier(route_id_, stream_id_, put_offset, ++flush_count_, 267 const uint32_t flush_id =
254 latency_info_, put_offset_changed, false); 268 channel_->OrderingBarrier(route_id_, stream_id_, put_offset,
269 ++flush_count_, latency_info_,
270 put_offset_changed, false);
271 if (put_offset_changed) {
272 DCHECK(flush_id);
273 const uint32_t fence_sync_release = next_fence_sync_release_ - 1;
274 if (fence_sync_release > flushed_fence_sync_release_) {
275 flushed_fence_sync_release_ = fence_sync_release;
276 flushed_release_flush_id_.push(std::make_pair(fence_sync_release,
277 flush_id));
278 }
279 }
255 } 280 }
256 281
257 if (put_offset_changed) 282 if (put_offset_changed)
258 latency_info_.clear(); 283 latency_info_.clear();
259 } 284 }
260 285
261 void CommandBufferProxyImpl::SetLatencyInfo( 286 void CommandBufferProxyImpl::SetLatencyInfo(
262 const std::vector<ui::LatencyInfo>& latency_info) { 287 const std::vector<ui::LatencyInfo>& latency_info) {
263 CheckLock(); 288 CheckLock();
264 for (size_t i = 0; i < latency_info.size(); i++) 289 for (size_t i = 0; i < latency_info.size(); i++)
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 } 510 }
486 511
487 gpu::CommandBufferNamespace CommandBufferProxyImpl::GetNamespaceID() const { 512 gpu::CommandBufferNamespace CommandBufferProxyImpl::GetNamespaceID() const {
488 return gpu::CommandBufferNamespace::GPU_IO; 513 return gpu::CommandBufferNamespace::GPU_IO;
489 } 514 }
490 515
491 uint64_t CommandBufferProxyImpl::GetCommandBufferID() const { 516 uint64_t CommandBufferProxyImpl::GetCommandBufferID() const {
492 return command_buffer_id_; 517 return command_buffer_id_;
493 } 518 }
494 519
520 uint32_t CommandBufferProxyImpl::GenerateFenceSyncRelease() {
521 return next_fence_sync_release_++;
522 }
523
524 bool CommandBufferProxyImpl::IsFenceSyncRelease(uint32_t release) {
525 return release != 0 && release < next_fence_sync_release_;
piman 2015/09/26 00:09:51 Do we need to handle wraparound? 1 per frame would
David Yen 2015/09/28 17:38:18 What about just using a uint64? This number doesn'
526 }
527
528 bool CommandBufferProxyImpl::IsFenceSyncFlushed(uint32_t release) {
529 if (release <= verified_fence_sync_release_)
530 return true;
531
532 // Check if we have actually flushed the fence sync release.
533 if (release <= flushed_fence_sync_release_) {
534 DCHECK(!flushed_release_flush_id_.empty());
535 // Check if it has already been validated by another context.
536 UpdateVerifiedReleases(channel_->GetHighestValidatedFlushID(stream_id_));
537 if (release <= verified_fence_sync_release_)
538 return true;
539
540 // Has not been validated, validate it now.
541 UpdateVerifiedReleases(channel_->ValidateFlushIDReachedServer(stream_id_));
542 return (release <= verified_fence_sync_release_);
543 }
544
545 return false;
546 }
547
495 uint32 CommandBufferProxyImpl::InsertSyncPoint() { 548 uint32 CommandBufferProxyImpl::InsertSyncPoint() {
496 CheckLock(); 549 CheckLock();
497 if (last_state_.error != gpu::error::kNoError) 550 if (last_state_.error != gpu::error::kNoError)
498 return 0; 551 return 0;
499 552
500 uint32 sync_point = 0; 553 uint32 sync_point = 0;
501 Send(new GpuCommandBufferMsg_InsertSyncPoint(route_id_, true, &sync_point)); 554 Send(new GpuCommandBufferMsg_InsertSyncPoint(route_id_, true, &sync_point));
502 return sync_point; 555 return sync_point;
503 } 556 }
504 557
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 const GpuConsoleMessageCallback& callback) { 684 const GpuConsoleMessageCallback& callback) {
632 CheckLock(); 685 CheckLock();
633 console_message_callback_ = callback; 686 console_message_callback_ = callback;
634 } 687 }
635 688
636 void CommandBufferProxyImpl::TryUpdateState() { 689 void CommandBufferProxyImpl::TryUpdateState() {
637 if (last_state_.error == gpu::error::kNoError) 690 if (last_state_.error == gpu::error::kNoError)
638 shared_state()->Read(&last_state_); 691 shared_state()->Read(&last_state_);
639 } 692 }
640 693
694 void CommandBufferProxyImpl::UpdateVerifiedReleases(uint32_t verified_flush) {
695 while (!flushed_release_flush_id_.empty()) {
696 const std::pair<uint32_t, uint32_t>& front_item =
697 flushed_release_flush_id_.front();
698 if (front_item.second > verified_flush)
699 break;
700 verified_fence_sync_release_ = front_item.first;
701 flushed_release_flush_id_.pop();
702 }
703 }
704
641 gpu::CommandBufferSharedState* CommandBufferProxyImpl::shared_state() const { 705 gpu::CommandBufferSharedState* CommandBufferProxyImpl::shared_state() const {
642 return reinterpret_cast<gpu::CommandBufferSharedState*>( 706 return reinterpret_cast<gpu::CommandBufferSharedState*>(
643 shared_state_shm_->memory()); 707 shared_state_shm_->memory());
644 } 708 }
645 709
646 void CommandBufferProxyImpl::OnSwapBuffersCompleted( 710 void CommandBufferProxyImpl::OnSwapBuffersCompleted(
647 const std::vector<ui::LatencyInfo>& latency_info, 711 const std::vector<ui::LatencyInfo>& latency_info,
648 gfx::SwapResult result) { 712 gfx::SwapResult result) {
649 if (!swap_buffers_completion_callback_.is_null()) { 713 if (!swap_buffers_completion_callback_.is_null()) {
650 if (!ui::LatencyInfo::Verify( 714 if (!ui::LatencyInfo::Verify(
651 latency_info, "CommandBufferProxyImpl::OnSwapBuffersCompleted")) { 715 latency_info, "CommandBufferProxyImpl::OnSwapBuffersCompleted")) {
652 swap_buffers_completion_callback_.Run(std::vector<ui::LatencyInfo>(), 716 swap_buffers_completion_callback_.Run(std::vector<ui::LatencyInfo>(),
653 result); 717 result);
654 return; 718 return;
655 } 719 }
656 swap_buffers_completion_callback_.Run(latency_info, result); 720 swap_buffers_completion_callback_.Run(latency_info, result);
657 } 721 }
658 } 722 }
659 723
660 void CommandBufferProxyImpl::OnUpdateVSyncParameters(base::TimeTicks timebase, 724 void CommandBufferProxyImpl::OnUpdateVSyncParameters(base::TimeTicks timebase,
661 base::TimeDelta interval) { 725 base::TimeDelta interval) {
662 if (!update_vsync_parameters_completion_callback_.is_null()) 726 if (!update_vsync_parameters_completion_callback_.is_null())
663 update_vsync_parameters_completion_callback_.Run(timebase, interval); 727 update_vsync_parameters_completion_callback_.Run(timebase, interval);
664 } 728 }
665 729
666 } // namespace content 730 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698