diff options
Diffstat (limited to 'content/common/gpu')
-rw-r--r-- | content/common/gpu/client/command_buffer_proxy_impl.cc | 55 | ||||
-rw-r--r-- | content/common/gpu/client/command_buffer_proxy_impl.h | 4 | ||||
-rw-r--r-- | content/common/gpu/client/gl_helper.cc | 6 | ||||
-rw-r--r-- | content/common/gpu/client/gl_helper.h | 3 | ||||
-rw-r--r-- | content/common/gpu/client/gpu_channel_host.cc | 5 | ||||
-rw-r--r-- | content/common/gpu/client/gpu_channel_host.h | 2 | ||||
-rw-r--r-- | content/common/gpu/client/gpu_memory_buffer_impl.cc | 5 | ||||
-rw-r--r-- | content/common/gpu/client/gpu_memory_buffer_impl.h | 9 | ||||
-rw-r--r-- | content/common/gpu/client/gpu_memory_buffer_impl_shared_memory_unittest.cc | 2 | ||||
-rw-r--r-- | content/common/gpu/gpu_channel_manager.cc | 26 | ||||
-rw-r--r-- | content/common/gpu/gpu_channel_manager.h | 5 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.cc | 16 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.h | 8 | ||||
-rw-r--r-- | content/common/gpu/gpu_messages.h | 23 |
14 files changed, 108 insertions, 61 deletions
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.cc b/content/common/gpu/client/command_buffer_proxy_impl.cc index c3c8419..b8785bc 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 internalformat) { + unsigned internal_format) { CheckLock(); if (last_state_.error != gpu::error::kNoError) return -1; @@ -416,29 +416,47 @@ 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_point = false; + bool requires_sync_token = false; gfx::GpuMemoryBufferHandle handle = channel_->ShareGpuMemoryBufferToGpuProcess(gpu_memory_buffer->GetHandle(), - &requires_sync_point); + &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_); + } 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( - internalformat, gpu_memory_buffer->GetFormat())); - if (!Send(new GpuCommandBufferMsg_CreateImage(route_id_, - new_id, - handle, - gfx::Size(width, height), - gpu_memory_buffer->GetFormat(), - internalformat))) { + 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))) return -1; - } - if (requires_sync_point) { - gpu_memory_buffer_manager->SetDestructionSyncPoint(gpu_memory_buffer, - InsertSyncPoint()); + 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); } return new_id; @@ -455,18 +473,18 @@ void CommandBufferProxyImpl::DestroyImage(int32 id) { int32_t CommandBufferProxyImpl::CreateGpuMemoryBufferImage( size_t width, size_t height, - unsigned internalformat, + unsigned internal_format, unsigned usage) { CheckLock(); scoped_ptr<gfx::GpuMemoryBuffer> buffer( channel_->gpu_memory_buffer_manager()->AllocateGpuMemoryBuffer( gfx::Size(width, height), - gpu::ImageFactory::DefaultBufferFormatForImageFormat(internalformat), + gpu::ImageFactory::DefaultBufferFormatForImageFormat(internal_format), gfx::BufferUsage::SCANOUT)); if (!buffer) return -1; - return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); + return CreateImage(buffer->AsClientBuffer(), width, height, internal_format); } uint32 CommandBufferProxyImpl::CreateStreamTexture(uint32 texture_id) { @@ -530,7 +548,8 @@ bool CommandBufferProxyImpl::IsFenceSyncFlushReceived(uint64_t release) { return true; // Has not been validated, validate it now. - UpdateVerifiedReleases(channel_->ValidateFlushIDReachedServer(stream_id_)); + UpdateVerifiedReleases( + channel_->ValidateFlushIDReachedServer(stream_id_, false)); 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 39bc76b..5646cca 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 internalformat) override; + unsigned internal_format) override; void DestroyImage(int32 id) override; int32 CreateGpuMemoryBufferImage(size_t width, size_t height, - unsigned internalformat, + unsigned internal_format, 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 88c6499..33c9521 100644 --- a/content/common/gpu/client/gl_helper.cc +++ b/content/common/gpu/client/gl_helper.cc @@ -954,6 +954,12 @@ 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 828097d..c8224d4 100644 --- a/content/common/gpu/client/gl_helper.h +++ b/content/common/gpu/client/gl_helper.h @@ -247,6 +247,9 @@ 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 30700df..8ff3ab8 100644 --- a/content/common/gpu/client/gpu_channel_host.cc +++ b/content/common/gpu/client/gpu_channel_host.cc @@ -398,7 +398,8 @@ int32 GpuChannelHost::GenerateStreamID() { return next_stream_id_.GetNext(); } -uint32_t GpuChannelHost::ValidateFlushIDReachedServer(int32 stream_id) { +uint32_t GpuChannelHost::ValidateFlushIDReachedServer(int32 stream_id, + bool force_validate) { // 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; @@ -421,7 +422,7 @@ uint32_t GpuChannelHost::ValidateFlushIDReachedServer(int32 stream_id) { } } - if (flushed_stream_flush_id == verified_stream_flush_id) { + if (!force_validate && 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 a161a78..b5488ed9 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); + uint32_t ValidateFlushIDReachedServer(int32 stream_id, bool force_validate); // 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 bfe4656..e900829 100644 --- a/content/common/gpu/client/gpu_memory_buffer_impl.cc +++ b/content/common/gpu/client/gpu_memory_buffer_impl.cc @@ -29,12 +29,11 @@ GpuMemoryBufferImpl::GpuMemoryBufferImpl(gfx::GpuMemoryBufferId id, size_(size), format_(format), callback_(callback), - mapped_(false), - destruction_sync_point_(0) {} + mapped_(false) {} GpuMemoryBufferImpl::~GpuMemoryBufferImpl() { DCHECK(!mapped_); - callback_.Run(destruction_sync_point_); + callback_.Run(destruction_sync_token_); } // static diff --git a/content/common/gpu/client/gpu_memory_buffer_impl.h b/content/common/gpu/client/gpu_memory_buffer_impl.h index 44b528e..a3ba3f5 100644 --- a/content/common/gpu/client/gpu_memory_buffer_impl.h +++ b/content/common/gpu/client/gpu_memory_buffer_impl.h @@ -8,6 +8,7 @@ #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" @@ -16,7 +17,7 @@ namespace content { // Provides common implementation of a GPU memory buffer. class CONTENT_EXPORT GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { public: - typedef base::Callback<void(uint32 sync_point)> DestructionCallback; + typedef base::Callback<void(const gpu::SyncToken& sync)> DestructionCallback; ~GpuMemoryBufferImpl() override; @@ -40,8 +41,8 @@ class CONTENT_EXPORT GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { gfx::GpuMemoryBufferId GetId() const override; ClientBuffer AsClientBuffer() override; - void set_destruction_sync_point(uint32 sync_point) { - destruction_sync_point_ = sync_point; + void set_destruction_sync_token(const gpu::SyncToken& sync_token) { + destruction_sync_token_ = sync_token; } protected: @@ -55,7 +56,7 @@ class CONTENT_EXPORT GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer { const gfx::BufferFormat format_; const DestructionCallback callback_; bool mapped_; - uint32 destruction_sync_point_; + gpu::SyncToken destruction_sync_token_; 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 cce258b..251e16c 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, uint32 sync_point) { +void BufferDestroyed(bool* destroyed, const gpu::SyncToken& sync_token) { *destroyed = true; } diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc index 4d9c435..3f603a6 100644 --- a/content/common/gpu/gpu_channel_manager.cc +++ b/content/common/gpu/gpu_channel_manager.cc @@ -60,6 +60,7 @@ 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); @@ -227,17 +228,22 @@ void GpuChannelManager::DestroyGpuMemoryBufferOnIO( void GpuChannelManager::OnDestroyGpuMemoryBuffer( gfx::GpuMemoryBufferId id, int client_id, - 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)); + 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; + } } + + // 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 19cec9d..c3e889a 100644 --- a/content/common/gpu/gpu_channel_manager.h +++ b/content/common/gpu/gpu_channel_manager.h @@ -34,7 +34,9 @@ class GLShareGroup; namespace gpu { class PreemptionFlag; +class SyncPointClientWaiter; class SyncPointManager; +struct SyncToken; union ValueState; namespace gles2 { class FramebufferCompletenessCache; @@ -156,7 +158,7 @@ class CONTENT_EXPORT GpuChannelManager : public IPC::Listener, void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, int client_id); void OnDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id, - int32 sync_point); + const gpu::SyncToken& sync_token); void OnUpdateValueState(int client_id, unsigned int target, @@ -182,6 +184,7 @@ 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 b82d715..a26854f 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -1107,12 +1107,15 @@ void GpuCommandBufferStub::OnWaitFenceSyncCompleted( scheduler_->SetScheduled(true); } -void GpuCommandBufferStub::OnCreateImage(int32 id, - gfx::GpuMemoryBufferHandle handle, - gfx::Size size, - gfx::BufferFormat format, - uint32 internalformat) { +void GpuCommandBufferStub::OnCreateImage( + const GpuCommandBufferMsg_CreateImage_Params& params) { 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; @@ -1148,6 +1151,9 @@ void GpuCommandBufferStub::OnCreateImage(int32 id, 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 910cd91..0537c30 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -44,6 +44,8 @@ class SubscriptionRefSet; } } +struct GpuCommandBufferMsg_CreateImage_Params; + namespace content { class GpuChannel; @@ -214,11 +216,7 @@ class GpuCommandBufferStub uint64_t command_buffer_id, uint64_t release); - void OnCreateImage(int32 id, - gfx::GpuMemoryBufferHandle handle, - gfx::Size size, - gfx::BufferFormat format, - uint32 internalformat); + void OnCreateImage(const GpuCommandBufferMsg_CreateImage_Params& params); 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 949ecf9..a9c84a4 100644 --- a/content/common/gpu/gpu_messages.h +++ b/content/common/gpu/gpu_messages.h @@ -184,7 +184,16 @@ IPC_STRUCT_BEGIN(GpuStreamTextureMsg_MatrixChanged_Params) IPC_STRUCT_END() #endif - IPC_STRUCT_TRAITS_BEGIN(gpu::DxDiagNode) +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_MEMBER(values) IPC_STRUCT_TRAITS_MEMBER(children) IPC_STRUCT_TRAITS_END() @@ -331,8 +340,8 @@ IPC_MESSAGE_CONTROL1(GpuMsg_CreateGpuMemoryBufferFromHandle, // Tells the GPU process to destroy buffer. IPC_MESSAGE_CONTROL3(GpuMsg_DestroyGpuMemoryBuffer, gfx::GpuMemoryBufferId, /* id */ - int32, /* client_id */ - int32 /* sync_point */) + int32, /* client_id */ + gpu::SyncToken /* sync_token */) // Create and initialize a hardware jpeg decoder using the specified route_id. // Created decoders should be freed with AcceleratedJpegDecoderMsg_Destroy when @@ -652,12 +661,8 @@ 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_ROUTED5(GpuCommandBufferMsg_CreateImage, - int32 /* id */, - gfx::GpuMemoryBufferHandle /* gpu_memory_buffer */, - gfx::Size /* size */, - gfx::BufferFormat /* format */, - uint32 /* internalformat */) +IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_CreateImage, + GpuCommandBufferMsg_CreateImage_Params /* params */) // Destroy a previously created image. IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_DestroyImage, |