diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-27 00:28:48 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-27 00:28:48 +0000 |
commit | 08bd43bd401695273f19468cec628710ffe13354 (patch) | |
tree | 37d917101696c2177460743747a1cbad80b2d7de /content | |
parent | 43b4137708c9d40639cc38b1c960a449b48229bd (diff) | |
download | chromium_src-08bd43bd401695273f19468cec628710ffe13354.zip chromium_src-08bd43bd401695273f19468cec628710ffe13354.tar.gz chromium_src-08bd43bd401695273f19468cec628710ffe13354.tar.bz2 |
Removed vestigial GL_latch_CHROMIUM code.
glFlush now has barrier semantics and is now used as an alternative.
This patch is dependent on https://bugs.webkit.org/show_bug.cgi?id=65043, now landed as webkit r91736.
Review URL: http://codereview.chromium.org/7495009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94215 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/common/gpu/gpu_channel.cc | 22 | ||||
-rw-r--r-- | content/common/gpu/gpu_channel.h | 7 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.cc | 7 | ||||
-rw-r--r-- | content/renderer/gpu/renderer_gl_context.cc | 142 | ||||
-rw-r--r-- | content/renderer/gpu/renderer_gl_context.h | 18 | ||||
-rw-r--r-- | content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc | 31 | ||||
-rw-r--r-- | content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h | 5 |
7 files changed, 1 insertions, 231 deletions
diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc index aba6c6d..17de5c4 100644 --- a/content/common/gpu/gpu_channel.cc +++ b/content/common/gpu/gpu_channel.cc @@ -61,28 +61,6 @@ 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()->SetScheduled(true); - } - latched_routes_.clear(); - } else { - // Add route_id context to a set to be woken upon any set latch. - latched_routes_.insert(route_id); - GpuCommandBufferStub* stub = stubs_.Lookup(route_id); - if (stub) - stub->scheduler()->SetScheduled(false); - } -#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 6f7614b..1efebca 100644 --- a/content/common/gpu/gpu_channel.h +++ b/content/common/gpu/gpu_channel.h @@ -122,11 +122,6 @@ 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: void OnDestroy(); @@ -181,8 +176,6 @@ class GpuChannel : public IPC::Channel::Listener, typedef IDMap<GpuSurfaceStub, IDMapOwnPointer> SurfaceMap; SurfaceMap surfaces_; - - 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 b86750a..a93c173 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -292,13 +292,6 @@ void GpuCommandBufferStub::OnParseError() { route_id_, state.context_lost_reason); msg->set_unblock(true); Send(msg); - // If an error occurs, the remaining commands will not be processed. - // Since we may have a pending WaitLatch on a related context, we need to - // forcefully unblock all contexts on the same GpuChannel. However, since we - // don't know whether the corresponding WaitLatch is in the past or future, - // it may cause other side effects to simply pass the next WaitLatch on all - // contexts. Instead, just lose all related contexts when there's an error. - channel_->DestroySoon(); } void GpuCommandBufferStub::OnFlush(int32 put_offset, diff --git a/content/renderer/gpu/renderer_gl_context.cc b/content/renderer/gpu/renderer_gl_context.cc index 4937a46..894a950 100644 --- a/content/renderer/gpu/renderer_gl_context.cc +++ b/content/renderer/gpu/renderer_gl_context.cc @@ -36,8 +36,6 @@ const int32 kCommandBufferSize = 1024 * 1024; // creation attributes. const int32 kTransferBufferSize = 1024 * 1024; -const uint32 kMaxLatchesPerRenderer = 2048; - // Singleton used to initialize and terminate the gles2 library. class GLES2Initializer { public: @@ -53,93 +51,6 @@ class GLES2Initializer { DISALLOW_COPY_AND_ASSIGN(GLES2Initializer); }; -// Shared memory allocator for latches. Creates a block of shared memory for -// each renderer process. -class LatchAllocator { - public: - static LatchAllocator* GetInstance(); - static uint32 size() { return kMaxLatchesPerRenderer*sizeof(uint32); } - static const uint32_t kFreeLatch = 0xffffffffu; - - LatchAllocator(); - ~LatchAllocator(); - - base::SharedMemoryHandle handle() const { return shm_->handle(); } - base::SharedMemory* shared_memory() { return shm_.get(); } - - bool AllocateLatch(uint32* latch_id); - bool FreeLatch(uint32 latch_id); - - private: - friend struct DefaultSingletonTraits<LatchAllocator>; - - scoped_ptr<base::SharedMemory> shm_; - // Pointer to mapped shared memory. - volatile uint32* latches_; - - DISALLOW_COPY_AND_ASSIGN(LatchAllocator); -}; - -//////////////////////////////////////////////////////////////////////////////// -/// LatchAllocator implementation - -LatchAllocator* LatchAllocator::GetInstance() { - return Singleton<LatchAllocator>::get(); -} - -LatchAllocator::LatchAllocator() { - base::SharedMemoryHandle handle; - RenderThread* render_thread = RenderThread::current(); - if (!render_thread->Send( - new ViewHostMsg_AllocateSharedMemoryBuffer(size(), &handle))) { - NOTREACHED() << "failed to send sync IPC"; - } - - if (!base::SharedMemory::IsHandleValid(handle)) { - NOTREACHED() << "failed to create shared memory"; - } - - // Handle is closed by the SharedMemory object below. This stops - // base::FileDescriptor from closing it as well. -#if defined(OS_POSIX) - handle.auto_close = false; -#endif - - shm_.reset(new base::SharedMemory(handle, false)); - if (!shm_->Map(size())) { - NOTREACHED() << "failed to map shared memory"; - } - - latches_ = static_cast<uint32*>(shm_->memory()); - // Mark all latches as unallocated. - for (uint32 i = 0; i < kMaxLatchesPerRenderer; ++i) - latches_[i] = kFreeLatch; -} - -LatchAllocator::~LatchAllocator() { -} - -bool LatchAllocator::AllocateLatch(uint32* latch_id) { - for (uint32 i = 0; i < kMaxLatchesPerRenderer; ++i) { - if (latches_[i] == kFreeLatch) { - // mark latch as taken and blocked. - // 0 means waiter will block, 1 means waiter will pass. - latches_[i] = 0; - *latch_id = i; - return true; - } - } - return false; -} - -bool LatchAllocator::FreeLatch(uint32 latch_id) { - if (latch_id < kMaxLatchesPerRenderer && latches_[latch_id] != kFreeLatch) { - latches_[latch_id] = kFreeLatch; - return true; - } - return false; -} - //////////////////////////////////////////////////////////////////////////////// static base::LazyInstance<GLES2Initializer> g_gles2_initializer( @@ -407,9 +318,6 @@ RendererGLContext::RendererGLContext(GpuChannelHost* channel) : channel_(channel), parent_(base::WeakPtr<RendererGLContext>()), parent_texture_id_(0), - child_to_parent_latch_(gpu::kInvalidLatchId), - parent_to_child_latch_(gpu::kInvalidLatchId), - latch_transfer_buffer_id_(-1), command_buffer_(NULL), gles2_helper_(NULL), transfer_buffer_id_(-1), @@ -527,24 +435,6 @@ bool RendererGLContext::Initialize(bool onscreen, return false; } - // Register transfer buffer so that the context can access latches. - LatchAllocator* latch_shm = LatchAllocator::GetInstance(); - latch_transfer_buffer_id_ = command_buffer_->RegisterTransferBuffer( - latch_shm->shared_memory(), LatchAllocator::size(), - gpu::kLatchSharedMemoryId); - if (latch_transfer_buffer_id_ != gpu::kLatchSharedMemoryId) { - Destroy(); - return false; - } - - // If this is a child context, setup latches for synchronization between child - // and parent. - if (!CreateLatch(&child_to_parent_latch_) || - !CreateLatch(&parent_to_child_latch_)) { - Destroy(); - return false; - } - // Create the object exposing the OpenGL API. gles2_implementation_ = new gpu::gles2::GLES2Implementation( gles2_helper_, @@ -565,10 +455,9 @@ void RendererGLContext::Destroy() { delete gles2_implementation_; gles2_implementation_ = NULL; - // Do not destroy these transfer buffers here, because commands are still + // Do not destroy this transfer buffer here, because commands are still // in flight on the GPU process that may access them. When the command buffer // is destroyed, the associated shared memory will be cleaned up. - latch_transfer_buffer_id_ = -1; transfer_buffer_id_ = -1; delete gles2_helper_; @@ -580,17 +469,6 @@ void RendererGLContext::Destroy() { } channel_ = NULL; - - // Destroy latches here, after the command buffer is destroyed so that no - // commands are still in flight that may access the latch memory. - if (child_to_parent_latch_ != gpu::kInvalidLatchId) { - DestroyLatch(child_to_parent_latch_); - child_to_parent_latch_ = gpu::kInvalidLatchId; - } - if (parent_to_child_latch_ != gpu::kInvalidLatchId) { - DestroyLatch(parent_to_child_latch_); - parent_to_child_latch_ = gpu::kInvalidLatchId; - } } void RendererGLContext::OnSwapBuffers() { @@ -608,21 +486,3 @@ void RendererGLContext::OnContextLost() { context_lost_callback_->Run(reason); } } - -bool RendererGLContext::CreateLatch(uint32* ret_latch) { - return LatchAllocator::GetInstance()->AllocateLatch(ret_latch); -} - -bool RendererGLContext::DestroyLatch(uint32 latch) { - return LatchAllocator::GetInstance()->FreeLatch(latch); -} - -bool RendererGLContext::GetParentToChildLatch(uint32* parent_to_child_latch) { - *parent_to_child_latch = parent_to_child_latch_; - return true; -} - -bool RendererGLContext::GetChildToParentLatch(uint32* child_to_parent_latch) { - *child_to_parent_latch = child_to_parent_latch_; - return true; -} diff --git a/content/renderer/gpu/renderer_gl_context.h b/content/renderer/gpu/renderer_gl_context.h index 1c0280e..911e0c6 100644 --- a/content/renderer/gpu/renderer_gl_context.h +++ b/content/renderer/gpu/renderer_gl_context.h @@ -181,21 +181,6 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> { CommandBufferProxy* GetCommandBufferProxy(); - // Create a latch for synchronization between contexts using glSetLatch and - // glWaitLatch. - // CreateLatch will only fail if there is a generally unrecoverable - // error, in which case 0 is returned. Returns latch_id on success. - bool CreateLatch(uint32* ret_latch); - - // Destroy a latch. - bool DestroyLatch(uint32 latch); - - // All child contexts get a latch pair automatically. These latches are used - // for synchronization with parent context. If *this* context does not have a - // parent context, these methods will return false. - bool GetParentToChildLatch(uint32* parent_to_child_latch); - bool GetChildToParentLatch(uint32* child_to_parent_latch); - private: explicit RendererGLContext(GpuChannelHost* channel); @@ -215,9 +200,6 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> { scoped_ptr<Callback0::Type> swap_buffers_callback_; scoped_ptr<Callback1<ContextLostReason>::Type> context_lost_callback_; uint32 parent_texture_id_; - uint32 child_to_parent_latch_; - uint32 parent_to_child_latch_; - int32 latch_transfer_buffer_id_; CommandBufferProxy* command_buffer_; gpu::gles2::GLES2CmdHelper* gles2_helper_; int32 transfer_buffer_id_; diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc index 7836744..8d4d0c8 100644 --- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc @@ -337,37 +337,6 @@ void WebGraphicsContext3DCommandBufferImpl::copyTextureToParentTextureCHROMIUM( gl_->Flush(); } -void WebGraphicsContext3DCommandBufferImpl::getParentToChildLatchCHROMIUM( - WGC3Duint* latch_id) -{ - if (!context_->GetParentToChildLatch(latch_id)) { - LOG(ERROR) << "getLatch must only be called on child context"; - synthesizeGLError(GL_INVALID_OPERATION); - *latch_id = gpu::kInvalidLatchId; - } -} - -void WebGraphicsContext3DCommandBufferImpl::getChildToParentLatchCHROMIUM( - WGC3Duint* latch_id) -{ - if (!context_->GetChildToParentLatch(latch_id)) { - LOG(ERROR) << "getLatch must only be called on child context"; - synthesizeGLError(GL_INVALID_OPERATION); - *latch_id = gpu::kInvalidLatchId; - } -} - -void WebGraphicsContext3DCommandBufferImpl::waitLatchCHROMIUM( - WGC3Duint latch_id) -{ -} - -void WebGraphicsContext3DCommandBufferImpl::setLatchCHROMIUM( - WGC3Duint latch_id) -{ - gl_->Flush(); -} - void WebGraphicsContext3DCommandBufferImpl:: rateLimitOffscreenContextCHROMIUM() { gl_->RateLimitOffscreenContextCHROMIUM(); diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h index e291c82..be6b9cc 100644 --- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h +++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h @@ -405,11 +405,6 @@ class WebGraphicsContext3DCommandBufferImpl virtual void copyTextureToParentTextureCHROMIUM( WebGLId texture, WebGLId parentTexture); - virtual void getParentToChildLatchCHROMIUM(WGC3Duint* latch_id); - virtual void getChildToParentLatchCHROMIUM(WGC3Duint* latch_id); - virtual void waitLatchCHROMIUM(WGC3Duint latch_id); - virtual void setLatchCHROMIUM(WGC3Duint latch_id); - virtual void rateLimitOffscreenContextCHROMIUM(); virtual WebKit::WebString getRequestableExtensionsCHROMIUM(); |