Index: gpu/command_buffer/client/cmd_buffer_helper.h |
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.h b/gpu/command_buffer/client/cmd_buffer_helper.h |
index a50dc7bfe4e4e73e4bc4ce392bc1cb85e32182be..9cfb6e69d1673f4e721065142af3c6bdc84cecc2 100644 |
--- a/gpu/command_buffer/client/cmd_buffer_helper.h |
+++ b/gpu/command_buffer/client/cmd_buffer_helper.h |
@@ -83,6 +83,15 @@ class GPU_EXPORT CommandBufferHelper { |
// shutdown. |
int32 InsertToken(); |
+ // Returns true if the token has passed. |
+ // Parameters: |
+ // the value of the token to check whether it has passed |
+ bool HasTokenPassed(int32 token) const { |
+ if (token > token_) |
+ return true; // we wrapped |
+ return last_token_read() >= token; |
+ } |
+ |
// Waits until the token of a particular value has passed through the command |
// stream (i.e. commands inserted before that token have been executed). |
// NOTE: This will call Flush if it needs to block. |
@@ -90,6 +99,32 @@ class GPU_EXPORT CommandBufferHelper { |
// the value of the token to wait for. |
void WaitForToken(int32 token); |
+ // Inserts a new async token to the command buffer. One can then check if the |
+ // token has passed using HasAsyncTokenPassed(). It is guaranteed that the |
+ // order of returned async tokens is the same as inserted, but it is |
+ // implementation specific when a token is returned. |
+ // |
+ // NOTE: A async token is asynchronous in a way that Finish():ing the command |
+ // buffer does mean it has passed. |
epenner
2014/01/23 02:52:44
Nit: 'doesn't'
|
+ uint32 InsertAsyncToken(); |
+ |
+ // Returns true if the async 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. |
+ // |
+ // Parameters: |
+ // the value of the async token to check whether it has passed |
+ bool HasAsyncTokenPassed(uint32 token) const { |
+ uint32 last_async_token = last_async_token_read(); |
+ if (token <= last_async_token) |
+ return true; |
+ if (token & 0x80000000 && !(last_async_token & 0x80000000)) |
+ return true; // we wrapped |
+ return false; |
+ } |
+ |
// Called prior to each command being issued. Waits for a certain amount of |
// space to be available. Returns address of space. |
CommandBufferEntry* GetSpace(uint32 entries); |
@@ -244,6 +279,11 @@ class GPU_EXPORT CommandBufferHelper { |
bool AllocateRingBuffer(); |
void FreeResources(); |
+ // Get the async token number last read by the command buffer. |
+ uint32 last_async_token_read() const { |
+ return command_buffer_->GetLastState().async_token; |
+ } |
+ |
CommandBuffer* command_buffer_; |
int32 ring_buffer_id_; |
int32 ring_buffer_size_; |
@@ -251,6 +291,7 @@ class GPU_EXPORT CommandBufferHelper { |
CommandBufferEntry* entries_; |
int32 total_entry_count_; // the total number of entries |
int32 token_; |
+ uint32 async_token_; |
int32 put_; |
int32 last_put_sent_; |
int commands_issued_; |