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 #include "gpu/command_buffer/service/sync_point_manager.h" | 5 #include "gpu/command_buffer/service/sync_point_manager.h" |
6 | 6 |
7 #include <climits> | 7 #include <climits> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 275 |
276 SyncPointClient::SyncPointClient(SyncPointManager* sync_point_manager, | 276 SyncPointClient::SyncPointClient(SyncPointManager* sync_point_manager, |
277 scoped_refptr<SyncPointOrderData> order_data, | 277 scoped_refptr<SyncPointOrderData> order_data, |
278 CommandBufferNamespace namespace_id, | 278 CommandBufferNamespace namespace_id, |
279 uint64_t client_id) | 279 uint64_t client_id) |
280 : sync_point_manager_(sync_point_manager), | 280 : sync_point_manager_(sync_point_manager), |
281 client_state_(new SyncPointClientState(order_data)), | 281 client_state_(new SyncPointClientState(order_data)), |
282 namespace_id_(namespace_id), | 282 namespace_id_(namespace_id), |
283 client_id_(client_id) {} | 283 client_id_(client_id) {} |
284 | 284 |
| 285 bool SyncPointClientWaiter::Wait(SyncPointClientState* release_state, |
| 286 uint64_t release_count, |
| 287 const base::Closure& wait_complete_callback) { |
| 288 // No order number associated with the current execution context, using |
| 289 // UINT32_MAX will just assume the release is in the SyncPointClientState's |
| 290 // order numbers to be executed. |
| 291 if (!release_state->WaitForRelease(UINT32_MAX, release_count, |
| 292 wait_complete_callback)) { |
| 293 wait_complete_callback.Run(); |
| 294 return false; |
| 295 } |
| 296 return true; |
| 297 } |
| 298 |
| 299 bool SyncPointClientWaiter::WaitNonThreadSafe( |
| 300 SyncPointClientState* release_state, |
| 301 uint64_t release_count, |
| 302 scoped_refptr<base::SingleThreadTaskRunner> runner, |
| 303 const base::Closure& wait_complete_callback) { |
| 304 return Wait(release_state, release_count, |
| 305 base::Bind(&RunOnThread, runner, wait_complete_callback)); |
| 306 } |
| 307 |
285 SyncPointManager::SyncPointManager(bool allow_threaded_wait) | 308 SyncPointManager::SyncPointManager(bool allow_threaded_wait) |
286 : allow_threaded_wait_(allow_threaded_wait), | 309 : allow_threaded_wait_(allow_threaded_wait), |
287 // To reduce the risk that a sync point created in a previous GPU process | 310 // To reduce the risk that a sync point created in a previous GPU process |
288 // will be in flight in the next GPU process, randomize the starting sync | 311 // will be in flight in the next GPU process, randomize the starting sync |
289 // point number. http://crbug.com/373452 | 312 // point number. http://crbug.com/373452 |
290 next_sync_point_(base::RandInt(1, kMaxSyncBase)), | 313 next_sync_point_(base::RandInt(1, kMaxSyncBase)), |
291 retire_cond_var_(&lock_) { | 314 retire_cond_var_(&lock_) { |
292 global_order_num_.GetNext(); | 315 global_order_num_.GetNext(); |
293 } | 316 } |
294 | 317 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_)); | 433 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_)); |
411 | 434 |
412 base::AutoLock auto_lock(client_maps_lock_); | 435 base::AutoLock auto_lock(client_maps_lock_); |
413 ClientMap& client_map = client_maps_[namespace_id]; | 436 ClientMap& client_map = client_maps_[namespace_id]; |
414 ClientMap::iterator it = client_map.find(client_id); | 437 ClientMap::iterator it = client_map.find(client_id); |
415 DCHECK(it != client_map.end()); | 438 DCHECK(it != client_map.end()); |
416 client_map.erase(it); | 439 client_map.erase(it); |
417 } | 440 } |
418 | 441 |
419 } // namespace gpu | 442 } // namespace gpu |
OLD | NEW |