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

Unified Diff: content/common/gpu/gpu_command_buffer_stub.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: Fixed memory leak Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
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 c31e167d8a778b2e8e277465f9e16964b5052d1b..62a7b6c4845f5609ff9078ba158224921eacddc3 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -546,7 +546,7 @@ void GpuCommandBufferStub::OnInitialize(
decoder_.get()));
sync_point_client_ =
sync_point_manager->CreateSyncPointClient(
- channel_->GetSyncPointClientState(),
+ channel_->GetSyncPointOrderData(),
gpu::CommandBufferNamespace::GPU_IO,
command_buffer_id_);
@@ -653,6 +653,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)));
@@ -942,8 +946,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);
@@ -956,7 +970,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;
}
@@ -978,16 +996,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) {
@@ -1022,6 +1053,73 @@ void GpuCommandBufferStub::OnSignalQuery(uint32 query_id, uint32 id) {
OnSignalSyncPointAck(id);
}
+void GpuCommandBufferStub::OnFenceSyncRelease(uint64_t release) {
+ if (!sync_point_client_->client_state()->IsFenceSyncReleased(release)) {
piman 2015/09/30 22:50:23 It's worth DLOG(ERROR) if this is false, because i
David Yen 2015/09/30 23:55:18 Done.
+ 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,
+ uint64_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)
+ 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_->WaitNonThreadSafe(
+ release_state,
+ release,
+ task_runner_,
+ 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,
+ uint64_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);
piman 2015/09/30 22:50:23 You would want to reset waiting_for_sync_point_ he
David Yen 2015/09/30 23:55:18 Done.
+ scheduler_->SetScheduled(true);
+}
void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback(
bool has_callback) {

Powered by Google App Engine
This is Rietveld 408576698