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