| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
| 11 #include <time.h> |
| 11 | 12 |
| 12 #include "../common/logging.h" | 13 #include "../common/logging.h" |
| 13 #include "../common/constants.h" | 14 #include "../common/constants.h" |
| 14 #include "../common/cmd_buffer_common.h" | 15 #include "../common/cmd_buffer_common.h" |
| 15 #include "../common/command_buffer.h" | 16 #include "../common/command_buffer.h" |
| 16 | 17 |
| 17 namespace gpu { | 18 namespace gpu { |
| 18 | 19 |
| 19 // Command buffer helper class. This class simplifies ring buffer management: | 20 // Command buffer helper class. This class simplifies ring buffer management: |
| 20 // it will allocate the buffer, give it to the buffer interface, and let the | 21 // it will allocate the buffer, give it to the buffer interface, and let the |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // NOTE: This will call Flush if it needs to block. | 81 // NOTE: This will call Flush if it needs to block. |
| 81 // Parameters: | 82 // Parameters: |
| 82 // the value of the token to wait for. | 83 // the value of the token to wait for. |
| 83 void WaitForToken(int32 token); | 84 void WaitForToken(int32 token); |
| 84 | 85 |
| 85 // Inserts a yield command, signaling the scheduler that this is a good point | 86 // Inserts a yield command, signaling the scheduler that this is a good point |
| 86 // to update the state and schedule other command buffers. This is | 87 // to update the state and schedule other command buffers. This is |
| 87 // particularly useful after inserting a token that will be waited on. | 88 // particularly useful after inserting a token that will be waited on. |
| 88 void YieldScheduler(); | 89 void YieldScheduler(); |
| 89 | 90 |
| 90 // Waits for a certain amount of space to be available. Returns address | 91 // Called prior to each command being issued. Waits for a certain amount of |
| 91 // of space. | 92 // space to be available. Returns address of space. |
| 92 CommandBufferEntry* GetSpace(uint32 entries); | 93 CommandBufferEntry* GetSpace(uint32 entries); |
| 93 | 94 |
| 94 // Typed version of GetSpace. Gets enough room for the given type and returns | 95 // Typed version of GetSpace. Gets enough room for the given type and returns |
| 95 // a reference to it. | 96 // a reference to it. |
| 96 template <typename T> | 97 template <typename T> |
| 97 T& GetCmdSpace() { | 98 T& GetCmdSpace() { |
| 98 COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed); | 99 COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed); |
| 99 uint32 space_needed = ComputeNumEntries(sizeof(T)); | 100 uint32 space_needed = ComputeNumEntries(sizeof(T)); |
| 100 void* data = GetSpace(space_needed); | 101 void* data = GetSpace(space_needed); |
| 101 return *reinterpret_cast<T*>(data); | 102 return *reinterpret_cast<T*>(data); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 CommandBuffer* command_buffer_; | 230 CommandBuffer* command_buffer_; |
| 230 Buffer ring_buffer_; | 231 Buffer ring_buffer_; |
| 231 CommandBufferEntry *entries_; | 232 CommandBufferEntry *entries_; |
| 232 int32 total_entry_count_; // the total number of entries | 233 int32 total_entry_count_; // the total number of entries |
| 233 int32 usable_entry_count_; // the usable number (ie, minus space for jump) | 234 int32 usable_entry_count_; // the usable number (ie, minus space for jump) |
| 234 int32 token_; | 235 int32 token_; |
| 235 int32 last_token_read_; | 236 int32 last_token_read_; |
| 236 int32 get_; | 237 int32 get_; |
| 237 int32 put_; | 238 int32 put_; |
| 238 int32 last_put_sent_; | 239 int32 last_put_sent_; |
| 240 int commands_issued_; |
| 241 |
| 242 // Using C runtime instead of base because this file cannot depend on base. |
| 243 time_t last_flush_time_; |
| 239 | 244 |
| 240 friend class CommandBufferHelperTest; | 245 friend class CommandBufferHelperTest; |
| 241 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); | 246 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); |
| 242 }; | 247 }; |
| 243 | 248 |
| 244 } // namespace gpu | 249 } // namespace gpu |
| 245 | 250 |
| 246 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ | 251 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ |
| OLD | NEW |