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

Unified Diff: gpu/command_buffer/common/sync_token.h

Issue 1399173002: Reland: Added SyncToken command buffer trait to help with IPC messages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Read/Write SyncToken variables separately. Created 5 years, 2 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/common/sync_token.h
diff --git a/gpu/command_buffer/common/sync_token.h b/gpu/command_buffer/common/sync_token.h
new file mode 100644
index 0000000000000000000000000000000000000000..76fdc1c454373939524a8cf309929bb5b201f088
--- /dev/null
+++ b/gpu/command_buffer/common/sync_token.h
@@ -0,0 +1,77 @@
+// Copyright 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_COMMON_SYNC_TOKEN_H_
+#define GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_
+
+#include <stdint.h>
+#include <string.h>
+
+#include "gpu/command_buffer/common/constants.h"
+#include "gpu/gpu_export.h"
+
+// From glextchromium.h.
+#ifndef GL_SYNC_TOKEN_SIZE_CHROMIUM
+#define GL_SYNC_TOKEN_SIZE_CHROMIUM 24
+#endif
+
+namespace gpu {
+
+// A Sync Token is a binary blob which represents a waitable fence sync
+// on a particular command buffer namespace and id.
+// See src/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_sync_point.txt for more
+// details.
+struct GPU_EXPORT SyncToken {
+ SyncToken()
+ : namespace_id_(CommandBufferNamespace::INVALID),
+ command_buffer_id_(0),
+ release_count_(0) {}
+
+ SyncToken(CommandBufferNamespace namespace_id,
+ uint64_t command_buffer_id,
+ uint64_t release_count)
+ : namespace_id_(namespace_id),
+ command_buffer_id_(command_buffer_id),
+ release_count_(release_count) {}
+
+ void Set(CommandBufferNamespace namespace_id,
+ uint64_t command_buffer_id,
+ uint64_t release_count) {
+ namespace_id_ = namespace_id;
+ command_buffer_id_ = command_buffer_id;
+ release_count_ = release_count;
+ }
+
+ int8_t* GetData() { return reinterpret_cast<int8_t*>(this); }
+
+ const int8_t* GetConstData() const {
+ return reinterpret_cast<const int8_t*>(this);
+ }
+
+ CommandBufferNamespace namespace_id() const { return namespace_id_; }
+ uint64_t command_buffer_id() const { return command_buffer_id_; }
+ uint64_t release_count() const { return release_count_; }
+
+ bool operator<(const SyncToken& other) const {
+ // TODO(dyen): Once all our compilers support c++11, we can replace this
+ // long list of comparisons with std::tie().
+ return (namespace_id_ < other.namespace_id()) ||
+ ((namespace_id_ == other.namespace_id()) &&
+ ((command_buffer_id_ < other.command_buffer_id()) ||
+ ((command_buffer_id_ == other.command_buffer_id()) &&
+ (release_count_ < other.release_count()))));
+ }
+
+ private:
+ CommandBufferNamespace namespace_id_;
+ uint64_t command_buffer_id_;
+ uint64_t release_count_;
+};
+
+static_assert(sizeof(SyncToken) <= GL_SYNC_TOKEN_SIZE_CHROMIUM,
+ "SyncToken size must not exceed GL_SYNC_TOKEN_SIZE_CHROMIUM");
+
+} // namespace gpu
+
+#endif // GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_format.h ('k') | gpu/command_buffer/service/in_process_command_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698