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 | |
96 // Waits until the token of a particular value has passed through the command | 87 // Waits until the token of a particular value has passed through the command |
97 // stream (i.e. commands inserted before that token have been executed). | 88 // stream (i.e. commands inserted before that token have been executed). |
98 // NOTE: This will call Flush if it needs to block. | 89 // NOTE: This will call Flush if it needs to block. |
99 // Parameters: | 90 // Parameters: |
100 // the value of the token to wait for. | 91 // the value of the token to wait for. |
101 void WaitForToken(int32 token); | 92 void WaitForToken(int32 token); |
102 | 93 |
103 // Called prior to each command being issued. Waits for a certain amount of | 94 // Called prior to each command being issued. Waits for a certain amount of |
104 // space to be available. Returns address of space. | 95 // space to be available. Returns address of space. |
105 CommandBufferEntry* GetSpace(int32 entries) { | 96 CommandBufferEntry* GetSpace(int32 entries) { |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 // Can be used to track when prior commands have been flushed. | 308 // Can be used to track when prior commands have been flushed. |
318 uint32 flush_generation_; | 309 uint32 flush_generation_; |
319 | 310 |
320 friend class CommandBufferHelperTest; | 311 friend class CommandBufferHelperTest; |
321 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); | 312 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); |
322 }; | 313 }; |
323 | 314 |
324 } // namespace gpu | 315 } // namespace gpu |
325 | 316 |
326 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 317 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
OLD | NEW |