Chromium Code Reviews| Index: gpu/command_buffer/client/gles2_implementation.h |
| diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h |
| index 8a7ab68466d0f50bb11e6c5b86484f230f5e32d9..b1e9aab22a8a83cf766881dfd25cc80ac65684df 100644 |
| --- a/gpu/command_buffer/client/gles2_implementation.h |
| +++ b/gpu/command_buffer/client/gles2_implementation.h |
| @@ -591,6 +591,43 @@ 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 { |
| + if (token <= async_upload_sync_->async_token) |
| + return true; |
| + if (token & 0x80000000 && |
| + !(async_upload_sync_->async_token & 0x80000000)) { |
|
piman
2014/02/07 22:58:20
Reading async_token twice seems race-prone, it cou
jadahl
2014/02/08 09:18:25
True. Good catch.
|
| + return true; // we wrapped |
| + } |
| + return false; |
| + } |
| + |
| + // 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. |
| + // |
| + // If |wait| is true, poll until all unmanaged transfer buffers has been |
| + // free:ed. |
| + void PollAsyncUploads(bool wait); |
| + |
| bool GetBoundPixelTransferBuffer( |
| GLenum target, const char* function_name, GLuint* buffer_id); |
| BufferTracker::Buffer* GetBoundPixelUnpackTransferBufferIfValid( |
| @@ -663,6 +700,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_; |