| 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 "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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 route_id_(route_id), | 45 route_id_(route_id), |
| 46 stream_id_(stream_id), | 46 stream_id_(stream_id), |
| 47 flush_count_(0), | 47 flush_count_(0), |
| 48 last_put_offset_(-1), | 48 last_put_offset_(-1), |
| 49 last_barrier_put_offset_(-1), | 49 last_barrier_put_offset_(-1), |
| 50 next_fence_sync_release_(1), | 50 next_fence_sync_release_(1), |
| 51 flushed_fence_sync_release_(0), | 51 flushed_fence_sync_release_(0), |
| 52 verified_fence_sync_release_(0), | 52 verified_fence_sync_release_(0), |
| 53 next_signal_id_(0) { | 53 next_signal_id_(0) { |
| 54 DCHECK(channel); | 54 DCHECK(channel); |
| 55 DCHECK(stream_id); | |
| 56 } | 55 } |
| 57 | 56 |
| 58 CommandBufferProxyImpl::~CommandBufferProxyImpl() { | 57 CommandBufferProxyImpl::~CommandBufferProxyImpl() { |
| 59 FOR_EACH_OBSERVER(DeletionObserver, | 58 FOR_EACH_OBSERVER(DeletionObserver, |
| 60 deletion_observers_, | 59 deletion_observers_, |
| 61 OnWillDeleteImpl()); | 60 OnWillDeleteImpl()); |
| 62 if (channel_) { | 61 if (channel_) { |
| 63 channel_->DestroyCommandBuffer(this); | 62 channel_->DestroyCommandBuffer(this); |
| 64 channel_ = nullptr; | 63 channel_ = nullptr; |
| 65 } | 64 } |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 params.size = gfx::Size(width, height); | 442 params.size = gfx::Size(width, height); |
| 444 params.format = gpu_memory_buffer->GetFormat(); | 443 params.format = gpu_memory_buffer->GetFormat(); |
| 445 params.internal_format = internal_format; | 444 params.internal_format = internal_format; |
| 446 params.image_release_count = image_fence_sync; | 445 params.image_release_count = image_fence_sync; |
| 447 | 446 |
| 448 if (!Send(new GpuCommandBufferMsg_CreateImage(route_id_, params))) | 447 if (!Send(new GpuCommandBufferMsg_CreateImage(route_id_, params))) |
| 449 return -1; | 448 return -1; |
| 450 | 449 |
| 451 if (image_fence_sync) { | 450 if (image_fence_sync) { |
| 452 gpu::SyncToken sync_token(GetNamespaceID(), GetCommandBufferID(), | 451 gpu::SyncToken sync_token(GetNamespaceID(), GetCommandBufferID(), |
| 453 GetExtraCommandBufferData(), image_fence_sync); | 452 image_fence_sync); |
| 454 | 453 |
| 455 // Force a synchronous IPC to validate sync token. | 454 // Force a synchronous IPC to validate sync token. |
| 456 channel_->ValidateFlushIDReachedServer(stream_id_, true); | 455 channel_->ValidateFlushIDReachedServer(stream_id_, true); |
| 457 sync_token.SetVerifyFlush(); | 456 sync_token.SetVerifyFlush(); |
| 458 | 457 |
| 459 gpu_memory_buffer_manager->SetDestructionSyncToken(gpu_memory_buffer, | 458 gpu_memory_buffer_manager->SetDestructionSyncToken(gpu_memory_buffer, |
| 460 sync_token); | 459 sync_token); |
| 461 } | 460 } |
| 462 | 461 |
| 463 return new_id; | 462 return new_id; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 } | 512 } |
| 514 | 513 |
| 515 gpu::CommandBufferNamespace CommandBufferProxyImpl::GetNamespaceID() const { | 514 gpu::CommandBufferNamespace CommandBufferProxyImpl::GetNamespaceID() const { |
| 516 return gpu::CommandBufferNamespace::GPU_IO; | 515 return gpu::CommandBufferNamespace::GPU_IO; |
| 517 } | 516 } |
| 518 | 517 |
| 519 uint64_t CommandBufferProxyImpl::GetCommandBufferID() const { | 518 uint64_t CommandBufferProxyImpl::GetCommandBufferID() const { |
| 520 return command_buffer_id_; | 519 return command_buffer_id_; |
| 521 } | 520 } |
| 522 | 521 |
| 523 int32_t CommandBufferProxyImpl::GetExtraCommandBufferData() const { | |
| 524 return stream_id_; | |
| 525 } | |
| 526 | |
| 527 uint64_t CommandBufferProxyImpl::GenerateFenceSyncRelease() { | 522 uint64_t CommandBufferProxyImpl::GenerateFenceSyncRelease() { |
| 528 return next_fence_sync_release_++; | 523 return next_fence_sync_release_++; |
| 529 } | 524 } |
| 530 | 525 |
| 531 bool CommandBufferProxyImpl::IsFenceSyncRelease(uint64_t release) { | 526 bool CommandBufferProxyImpl::IsFenceSyncRelease(uint64_t release) { |
| 532 return release != 0 && release < next_fence_sync_release_; | 527 return release != 0 && release < next_fence_sync_release_; |
| 533 } | 528 } |
| 534 | 529 |
| 535 bool CommandBufferProxyImpl::IsFenceSyncFlushed(uint64_t release) { | 530 bool CommandBufferProxyImpl::IsFenceSyncFlushed(uint64_t release) { |
| 536 return release != 0 && release <= flushed_fence_sync_release_; | 531 return release != 0 && release <= flushed_fence_sync_release_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 } | 570 } |
| 576 | 571 |
| 577 signal_tasks_.insert(std::make_pair(signal_id, callback)); | 572 signal_tasks_.insert(std::make_pair(signal_id, callback)); |
| 578 } | 573 } |
| 579 | 574 |
| 580 bool CommandBufferProxyImpl::CanWaitUnverifiedSyncToken( | 575 bool CommandBufferProxyImpl::CanWaitUnverifiedSyncToken( |
| 581 const gpu::SyncToken* sync_token) { | 576 const gpu::SyncToken* sync_token) { |
| 582 // Can only wait on an unverified sync token if it is from the same channel. | 577 // Can only wait on an unverified sync token if it is from the same channel. |
| 583 const uint64_t token_channel = sync_token->command_buffer_id() >> 32; | 578 const uint64_t token_channel = sync_token->command_buffer_id() >> 32; |
| 584 const uint64_t channel = command_buffer_id_ >> 32; | 579 const uint64_t channel = command_buffer_id_ >> 32; |
| 585 if (sync_token->namespace_id() != gpu::CommandBufferNamespace::GPU_IO || | 580 return (sync_token->namespace_id() == gpu::CommandBufferNamespace::GPU_IO && |
| 586 token_channel != channel) { | 581 token_channel == channel); |
| 587 return false; | |
| 588 } | |
| 589 | |
| 590 // If waiting on a different stream, flush pending commands on that stream. | |
| 591 const int32_t release_stream_id = sync_token->extra_data_field(); | |
| 592 if (release_stream_id == 0) | |
| 593 return false; | |
| 594 | |
| 595 if (release_stream_id != stream_id_) | |
| 596 channel_->FlushPendingStream(release_stream_id); | |
| 597 | |
| 598 return true; | |
| 599 } | 582 } |
| 600 | 583 |
| 601 uint32 CommandBufferProxyImpl::InsertSyncPoint() { | 584 uint32 CommandBufferProxyImpl::InsertSyncPoint() { |
| 602 CheckLock(); | 585 CheckLock(); |
| 603 if (last_state_.error != gpu::error::kNoError) | 586 if (last_state_.error != gpu::error::kNoError) |
| 604 return 0; | 587 return 0; |
| 605 | 588 |
| 606 uint32 sync_point = 0; | 589 uint32 sync_point = 0; |
| 607 Send(new GpuCommandBufferMsg_InsertSyncPoint(route_id_, true, &sync_point)); | 590 Send(new GpuCommandBufferMsg_InsertSyncPoint(route_id_, true, &sync_point)); |
| 608 return sync_point; | 591 return sync_point; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 } | 749 } |
| 767 } | 750 } |
| 768 | 751 |
| 769 void CommandBufferProxyImpl::OnUpdateVSyncParameters(base::TimeTicks timebase, | 752 void CommandBufferProxyImpl::OnUpdateVSyncParameters(base::TimeTicks timebase, |
| 770 base::TimeDelta interval) { | 753 base::TimeDelta interval) { |
| 771 if (!update_vsync_parameters_completion_callback_.is_null()) | 754 if (!update_vsync_parameters_completion_callback_.is_null()) |
| 772 update_vsync_parameters_completion_callback_.Run(timebase, interval); | 755 update_vsync_parameters_completion_callback_.Run(timebase, interval); |
| 773 } | 756 } |
| 774 | 757 |
| 775 } // namespace content | 758 } // namespace content |
| OLD | NEW |