OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file contains the command buffer helper class. | 5 // This file contains the command buffer helper class. |
6 | 6 |
7 #ifndef GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 7 #ifndef GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
8 #define GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 8 #define GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
9 | 9 |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 // Inserts a new token into the command buffer. This token either has a value | 78 // Inserts a new token into the command buffer. This token either has a value |
79 // different from previously inserted tokens, or ensures that previously | 79 // different from previously inserted tokens, or ensures that previously |
80 // inserted tokens with that value have already passed through the command | 80 // inserted tokens with that value have already passed through the command |
81 // stream. | 81 // stream. |
82 // Returns: | 82 // Returns: |
83 // the value of the new token or -1 if the command buffer reader has | 83 // the value of the new token or -1 if the command buffer reader has |
84 // shutdown. | 84 // shutdown. |
85 int32 InsertToken(); | 85 int32 InsertToken(); |
86 | 86 |
| 87 // Returns true if the token has passed. |
| 88 // Parameters: |
| 89 // the value of the token to check whether it has passed |
| 90 bool HasTokenPassed(int32 token) const { |
| 91 if (token > token_) |
| 92 return true; // we wrapped |
| 93 return last_token_read() >= token; |
| 94 } |
| 95 |
87 // Waits until the token of a particular value has passed through the command | 96 // Waits until the token of a particular value has passed through the command |
88 // stream (i.e. commands inserted before that token have been executed). | 97 // stream (i.e. commands inserted before that token have been executed). |
89 // NOTE: This will call Flush if it needs to block. | 98 // NOTE: This will call Flush if it needs to block. |
90 // Parameters: | 99 // Parameters: |
91 // the value of the token to wait for. | 100 // the value of the token to wait for. |
92 void WaitForToken(int32 token); | 101 void WaitForToken(int32 token); |
93 | 102 |
94 // Called prior to each command being issued. Waits for a certain amount of | 103 // Called prior to each command being issued. Waits for a certain amount of |
95 // space to be available. Returns address of space. | 104 // space to be available. Returns address of space. |
96 CommandBufferEntry* GetSpace(int32 entries) { | 105 CommandBufferEntry* GetSpace(int32 entries) { |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // Can be used to track when prior commands have been flushed. | 317 // Can be used to track when prior commands have been flushed. |
309 uint32 flush_generation_; | 318 uint32 flush_generation_; |
310 | 319 |
311 friend class CommandBufferHelperTest; | 320 friend class CommandBufferHelperTest; |
312 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); | 321 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); |
313 }; | 322 }; |
314 | 323 |
315 } // namespace gpu | 324 } // namespace gpu |
316 | 325 |
317 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 326 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
OLD | NEW |