| 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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // on a particular command buffer namespace and id. | 22 // on a particular command buffer namespace and id. |
| 23 // See src/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_sync_point.txt for more | 23 // See src/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_sync_point.txt for more |
| 24 // details. | 24 // details. |
| 25 struct GPU_EXPORT SyncToken { | 25 struct GPU_EXPORT SyncToken { |
| 26 SyncToken() | 26 SyncToken() |
| 27 : verified_flush_(false), | 27 : verified_flush_(false), |
| 28 namespace_id_(CommandBufferNamespace::INVALID), | 28 namespace_id_(CommandBufferNamespace::INVALID), |
| 29 command_buffer_id_(0), | 29 command_buffer_id_(0), |
| 30 release_count_(0) {} | 30 release_count_(0) {} |
| 31 | 31 |
| 32 // TODO(dyen): This is an intermediate conversion constructor while we |
| 33 // are converting from the old sync point system. Remove once conversion |
| 34 // is finished. |
| 35 explicit SyncToken(uint32_t sync_point) |
| 36 : verified_flush_(sync_point ? true : false), |
| 37 namespace_id_(sync_point ? gpu::CommandBufferNamespace::OLD_SYNC_POINTS |
| 38 : gpu::CommandBufferNamespace::INVALID), |
| 39 command_buffer_id_(0), |
| 40 release_count_(sync_point) {} |
| 41 |
| 32 SyncToken(CommandBufferNamespace namespace_id, | 42 SyncToken(CommandBufferNamespace namespace_id, |
| 33 uint64_t command_buffer_id, | 43 uint64_t command_buffer_id, |
| 34 uint64_t release_count) | 44 uint64_t release_count) |
| 35 : verified_flush_(false), | 45 : verified_flush_(false), |
| 36 namespace_id_(namespace_id), | 46 namespace_id_(namespace_id), |
| 37 command_buffer_id_(command_buffer_id), | 47 command_buffer_id_(command_buffer_id), |
| 38 release_count_(release_count) {} | 48 release_count_(release_count) {} |
| 39 | 49 |
| 40 void Set(CommandBufferNamespace namespace_id, | 50 void Set(CommandBufferNamespace namespace_id, |
| 41 uint64_t command_buffer_id, | 51 uint64_t command_buffer_id, |
| 42 uint64_t release_count) { | 52 uint64_t release_count) { |
| 43 namespace_id_ = namespace_id; | 53 namespace_id_ = namespace_id; |
| 44 command_buffer_id_ = command_buffer_id; | 54 command_buffer_id_ = command_buffer_id; |
| 45 release_count_ = release_count; | 55 release_count_ = release_count; |
| 46 } | 56 } |
| 47 | 57 |
| 58 void Clear() { |
| 59 verified_flush_ = false; |
| 60 namespace_id_ = CommandBufferNamespace::INVALID; |
| 61 command_buffer_id_ = 0; |
| 62 release_count_ = 0; |
| 63 } |
| 64 |
| 48 void SetVerifyFlush() { | 65 void SetVerifyFlush() { |
| 49 verified_flush_ = true; | 66 verified_flush_ = true; |
| 50 } | 67 } |
| 51 | 68 |
| 69 bool HasData() const { |
| 70 return namespace_id_ != CommandBufferNamespace::INVALID; |
| 71 } |
| 72 |
| 52 int8_t* GetData() { return reinterpret_cast<int8_t*>(this); } | 73 int8_t* GetData() { return reinterpret_cast<int8_t*>(this); } |
| 53 | 74 |
| 54 const int8_t* GetConstData() const { | 75 const int8_t* GetConstData() const { |
| 55 return reinterpret_cast<const int8_t*>(this); | 76 return reinterpret_cast<const int8_t*>(this); |
| 56 } | 77 } |
| 57 | 78 |
| 58 bool verified_flush() const { return verified_flush_; } | 79 bool verified_flush() const { return verified_flush_; } |
| 59 CommandBufferNamespace namespace_id() const { return namespace_id_; } | 80 CommandBufferNamespace namespace_id() const { return namespace_id_; } |
| 60 uint64_t command_buffer_id() const { return command_buffer_id_; } | 81 uint64_t command_buffer_id() const { return command_buffer_id_; } |
| 61 uint64_t release_count() const { return release_count_; } | 82 uint64_t release_count() const { return release_count_; } |
| 62 | 83 |
| 63 bool operator<(const SyncToken& other) const { | 84 bool operator<(const SyncToken& other) const { |
| 64 // TODO(dyen): Once all our compilers support c++11, we can replace this | 85 // TODO(dyen): Once all our compilers support c++11, we can replace this |
| 65 // long list of comparisons with std::tie(). | 86 // long list of comparisons with std::tie(). |
| 66 return (namespace_id_ < other.namespace_id()) || | 87 return (namespace_id_ < other.namespace_id()) || |
| 67 ((namespace_id_ == other.namespace_id()) && | 88 ((namespace_id_ == other.namespace_id()) && |
| 68 ((command_buffer_id_ < other.command_buffer_id()) || | 89 ((command_buffer_id_ < other.command_buffer_id()) || |
| 69 ((command_buffer_id_ == other.command_buffer_id()) && | 90 ((command_buffer_id_ == other.command_buffer_id()) && |
| 70 (release_count_ < other.release_count())))); | 91 (release_count_ < other.release_count())))); |
| 71 } | 92 } |
| 72 | 93 |
| 94 bool operator==(const SyncToken& other) const { |
| 95 return verified_flush_ == other.verified_flush() && |
| 96 namespace_id_ == other.namespace_id() && |
| 97 command_buffer_id_ == other.command_buffer_id() && |
| 98 release_count_ == other.release_count(); |
| 99 } |
| 100 |
| 101 bool operator!=(const SyncToken& other) const { return !(*this == other); } |
| 102 |
| 73 private: | 103 private: |
| 74 bool verified_flush_; | 104 bool verified_flush_; |
| 75 CommandBufferNamespace namespace_id_; | 105 CommandBufferNamespace namespace_id_; |
| 76 uint64_t command_buffer_id_; | 106 uint64_t command_buffer_id_; |
| 77 uint64_t release_count_; | 107 uint64_t release_count_; |
| 78 }; | 108 }; |
| 79 | 109 |
| 80 static_assert(sizeof(SyncToken) <= GL_SYNC_TOKEN_SIZE_CHROMIUM, | 110 static_assert(sizeof(SyncToken) <= GL_SYNC_TOKEN_SIZE_CHROMIUM, |
| 81 "SyncToken size must not exceed GL_SYNC_TOKEN_SIZE_CHROMIUM"); | 111 "SyncToken size must not exceed GL_SYNC_TOKEN_SIZE_CHROMIUM"); |
| 82 | 112 |
| 83 } // namespace gpu | 113 } // namespace gpu |
| 84 | 114 |
| 85 #endif // GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_ | 115 #endif // GPU_COMMAND_BUFFER_COMMON_SYNC_TOKEN_H_ |
| OLD | NEW |