summaryrefslogtreecommitdiffstats
path: root/content/common
diff options
context:
space:
mode:
authorjbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-18 23:55:10 +0000
committerjbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-18 23:55:10 +0000
commit80c49759f6489e638e7777256aa4700e38dbdcfc (patch)
treed61f4b4d4cc25cab5068fe73b016fcd24e06b4ba /content/common
parent5f9f681a330988123e0e01d00da2888789e9b476 (diff)
downloadchromium_src-80c49759f6489e638e7777256aa4700e38dbdcfc.zip
chromium_src-80c49759f6489e638e7777256aa4700e38dbdcfc.tar.gz
chromium_src-80c49759f6489e638e7777256aa4700e38dbdcfc.tar.bz2
GpuScheduler no longer spins when it is waiting on a latch.
BUG=79632 TEST=run trace in about:gpu; observe the number of times the GPU process sequentially calls WaitLatch; verify it is not spinning. Review URL: http://codereview.chromium.org/6874029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82033 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common')
-rw-r--r--content/common/gpu/gpu_channel.cc19
-rw-r--r--content/common/gpu/gpu_channel.h6
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc3
3 files changed, 28 insertions, 0 deletions
diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc
index 21b6d06..0da5925 100644
--- a/content/common/gpu/gpu_channel.cc
+++ b/content/common/gpu/gpu_channel.cc
@@ -55,6 +55,25 @@ void GpuChannel::DestroyTransportTexture(int32 route_id) {
router_.RemoveRoute(route_id);
}
+void GpuChannel::OnLatchCallback(int route_id, bool is_set_latch) {
+#if defined(ENABLE_GPU)
+ if (is_set_latch) {
+ // Wake up any waiting contexts. If they are still blocked, they will re-add
+ // themselves to the set.
+ for (std::set<int32>::iterator i = latched_routes_.begin();
+ i != latched_routes_.end(); ++i) {
+ GpuCommandBufferStub* stub = stubs_.Lookup(*i);
+ if (stub)
+ stub->scheduler()->ScheduleProcessCommands();
+ }
+ latched_routes_.clear();
+ } else {
+ // Add route_id context to a set to be woken upon any set latch.
+ latched_routes_.insert(route_id);
+ }
+#endif
+}
+
bool GpuChannel::OnMessageReceived(const IPC::Message& message) {
if (log_messages_) {
VLOG(1) << "received message @" << &message << " on channel @" << this
diff --git a/content/common/gpu/gpu_channel.h b/content/common/gpu/gpu_channel.h
index 012656e..05af1ca 100644
--- a/content/common/gpu/gpu_channel.h
+++ b/content/common/gpu/gpu_channel.h
@@ -89,6 +89,11 @@ class GpuChannel : public IPC::Channel::Listener,
// TransportTexture to delete and detach itself.
void DestroyTransportTexture(int32 route_id);
+ // A callback which is called after a Set/WaitLatch command is processed.
+ // The bool parameter will be true for SetLatch, and false for a WaitLatch
+ // that is blocked. An unblocked WaitLatch will not trigger a callback.
+ void OnLatchCallback(int route_id, bool is_set_latch);
+
private:
bool OnControlMessageReceived(const IPC::Message& msg);
@@ -131,6 +136,7 @@ class GpuChannel : public IPC::Channel::Listener,
#if defined(ENABLE_GPU)
typedef IDMap<GpuCommandBufferStub, IDMapOwnPointer> StubMap;
StubMap stubs_;
+ std::set<int32> latched_routes_;
#endif // defined (ENABLE_GPU)
// A collection of transport textures created.
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index 94c8c6f..42e086d 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -4,6 +4,7 @@
#if defined(ENABLE_GPU)
+#include "base/bind.h"
#include "base/process_util.h"
#include "base/shared_memory.h"
#include "build/build_config.h"
@@ -258,6 +259,8 @@ void GpuCommandBufferStub::OnInitialize(
&gpu::GpuScheduler::ProcessCommands));
scheduler_->SetSwapBuffersCallback(
NewCallback(this, &GpuCommandBufferStub::OnSwapBuffers));
+ scheduler_->SetLatchCallback(
+ base::Bind(&GpuChannel::OnLatchCallback, channel_, route_id_));
if (watchdog_)
scheduler_->SetCommandProcessedCallback(
NewCallback(this, &GpuCommandBufferStub::OnCommandProcessed));