OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // around, adding noops. Thus this function may change the value of put_. | 155 // around, adding noops. Thus this function may change the value of put_. |
156 // The function will return early if an error occurs, in which case the | 156 // The function will return early if an error occurs, in which case the |
157 // available space may not be available. | 157 // available space may not be available. |
158 void CommandBufferHelper::WaitForAvailableEntries(unsigned int count) { | 158 void CommandBufferHelper::WaitForAvailableEntries(unsigned int count) { |
159 CHECK(count < entry_count_); | 159 CHECK(count < entry_count_); |
160 if (put_ + count > entry_count_) { | 160 if (put_ + count > entry_count_) { |
161 // There's not enough room between the current put and the end of the | 161 // There's not enough room between the current put and the end of the |
162 // buffer, so we need to wrap. We will add noops all the way to the end, | 162 // buffer, so we need to wrap. We will add noops all the way to the end, |
163 // but we need to make sure get wraps first, actually that get is 1 or | 163 // but we need to make sure get wraps first, actually that get is 1 or |
164 // more (since put will wrap to 0 after we add the noops). | 164 // more (since put will wrap to 0 after we add the noops). |
165 DCHECK_LE(1, put_); | 165 DCHECK_LE(1U, put_); |
166 Flush(); | 166 Flush(); |
167 while (get_ > put_ || get_ == 0) WaitForGetChange(); | 167 while (get_ > put_ || get_ == 0) WaitForGetChange(); |
168 // Add the noops. By convention, a noop is a command 0 with no args. | 168 // Add the noops. By convention, a noop is a command 0 with no args. |
169 CommandHeader header; | 169 CommandHeader header; |
170 header.size = 1; | 170 header.size = 1; |
171 header.command = 0; | 171 header.command = 0; |
172 while (put_ < entry_count_) { | 172 while (put_ < entry_count_) { |
173 entries_[put_++].value_header = header; | 173 entries_[put_++].value_header = header; |
174 } | 174 } |
175 put_ = 0; | 175 put_ = 0; |
176 } | 176 } |
177 // If we have enough room, return immediatly. | 177 // If we have enough room, return immediatly. |
178 if (count <= AvailableEntries()) return; | 178 if (count <= AvailableEntries()) return; |
179 // Otherwise flush, and wait until we do have enough room. | 179 // Otherwise flush, and wait until we do have enough room. |
180 Flush(); | 180 Flush(); |
181 while (AvailableEntries() < count) WaitForGetChange(); | 181 while (AvailableEntries() < count) WaitForGetChange(); |
182 } | 182 } |
183 | 183 |
184 } // namespace command_buffer | 184 } // namespace command_buffer |
185 } // namespace o3d | 185 } // namespace o3d |
OLD | NEW |