diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-08 02:25:15 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-08 02:25:15 +0000 |
commit | 20f656fa24a2c96bf28d9889dc226dbc6eba1011 (patch) | |
tree | 0ac68bf2828c732225b68d7b68c3fdd0e172a383 /content/common | |
parent | 37b89cacd9d5aa309eeb3689c8871c9c07d3b879 (diff) | |
download | chromium_src-20f656fa24a2c96bf28d9889dc226dbc6eba1011.zip chromium_src-20f656fa24a2c96bf28d9889dc226dbc6eba1011.tar.gz chromium_src-20f656fa24a2c96bf28d9889dc226dbc6eba1011.tar.bz2 |
Ensure that GpuScheduler invokes fence tasks even if client is not flushing.
Review URL: http://codereview.chromium.org/8495038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113535 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common')
-rw-r--r-- | content/common/gpu/gpu_channel.cc | 24 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.cc | 12 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.h | 3 |
3 files changed, 31 insertions, 8 deletions
diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc index 27eb490..e8cc269 100644 --- a/content/common/gpu/gpu_channel.cc +++ b/content/common/gpu/gpu_channel.cc @@ -26,6 +26,10 @@ #include "ipc/ipc_channel_posix.h" #endif +namespace { +const int64 kHandleMoreWorkPeriod = 1; +} + GpuChannel::GpuChannel(GpuChannelManager* gpu_channel_manager, GpuWatchdog* watchdog, int renderer_id, @@ -154,7 +158,7 @@ void GpuChannel::OnScheduled() { // Post a task to handle any deferred messages. The deferred message queue is // not emptied here, which ensures that OnMessageReceived will continue to // defer newly received messages until the ones in the queue have all been - // handled by HandleDeferredMessages. HandleDeferredMessages is invoked as a + // handled by HandleMessage. HandleMessage is invoked as a // task to prevent reentrancy. MessageLoop::current()->PostTask( FROM_HERE, @@ -256,18 +260,28 @@ void GpuChannel::HandleMessage() { Send(reply); } } else { - // If the channel becomes unscheduled as a result of handling the message, - // synthesize an IPC message to flush the command buffer that became - // unscheduled. + // If the channel becomes unscheduled as a result of handling the message + // or has more work to do, synthesize an IPC message to flush the command + // buffer that became unscheduled. + bool has_more_work = false; for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); !it.IsAtEnd(); it.Advance()) { GpuCommandBufferStub* stub = it.GetCurrentValue(); - if (!stub->IsScheduled()) { + + if (!stub->IsScheduled() || stub->HasMoreWork()) { + has_more_work = true; deferred_messages_.push_front(new GpuCommandBufferMsg_Rescheduled( stub->route_id())); } } + + if (has_more_work) { + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::Bind(&GpuChannel::HandleMessage, weak_factory_.GetWeakPtr()), + kHandleMoreWorkPeriod); + } } } diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc index af478e0..ff2ab82 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -123,6 +123,10 @@ bool GpuCommandBufferStub::IsScheduled() { return !scheduler_.get() || scheduler_->IsScheduled(); } +bool GpuCommandBufferStub::HasMoreWork() { + return scheduler_.get() && scheduler_->HasMoreWork(); +} + void GpuCommandBufferStub::SetSwapInterval() { #if !defined(OS_MACOSX) && !defined(UI_COMPOSITOR_IMAGE_TRANSPORT) // Set up swap interval for onscreen contexts. @@ -360,10 +364,12 @@ void GpuCommandBufferStub::OnAsyncFlush(int32 put_offset, } void GpuCommandBufferStub::OnRescheduled() { - gpu::CommandBuffer::State state = command_buffer_->GetLastState(); - command_buffer_->Flush(state.put_offset); + gpu::CommandBuffer::State pre_state = command_buffer_->GetLastState(); + command_buffer_->Flush(pre_state.put_offset); + gpu::CommandBuffer::State post_state = command_buffer_->GetLastState(); - ReportState(); + if (pre_state.get_offset != post_state.get_offset) + ReportState(); } void GpuCommandBufferStub::OnCreateTransferBuffer(int32 size, diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h index f581593..50e2b23 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -65,6 +65,9 @@ class GpuCommandBufferStub // Whether this command buffer can currently handle IPC messages. bool IsScheduled(); + // Whether this command buffer needs to be polled again in the future. + bool HasMoreWork(); + // Set the swap interval according to the command line. void SetSwapInterval(); |