diff options
author | nhiroki <nhiroki@chromium.org> | 2015-11-04 21:56:05 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-05 05:56:50 +0000 |
commit | a1ab22a90140fe9e6c669998f3efc52795e569e2 (patch) | |
tree | 98e158c1d36c83f57f9c9334dc600dc7468f3c4f | |
parent | 29a936f7a618bc15e90e1308eab78ffc9d5b6ce8 (diff) | |
download | chromium_src-a1ab22a90140fe9e6c669998f3efc52795e569e2.zip chromium_src-a1ab22a90140fe9e6c669998f3efc52795e569e2.tar.gz chromium_src-a1ab22a90140fe9e6c669998f3efc52795e569e2.tar.bz2 |
Revert of Converted video frame and image callbacks to use new sync tokens. (patchset #9 id:160001 of https://codereview.chromium.org/1429213002/ )
Reason for revert:
This could be breaking webkit_tests:
http://build.chromium.org/p/chromium.webkit/builders/WebKit%20Linux%20%28dbg%29/builds/4445
http://build.chromium.org/p/chromium.webkit/builders/WebKit%20Mac10.7%20%28dbg%29/builds/25461
Original issue's description:
> Converted video frame and image callbacks to use new sync tokens.
>
> As an incremental step towards utilizing the new sync tokens, this
> CL converts existing video frame and image sync points to use
> sync tokens instead.
>
> In order to accomplish this, the GpuCommandBufferMsg_CreateImage
> IPC message has been modified to accept a fence_release parameter
> so that it can act as a sync token IPC.
>
> A new SyncPointClientWaiter concept has also added which can wait
> on other sync point clients without an associated order number.
> This only works because the SyncPointClientWaiter cannot be waited
> on so no deadlocks can occur.
>
> BUG=514815
> CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
>
> Committed: https://crrev.com/c7aff68a0c11820cc2b8d488851c682c0d32cd2b
> Cr-Commit-Position: refs/heads/master@{#357997}
TBR=dcheng@chromium.org,dalecurtis@chromium.org,piman@chromium.org,sky@chromium.org,dyen@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=514815
Review URL: https://codereview.chromium.org/1414793018
Cr-Commit-Position: refs/heads/master@{#358008}
44 files changed, 150 insertions, 315 deletions
diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc index 3ef6e76..fd32212 100644 --- a/cc/resources/video_resource_updater.cc +++ b/cc/resources/video_resource_updater.cc @@ -75,14 +75,13 @@ class SyncTokenClientImpl : public media::VideoFrame::SyncTokenClient { const gpu::SyncToken& sync_token) : gl_(gl), sync_token_(sync_token) {} ~SyncTokenClientImpl() override {} - void GenerateSyncToken(gpu::SyncToken* sync_token) override { + uint32 InsertSyncPoint() override { if (sync_token_.HasData()) { - *sync_token = sync_token_; - } else { - const uint64_t fence_sync = gl_->InsertFenceSyncCHROMIUM(); - gl_->ShallowFlushCHROMIUM(); - gl_->GenSyncTokenCHROMIUM(fence_sync, sync_token->GetData()); + DCHECK_EQ(gpu::CommandBufferNamespace::OLD_SYNC_POINTS, + sync_token_.namespace_id()); + return static_cast<uint32>(sync_token_.release_count()); } + return gl_->InsertSyncPointCHROMIUM(); } void WaitSyncToken(const gpu::SyncToken& sync_token) override { if (sync_token.HasData()) { diff --git a/cc/test/test_gpu_memory_buffer_manager.cc b/cc/test/test_gpu_memory_buffer_manager.cc index ed5e713..352a75c 100644 --- a/cc/test/test_gpu_memory_buffer_manager.cc +++ b/cc/test/test_gpu_memory_buffer_manager.cc @@ -114,8 +114,9 @@ TestGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer( return reinterpret_cast<gfx::GpuMemoryBuffer*>(buffer); } -void TestGpuMemoryBufferManager::SetDestructionSyncToken( +void TestGpuMemoryBufferManager::SetDestructionSyncPoint( gfx::GpuMemoryBuffer* buffer, - const gpu::SyncToken& sync_token) {} + uint32 sync_point) { +} } // namespace cc diff --git a/cc/test/test_gpu_memory_buffer_manager.h b/cc/test/test_gpu_memory_buffer_manager.h index 85f642c..a3720bf 100644 --- a/cc/test/test_gpu_memory_buffer_manager.h +++ b/cc/test/test_gpu_memory_buffer_manager.h @@ -25,8 +25,8 @@ class TestGpuMemoryBufferManager : public gpu::GpuMemoryBufferManager { gfx::BufferFormat format) override; gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer( ClientBuffer buffer) override; - void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer, - const gpu::SyncToken& sync_token) override; + void SetDestructionSyncPoint(gfx::GpuMemoryBuffer* buffer, + uint32 sync_point) override; private: DISALLOW_COPY_AND_ASSIGN(TestGpuMemoryBufferManager); diff --git a/components/mus/gles2/mojo_gpu_memory_buffer_manager.cc b/components/mus/gles2/mojo_gpu_memory_buffer_manager.cc index 1f5c084..5de16a5 100644 --- a/components/mus/gles2/mojo_gpu_memory_buffer_manager.cc +++ b/components/mus/gles2/mojo_gpu_memory_buffer_manager.cc @@ -35,9 +35,9 @@ MojoGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer( return MojoGpuMemoryBufferImpl::FromClientBuffer(buffer); } -void MojoGpuMemoryBufferManager::SetDestructionSyncToken( +void MojoGpuMemoryBufferManager::SetDestructionSyncPoint( gfx::GpuMemoryBuffer* buffer, - const gpu::SyncToken& sync_token) { + uint32 sync_point) { NOTIMPLEMENTED(); } diff --git a/components/mus/gles2/mojo_gpu_memory_buffer_manager.h b/components/mus/gles2/mojo_gpu_memory_buffer_manager.h index 6d4e235..b44c84c 100644 --- a/components/mus/gles2/mojo_gpu_memory_buffer_manager.h +++ b/components/mus/gles2/mojo_gpu_memory_buffer_manager.h @@ -25,8 +25,8 @@ class MojoGpuMemoryBufferManager : public gpu::GpuMemoryBufferManager { gfx::BufferFormat format) override; gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer( ClientBuffer buffer) override; - void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer, - const gpu::SyncToken& sync_token) override; + void SetDestructionSyncPoint(gfx::GpuMemoryBuffer* buffer, + uint32 sync_point) override; private: DISALLOW_COPY_AND_ASSIGN(MojoGpuMemoryBufferManager); diff --git a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc index b7f36b6..fa61b00a 100644 --- a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc +++ b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc @@ -67,9 +67,9 @@ void HostCreateGpuMemoryBufferFromHandle( void GpuMemoryBufferDeleted( scoped_refptr<base::SingleThreadTaskRunner> destruction_task_runner, const GpuMemoryBufferImpl::DestructionCallback& destruction_callback, - const gpu::SyncToken& sync_token) { + uint32 sync_point) { destruction_task_runner->PostTask( - FROM_HERE, base::Bind(destruction_callback, sync_token)); + FROM_HERE, base::Bind(destruction_callback, sync_point)); } bool IsNativeGpuMemoryBufferFactoryConfigurationSupported( @@ -342,11 +342,11 @@ BrowserGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer( return GpuMemoryBufferImpl::FromClientBuffer(buffer); } -void BrowserGpuMemoryBufferManager::SetDestructionSyncToken( +void BrowserGpuMemoryBufferManager::SetDestructionSyncPoint( gfx::GpuMemoryBuffer* buffer, - const gpu::SyncToken& sync_token) { + uint32 sync_point) { static_cast<GpuMemoryBufferImpl*>(buffer) - ->set_destruction_sync_token(sync_token); + ->set_destruction_sync_point(sync_point); } bool BrowserGpuMemoryBufferManager::OnMemoryDump( @@ -395,10 +395,10 @@ void BrowserGpuMemoryBufferManager::ChildProcessDeletedGpuMemoryBuffer( gfx::GpuMemoryBufferId id, base::ProcessHandle child_process_handle, int child_client_id, - const gpu::SyncToken& sync_token) { + uint32 sync_point) { DCHECK_CURRENTLY_ON(BrowserThread::IO); - DestroyGpuMemoryBufferOnIO(id, child_client_id, sync_token); + DestroyGpuMemoryBufferOnIO(id, child_client_id, sync_point); } void BrowserGpuMemoryBufferManager::ProcessRemoved( @@ -419,7 +419,7 @@ void BrowserGpuMemoryBufferManager::ProcessRemoved( GpuProcessHost* host = GpuProcessHost::FromID(buffer.second.gpu_host_id); if (host) - host->DestroyGpuMemoryBuffer(buffer.first, client_id, gpu::SyncToken()); + host->DestroyGpuMemoryBuffer(buffer.first, client_id, 0); } clients_.erase(client_it); @@ -654,7 +654,7 @@ void BrowserGpuMemoryBufferManager::GpuMemoryBufferCreatedOnIO( if (!handle.is_null()) { GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id); if (host) - host->DestroyGpuMemoryBuffer(handle.id, client_id, gpu::SyncToken()); + host->DestroyGpuMemoryBuffer(handle.id, client_id, 0); } callback.Run(gfx::GpuMemoryBufferHandle()); return; @@ -706,7 +706,7 @@ void BrowserGpuMemoryBufferManager::GpuMemoryBufferCreatedOnIO( void BrowserGpuMemoryBufferManager::DestroyGpuMemoryBufferOnIO( gfx::GpuMemoryBufferId id, int client_id, - const gpu::SyncToken& sync_token) { + uint32 sync_point) { DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK(clients_.find(client_id) != clients_.end()); @@ -727,7 +727,7 @@ void BrowserGpuMemoryBufferManager::DestroyGpuMemoryBufferOnIO( GpuProcessHost* host = GpuProcessHost::FromID(buffer_it->second.gpu_host_id); if (host) - host->DestroyGpuMemoryBuffer(id, client_id, sync_token); + host->DestroyGpuMemoryBuffer(id, client_id, sync_point); buffers.erase(buffer_it); } diff --git a/content/browser/gpu/browser_gpu_memory_buffer_manager.h b/content/browser/gpu/browser_gpu_memory_buffer_manager.h index 09c8f73..9cb9c43 100644 --- a/content/browser/gpu/browser_gpu_memory_buffer_manager.h +++ b/content/browser/gpu/browser_gpu_memory_buffer_manager.h @@ -65,8 +65,8 @@ class CONTENT_EXPORT BrowserGpuMemoryBufferManager gfx::BufferFormat format) override; gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer( ClientBuffer buffer) override; - void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer, - const gpu::SyncToken& sync_token) override; + void SetDestructionSyncPoint(gfx::GpuMemoryBuffer* buffer, + uint32 sync_point) override; // Overridden from base::trace_event::MemoryDumpProvider: bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, @@ -90,7 +90,7 @@ class CONTENT_EXPORT BrowserGpuMemoryBufferManager gfx::GpuMemoryBufferId id, base::ProcessHandle child_process_handle, int child_client_id, - const gpu::SyncToken& sync_token); + uint32 sync_point); void ProcessRemoved(base::ProcessHandle process_handle, int client_id); bool IsNativeGpuMemoryBufferConfiguration(gfx::BufferFormat format, @@ -164,7 +164,7 @@ class CONTENT_EXPORT BrowserGpuMemoryBufferManager const gfx::GpuMemoryBufferHandle& handle); void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, int client_id, - const gpu::SyncToken& sync_token); + uint32 sync_point); uint64_t ClientIdToTracingProcessId(int client_id) const; diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index a3b56cc..9edf3ab 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -766,12 +766,12 @@ void GpuProcessHost::CreateGpuMemoryBufferFromHandle( void GpuProcessHost::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id, - const gpu::SyncToken& sync_token) { + int sync_point) { TRACE_EVENT0("gpu", "GpuProcessHost::DestroyGpuMemoryBuffer"); DCHECK(CalledOnValidThread()); - Send(new GpuMsg_DestroyGpuMemoryBuffer(id, client_id, sync_token)); + Send(new GpuMsg_DestroyGpuMemoryBuffer(id, client_id, sync_point)); } void GpuProcessHost::OnInitialized(bool result, const gpu::GPUInfo& gpu_info) { diff --git a/content/browser/gpu/gpu_process_host.h b/content/browser/gpu/gpu_process_host.h index 245e330..83e3410 100644 --- a/content/browser/gpu/gpu_process_host.h +++ b/content/browser/gpu/gpu_process_host.h @@ -40,10 +40,6 @@ namespace IPC { struct ChannelHandle; } -namespace gpu { -struct SyncToken; -} - namespace content { class BrowserChildProcessHostImpl; class GpuMainThread; @@ -152,7 +148,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, // Tells the GPU process to destroy GPU memory buffer. void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id, - const gpu::SyncToken& sync_token); + int sync_point); // What kind of GPU process, e.g. sandboxed or unsandboxed. GpuProcessKind kind(); diff --git a/content/browser/renderer_host/media/video_capture_controller.cc b/content/browser/renderer_host/media/video_capture_controller.cc index 01a7772..50f3a5f 100644 --- a/content/browser/renderer_host/media/video_capture_controller.cc +++ b/content/browser/renderer_host/media/video_capture_controller.cc @@ -45,9 +45,7 @@ class SyncTokenClientImpl : public VideoFrame::SyncTokenClient { public: explicit SyncTokenClientImpl(GLHelper* gl_helper) : gl_helper_(gl_helper) {} ~SyncTokenClientImpl() override {} - void GenerateSyncToken(gpu::SyncToken* sync_token) override { - gl_helper_->GenerateSyncToken(sync_token); - } + uint32 InsertSyncPoint() override { return gl_helper_->InsertSyncPoint(); } void WaitSyncToken(const gpu::SyncToken& sync_token) override { gl_helper_->WaitSyncToken(sync_token); } diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index 9feac40..8861e37 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc @@ -687,11 +687,11 @@ void RenderMessageFilter::GpuMemoryBufferAllocated( void RenderMessageFilter::OnDeletedGpuMemoryBuffer( gfx::GpuMemoryBufferId id, - const gpu::SyncToken& sync_token) { + uint32 sync_point) { DCHECK(BrowserGpuMemoryBufferManager::current()); BrowserGpuMemoryBufferManager::current()->ChildProcessDeletedGpuMemoryBuffer( - id, PeerHandle(), render_process_id_, sync_token); + id, PeerHandle(), render_process_id_, sync_point); } } // namespace content diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h index da1f387..2fdf7f6 100644 --- a/content/browser/renderer_host/render_message_filter.h +++ b/content/browser/renderer_host/render_message_filter.h @@ -59,10 +59,6 @@ namespace gfx { struct GpuMemoryBufferHandle; } -namespace gpu { -struct SyncToken; -} - namespace media { class AudioManager; struct MediaLogEvent; @@ -214,7 +210,7 @@ class CONTENT_EXPORT RenderMessageFilter : public BrowserMessageFilter { void GpuMemoryBufferAllocated(IPC::Message* reply, const gfx::GpuMemoryBufferHandle& handle); void OnDeletedGpuMemoryBuffer(gfx::GpuMemoryBufferId id, - const gpu::SyncToken& sync_token); + uint32 sync_point); // Cached resource request dispatcher host, guaranteed to be non-null. We do // not own it; it is managed by the BrowserProcess, which has a wider scope diff --git a/content/child/child_gpu_memory_buffer_manager.cc b/content/child/child_gpu_memory_buffer_manager.cc index c83ceea..6eaf229 100644 --- a/content/child/child_gpu_memory_buffer_manager.cc +++ b/content/child/child_gpu_memory_buffer_manager.cc @@ -13,10 +13,10 @@ namespace { void DeletedGpuMemoryBuffer(ThreadSafeSender* sender, gfx::GpuMemoryBufferId id, - const gpu::SyncToken& sync_token) { + uint32 sync_point) { TRACE_EVENT0("renderer", "ChildGpuMemoryBufferManager::DeletedGpuMemoryBuffer"); - sender->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer(id, sync_token)); + sender->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer(id, sync_point)); } } // namespace @@ -52,8 +52,7 @@ ChildGpuMemoryBufferManager::AllocateGpuMemoryBuffer(const gfx::Size& size, handle, size, format, usage, base::Bind(&DeletedGpuMemoryBuffer, sender_, handle.id))); if (!buffer) { - sender_->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer( - handle.id, gpu::SyncToken())); + sender_->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer(handle.id, 0)); return nullptr; } @@ -75,11 +74,11 @@ ChildGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer( return GpuMemoryBufferImpl::FromClientBuffer(buffer); } -void ChildGpuMemoryBufferManager::SetDestructionSyncToken( +void ChildGpuMemoryBufferManager::SetDestructionSyncPoint( gfx::GpuMemoryBuffer* buffer, - const gpu::SyncToken& sync_token) { + uint32 sync_point) { static_cast<GpuMemoryBufferImpl*>(buffer) - ->set_destruction_sync_token(sync_token); + ->set_destruction_sync_point(sync_point); } } // namespace content diff --git a/content/child/child_gpu_memory_buffer_manager.h b/content/child/child_gpu_memory_buffer_manager.h index 1cdb945..2625853 100644 --- a/content/child/child_gpu_memory_buffer_manager.h +++ b/content/child/child_gpu_memory_buffer_manager.h @@ -26,8 +26,8 @@ class ChildGpuMemoryBufferManager : public gpu::GpuMemoryBufferManager { gfx::BufferFormat format) override; gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer( ClientBuffer buffer) override; - void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer, - const gpu::SyncToken& sync_token) override; + void SetDestructionSyncPoint(gfx::GpuMemoryBuffer* buffer, + uint32 sync_point) override; private: scoped_refptr<ThreadSafeSender> sender_; diff --git a/content/common/child_process_host_impl.cc b/content/common/child_process_host_impl.cc index b7ce51b..707d644a 100644 --- a/content/common/child_process_host_impl.cc +++ b/content/common/child_process_host_impl.cc @@ -317,7 +317,7 @@ void ChildProcessHostImpl::OnAllocateGpuMemoryBuffer( void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( gfx::GpuMemoryBufferId id, - const gpu::SyncToken& sync_token) { + uint32 sync_point) { // Note: Nothing to do here as ownership of shared memory backed // GpuMemoryBuffers is passed with IPC. } diff --git a/content/common/child_process_host_impl.h b/content/common/child_process_host_impl.h index f07e2a8..d859323 100644 --- a/content/common/child_process_host_impl.h +++ b/content/common/child_process_host_impl.h @@ -28,10 +28,6 @@ namespace IPC { class MessageFilter; } -namespace gpu { -struct SyncToken; -} - namespace content { class ChildProcessHostDelegate; @@ -105,7 +101,7 @@ class CONTENT_EXPORT ChildProcessHostImpl : public ChildProcessHost, gfx::BufferUsage usage, gfx::GpuMemoryBufferHandle* handle); void OnDeletedGpuMemoryBuffer(gfx::GpuMemoryBufferId id, - const gpu::SyncToken& sync_token); + uint32 sync_point); ChildProcessHostDelegate* delegate_; base::Process peer_process_; diff --git a/content/common/child_process_messages.h b/content/common/child_process_messages.h index ec2a4bf..7e78e87 100644 --- a/content/common/child_process_messages.h +++ b/content/common/child_process_messages.h @@ -14,7 +14,6 @@ #include "cc/resources/shared_bitmap_manager.h" #include "content/common/content_export.h" #include "content/common/host_discardable_shared_memory_manager.h" -#include "gpu/command_buffer/common/sync_token.h" #include "ipc/ipc_message_macros.h" #include "ui/gfx/gpu_memory_buffer.h" #include "ui/gfx/ipc/gfx_param_traits.h" @@ -211,7 +210,7 @@ IPC_SYNC_MESSAGE_CONTROL5_1(ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer, // Informs the browser that the child deleted a gpu memory buffer. IPC_MESSAGE_CONTROL2(ChildProcessHostMsg_DeletedGpuMemoryBuffer, gfx::GpuMemoryBufferId, - gpu::SyncToken /* sync_token */) + uint32 /* sync_point */) // Asks the browser to create a block of discardable shared memory for the // child process. diff --git a/content/common/gpu/client/command_buffer_proxy_impl.cc b/content/common/gpu/client/command_buffer_proxy_impl.cc index b8785bc..c3c8419 100644 --- a/content/common/gpu/client/command_buffer_proxy_impl.cc +++ b/content/common/gpu/client/command_buffer_proxy_impl.cc @@ -400,7 +400,7 @@ gpu::Capabilities CommandBufferProxyImpl::GetCapabilities() { int32_t CommandBufferProxyImpl::CreateImage(ClientBuffer buffer, size_t width, size_t height, - unsigned internal_format) { + unsigned internalformat) { CheckLock(); if (last_state_.error != gpu::error::kNoError) return -1; @@ -416,47 +416,29 @@ int32_t CommandBufferProxyImpl::CreateImage(ClientBuffer buffer, // This handle is owned by the GPU process and must be passed to it or it // will leak. In otherwords, do not early out on error between here and the // sending of the CreateImage IPC below. - bool requires_sync_token = false; + bool requires_sync_point = false; gfx::GpuMemoryBufferHandle handle = channel_->ShareGpuMemoryBufferToGpuProcess(gpu_memory_buffer->GetHandle(), - &requires_sync_token); - - uint64_t image_fence_sync = 0; - if (requires_sync_token) { - image_fence_sync = GenerateFenceSyncRelease(); - - // Make sure fence syncs were flushed before CreateImage() was called. - DCHECK_LE(image_fence_sync - 1, flushed_fence_sync_release_); - } + &requires_sync_point); DCHECK(gpu::ImageFactory::IsGpuMemoryBufferFormatSupported( gpu_memory_buffer->GetFormat(), capabilities_)); DCHECK(gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat( gfx::Size(width, height), gpu_memory_buffer->GetFormat())); DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( - internal_format, gpu_memory_buffer->GetFormat())); - - GpuCommandBufferMsg_CreateImage_Params params; - params.id = new_id; - params.gpu_memory_buffer = handle; - params.size = gfx::Size(width, height); - params.format = gpu_memory_buffer->GetFormat(); - params.internal_format = internal_format; - params.image_release_count = image_fence_sync; - - if (!Send(new GpuCommandBufferMsg_CreateImage(route_id_, params))) + internalformat, gpu_memory_buffer->GetFormat())); + if (!Send(new GpuCommandBufferMsg_CreateImage(route_id_, + new_id, + handle, + gfx::Size(width, height), + gpu_memory_buffer->GetFormat(), + internalformat))) { return -1; + } - if (image_fence_sync) { - gpu::SyncToken sync_token(GetNamespaceID(), GetCommandBufferID(), - image_fence_sync); - - // Force a synchronous IPC to validate sync token. - channel_->ValidateFlushIDReachedServer(stream_id_, true); - sync_token.SetVerifyFlush(); - - gpu_memory_buffer_manager->SetDestructionSyncToken(gpu_memory_buffer, - sync_token); + if (requires_sync_point) { + gpu_memory_buffer_manager->SetDestructionSyncPoint(gpu_memory_buffer, + InsertSyncPoint()); } return new_id; @@ -473,18 +455,18 @@ void CommandBufferProxyImpl::DestroyImage(int32 id) { int32_t CommandBufferProxyImpl::CreateGpuMemoryBufferImage( size_t width, size_t height, - unsigned internal_format, + unsigned internalformat, unsigned usage) { CheckLock(); scoped_ptr<gfx::GpuMemoryBuffer> buffer( channel_->gpu_memory_buffer_manager()->AllocateGpuMemoryBuffer( gfx::Size(width, height), - gpu::ImageFactory::DefaultBufferFormatForImageFormat(internal_format), + gpu::ImageFactory::DefaultBufferFormatForImageFormat(internalformat), gfx::BufferUsage::SCANOUT)); if (!buffer) return -1; - return CreateImage(buffer->AsClientBuffer(), width, height, internal_format); + return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); } uint32 CommandBufferProxyImpl::CreateStreamTexture(uint32 texture_id) { @@ -548,8 +530,7 @@ bool CommandBufferProxyImpl::IsFenceSyncFlushReceived(uint64_t release) { return true; // Has not been validated, validate it now. - UpdateVerifiedReleases( - channel_->ValidateFlushIDReachedServer(stream_id_, false)); + UpdateVerifiedReleases(channel_->ValidateFlushIDReachedServer(stream_id_)); return release <= verified_fence_sync_release_; } diff --git a/content/common/gpu/client/command_buffer_proxy_impl.h b/content/common/gpu/client/command_buffer_proxy_impl.h index 5646cca..39bc76b 100644 --- a/content/common/gpu/client/command_buffer_proxy_impl.h +++ b/content/common/gpu/client/command_buffer_proxy_impl.h @@ -106,11 +106,11 @@ class CommandBufferProxyImpl int32 CreateImage(ClientBuffer buffer, size_t width, size_t height, - unsigned internal_format) override; + unsigned internalformat) override; void DestroyImage(int32 id) override; int32 CreateGpuMemoryBufferImage(size_t width, size_t height, - unsigned internal_format, + unsigned internalformat, unsigned usage) override; uint32 InsertSyncPoint() override; uint32_t InsertFutureSyncPoint() override; diff --git a/content/common/gpu/client/gl_helper.cc b/content/common/gpu/client/gl_helper.cc index 33c9521..88c6499 100644 --- a/content/common/gpu/client/gl_helper.cc +++ b/content/common/gpu/client/gl_helper.cc @@ -954,12 +954,6 @@ void GLHelper::DeleteTexture(GLuint texture_id) { uint32 GLHelper::InsertSyncPoint() { return gl_->InsertSyncPointCHROMIUM(); } -void GLHelper::GenerateSyncToken(gpu::SyncToken* sync_token) { - const uint64_t fence_sync = gl_->InsertFenceSyncCHROMIUM(); - gl_->ShallowFlushCHROMIUM(); - gl_->GenSyncTokenCHROMIUM(fence_sync, sync_token->GetData()); -} - void GLHelper::WaitSyncToken(const gpu::SyncToken& sync_token) { gl_->WaitSyncTokenCHROMIUM(sync_token.GetConstData()); } diff --git a/content/common/gpu/client/gl_helper.h b/content/common/gpu/client/gl_helper.h index c8224d4..828097d 100644 --- a/content/common/gpu/client/gl_helper.h +++ b/content/common/gpu/client/gl_helper.h @@ -247,9 +247,6 @@ class CONTENT_EXPORT GLHelper { // Insert a sync point into the GL command buffer. uint32 InsertSyncPoint(); - // Inserts a fence sync, flushes, and generates a sync token. - void GenerateSyncToken(gpu::SyncToken* sync_token); - // Wait for the sync token before executing further GL commands. void WaitSyncToken(const gpu::SyncToken& sync_token); diff --git a/content/common/gpu/client/gpu_channel_host.cc b/content/common/gpu/client/gpu_channel_host.cc index 8ff3ab8..30700df 100644 --- a/content/common/gpu/client/gpu_channel_host.cc +++ b/content/common/gpu/client/gpu_channel_host.cc @@ -398,8 +398,7 @@ int32 GpuChannelHost::GenerateStreamID() { return next_stream_id_.GetNext(); } -uint32_t GpuChannelHost::ValidateFlushIDReachedServer(int32 stream_id, - bool force_validate) { +uint32_t GpuChannelHost::ValidateFlushIDReachedServer(int32 stream_id) { // Store what flush ids we will be validating for all streams. base::hash_map<int32, uint32_t> validate_flushes; uint32_t flushed_stream_flush_id = 0; @@ -422,7 +421,7 @@ uint32_t GpuChannelHost::ValidateFlushIDReachedServer(int32 stream_id, } } - if (!force_validate && flushed_stream_flush_id == verified_stream_flush_id) { + if (flushed_stream_flush_id == verified_stream_flush_id) { // Current stream has no unverified flushes. return verified_stream_flush_id; } diff --git a/content/common/gpu/client/gpu_channel_host.h b/content/common/gpu/client/gpu_channel_host.h index b5488ed9..a161a78 100644 --- a/content/common/gpu/client/gpu_channel_host.h +++ b/content/common/gpu/client/gpu_channel_host.h @@ -190,7 +190,7 @@ class GpuChannelHost : public IPC::Sender, // If the validation fails (which can only happen upon context lost), the // highest validated flush id will not change. If no flush ID were ever // validated then it will return 0 (Note the lowest valid flush ID is 1). - uint32_t ValidateFlushIDReachedServer(int32 stream_id, bool force_validate); + uint32_t ValidateFlushIDReachedServer(int32 stream_id); // Returns the highest validated flush ID for a given stream. uint32_t GetHighestValidatedFlushID(int32 stream_id); diff --git a/content/common/gpu/client/gpu_memory_buffer_impl.cc b/content/common/gpu/client/gpu_memory_buffer_impl.cc index e900829..bfe4656 100644 --- a/content/common/gpu/client/gpu_memory_buffer_impl.cc +++ b/content/common/gpu/client/gpu_memory_buffer_impl.cc @@ -29,11 +29,12 @@ GpuMemoryBufferImpl::GpuMemoryBufferImpl(gfx::GpuMemoryBufferId id, size_(size), format_(format), callback_(callback), - mapped_(false) {} + mapped_(false), + destruction_sync_point_(0) {} GpuMemoryBufferImpl::~GpuMemoryBufferImpl() { DCHECK(!mapped_); - callback_.Run(destruction_sync_token_); + callback_.Run(destruction_sync_point_); } // static diff --git a/content/common/gpu/client/gpu_memory_buffer_impl.h b/content/common/gpu/client/gpu_memory_buffer_impl.h index a3ba3f5..44b528e 100644 --- a/content/common/gpu/client/gpu_memory_buffer_impl.h +++ b/content/common/gpu/client/gpu_memory_buffer_impl.h @@ -8,7 +8,6 @@ #include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" -#include "gpu/command_buffer/common/sync_token.h" #include "ui/gfx/geometry/size.h" #include "ui/gfx/gpu_memory_buffer.h" @@ -17,7 +16,7 @@ namespace content { // Provides common implementation of a GPU memory buffer. class CONTENT_EXPORT GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { public: - typedef base::Callback<void(const gpu::SyncToken& sync)> DestructionCallback; + typedef base::Callback<void(uint32 sync_point)> DestructionCallback; ~GpuMemoryBufferImpl() override; @@ -41,8 +40,8 @@ class CONTENT_EXPORT GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { gfx::GpuMemoryBufferId GetId() const override; ClientBuffer AsClientBuffer() override; - void set_destruction_sync_token(const gpu::SyncToken& sync_token) { - destruction_sync_token_ = sync_token; + void set_destruction_sync_point(uint32 sync_point) { + destruction_sync_point_ = sync_point; } protected: @@ -56,7 +55,7 @@ class CONTENT_EXPORT GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { const gfx::BufferFormat format_; const DestructionCallback callback_; bool mapped_; - gpu::SyncToken destruction_sync_token_; + uint32 destruction_sync_point_; private: DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl); diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory_unittest.cc b/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory_unittest.cc index 251e16c..cce258b 100644 --- a/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory_unittest.cc +++ b/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory_unittest.cc @@ -12,7 +12,7 @@ INSTANTIATE_TYPED_TEST_CASE_P(GpuMemoryBufferImplSharedMemory, GpuMemoryBufferImplTest, GpuMemoryBufferImplSharedMemory); -void BufferDestroyed(bool* destroyed, const gpu::SyncToken& sync_token) { +void BufferDestroyed(bool* destroyed, uint32 sync_point) { *destroyed = true; } diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc index 3f603a6..4d9c435 100644 --- a/content/common/gpu/gpu_channel_manager.cc +++ b/content/common/gpu/gpu_channel_manager.cc @@ -60,7 +60,6 @@ GpuChannelManager::GpuChannelManager( this, GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit), sync_point_manager_(sync_point_manager), - sync_point_client_waiter_(new gpu::SyncPointClientWaiter), gpu_memory_buffer_factory_(gpu_memory_buffer_factory), weak_factory_(this) { DCHECK(task_runner); @@ -228,22 +227,17 @@ void GpuChannelManager::DestroyGpuMemoryBufferOnIO( void GpuChannelManager::OnDestroyGpuMemoryBuffer( gfx::GpuMemoryBufferId id, int client_id, - const gpu::SyncToken& sync_token) { - if (sync_token.HasData()) { - scoped_refptr<gpu::SyncPointClientState> release_state = - sync_point_manager()->GetSyncPointClientState( - sync_token.namespace_id(), sync_token.command_buffer_id()); - if (release_state) { - sync_point_client_waiter_->Wait( - release_state.get(), sync_token.release_count(), - base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer, - base::Unretained(this), id, client_id)); - return; - } + int32 sync_point) { + if (!sync_point) { + DestroyGpuMemoryBuffer(id, client_id); + } else { + sync_point_manager()->AddSyncPointCallback( + sync_point, + base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer, + base::Unretained(this), + id, + client_id)); } - - // No sync token or invalid sync token, destroy immediately. - DestroyGpuMemoryBuffer(id, client_id); } void GpuChannelManager::OnUpdateValueState( diff --git a/content/common/gpu/gpu_channel_manager.h b/content/common/gpu/gpu_channel_manager.h index c3e889a..19cec9d 100644 --- a/content/common/gpu/gpu_channel_manager.h +++ b/content/common/gpu/gpu_channel_manager.h @@ -34,9 +34,7 @@ class GLShareGroup; namespace gpu { class PreemptionFlag; -class SyncPointClientWaiter; class SyncPointManager; -struct SyncToken; union ValueState; namespace gles2 { class FramebufferCompletenessCache; @@ -158,7 +156,7 @@ class CONTENT_EXPORT GpuChannelManager : public IPC::Listener, void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, int client_id); void OnDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id, - const gpu::SyncToken& sync_token); + int32 sync_point); void OnUpdateValueState(int client_id, unsigned int target, @@ -184,7 +182,6 @@ class CONTENT_EXPORT GpuChannelManager : public IPC::Listener, GpuMemoryManager gpu_memory_manager_; // SyncPointManager guaranteed to outlive running MessageLoop. gpu::SyncPointManager* sync_point_manager_; - scoped_ptr<gpu::SyncPointClientWaiter> sync_point_client_waiter_; scoped_ptr<gpu::gles2::ProgramCache> program_cache_; scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; scoped_refptr<gpu::gles2::FramebufferCompletenessCache> diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc index a26854f..b82d715 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -1107,15 +1107,12 @@ void GpuCommandBufferStub::OnWaitFenceSyncCompleted( scheduler_->SetScheduled(true); } -void GpuCommandBufferStub::OnCreateImage( - const GpuCommandBufferMsg_CreateImage_Params& params) { +void GpuCommandBufferStub::OnCreateImage(int32 id, + gfx::GpuMemoryBufferHandle handle, + gfx::Size size, + gfx::BufferFormat format, + uint32 internalformat) { TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnCreateImage"); - const int32_t id = params.id; - const gfx::GpuMemoryBufferHandle& handle = params.gpu_memory_buffer; - const gfx::Size& size = params.size; - const gfx::BufferFormat& format = params.format; - const uint32_t internalformat = params.internal_format; - const uint64_t image_release_count = params.image_release_count; if (!decoder_) return; @@ -1151,9 +1148,6 @@ void GpuCommandBufferStub::OnCreateImage( return; image_manager->AddImage(image.get(), id); - if (image_release_count) { - sync_point_client_->ReleaseFenceSync(image_release_count); - } } void GpuCommandBufferStub::OnDestroyImage(int32 id) { diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h index 0537c30..910cd91 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -44,8 +44,6 @@ class SubscriptionRefSet; } } -struct GpuCommandBufferMsg_CreateImage_Params; - namespace content { class GpuChannel; @@ -216,7 +214,11 @@ class GpuCommandBufferStub uint64_t command_buffer_id, uint64_t release); - void OnCreateImage(const GpuCommandBufferMsg_CreateImage_Params& params); + void OnCreateImage(int32 id, + gfx::GpuMemoryBufferHandle handle, + gfx::Size size, + gfx::BufferFormat format, + uint32 internalformat); void OnDestroyImage(int32 id); void OnCreateStreamTexture(uint32 texture_id, int32 stream_id, diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h index a9c84a4..949ecf9 100644 --- a/content/common/gpu/gpu_messages.h +++ b/content/common/gpu/gpu_messages.h @@ -184,16 +184,7 @@ IPC_STRUCT_BEGIN(GpuStreamTextureMsg_MatrixChanged_Params) IPC_STRUCT_END() #endif -IPC_STRUCT_BEGIN(GpuCommandBufferMsg_CreateImage_Params) - IPC_STRUCT_MEMBER(int32, id) - IPC_STRUCT_MEMBER(gfx::GpuMemoryBufferHandle, gpu_memory_buffer) - IPC_STRUCT_MEMBER(gfx::Size, size) - IPC_STRUCT_MEMBER(gfx::BufferFormat, format) - IPC_STRUCT_MEMBER(uint32, internal_format) - IPC_STRUCT_MEMBER(uint64, image_release_count) -IPC_STRUCT_END() - -IPC_STRUCT_TRAITS_BEGIN(gpu::DxDiagNode) + IPC_STRUCT_TRAITS_BEGIN(gpu::DxDiagNode) IPC_STRUCT_TRAITS_MEMBER(values) IPC_STRUCT_TRAITS_MEMBER(children) IPC_STRUCT_TRAITS_END() @@ -340,8 +331,8 @@ IPC_MESSAGE_CONTROL1(GpuMsg_CreateGpuMemoryBufferFromHandle, // Tells the GPU process to destroy buffer. IPC_MESSAGE_CONTROL3(GpuMsg_DestroyGpuMemoryBuffer, gfx::GpuMemoryBufferId, /* id */ - int32, /* client_id */ - gpu::SyncToken /* sync_token */) + int32, /* client_id */ + int32 /* sync_point */) // Create and initialize a hardware jpeg decoder using the specified route_id. // Created decoders should be freed with AcceleratedJpegDecoderMsg_Destroy when @@ -661,8 +652,12 @@ IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SignalAck, // Create an image from an existing gpu memory buffer. The id that can be // used to identify the image from a command buffer. -IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_CreateImage, - GpuCommandBufferMsg_CreateImage_Params /* params */) +IPC_MESSAGE_ROUTED5(GpuCommandBufferMsg_CreateImage, + int32 /* id */, + gfx::GpuMemoryBufferHandle /* gpu_memory_buffer */, + gfx::Size /* size */, + gfx::BufferFormat /* format */, + uint32 /* internalformat */) // Destroy a previously created image. IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_DestroyImage, diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc index ceecc08..e732515 100644 --- a/content/renderer/media/android/webmediaplayer_android.cc +++ b/content/renderer/media/android/webmediaplayer_android.cc @@ -136,10 +136,11 @@ class SyncTokenClientImpl : public media::VideoFrame::SyncTokenClient { blink::WebGraphicsContext3D* web_graphics_context) : web_graphics_context_(web_graphics_context) {} ~SyncTokenClientImpl() override {} - void GenerateSyncToken(gpu::SyncToken* sync_token) override { - if (!web_graphics_context_->insertSyncPoint(sync_token->GetData())) { - sync_token->Clear(); - } + uint32 InsertSyncPoint() override { + gpu::SyncToken sync_token; + if (!web_graphics_context_->insertSyncPoint(sync_token.GetData())) + return 0; + return static_cast<uint32>(sync_token.release_count()); } void WaitSyncToken(const gpu::SyncToken& sync_token) override { web_graphics_context_->waitSyncToken(sync_token.GetConstData()); diff --git a/content/renderer/media/video_capture_impl.cc b/content/renderer/media/video_capture_impl.cc index 3349590..174344d 100644 --- a/content/renderer/media/video_capture_impl.cc +++ b/content/renderer/media/video_capture_impl.cc @@ -100,7 +100,7 @@ class VideoCaptureImpl::ClientBuffer2 buffer->Unmap(); } - void DestroyGpuMemoryBuffer(const gpu::SyncToken& sync_token) {} + void DestroyGpuMemoryBuffer(uint32 sync_point) {} const std::vector<gfx::GpuMemoryBufferHandle> handles_; const gfx::Size size_; diff --git a/content/test/gpu_memory_buffer_impl_test_template.h b/content/test/gpu_memory_buffer_impl_test_template.h index 73cce9e..a91589f 100644 --- a/content/test/gpu_memory_buffer_impl_test_template.h +++ b/content/test/gpu_memory_buffer_impl_test_template.h @@ -32,7 +32,7 @@ class GpuMemoryBufferImplTest : public testing::Test { private: void FreeGpuMemoryBuffer(const base::Closure& free_callback, bool* destroyed, - const gpu::SyncToken& sync_token) { + uint32 sync_point) { free_callback.Run(); if (destroyed) *destroyed = true; diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index d1258e87..4fcb0b3 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -5522,7 +5522,6 @@ GLuint GLES2Implementation::CreateImageCHROMIUMHelper(ClientBuffer buffer, return 0; } - ShallowFlushCHROMIUM(); int32_t image_id = gpu_control_->CreateImage(buffer, width, height, internalformat); if (image_id < 0) { diff --git a/gpu/command_buffer/client/gpu_memory_buffer_manager.h b/gpu/command_buffer/client/gpu_memory_buffer_manager.h index c95f841..9502b28 100644 --- a/gpu/command_buffer/client/gpu_memory_buffer_manager.h +++ b/gpu/command_buffer/client/gpu_memory_buffer_manager.h @@ -12,8 +12,6 @@ namespace gpu { -struct SyncToken; - class GPU_EXPORT GpuMemoryBufferManager { public: GpuMemoryBufferManager(); @@ -36,8 +34,8 @@ class GPU_EXPORT GpuMemoryBufferManager { ClientBuffer buffer) = 0; // Associates destruction sync point with |buffer|. - virtual void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer, - const gpu::SyncToken& sync_token) = 0; + virtual void SetDestructionSyncPoint(gfx::GpuMemoryBuffer* buffer, + uint32 sync_point) = 0; protected: virtual ~GpuMemoryBufferManager(); diff --git a/gpu/command_buffer/service/in_process_command_buffer.cc b/gpu/command_buffer/service/in_process_command_buffer.cc index 5e1921a..b3b1b12 100644 --- a/gpu/command_buffer/service/in_process_command_buffer.cc +++ b/gpu/command_buffer/service/in_process_command_buffer.cc @@ -65,21 +65,6 @@ static void RunTaskWithResult(base::Callback<T(void)> task, completion->Signal(); } -struct ScopedOrderNumberProcessor { - ScopedOrderNumberProcessor(SyncPointOrderData* order_data, uint32_t order_num) - : order_data_(order_data), order_num_(order_num) { - order_data_->BeginProcessingOrderNumber(order_num_); - } - - ~ScopedOrderNumberProcessor() { - order_data_->FinishProcessingOrderNumber(order_num_); - } - - private: - SyncPointOrderData* order_data_; - uint32_t order_num_; -}; - struct GpuInProcessThreadHolder { GpuInProcessThreadHolder() : sync_point_manager(new SyncPointManager(false)), @@ -512,24 +497,22 @@ void InProcessCommandBuffer::FlushOnGpuThread(int32 put_offset, ScopedEvent handle_flush(&flush_event_); base::AutoLock lock(command_buffer_lock_); + sync_point_order_data_->BeginProcessingOrderNumber(order_num); + command_buffer_->Flush(put_offset); { - ScopedOrderNumberProcessor scoped_order_num(sync_point_order_data_.get(), - order_num); - command_buffer_->Flush(put_offset); - { - // Update state before signaling the flush event. - base::AutoLock lock(state_after_last_flush_lock_); - state_after_last_flush_ = command_buffer_->GetLastState(); - } - DCHECK((!error::IsError(state_after_last_flush_.error) && !context_lost_) || - (error::IsError(state_after_last_flush_.error) && context_lost_)); - - // Currently the in process command buffer does not support being - // descheduled, if it does we would need to back off on calling the finish - // processing number function until the message is rescheduled and finished - // processing. This DCHECK is to enforce this. - DCHECK(context_lost_ || put_offset == state_after_last_flush_.get_offset); + // Update state before signaling the flush event. + base::AutoLock lock(state_after_last_flush_lock_); + state_after_last_flush_ = command_buffer_->GetLastState(); } + DCHECK((!error::IsError(state_after_last_flush_.error) && !context_lost_) || + (error::IsError(state_after_last_flush_.error) && context_lost_)); + + // Currently the in process command buffer does not support being descheduled, + // if it does we would need to back off on calling the finish processing + // order number function until the message is rescheduled and finished + // processing. This DCHECK is to enforce this. + DCHECK(context_lost_ || put_offset == state_after_last_flush_.get_offset); + sync_point_order_data_->FinishProcessingOrderNumber(order_num); // If we've processed all pending commands but still have pending queries, // pump idle work until the query is passed. @@ -685,29 +668,17 @@ int32 InProcessCommandBuffer::CreateImage(ClientBuffer buffer, ShareGpuMemoryBufferToGpuThread(gpu_memory_buffer->GetHandle(), &requires_sync_point); - SyncPointManager* sync_manager = service_->sync_point_manager(); - const uint32_t order_num = - sync_point_order_data_->GenerateUnprocessedOrderNumber(sync_manager); + QueueTask(base::Bind(&InProcessCommandBuffer::CreateImageOnGpuThread, + base::Unretained(this), + new_id, + handle, + gfx::Size(width, height), + gpu_memory_buffer->GetFormat(), + internalformat)); - uint64_t fence_sync = 0; if (requires_sync_point) { - fence_sync = GenerateFenceSyncRelease(); - - // Previous fence syncs should be flushed already. - DCHECK_EQ(fence_sync - 1, flushed_fence_sync_release_); - } - - QueueTask(base::Bind(&InProcessCommandBuffer::CreateImageOnGpuThread, - base::Unretained(this), new_id, handle, - gfx::Size(width, height), gpu_memory_buffer->GetFormat(), - internalformat, order_num, fence_sync)); - - if (fence_sync) { - flushed_fence_sync_release_ = fence_sync; - SyncToken sync_token(GetNamespaceID(), GetCommandBufferID(), fence_sync); - sync_token.SetVerifyFlush(); - gpu_memory_buffer_manager_->SetDestructionSyncToken(gpu_memory_buffer, - sync_token); + gpu_memory_buffer_manager_->SetDestructionSyncPoint(gpu_memory_buffer, + InsertSyncPoint()); } return new_id; @@ -718,11 +689,7 @@ void InProcessCommandBuffer::CreateImageOnGpuThread( const gfx::GpuMemoryBufferHandle& handle, const gfx::Size& size, gfx::BufferFormat format, - uint32 internalformat, - uint32_t order_num, - uint64_t fence_sync) { - ScopedOrderNumberProcessor scoped_order_num(sync_point_order_data_.get(), - order_num); + uint32 internalformat) { if (!decoder_) return; @@ -766,10 +733,6 @@ void InProcessCommandBuffer::CreateImageOnGpuThread( break; } } - - if (fence_sync) { - sync_point_client_->ReleaseFenceSync(fence_sync); - } } void InProcessCommandBuffer::DestroyImage(int32 id) { diff --git a/gpu/command_buffer/service/in_process_command_buffer.h b/gpu/command_buffer/service/in_process_command_buffer.h index 0c881c1..83318b5 100644 --- a/gpu/command_buffer/service/in_process_command_buffer.h +++ b/gpu/command_buffer/service/in_process_command_buffer.h @@ -230,9 +230,7 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, const gfx::GpuMemoryBufferHandle& handle, const gfx::Size& size, gfx::BufferFormat format, - uint32 internalformat, - uint32_t order_num, - uint64_t fence_sync); + uint32 internalformat); void DestroyImageOnGpuThread(int32 id); void SetGetBufferOnGpuThread(int32 shm_id, base::WaitableEvent* completion); diff --git a/gpu/command_buffer/service/sync_point_manager.cc b/gpu/command_buffer/service/sync_point_manager.cc index 3fa7539..bc73adb 100644 --- a/gpu/command_buffer/service/sync_point_manager.cc +++ b/gpu/command_buffer/service/sync_point_manager.cc @@ -282,29 +282,6 @@ SyncPointClient::SyncPointClient(SyncPointManager* sync_point_manager, namespace_id_(namespace_id), client_id_(client_id) {} -bool SyncPointClientWaiter::Wait(SyncPointClientState* release_state, - uint64_t release_count, - const base::Closure& wait_complete_callback) { - // No order number associated with the current execution context, using - // UINT32_MAX will just assume the release is in the SyncPointClientState's - // order numbers to be executed. - if (!release_state->WaitForRelease(UINT32_MAX, release_count, - wait_complete_callback)) { - wait_complete_callback.Run(); - return false; - } - return true; -} - -bool SyncPointClientWaiter::WaitNonThreadSafe( - SyncPointClientState* release_state, - uint64_t release_count, - scoped_refptr<base::SingleThreadTaskRunner> runner, - const base::Closure& wait_complete_callback) { - return Wait(release_state, release_count, - base::Bind(&RunOnThread, runner, wait_complete_callback)); -} - SyncPointManager::SyncPointManager(bool allow_threaded_wait) : allow_threaded_wait_(allow_threaded_wait), // To reduce the risk that a sync point created in a previous GPU process diff --git a/gpu/command_buffer/service/sync_point_manager.h b/gpu/command_buffer/service/sync_point_manager.h index c71b471..a72566b 100644 --- a/gpu/command_buffer/service/sync_point_manager.h +++ b/gpu/command_buffer/service/sync_point_manager.h @@ -13,7 +13,6 @@ #include "base/callback.h" #include "base/containers/hash_tables.h" #include "base/logging.h" -#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/synchronization/condition_variable.h" @@ -138,7 +137,6 @@ class GPU_EXPORT SyncPointClientState private: friend class base::RefCountedThreadSafe<SyncPointClientState>; friend class SyncPointClient; - friend class SyncPointClientWaiter; friend class SyncPointOrderData; struct ReleaseCallback { @@ -234,32 +232,6 @@ class GPU_EXPORT SyncPointClient { DISALLOW_COPY_AND_ASSIGN(SyncPointClient); }; -// A SyncPointClientWaiter is a Sync Point Client which can only wait and on -// fence syncs and not release any fence syncs itself. Because they cannot -// release any fence syncs they do not need an associated order number since -// deadlocks cannot happen. Note that it is important that this class does -// not exist in the same execution context as a SyncPointClient, or else a -// deadlock could occur. Basically, SyncPointClientWaiter::Wait() should never -// be called between SyncPointOrderData::BeginProcessingOrderNumber() and -// SyncPointOrderData::FinishProcessingOrderNumber() on the same thread. -class GPU_EXPORT SyncPointClientWaiter { - public: - SyncPointClientWaiter() {} - ~SyncPointClientWaiter() {} - - bool Wait(SyncPointClientState* release_state, - uint64_t release_count, - const base::Closure& wait_complete_callback); - - bool WaitNonThreadSafe(SyncPointClientState* release_state, - uint64_t release_count, - scoped_refptr<base::SingleThreadTaskRunner> runner, - const base::Closure& wait_complete_callback); - - private: - DISALLOW_COPY_AND_ASSIGN(SyncPointClientWaiter); -}; - // This class manages the sync points, which allow cross-channel // synchronization. class GPU_EXPORT SyncPointManager { diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc index f14e91f..f73d5ac 100644 --- a/media/base/video_frame.cc +++ b/media/base/video_frame.cc @@ -813,7 +813,7 @@ void VideoFrame::UpdateReleaseSyncToken(SyncTokenClient* client) { // occurred when it waits on |release_sync_token_|. if (release_sync_token_.HasData()) client->WaitSyncToken(release_sync_token_); - client->GenerateSyncToken(&release_sync_token_); + release_sync_token_ = gpu::SyncToken(client->InsertSyncPoint()); } // static diff --git a/media/base/video_frame.h b/media/base/video_frame.h index a6ff33a..717649e 100644 --- a/media/base/video_frame.h +++ b/media/base/video_frame.h @@ -80,7 +80,7 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { class SyncTokenClient { public: SyncTokenClient() {} - virtual void GenerateSyncToken(gpu::SyncToken* sync_token) = 0; + virtual uint32 InsertSyncPoint() = 0; virtual void WaitSyncToken(const gpu::SyncToken& sync_token) = 0; protected: diff --git a/media/base/video_frame_unittest.cc b/media/base/video_frame_unittest.cc index ee2a454..c9f05ec 100644 --- a/media/base/video_frame_unittest.cc +++ b/media/base/video_frame_unittest.cc @@ -269,7 +269,7 @@ static void TextureCallback(gpu::SyncToken* called_sync_token, // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is // destroyed with the default release sync point. TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) { - gpu::SyncToken called_sync_token(gpu::CommandBufferNamespace::GPU_IO, 1, 1); + gpu::SyncToken called_sync_token(1); { scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( @@ -296,8 +296,8 @@ class SyncTokenClientImpl : public VideoFrame::SyncTokenClient { explicit SyncTokenClientImpl(const gpu::SyncToken& sync_token) : sync_token_(sync_token) {} ~SyncTokenClientImpl() override {} - void GenerateSyncToken(gpu::SyncToken* sync_token) override { - *sync_token = sync_token_; + uint32 InsertSyncPoint() override { + return static_cast<uint32>(sync_token_.release_count()); } void WaitSyncToken(const gpu::SyncToken& sync_token) override {} @@ -313,20 +313,14 @@ class SyncTokenClientImpl : public VideoFrame::SyncTokenClient { TEST(VideoFrame, TexturesNoLongerNeededCallbackAfterTakingAndReleasingMailboxes) { const int kPlanesNum = 3; - const gpu::CommandBufferNamespace kNamespace = - gpu::CommandBufferNamespace::GPU_IO; - const uint64_t kCommandBufferId = 0x123; gpu::Mailbox mailbox[kPlanesNum]; for (int i = 0; i < kPlanesNum; ++i) { mailbox[i].name[0] = 50 + 1; } - gpu::SyncToken sync_token(kNamespace, kCommandBufferId, 7); - sync_token.SetVerifyFlush(); + gpu::SyncToken sync_token(7); uint32 target = 9; - gpu::SyncToken release_sync_token(kNamespace, kCommandBufferId, 111); - release_sync_token.SetVerifyFlush(); - + gpu::SyncToken release_sync_token(111); gpu::SyncToken called_sync_token; { scoped_refptr<VideoFrame> frame = VideoFrame::WrapYUV420NativeTextures( diff --git a/media/renderers/skcanvas_video_renderer.cc b/media/renderers/skcanvas_video_renderer.cc index d2f25d6..675839b 100644 --- a/media/renderers/skcanvas_video_renderer.cc +++ b/media/renderers/skcanvas_video_renderer.cc @@ -63,11 +63,7 @@ class SyncTokenClientImpl : public VideoFrame::SyncTokenClient { public: explicit SyncTokenClientImpl(gpu::gles2::GLES2Interface* gl) : gl_(gl) {} ~SyncTokenClientImpl() override {} - void GenerateSyncToken(gpu::SyncToken* sync_token) override { - const uint64_t fence_sync = gl_->InsertFenceSyncCHROMIUM(); - gl_->ShallowFlushCHROMIUM(); - gl_->GenSyncTokenCHROMIUM(fence_sync, sync_token->GetData()); - } + uint32 InsertSyncPoint() override { return gl_->InsertSyncPointCHROMIUM(); } void WaitSyncToken(const gpu::SyncToken& sync_token) override { gl_->WaitSyncTokenCHROMIUM(sync_token.GetConstData()); } |