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

Side by Side Diff: gpu/command_buffer/common/sync_token.h

Issue 1489573003: Added an extra sync token field for extra command buffer identification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_COMMON_SYNC_TOKEN_H_ 5 #ifndef GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_
6 #define GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_ 6 #define GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 #include <tuple>
10 11
11 #include "gpu/command_buffer/common/constants.h" 12 #include "gpu/command_buffer/common/constants.h"
12 #include "gpu/gpu_export.h" 13 #include "gpu/gpu_export.h"
13 14
14 // From glextchromium.h. 15 // From glextchromium.h.
15 #ifndef GL_SYNC_TOKEN_SIZE_CHROMIUM 16 #ifndef GL_SYNC_TOKEN_SIZE_CHROMIUM
16 #define GL_SYNC_TOKEN_SIZE_CHROMIUM 24 17 #define GL_SYNC_TOKEN_SIZE_CHROMIUM 24
17 #endif 18 #endif
18 19
19 namespace gpu { 20 namespace gpu {
20 21
21 // A Sync Token is a binary blob which represents a waitable fence sync 22 // A Sync Token is a binary blob which represents a waitable fence sync
22 // on a particular command buffer namespace and id. 23 // on a particular command buffer namespace and id.
23 // See src/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_sync_point.txt for more 24 // See src/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_sync_point.txt for more
24 // details. 25 // details.
25 struct GPU_EXPORT SyncToken { 26 struct GPU_EXPORT SyncToken {
26 SyncToken() 27 SyncToken()
27 : verified_flush_(false), 28 : verified_flush_(false),
28 namespace_id_(CommandBufferNamespace::INVALID), 29 namespace_id_(CommandBufferNamespace::INVALID),
30 extra_data_field_(0),
29 command_buffer_id_(0), 31 command_buffer_id_(0),
30 release_count_(0) {} 32 release_count_(0) {}
31 33
32 // TODO(dyen): This is an intermediate conversion constructor while we 34 // TODO(dyen): This is an intermediate conversion constructor while we
33 // are converting from the old sync point system. Remove once conversion 35 // are converting from the old sync point system. Remove once conversion
34 // is finished. 36 // is finished.
35 explicit SyncToken(uint32_t sync_point) 37 explicit SyncToken(uint32_t sync_point)
36 : verified_flush_(sync_point ? true : false), 38 : verified_flush_(sync_point ? true : false),
37 namespace_id_(sync_point ? gpu::CommandBufferNamespace::OLD_SYNC_POINTS 39 namespace_id_(sync_point ? gpu::CommandBufferNamespace::OLD_SYNC_POINTS
38 : gpu::CommandBufferNamespace::INVALID), 40 : gpu::CommandBufferNamespace::INVALID),
41 extra_data_field_(0),
39 command_buffer_id_(0), 42 command_buffer_id_(0),
40 release_count_(sync_point) {} 43 release_count_(sync_point) {}
41 44
42 SyncToken(CommandBufferNamespace namespace_id, 45 SyncToken(CommandBufferNamespace namespace_id,
46 uint32_t extra_data_field,
43 uint64_t command_buffer_id, 47 uint64_t command_buffer_id,
44 uint64_t release_count) 48 uint64_t release_count)
45 : verified_flush_(false), 49 : verified_flush_(false),
46 namespace_id_(namespace_id), 50 namespace_id_(namespace_id),
51 extra_data_field_(extra_data_field),
47 command_buffer_id_(command_buffer_id), 52 command_buffer_id_(command_buffer_id),
48 release_count_(release_count) {} 53 release_count_(release_count) {}
49 54
50 void Set(CommandBufferNamespace namespace_id, 55 void Set(CommandBufferNamespace namespace_id,
56 uint32_t extra_data_field,
51 uint64_t command_buffer_id, 57 uint64_t command_buffer_id,
52 uint64_t release_count) { 58 uint64_t release_count) {
53 namespace_id_ = namespace_id; 59 namespace_id_ = namespace_id;
60 extra_data_field_ = extra_data_field;
54 command_buffer_id_ = command_buffer_id; 61 command_buffer_id_ = command_buffer_id;
55 release_count_ = release_count; 62 release_count_ = release_count;
56 } 63 }
57 64
58 void Clear() { 65 void Clear() {
59 verified_flush_ = false; 66 verified_flush_ = false;
60 namespace_id_ = CommandBufferNamespace::INVALID; 67 namespace_id_ = CommandBufferNamespace::INVALID;
68 extra_data_field_ = 0;
61 command_buffer_id_ = 0; 69 command_buffer_id_ = 0;
62 release_count_ = 0; 70 release_count_ = 0;
63 } 71 }
64 72
65 void SetVerifyFlush() { 73 void SetVerifyFlush() {
66 verified_flush_ = true; 74 verified_flush_ = true;
67 } 75 }
68 76
69 bool HasData() const { 77 bool HasData() const {
70 return namespace_id_ != CommandBufferNamespace::INVALID; 78 return namespace_id_ != CommandBufferNamespace::INVALID;
71 } 79 }
72 80
73 int8_t* GetData() { return reinterpret_cast<int8_t*>(this); } 81 int8_t* GetData() { return reinterpret_cast<int8_t*>(this); }
74 82
75 const int8_t* GetConstData() const { 83 const int8_t* GetConstData() const {
76 return reinterpret_cast<const int8_t*>(this); 84 return reinterpret_cast<const int8_t*>(this);
77 } 85 }
78 86
79 bool verified_flush() const { return verified_flush_; } 87 bool verified_flush() const { return verified_flush_; }
80 CommandBufferNamespace namespace_id() const { return namespace_id_; } 88 CommandBufferNamespace namespace_id() const { return namespace_id_; }
89 uint32_t extra_data_field() const { return extra_data_field_; }
81 uint64_t command_buffer_id() const { return command_buffer_id_; } 90 uint64_t command_buffer_id() const { return command_buffer_id_; }
82 uint64_t release_count() const { return release_count_; } 91 uint64_t release_count() const { return release_count_; }
83 92
84 bool operator<(const SyncToken& other) const { 93 bool operator<(const SyncToken& other) const {
85 // TODO(dyen): Once all our compilers support c++11, we can replace this 94 // TODO(dyen): Once all our compilers support c++11, we can replace this
86 // long list of comparisons with std::tie(). 95 // long list of comparisons with std::tie().
87 return (namespace_id_ < other.namespace_id()) || 96 return (namespace_id_ < other.namespace_id()) ||
88 ((namespace_id_ == other.namespace_id()) && 97 ((namespace_id_ == other.namespace_id()) &&
89 ((command_buffer_id_ < other.command_buffer_id()) || 98 ((command_buffer_id_ < other.command_buffer_id()) ||
90 ((command_buffer_id_ == other.command_buffer_id()) && 99 ((command_buffer_id_ == other.command_buffer_id()) &&
91 (release_count_ < other.release_count())))); 100 (release_count_ < other.release_count()))));
92 } 101 }
93 102
94 bool operator==(const SyncToken& other) const { 103 bool operator==(const SyncToken& other) const {
95 return verified_flush_ == other.verified_flush() && 104 return verified_flush_ == other.verified_flush() &&
96 namespace_id_ == other.namespace_id() && 105 namespace_id_ == other.namespace_id() &&
106 extra_data_field_ == other.extra_data_field() &&
97 command_buffer_id_ == other.command_buffer_id() && 107 command_buffer_id_ == other.command_buffer_id() &&
98 release_count_ == other.release_count(); 108 release_count_ == other.release_count();
99 } 109 }
100 110
101 bool operator!=(const SyncToken& other) const { return !(*this == other); } 111 bool operator!=(const SyncToken& other) const { return !(*this == other); }
102 112
103 private: 113 private:
104 bool verified_flush_; 114 bool verified_flush_;
105 CommandBufferNamespace namespace_id_; 115 CommandBufferNamespace namespace_id_;
116 uint32_t extra_data_field_;
106 uint64_t command_buffer_id_; 117 uint64_t command_buffer_id_;
107 uint64_t release_count_; 118 uint64_t release_count_;
108 }; 119 };
109 120
110 static_assert(sizeof(SyncToken) <= GL_SYNC_TOKEN_SIZE_CHROMIUM, 121 static_assert(sizeof(SyncToken) <= GL_SYNC_TOKEN_SIZE_CHROMIUM,
111 "SyncToken size must not exceed GL_SYNC_TOKEN_SIZE_CHROMIUM"); 122 "SyncToken size must not exceed GL_SYNC_TOKEN_SIZE_CHROMIUM");
112 123
113 } // namespace gpu 124 } // namespace gpu
114 125
115 #endif // GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_ 126 #endif // GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698