OLD | NEW |
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 | 10 |
| 11 #include "gpu/command_buffer/common/command_buffer_id.h" |
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 namespace_id_(CommandBufferNamespace::INVALID), | |
29 extra_data_field_(0), | |
30 command_buffer_id_(0), | |
31 release_count_(0) {} | |
32 | 28 |
33 SyncToken(CommandBufferNamespace namespace_id, | 29 SyncToken(CommandBufferNamespace namespace_id, |
34 int32_t extra_data_field, | 30 int32_t extra_data_field, |
35 uint64_t command_buffer_id, | 31 CommandBufferId command_buffer_id, |
36 uint64_t release_count) | 32 uint64_t release_count); |
37 : verified_flush_(false), | |
38 namespace_id_(namespace_id), | |
39 extra_data_field_(extra_data_field), | |
40 command_buffer_id_(command_buffer_id), | |
41 release_count_(release_count) {} | |
42 | 33 |
43 void Set(CommandBufferNamespace namespace_id, | 34 void Set(CommandBufferNamespace namespace_id, |
44 int32_t extra_data_field, | 35 int32_t extra_data_field, |
45 uint64_t command_buffer_id, | 36 CommandBufferId command_buffer_id, |
46 uint64_t release_count) { | 37 uint64_t release_count) { |
47 namespace_id_ = namespace_id; | 38 namespace_id_ = namespace_id; |
48 extra_data_field_ = extra_data_field; | 39 extra_data_field_ = extra_data_field; |
49 command_buffer_id_ = command_buffer_id; | 40 command_buffer_id_ = command_buffer_id; |
50 release_count_ = release_count; | 41 release_count_ = release_count; |
51 } | 42 } |
52 | 43 |
53 void Clear() { | 44 void Clear() { |
54 verified_flush_ = false; | 45 verified_flush_ = false; |
55 namespace_id_ = CommandBufferNamespace::INVALID; | 46 namespace_id_ = CommandBufferNamespace::INVALID; |
56 extra_data_field_ = 0; | 47 extra_data_field_ = 0; |
57 command_buffer_id_ = 0; | 48 command_buffer_id_ = CommandBufferId(); |
58 release_count_ = 0; | 49 release_count_ = 0; |
59 } | 50 } |
60 | 51 |
61 void SetVerifyFlush() { | 52 void SetVerifyFlush() { |
62 verified_flush_ = true; | 53 verified_flush_ = true; |
63 } | 54 } |
64 | 55 |
65 bool HasData() const { | 56 bool HasData() const { |
66 return namespace_id_ != CommandBufferNamespace::INVALID; | 57 return namespace_id_ != CommandBufferNamespace::INVALID; |
67 } | 58 } |
68 | 59 |
69 int8_t* GetData() { return reinterpret_cast<int8_t*>(this); } | 60 int8_t* GetData() { return reinterpret_cast<int8_t*>(this); } |
70 | 61 |
71 const int8_t* GetConstData() const { | 62 const int8_t* GetConstData() const { |
72 return reinterpret_cast<const int8_t*>(this); | 63 return reinterpret_cast<const int8_t*>(this); |
73 } | 64 } |
74 | 65 |
75 bool verified_flush() const { return verified_flush_; } | 66 bool verified_flush() const { return verified_flush_; } |
76 CommandBufferNamespace namespace_id() const { return namespace_id_; } | 67 CommandBufferNamespace namespace_id() const { return namespace_id_; } |
77 uint64_t command_buffer_id() const { return command_buffer_id_; } | 68 CommandBufferId command_buffer_id() const { return command_buffer_id_; } |
78 uint64_t release_count() const { return release_count_; } | 69 uint64_t release_count() const { return release_count_; } |
79 | 70 |
80 // This extra data field can be used by command buffers to add extra | 71 // This extra data field can be used by command buffers to add extra |
81 // information to identify unverified sync tokens. The current purpose | 72 // information to identify unverified sync tokens. The current purpose |
82 // of this field is only for unverified sync tokens which only exist within | 73 // of this field is only for unverified sync tokens which only exist within |
83 // the same process so this information will not survive cross-process IPCs. | 74 // the same process so this information will not survive cross-process IPCs. |
84 int32_t extra_data_field() const { return extra_data_field_; } | 75 int32_t extra_data_field() const { return extra_data_field_; } |
85 | 76 |
86 bool operator<(const SyncToken& other) const { | 77 bool operator<(const SyncToken& other) const { |
87 // TODO(dyen): Once all our compilers support c++11, we can replace this | 78 // TODO(dyen): Once all our compilers support c++11, we can replace this |
(...skipping 12 matching lines...) Expand all Loading... |
100 command_buffer_id_ == other.command_buffer_id() && | 91 command_buffer_id_ == other.command_buffer_id() && |
101 release_count_ == other.release_count(); | 92 release_count_ == other.release_count(); |
102 } | 93 } |
103 | 94 |
104 bool operator!=(const SyncToken& other) const { return !(*this == other); } | 95 bool operator!=(const SyncToken& other) const { return !(*this == other); } |
105 | 96 |
106 private: | 97 private: |
107 bool verified_flush_; | 98 bool verified_flush_; |
108 CommandBufferNamespace namespace_id_; | 99 CommandBufferNamespace namespace_id_; |
109 int32_t extra_data_field_; | 100 int32_t extra_data_field_; |
110 uint64_t command_buffer_id_; | 101 CommandBufferId command_buffer_id_; |
111 uint64_t release_count_; | 102 uint64_t release_count_; |
112 }; | 103 }; |
113 | 104 |
114 static_assert(sizeof(SyncToken) <= GL_SYNC_TOKEN_SIZE_CHROMIUM, | 105 static_assert(sizeof(SyncToken) <= GL_SYNC_TOKEN_SIZE_CHROMIUM, |
115 "SyncToken size must not exceed GL_SYNC_TOKEN_SIZE_CHROMIUM"); | 106 "SyncToken size must not exceed GL_SYNC_TOKEN_SIZE_CHROMIUM"); |
116 | 107 |
117 } // namespace gpu | 108 } // namespace gpu |
118 | 109 |
119 #endif // GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_ | 110 #endif // GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_ |
OLD | NEW |