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

Unified Diff: gpu/command_buffer/service/fence_sync_manager.h

Issue 1331843005: Implemented new fence syncs which replaces the old sync points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some fixes Created 5 years, 3 months 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/fence_sync_manager.h
diff --git a/gpu/command_buffer/service/fence_sync_manager.h b/gpu/command_buffer/service/fence_sync_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..fc59d432cd3c69c627e7029fb63594ba5dd08182
--- /dev/null
+++ b/gpu/command_buffer/service/fence_sync_manager.h
@@ -0,0 +1,61 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GPU_COMMAND_BUFFER_SERVICE_SYNC_FENCE_MANAGER_H_
+#define GPU_COMMAND_BUFFER_SERVICE_SYNC_FENCE_MANAGER_H_
+
+#include <functional>
+#include <queue>
+
+#include "base/callback.h"
+#include "gpu/gpu_export.h"
+
+namespace gpu {
+
+// This class manages the sync fences, which allow cross-channel
+// synchronization.
+class GPU_EXPORT FenceSyncManager {
+ public:
+ FenceSyncManager();
+ ~FenceSyncManager();
+
+ void AddFenceSyncCallback(uint32_t max_order_number,
+ uint32_t release,
+ const base::Closure& callback);
+
+ bool IsFenceSyncReleased(uint32_t release) const {
+ return release <= fence_sync_release_;
+ }
+
+ void ReleaseFenceSync(uint32_t release);
+
+ private:
+ struct FenceSyncCallback {
+ uint32_t release_count;
+ base::Closure callback_closure;
+
+ FenceSyncCallback(uint32_t release, const base::Closure& callback);
+ ~FenceSyncCallback();
+
+ bool operator>(const FenceSyncCallback& rhs) const {
+ return release_count > rhs.release_count;
+ }
+ };
+ typedef std::priority_queue<FenceSyncCallback,
+ std::vector<FenceSyncCallback>,
+ std::greater<FenceSyncCallback>> CallbackQueue;
+
+ // Current fence sync release that has been signaled.
+ uint32_t fence_sync_release_;
+
+ // In well defined fence sync operations, fence syncs are released in order
+ // so simply having a priority queue for callbacks is enough.
+ CallbackQueue fence_callback_queue_;
+
+ DISALLOW_COPY_AND_ASSIGN(FenceSyncManager);
+};
+
+} // namespace gpu
+
+#endif // GPU_COMMAND_BUFFER_SERVICE_SYNC_FENCE_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698