| 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 <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 void SyncPointClient::ReleaseFenceSync(uint64_t release) { | 320 void SyncPointClient::ReleaseFenceSync(uint64_t release) { |
| 321 // Validate that this Release call is between BeginProcessingOrderNumber() and | 321 // Validate that this Release call is between BeginProcessingOrderNumber() and |
| 322 // FinishProcessingOrderNumber(), or else we may deadlock. | 322 // FinishProcessingOrderNumber(), or else we may deadlock. |
| 323 DCHECK(client_state_->order_data()->IsProcessingOrderNumber()); | 323 DCHECK(client_state_->order_data()->IsProcessingOrderNumber()); |
| 324 client_state_->ReleaseFenceSync(release); | 324 client_state_->ReleaseFenceSync(release); |
| 325 } | 325 } |
| 326 | 326 |
| 327 SyncPointClient::SyncPointClient() | 327 SyncPointClient::SyncPointClient() |
| 328 : sync_point_manager_(nullptr), | 328 : sync_point_manager_(nullptr), |
| 329 namespace_id_(gpu::CommandBufferNamespace::INVALID), | 329 namespace_id_(gpu::CommandBufferNamespace::INVALID), |
| 330 client_id_(0) {} | 330 client_id_() {} |
| 331 | 331 |
| 332 SyncPointClient::SyncPointClient(SyncPointManager* sync_point_manager, | 332 SyncPointClient::SyncPointClient(SyncPointManager* sync_point_manager, |
| 333 scoped_refptr<SyncPointOrderData> order_data, | 333 scoped_refptr<SyncPointOrderData> order_data, |
| 334 CommandBufferNamespace namespace_id, | 334 CommandBufferNamespace namespace_id, |
| 335 uint64_t client_id) | 335 CommandBufferId client_id) |
| 336 : sync_point_manager_(sync_point_manager), | 336 : sync_point_manager_(sync_point_manager), |
| 337 client_state_(new SyncPointClientState(order_data)), | 337 client_state_(new SyncPointClientState(order_data)), |
| 338 namespace_id_(namespace_id), | 338 namespace_id_(namespace_id), |
| 339 client_id_(client_id) {} | 339 client_id_(client_id) {} |
| 340 | 340 |
| 341 SyncPointManager::SyncPointManager(bool allow_threaded_wait) { | 341 SyncPointManager::SyncPointManager(bool allow_threaded_wait) { |
| 342 global_order_num_.GetNext(); | 342 global_order_num_.GetNext(); |
| 343 } | 343 } |
| 344 | 344 |
| 345 SyncPointManager::~SyncPointManager() { | 345 SyncPointManager::~SyncPointManager() { |
| 346 for (const ClientMap& client_map : client_maps_) { | 346 for (const ClientMap& client_map : client_maps_) { |
| 347 DCHECK(client_map.empty()); | 347 DCHECK(client_map.empty()); |
| 348 } | 348 } |
| 349 } | 349 } |
| 350 | 350 |
| 351 scoped_ptr<SyncPointClient> SyncPointManager::CreateSyncPointClient( | 351 scoped_ptr<SyncPointClient> SyncPointManager::CreateSyncPointClient( |
| 352 scoped_refptr<SyncPointOrderData> order_data, | 352 scoped_refptr<SyncPointOrderData> order_data, |
| 353 CommandBufferNamespace namespace_id, | 353 CommandBufferNamespace namespace_id, |
| 354 uint64_t client_id) { | 354 CommandBufferId client_id) { |
| 355 DCHECK_GE(namespace_id, 0); | 355 DCHECK_GE(namespace_id, 0); |
| 356 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_)); | 356 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_)); |
| 357 base::AutoLock auto_lock(client_maps_lock_); | 357 base::AutoLock auto_lock(client_maps_lock_); |
| 358 | 358 |
| 359 ClientMap& client_map = client_maps_[namespace_id]; | 359 ClientMap& client_map = client_maps_[namespace_id]; |
| 360 std::pair<ClientMap::iterator, bool> result = client_map.insert( | 360 std::pair<ClientMap::iterator, bool> result = client_map.insert( |
| 361 std::make_pair(client_id, new SyncPointClient(this, order_data, | 361 std::make_pair(client_id, new SyncPointClient(this, order_data, |
| 362 namespace_id, client_id))); | 362 namespace_id, client_id))); |
| 363 DCHECK(result.second); | 363 DCHECK(result.second); |
| 364 | 364 |
| 365 return make_scoped_ptr(result.first->second); | 365 return make_scoped_ptr(result.first->second); |
| 366 } | 366 } |
| 367 | 367 |
| 368 scoped_ptr<SyncPointClient> SyncPointManager::CreateSyncPointClientWaiter() { | 368 scoped_ptr<SyncPointClient> SyncPointManager::CreateSyncPointClientWaiter() { |
| 369 return make_scoped_ptr(new SyncPointClient); | 369 return make_scoped_ptr(new SyncPointClient); |
| 370 } | 370 } |
| 371 | 371 |
| 372 scoped_refptr<SyncPointClientState> SyncPointManager::GetSyncPointClientState( | 372 scoped_refptr<SyncPointClientState> SyncPointManager::GetSyncPointClientState( |
| 373 CommandBufferNamespace namespace_id, uint64_t client_id) { | 373 CommandBufferNamespace namespace_id, |
| 374 CommandBufferId client_id) { |
| 374 if (namespace_id >= 0) { | 375 if (namespace_id >= 0) { |
| 375 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_)); | 376 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_)); |
| 376 base::AutoLock auto_lock(client_maps_lock_); | 377 base::AutoLock auto_lock(client_maps_lock_); |
| 377 ClientMap& client_map = client_maps_[namespace_id]; | 378 ClientMap& client_map = client_maps_[namespace_id]; |
| 378 ClientMap::iterator it = client_map.find(client_id); | 379 ClientMap::iterator it = client_map.find(client_id); |
| 379 if (it != client_map.end()) { | 380 if (it != client_map.end()) { |
| 380 return it->second->client_state(); | 381 return it->second->client_state(); |
| 381 } | 382 } |
| 382 } | 383 } |
| 383 return nullptr; | 384 return nullptr; |
| 384 } | 385 } |
| 385 | 386 |
| 386 uint32_t SyncPointManager::GenerateOrderNumber() { | 387 uint32_t SyncPointManager::GenerateOrderNumber() { |
| 387 return global_order_num_.GetNext(); | 388 return global_order_num_.GetNext(); |
| 388 } | 389 } |
| 389 | 390 |
| 390 void SyncPointManager::DestroySyncPointClient( | 391 void SyncPointManager::DestroySyncPointClient( |
| 391 CommandBufferNamespace namespace_id, uint64_t client_id) { | 392 CommandBufferNamespace namespace_id, |
| 393 CommandBufferId client_id) { |
| 392 DCHECK_GE(namespace_id, 0); | 394 DCHECK_GE(namespace_id, 0); |
| 393 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_)); | 395 DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_maps_)); |
| 394 | 396 |
| 395 base::AutoLock auto_lock(client_maps_lock_); | 397 base::AutoLock auto_lock(client_maps_lock_); |
| 396 ClientMap& client_map = client_maps_[namespace_id]; | 398 ClientMap& client_map = client_maps_[namespace_id]; |
| 397 ClientMap::iterator it = client_map.find(client_id); | 399 ClientMap::iterator it = client_map.find(client_id); |
| 398 DCHECK(it != client_map.end()); | 400 DCHECK(it != client_map.end()); |
| 399 client_map.erase(it); | 401 client_map.erase(it); |
| 400 } | 402 } |
| 401 | 403 |
| 402 } // namespace gpu | 404 } // namespace gpu |
| OLD | NEW |