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 | |
308 SyncPointManager::SyncPointManager(bool allow_threaded_wait) | 285 SyncPointManager::SyncPointManager(bool allow_threaded_wait) |
309 : allow_threaded_wait_(allow_threaded_wait), | 286 : allow_threaded_wait_(allow_threaded_wait), |
310 // To reduce the risk that a sync point created in a previous GPU process | 287 // To reduce the risk that a sync point created in a previous GPU process |
311 // will be in flight in the next GPU process, randomize the starting sync | 288 // will be in flight in the next GPU process, randomize the starting sync |
312 // point number. http://crbug.com/373452 | 289 // point number. http://crbug.com/373452 |
313 next_sync_point_(base::RandInt(1, kMaxSyncBase)), | 290 next_sync_point_(base::RandInt(1, kMaxSyncBase)), |
314 retire_cond_var_(&lock_) { | 291 retire_cond_var_(&lock_) { |
315 global_order_num_.GetNext(); | 292 global_order_num_.GetNext(); |
316 } | 293 } |
317 | 294 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_)); | 410 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_)); |
434 | 411 |
435 base::AutoLock auto_lock(client_maps_lock_); | 412 base::AutoLock auto_lock(client_maps_lock_); |
436 ClientMap& client_map = client_maps_[namespace_id]; | 413 ClientMap& client_map = client_maps_[namespace_id]; |
437 ClientMap::iterator it = client_map.find(client_id); | 414 ClientMap::iterator it = client_map.find(client_id); |
438 DCHECK(it != client_map.end()); | 415 DCHECK(it != client_map.end()); |
439 client_map.erase(it); | 416 client_map.erase(it); |
440 } | 417 } |
441 | 418 |
442 } // namespace gpu | 419 } // namespace gpu |
OLD | NEW |