diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-19 00:03:51 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-19 00:03:51 +0000 |
commit | 5ab44efdb1f72aef69827ccf29ceab540f0a089c (patch) | |
tree | cb75c715bcfaa0d172751bfc4329fd021504dad2 | |
parent | 26af27ce9821548ca25c5c52437dc2a6121fcc4a (diff) | |
download | chromium_src-5ab44efdb1f72aef69827ccf29ceab540f0a089c.zip chromium_src-5ab44efdb1f72aef69827ccf29ceab540f0a089c.tar.gz chromium_src-5ab44efdb1f72aef69827ccf29ceab540f0a089c.tar.bz2 |
gpu: add SignalSyncPoint to complement WaitSyncPoint
BUG=112299
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10541185
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142869 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/common/gpu/client/command_buffer_proxy_impl.cc | 31 | ||||
-rw-r--r-- | content/common/gpu/client/command_buffer_proxy_impl.h | 14 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.cc | 15 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.h | 2 | ||||
-rw-r--r-- | content/common/gpu/gpu_messages.h | 11 | ||||
-rw-r--r-- | gpu/ipc/command_buffer_proxy.h | 5 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_command_buffer_proxy.cc | 6 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_command_buffer_proxy.h | 2 |
8 files changed, 83 insertions, 3 deletions
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.cc b/content/common/gpu/client/command_buffer_proxy_impl.cc index 8f3f4ce..1c762dc 100644 --- a/content/common/gpu/client/command_buffer_proxy_impl.cc +++ b/content/common/gpu/client/command_buffer_proxy_impl.cc @@ -33,7 +33,8 @@ CommandBufferProxyImpl::CommandBufferProxyImpl( channel_(channel), route_id_(route_id), flush_count_(0), - last_put_offset_(-1) { + last_put_offset_(-1), + next_signal_id_(0) { } CommandBufferProxyImpl::~CommandBufferProxyImpl() { @@ -57,6 +58,8 @@ bool CommandBufferProxyImpl::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ConsoleMsg, OnConsoleMessage); IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetMemoryAllocation, OnSetMemoryAllocation); + IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncPointAck, + OnSignalSyncPointAck); IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -119,6 +122,14 @@ void CommandBufferProxyImpl::OnSetMemoryAllocation( memory_allocation_changed_callback_.Run(allocation); } +void CommandBufferProxyImpl::OnSignalSyncPointAck(uint32 id) { + SignalTaskMap::iterator it = signal_tasks_.find(id); + DCHECK(it != signal_tasks_.end()); + base::Closure callback = it->second; + signal_tasks_.erase(it); + callback.Run(); +} + void CommandBufferProxyImpl::SetChannelErrorCallback( const base::Closure& callback) { channel_error_callback_ = callback; @@ -426,6 +437,24 @@ void CommandBufferProxyImpl::WaitSyncPoint(uint32 sync_point) { Send(new GpuCommandBufferMsg_WaitSyncPoint(route_id_, sync_point)); } +bool CommandBufferProxyImpl::SignalSyncPoint(uint32 sync_point, + const base::Closure& callback) { + if (last_state_.error != gpu::error::kNoError) { + return false; + } + + uint32 signal_id = next_signal_id_++; + if (!Send(new GpuCommandBufferMsg_SignalSyncPoint(route_id_, + sync_point, + signal_id))) { + return false; + } + + signal_tasks_.insert(std::make_pair(signal_id, callback)); + + return true; +} + bool CommandBufferProxyImpl::SetParent( CommandBufferProxy* parent_command_buffer, uint32 parent_texture_id) { diff --git a/content/common/gpu/client/command_buffer_proxy_impl.h b/content/common/gpu/client/command_buffer_proxy_impl.h index 787455b..8c09486 100644 --- a/content/common/gpu/client/command_buffer_proxy_impl.h +++ b/content/common/gpu/client/command_buffer_proxy_impl.h @@ -16,6 +16,7 @@ #include "base/callback.h" #include "base/compiler_specific.h" +#include "base/hash_tables.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" @@ -67,6 +68,8 @@ class CommandBufferProxyImpl virtual bool EnsureBackbuffer() OVERRIDE; virtual uint32 InsertSyncPoint() OVERRIDE; virtual void WaitSyncPoint(uint32 sync_point) OVERRIDE; + virtual bool SignalSyncPoint(uint32 sync_point, + const base::Closure& callback) OVERRIDE; virtual void SetMemoryAllocationChangedCallback( const base::Callback<void(const GpuMemoryAllocationForRenderer&)>& callback) OVERRIDE; @@ -105,6 +108,10 @@ class CommandBufferProxyImpl GpuChannelHost* channel() const { return channel_; } private: + typedef std::map<int32, gpu::Buffer> TransferBufferMap; + typedef std::map<int, scoped_refptr<GpuVideoDecodeAcceleratorHost> > Decoders; + typedef base::hash_map<uint32, base::Closure> SignalTaskMap; + // Send an IPC message over the GPU channel. This is private to fully // encapsulate the channel; all callers of this function must explicitly // verify that the context has not been lost. @@ -117,17 +124,16 @@ class CommandBufferProxyImpl void OnEchoAck(); void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message); void OnSetMemoryAllocation(const GpuMemoryAllocationForRenderer& allocation); + void OnSignalSyncPointAck(uint32 id); // Try to read an updated copy of the state from shared memory. void TryUpdateState(); // Local cache of id to transfer buffer mapping. - typedef std::map<int32, gpu::Buffer> TransferBufferMap; TransferBufferMap transfer_buffers_; // Zero or more video decoder hosts owned by this proxy, keyed by their // decoder_route_id. - typedef std::map<int, scoped_refptr<GpuVideoDecodeAcceleratorHost> > Decoders; Decoders video_decoder_hosts_; // The last cached state received from the service. @@ -155,6 +161,10 @@ class CommandBufferProxyImpl GpuConsoleMessageCallback console_message_callback_; + // Tasks to be invoked in SignalSyncPoint responses. + uint32 next_signal_id_; + SignalTaskMap signal_tasks_; + DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl); }; diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc index 8a70149..123c734 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -141,6 +141,8 @@ bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { OnRetireSyncPoint) IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_WaitSyncPoint, OnWaitSyncPoint) + IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncPoint, + OnSignalSyncPoint) IPC_MESSAGE_HANDLER( GpuCommandBufferMsg_SetClientHasMemoryAllocationChangedCallback, OnSetClientHasMemoryAllocationChangedCallback) @@ -657,6 +659,19 @@ void GpuCommandBufferStub::OnSyncPointRetired() { OnReschedule(); } +void GpuCommandBufferStub::OnSignalSyncPoint(uint32 sync_point, uint32 id) { + GpuChannelManager* manager = channel_->gpu_channel_manager(); + manager->sync_point_manager()->AddSyncPointCallback( + sync_point, + base::Bind(&GpuCommandBufferStub::OnSignalSyncPointAck, + this->AsWeakPtr(), + id)); +} + +void GpuCommandBufferStub::OnSignalSyncPointAck(uint32 id) { + Send(new GpuCommandBufferMsg_SignalSyncPointAck(route_id_, id)); +} + void GpuCommandBufferStub::OnSetClientHasMemoryAllocationChangedCallback( bool has_callback) { TRACE_EVENT0( diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h index 5061a7d..c09a4c0 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -214,6 +214,8 @@ class GpuCommandBufferStub void OnRetireSyncPoint(uint32 sync_point); void OnWaitSyncPoint(uint32 sync_point); void OnSyncPointRetired(); + void OnSignalSyncPoint(uint32 sync_point, uint32 id); + void OnSignalSyncPointAck(uint32 id); void OnSetClientHasMemoryAllocationChangedCallback(bool); diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h index 3d61a72..e8db3a9 100644 --- a/content/common/gpu/gpu_messages.h +++ b/content/common/gpu/gpu_messages.h @@ -462,6 +462,17 @@ IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_RetireSyncPoint, IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_WaitSyncPoint, uint32 /* sync_point */) +// Makes this command buffer signal when a sync point is reached, by sending +// back a GpuCommandBufferMsg_SignalSyncPointAck message with the same +// signal_id. +IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_SignalSyncPoint, + uint32 /* sync_point */, + uint32 /* signal_id */) + +// Response to GpuCommandBufferMsg_SignalSyncPoint. +IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SignalSyncPointAck, + uint32 /* signal_id */) + //------------------------------------------------------------------------------ // Accelerated Video Decoder Messages // These messages are sent from Renderer process to GPU process. diff --git a/gpu/ipc/command_buffer_proxy.h b/gpu/ipc/command_buffer_proxy.h index d4412f0..af72db7 100644 --- a/gpu/ipc/command_buffer_proxy.h +++ b/gpu/ipc/command_buffer_proxy.h @@ -48,6 +48,11 @@ class GPU_EXPORT CommandBufferProxy : public gpu::CommandBuffer { // it, or gets destroyed. virtual void WaitSyncPoint(uint32) = 0; + // Makes this command buffer invoke a task when a sync point is reached, or + // the command buffer that inserted that sync point is destroyed. + virtual bool SignalSyncPoint(uint32 sync_point, + const base::Closure& callback) = 0; + // Register a callback to invoke whenever we recieve a new memory allocation. virtual void SetMemoryAllocationChangedCallback( const base::Callback<void(const GpuMemoryAllocationForRenderer&)>& diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.cc b/ppapi/proxy/ppapi_command_buffer_proxy.cc index 371870e..91cd268 100644 --- a/ppapi/proxy/ppapi_command_buffer_proxy.cc +++ b/ppapi/proxy/ppapi_command_buffer_proxy.cc @@ -69,6 +69,12 @@ void PpapiCommandBufferProxy::WaitSyncPoint(uint32 sync_point) { NOTIMPLEMENTED(); } +bool PpapiCommandBufferProxy::SignalSyncPoint(uint32 sync_point, + const base::Closure& callback) { + NOTIMPLEMENTED(); + return false; +} + void PpapiCommandBufferProxy::SetMemoryAllocationChangedCallback( const base::Callback<void(const GpuMemoryAllocationForRenderer&)>& callback) { diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.h b/ppapi/proxy/ppapi_command_buffer_proxy.h index 0a5cde5..a82d303 100644 --- a/ppapi/proxy/ppapi_command_buffer_proxy.h +++ b/ppapi/proxy/ppapi_command_buffer_proxy.h @@ -38,6 +38,8 @@ class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public CommandBufferProxy { virtual bool EnsureBackbuffer() OVERRIDE; virtual uint32 InsertSyncPoint() OVERRIDE; virtual void WaitSyncPoint(uint32 sync_point) OVERRIDE; + virtual bool SignalSyncPoint(uint32 sync_point, + const base::Closure& callback) OVERRIDE; virtual void SetMemoryAllocationChangedCallback( const base::Callback<void(const GpuMemoryAllocationForRenderer&)>& callback) OVERRIDE; |