Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: gpu/command_buffer/client/cmd_buffer_helper.h

Issue 116863003: gpu: Reuse transfer buffers more aggresively (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: [WIP] gpu: Reuse transfer buffers more aggresively Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 // Inserts a new token into the command buffer. This token either has a value 77 // Inserts a new token into the command buffer. This token either has a value
78 // different from previously inserted tokens, or ensures that previously 78 // different from previously inserted tokens, or ensures that previously
79 // inserted tokens with that value have already passed through the command 79 // inserted tokens with that value have already passed through the command
80 // stream. 80 // stream.
81 // Returns: 81 // Returns:
82 // the value of the new token or -1 if the command buffer reader has 82 // the value of the new token or -1 if the command buffer reader has
83 // shutdown. 83 // shutdown.
84 int32 InsertToken(); 84 int32 InsertToken();
85 85
86 // Returns true if the token has already passed.
87 // Parameters:
88 // the value of the token to check whether it has passed
89 bool HasTokenPassed(int32 token) const {
90 if (token > token_)
91 return true; // we wrapped
92 return last_token_read() >= token;
93 }
94
86 // Waits until the token of a particular value has passed through the command 95 // Waits until the token of a particular value has passed through the command
87 // stream (i.e. commands inserted before that token have been executed). 96 // stream (i.e. commands inserted before that token have been executed).
88 // NOTE: This will call Flush if it needs to block. 97 // NOTE: This will call Flush if it needs to block.
89 // Parameters: 98 // Parameters:
90 // the value of the token to wait for. 99 // the value of the token to wait for.
91 void WaitForToken(int32 token); 100 void WaitForToken(int32 token);
92 101
102 // Get the serial number last read by the command buffer.
103 uint32 last_serial_read() const {
104 return command_buffer_->GetLastState().serial;
105 }
106
93 // Called prior to each command being issued. Waits for a certain amount of 107 // Called prior to each command being issued. Waits for a certain amount of
94 // space to be available. Returns address of space. 108 // space to be available. Returns address of space.
95 CommandBufferEntry* GetSpace(uint32 entries); 109 CommandBufferEntry* GetSpace(uint32 entries);
96 110
97 // Typed version of GetSpace. Gets enough room for the given type and returns 111 // Typed version of GetSpace. Gets enough room for the given type and returns
98 // a reference to it. 112 // a reference to it.
99 template <typename T> 113 template <typename T>
100 T* GetCmdSpace() { 114 T* GetCmdSpace() {
101 COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed); 115 COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed);
102 uint32 space_needed = ComputeNumEntries(sizeof(T)); 116 uint32 space_needed = ComputeNumEntries(sizeof(T));
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // Using C runtime instead of base because this file cannot depend on base. 275 // Using C runtime instead of base because this file cannot depend on base.
262 clock_t last_flush_time_; 276 clock_t last_flush_time_;
263 277
264 friend class CommandBufferHelperTest; 278 friend class CommandBufferHelperTest;
265 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); 279 DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper);
266 }; 280 };
267 281
268 } // namespace gpu 282 } // namespace gpu
269 283
270 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ 284 #endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698