| Index: content/common/gpu/gpu_command_buffer_stub.cc
|
| diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
|
| index 731c5fd2b9923c29352ce4bcb227a52700f31a37..9494d0f74a1426b34eaf983a829fdfb5e2050d45 100644
|
| --- a/content/common/gpu/gpu_command_buffer_stub.cc
|
| +++ b/content/common/gpu/gpu_command_buffer_stub.cc
|
| @@ -668,6 +668,10 @@ void GpuCommandBufferStub::OnInitialize(
|
| decoder_->SetWaitSyncPointCallback(
|
| base::Bind(&GpuCommandBufferStub::OnWaitSyncPoint,
|
| base::Unretained(this)));
|
| + decoder_->SetFenceSyncReleaseCallback(base::Bind(
|
| + &GpuCommandBufferStub::OnFenceSyncRelease, base::Unretained(this)));
|
| + decoder_->SetWaitFenceSyncCallback(base::Bind(
|
| + &GpuCommandBufferStub::OnWaitFenceSync, base::Unretained(this)));
|
|
|
| command_buffer_->SetPutOffsetChangeCallback(
|
| base::Bind(&GpuCommandBufferStub::PutChanged, base::Unretained(this)));
|
| @@ -957,8 +961,18 @@ void GpuCommandBufferStub::OnRetireSyncPoint(uint32 sync_point) {
|
|
|
| gpu::gles2::MailboxManager* mailbox_manager =
|
| context_group_->mailbox_manager();
|
| - if (mailbox_manager->UsesSync() && MakeCurrent())
|
| - mailbox_manager->PushTextureUpdates(sync_point);
|
| + if (mailbox_manager->UsesSync() && MakeCurrent()) {
|
| + // Old sync points are global and do not have a command buffer ID,
|
| + // We can simply use the global sync point number as the release count with
|
| + // 0 for the command buffer ID (under normal circumstances 0 is invalid so
|
| + // will not be used) until the old sync points are replaced.
|
| + gpu::gles2::SyncToken sync_token = {
|
| + gpu::CommandBufferNamespace::GPU_IO,
|
| + 0,
|
| + sync_point
|
| + };
|
| + mailbox_manager->PushTextureUpdates(sync_token);
|
| + }
|
|
|
| GpuChannelManager* manager = channel_->gpu_channel_manager();
|
| manager->sync_point_manager()->RetireSyncPoint(sync_point);
|
| @@ -971,7 +985,11 @@ bool GpuCommandBufferStub::OnWaitSyncPoint(uint32 sync_point) {
|
| return true;
|
| GpuChannelManager* manager = channel_->gpu_channel_manager();
|
| if (manager->sync_point_manager()->IsSyncPointRetired(sync_point)) {
|
| - PullTextureUpdates(sync_point);
|
| + // Old sync points are global and do not have a command buffer ID,
|
| + // We can simply use the global sync point number as the release count with
|
| + // 0 for the command buffer ID (under normal circumstances 0 is invalid so
|
| + // will not be used) until the old sync points are replaced.
|
| + PullTextureUpdates(gpu::CommandBufferNamespace::GPU_IO, 0, sync_point);
|
| return true;
|
| }
|
|
|
| @@ -993,16 +1011,29 @@ void GpuCommandBufferStub::OnWaitSyncPointCompleted(uint32 sync_point) {
|
| DCHECK(!scheduler_->scheduled());
|
| TRACE_EVENT_ASYNC_END1("gpu", "WaitSyncPoint", this, "GpuCommandBufferStub",
|
| this);
|
| - PullTextureUpdates(sync_point);
|
| + // Old sync points are global and do not have a command buffer ID,
|
| + // We can simply use the global sync point number as the release count with
|
| + // 0 for the command buffer ID (under normal circumstances 0 is invalid so
|
| + // will not be used) until the old sync points are replaced.
|
| + PullTextureUpdates(gpu::CommandBufferNamespace::GPU_IO, 0, sync_point);
|
| waiting_for_sync_point_ = false;
|
| scheduler_->SetScheduled(true);
|
| }
|
|
|
| -void GpuCommandBufferStub::PullTextureUpdates(uint32 sync_point) {
|
| +void GpuCommandBufferStub::PullTextureUpdates(
|
| + gpu::CommandBufferNamespace namespace_id,
|
| + uint64_t command_buffer_id,
|
| + uint32_t release) {
|
| gpu::gles2::MailboxManager* mailbox_manager =
|
| context_group_->mailbox_manager();
|
| - if (mailbox_manager->UsesSync() && MakeCurrent())
|
| - mailbox_manager->PullTextureUpdates(sync_point);
|
| + if (mailbox_manager->UsesSync() && MakeCurrent()) {
|
| + gpu::gles2::SyncToken sync_token = {
|
| + namespace_id,
|
| + command_buffer_id,
|
| + release
|
| + };
|
| + mailbox_manager->PullTextureUpdates(sync_token);
|
| + }
|
| }
|
|
|
| void GpuCommandBufferStub::OnSignalSyncPoint(uint32 sync_point, uint32 id) {
|
| @@ -1037,6 +1068,72 @@ void GpuCommandBufferStub::OnSignalQuery(uint32 query_id, uint32 id) {
|
| OnSignalSyncPointAck(id);
|
| }
|
|
|
| +void GpuCommandBufferStub::OnFenceSyncRelease(uint32_t release) {
|
| + if (!sync_point_client_->client_state()->IsFenceSyncReleased(release)) {
|
| + gpu::gles2::MailboxManager* mailbox_manager =
|
| + context_group_->mailbox_manager();
|
| + if (mailbox_manager->UsesSync() && MakeCurrent()) {
|
| + gpu::gles2::SyncToken sync_token = {
|
| + gpu::CommandBufferNamespace::GPU_IO,
|
| + command_buffer_id_,
|
| + release
|
| + };
|
| + mailbox_manager->PushTextureUpdates(sync_token);
|
| + }
|
| +
|
| + sync_point_client_->ReleaseFenceSync(release);
|
| + }
|
| +}
|
| +
|
| +bool GpuCommandBufferStub::OnWaitFenceSync(
|
| + gpu::CommandBufferNamespace namespace_id,
|
| + uint64_t command_buffer_id,
|
| + uint32_t release) {
|
| + DCHECK(!waiting_for_sync_point_);
|
| + DCHECK(scheduler_->scheduled());
|
| +
|
| + GpuChannelManager* manager = channel_->gpu_channel_manager();
|
| + DCHECK(manager);
|
| +
|
| + gpu::SyncPointManager* sync_point_manager = manager->sync_point_manager();
|
| + DCHECK(sync_point_manager);
|
| +
|
| + scoped_refptr<gpu::SyncPointClientState> release_state =
|
| + sync_point_manager->GetSyncPointClientState(namespace_id,
|
| + command_buffer_id);
|
| +
|
| + if (!release_state.get())
|
| + return true;
|
| +
|
| + if (release_state->IsFenceSyncReleased(release)) {
|
| + PullTextureUpdates(namespace_id, command_buffer_id, release);
|
| + return true;
|
| + }
|
| +
|
| + TRACE_EVENT_ASYNC_BEGIN1("gpu", "WaitFenceSync", this,
|
| + "GpuCommandBufferStub", this);
|
| + scheduler_->SetScheduled(false);
|
| + waiting_for_sync_point_ = true;
|
| + sync_point_client_->Wait(
|
| + release_state,
|
| + release,
|
| + base::Bind(&GpuCommandBufferStub::OnWaitFenceSyncCompleted,
|
| + this->AsWeakPtr(), namespace_id, command_buffer_id, release));
|
| +
|
| + return scheduler_->scheduled();
|
| +}
|
| +
|
| +void GpuCommandBufferStub::OnWaitFenceSyncCompleted(
|
| + gpu::CommandBufferNamespace namespace_id,
|
| + uint64_t command_buffer_id,
|
| + uint32_t release) {
|
| + DCHECK(waiting_for_sync_point_);
|
| + DCHECK(!scheduler_->scheduled());
|
| + TRACE_EVENT_ASYNC_END1("gpu", "WaitFenceSync", this, "GpuCommandBufferStub",
|
| + this);
|
| + PullTextureUpdates(namespace_id, command_buffer_id, release);
|
| + scheduler_->SetScheduled(true);
|
| +}
|
|
|
| void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback(
|
| bool has_callback) {
|
|
|