Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: gpu/command_buffer/service/sync_point_manager.h

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_
7 7
8 #include <stdint.h>
9
8 #include <functional> 10 #include <functional>
9 #include <queue> 11 #include <queue>
10 #include <vector> 12 #include <vector>
11 13
12 #include "base/atomic_sequence_num.h" 14 #include "base/atomic_sequence_num.h"
13 #include "base/callback.h" 15 #include "base/callback.h"
14 #include "base/containers/hash_tables.h" 16 #include "base/containers/hash_tables.h"
15 #include "base/logging.h" 17 #include "base/logging.h"
16 #include "base/macros.h" 18 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 scoped_refptr<SyncPointOrderData> order_data, 274 scoped_refptr<SyncPointOrderData> order_data,
273 CommandBufferNamespace namespace_id, 275 CommandBufferNamespace namespace_id,
274 uint64_t client_id); 276 uint64_t client_id);
275 277
276 // Finds the state of an already created sync point client. 278 // Finds the state of an already created sync point client.
277 scoped_refptr<SyncPointClientState> GetSyncPointClientState( 279 scoped_refptr<SyncPointClientState> GetSyncPointClientState(
278 CommandBufferNamespace namespace_id, uint64_t client_id); 280 CommandBufferNamespace namespace_id, uint64_t client_id);
279 281
280 // Generates a sync point, returning its ID. This can me called on any thread. 282 // Generates a sync point, returning its ID. This can me called on any thread.
281 // IDs start at a random number. Never return 0. 283 // IDs start at a random number. Never return 0.
282 uint32 GenerateSyncPoint(); 284 uint32_t GenerateSyncPoint();
283 285
284 // Retires a sync point. This will call all the registered callbacks for this 286 // Retires a sync point. This will call all the registered callbacks for this
285 // sync point. This can only be called on the main thread. 287 // sync point. This can only be called on the main thread.
286 void RetireSyncPoint(uint32 sync_point); 288 void RetireSyncPoint(uint32_t sync_point);
287 289
288 // Adds a callback to the sync point. The callback will be called when the 290 // Adds a callback to the sync point. The callback will be called when the
289 // sync point is retired, or immediately (from within that function) if the 291 // sync point is retired, or immediately (from within that function) if the
290 // sync point was already retired (or not created yet). This can only be 292 // sync point was already retired (or not created yet). This can only be
291 // called on the main thread. 293 // called on the main thread.
292 void AddSyncPointCallback(uint32 sync_point, const base::Closure& callback); 294 void AddSyncPointCallback(uint32_t sync_point, const base::Closure& callback);
293 295
294 bool IsSyncPointRetired(uint32 sync_point); 296 bool IsSyncPointRetired(uint32_t sync_point);
295 297
296 // Block and wait until a sync point is signaled. This is only useful when 298 // Block and wait until a sync point is signaled. This is only useful when
297 // the sync point is signaled on another thread. 299 // the sync point is signaled on another thread.
298 void WaitSyncPoint(uint32 sync_point); 300 void WaitSyncPoint(uint32_t sync_point);
299 301
300 private: 302 private:
301 friend class SyncPointClient; 303 friend class SyncPointClient;
302 friend class SyncPointOrderData; 304 friend class SyncPointOrderData;
303 305
304 typedef std::vector<base::Closure> ClosureList; 306 typedef std::vector<base::Closure> ClosureList;
305 typedef base::hash_map<uint32, ClosureList> SyncPointMap; 307 typedef base::hash_map<uint32_t, ClosureList> SyncPointMap;
306 typedef base::hash_map<uint64_t, SyncPointClient*> ClientMap; 308 typedef base::hash_map<uint64_t, SyncPointClient*> ClientMap;
307 309
308 bool IsSyncPointRetiredLocked(uint32 sync_point); 310 bool IsSyncPointRetiredLocked(uint32_t sync_point);
309 uint32_t GenerateOrderNumber(); 311 uint32_t GenerateOrderNumber();
310 void DestroySyncPointClient(CommandBufferNamespace namespace_id, 312 void DestroySyncPointClient(CommandBufferNamespace namespace_id,
311 uint64_t client_id); 313 uint64_t client_id);
312 314
313 const bool allow_threaded_wait_; 315 const bool allow_threaded_wait_;
314 316
315 // Order number is global for all clients. 317 // Order number is global for all clients.
316 base::AtomicSequenceNumber global_order_num_; 318 base::AtomicSequenceNumber global_order_num_;
317 319
318 // Client map holds a map of clients id to client for each namespace. 320 // Client map holds a map of clients id to client for each namespace.
319 base::Lock client_maps_lock_; 321 base::Lock client_maps_lock_;
320 ClientMap client_maps_[NUM_COMMAND_BUFFER_NAMESPACES]; 322 ClientMap client_maps_[NUM_COMMAND_BUFFER_NAMESPACES];
321 323
322 // Protects the 2 fields below. Note: callbacks shouldn't be called with this 324 // Protects the 2 fields below. Note: callbacks shouldn't be called with this
323 // held. 325 // held.
324 base::Lock lock_; 326 base::Lock lock_;
325 SyncPointMap sync_point_map_; 327 SyncPointMap sync_point_map_;
326 uint32 next_sync_point_; 328 uint32_t next_sync_point_;
327 base::ConditionVariable retire_cond_var_; 329 base::ConditionVariable retire_cond_var_;
328 330
329 DISALLOW_COPY_AND_ASSIGN(SyncPointManager); 331 DISALLOW_COPY_AND_ASSIGN(SyncPointManager);
330 }; 332 };
331 333
332 } // namespace gpu 334 } // namespace gpu
333 335
334 #endif // GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_ 336 #endif // GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698