Index: gpu/command_buffer/service/sync_point_manager.cc |
diff --git a/gpu/command_buffer/service/sync_point_manager.cc b/gpu/command_buffer/service/sync_point_manager.cc |
index 562fa8ca675c9ea61c4153e5190888caf8eb3fdf..26580f6453ff2b6d4d3f6cb4f322326c14a04e2e 100644 |
--- a/gpu/command_buffer/service/sync_point_manager.cc |
+++ b/gpu/command_buffer/service/sync_point_manager.cc |
@@ -14,15 +14,89 @@ namespace gpu { |
static const int kMaxSyncBase = INT_MAX; |
+uint32_t SyncPointClient::GenerateUnprocessedOrderNumber() { |
+ DCHECK(sync_point_manager_); |
+ const uint32_t order_num = sync_point_manager_->GenerateOrderNumber(); |
+ base::subtle::Release_Store(&unprocessed_order_num_, order_num); |
+ return order_num; |
+} |
+ |
+SyncPointClient::SyncPointClient(SyncPointManager* sync_point_manager, |
+ SyncPointNamespace namespace_id, |
+ uint64_t client_id) |
+ : sync_point_manager_(sync_point_manager), |
+ namespace_id_(namespace_id), |
+ client_id_(client_id), |
+ current_order_num_(0), |
+ processed_order_num_(0), |
+ unprocessed_order_num_(0) { |
+ processing_thread_checker_.DetachFromThread(); |
piman
2015/09/15 23:47:15
Do you need this? I would think the same thread th
David Yen
2015/09/18 18:43:59
Removed.
|
+} |
+ |
+void SyncPointClient::Destroy() { |
+ sync_point_manager_ = nullptr; |
+} |
+ |
+SyncPointClient::~SyncPointClient() { |
+ DCHECK(!IsValid()); |
+} |
+ |
SyncPointManager::SyncPointManager(bool allow_threaded_wait) |
: allow_threaded_wait_(allow_threaded_wait), |
// To reduce the risk that a sync point created in a previous GPU process |
// will be in flight in the next GPU process, randomize the starting sync |
// point number. http://crbug.com/373452 |
next_sync_point_(base::RandInt(1, kMaxSyncBase)), |
- retire_cond_var_(&lock_) {} |
+ retire_cond_var_(&lock_) { |
+ global_order_num_.GetNext(); |
+} |
+ |
+SyncPointManager::~SyncPointManager() { |
+ for (int i = 0; i < NUM_SYNC_POINT_NAMESPACES; ++i) { |
+ DCHECK(client_maps_[i].empty()); |
+ } |
+} |
-SyncPointManager::~SyncPointManager() {} |
+scoped_refptr<SyncPointClient> SyncPointManager::CreateSyncPointClient( |
+ SyncPointNamespace namespace_id, uint64_t client_id) { |
+ DCHECK(namespace_id >= 0 && namespace_id < NUM_SYNC_POINT_NAMESPACES); |
+ base::AutoLock auto_lock(client_maps_lock_); |
+ |
+ ClientMap& client_map = client_maps_[namespace_id]; |
+ std::pair<ClientMap::iterator, bool> result = client_map.insert( |
+ std::make_pair(client_id, new SyncPointClient(this, |
+ namespace_id, |
+ client_id))); |
+ DCHECK(result.second); |
+ |
+ return result.first->second; |
+} |
+ |
+void SyncPointManager::DestroySyncPointClient( |
+ scoped_refptr<SyncPointClient> client) { |
+ const SyncPointNamespace namespace_id = client->namespace_id_; |
+ const uint32_t client_id = client->client_id_; |
+ DCHECK(namespace_id >= 0 && namespace_id < NUM_SYNC_POINT_NAMESPACES); |
+ base::AutoLock auto_lock(client_maps_lock_); |
+ ClientMap& client_map = client_maps_[namespace_id]; |
+ ClientMap::iterator it = client_map.find(client_id); |
+ DCHECK(it != client_map.end()); |
+ it->second->Destroy(); |
piman
2015/09/15 23:47:15
nit: no need to do this under the lock. you can ju
David Yen
2015/09/18 18:43:59
Done.
|
+ client_map.erase(it); |
+} |
+ |
+scoped_refptr<SyncPointClient> SyncPointManager::GetSyncPointClient( |
+ SyncPointNamespace namespace_id, uint64_t client_id) { |
+ DCHECK(namespace_id >= 0 && namespace_id < NUM_SYNC_POINT_NAMESPACES); |
+ base::AutoLock auto_lock(client_maps_lock_); |
+ |
+ ClientMap& client_map = client_maps_[namespace_id]; |
+ ClientMap::iterator it = client_map.find(client_id); |
+ if (it != client_map.end()) { |
+ return it->second; |
+ } |
+ return nullptr; |
+} |
uint32 SyncPointManager::GenerateSyncPoint() { |
base::AutoLock lock(lock_); |
@@ -95,4 +169,8 @@ bool SyncPointManager::IsSyncPointRetiredLocked(uint32 sync_point) { |
return sync_point_map_.find(sync_point) == sync_point_map_.end(); |
} |
+uint32_t SyncPointManager::GenerateOrderNumber() { |
+ return global_order_num_.GetNext(); |
+} |
+ |
} // namespace gpu |