diff options
author | jadahl@opera.com <jadahl@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-31 09:07:02 +0000 |
---|---|---|
committer | jadahl@opera.com <jadahl@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-31 09:07:02 +0000 |
commit | e3c4a9abad01205eed3e7556158dc05800051f7b (patch) | |
tree | 20dcee8098386d67ed3d9322f230b08e74b451fb /gpu/command_buffer/client/gles2_implementation.h | |
parent | 15770a4144bf8def5cd689351db58a842f2535a1 (diff) | |
download | chromium_src-e3c4a9abad01205eed3e7556158dc05800051f7b.zip chromium_src-e3c4a9abad01205eed3e7556158dc05800051f7b.tar.gz chromium_src-e3c4a9abad01205eed3e7556158dc05800051f7b.tar.bz2 |
gpu: Reuse transfer buffers more aggresively
By keeping track of transfer buffer usage (both sync and async), it is
possible to reuse an existing transfer buffer earlier than it is today.
For synchronous uploads, this is done by inserting tokens marking a
buffer's last usage. If such a token has passed, the buffer can be
reused.
For asynchronous uploads, this is done by adding an internal async
upload token to the GLES2Implementation and GLES2CmdDecoderImpl that
enumerates all asynchronous uploads. When an upload is completed, the
token is synchronized with the client which then can free the memory
associated with the async token.
The fenced allocator and mapped memory manager gets a callback that is
used to allow fenced allocator to make the user, in this case
GLES2Implementation, poll the current async upload token and free any
associated memory.
BUG=328808
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=260177
Review URL: https://codereview.chromium.org/116863003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260507 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/client/gles2_implementation.h')
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h index bd5ee04..b120a62 100644 --- a/gpu/command_buffer/client/gles2_implementation.h +++ b/gpu/command_buffer/client/gles2_implementation.h @@ -601,6 +601,38 @@ class GLES2_IMPL_EXPORT GLES2Implementation void OnSwapBuffersComplete(); + // Remove the transfer buffer from the buffer tracker. For buffers used + // asynchronously the memory is free:ed if the upload has completed. For + // other buffers, the memory is either free:ed immediately or free:ed pending + // a token. + void RemoveTransferBuffer(BufferTracker::Buffer* buffer); + + // Returns true if the async upload token has passed. + // + // NOTE: This will detect wrapped async tokens by checking if the most + // significant bit of async token to check is 1 but the last read is 0, i.e. + // the uint32 wrapped. + bool HasAsyncUploadTokenPassed(uint32 token) const { + return async_upload_sync_->HasAsyncUploadTokenPassed(token); + } + + // Get the next async upload token. + uint32 NextAsyncUploadToken(); + + // Ensure that the shared memory used for synchronizing async upload tokens + // has been mapped. + // + // Returns false on error, true on success. + bool EnsureAsyncUploadSync(); + + // Checks the last read asynchronously upload token and frees any unmanaged + // transfer buffer that has its async token passed. + void PollAsyncUploads(); + + // Free every async upload buffer. If some async upload buffer is still in use + // wait for them to finish before freeing. + void FreeAllAsyncUploadBuffers(); + bool GetBoundPixelTransferBuffer( GLenum target, const char* function_name, GLuint* buffer_id); BufferTracker::Buffer* GetBoundPixelUnpackTransferBufferIfValid( @@ -673,6 +705,18 @@ class GLES2_IMPL_EXPORT GLES2Implementation GLuint bound_pixel_pack_transfer_buffer_id_; GLuint bound_pixel_unpack_transfer_buffer_id_; + // The current asynchronous pixel buffer upload token. + uint32 async_upload_token_; + + // The shared memory used for synchronizing asynchronous upload tokens. + AsyncUploadSync* async_upload_sync_; + int32 async_upload_sync_shm_id_; + unsigned int async_upload_sync_shm_offset_; + + // Unmanaged pixel transfer buffer memory pending asynchronous upload token. + typedef std::list<std::pair<void*, uint32> > DetachedAsyncUploadMemoryList; + DetachedAsyncUploadMemoryList detached_async_upload_memory_; + // Client side management for vertex array objects. Needed to correctly // track client side arrays. scoped_ptr<VertexArrayObjectManager> vertex_array_object_manager_; |