OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CLIENT_QUERY_TRACKER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_ |
6 #define GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_ | 6 #define GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_ |
7 | 7 |
8 #include <GLES2/gl2.h> | 8 #include <GLES2/gl2.h> |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
11 #include <list> | 11 #include <list> |
12 | 12 |
| 13 #include "base/atomicops.h" |
13 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
14 #include "gles2_impl_export.h" | 15 #include "gles2_impl_export.h" |
15 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 16 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
16 | 17 |
17 namespace gpu { | 18 namespace gpu { |
18 | 19 |
19 class CommandBufferHelper; | 20 class CommandBufferHelper; |
20 class MappedMemoryManager; | 21 class MappedMemoryManager; |
21 | 22 |
22 namespace gles2 { | 23 namespace gles2 { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 return info_.shm_id; | 99 return info_.shm_id; |
99 } | 100 } |
100 | 101 |
101 uint32 shm_offset() const { | 102 uint32 shm_offset() const { |
102 return info_.shm_offset; | 103 return info_.shm_offset; |
103 } | 104 } |
104 | 105 |
105 void MarkAsActive() { | 106 void MarkAsActive() { |
106 state_ = kActive; | 107 state_ = kActive; |
107 ++submit_count_; | 108 ++submit_count_; |
| 109 if (submit_count_ == INT_MAX) |
| 110 submit_count_ = 1; |
108 } | 111 } |
109 | 112 |
110 void MarkAsPending(int32 token) { | 113 void MarkAsPending(int32 token) { |
111 token_ = token; | 114 token_ = token; |
112 state_ = kPending; | 115 state_ = kPending; |
113 flushed_ = false; | 116 flushed_ = false; |
114 } | 117 } |
115 | 118 |
116 uint32 submit_count() const { | 119 base::subtle::Atomic32 submit_count() const { return submit_count_; } |
117 return submit_count_; | |
118 } | |
119 | 120 |
120 int32 token() const { | 121 int32 token() const { |
121 return token_; | 122 return token_; |
122 } | 123 } |
123 | 124 |
124 bool NeverUsed() const { | 125 bool NeverUsed() const { |
125 return state_ == kUninitialized; | 126 return state_ == kUninitialized; |
126 } | 127 } |
127 | 128 |
128 bool Pending() const { | 129 bool Pending() const { |
129 return state_ == kPending; | 130 return state_ == kPending; |
130 } | 131 } |
131 | 132 |
132 bool CheckResultsAvailable(CommandBufferHelper* helper); | 133 bool CheckResultsAvailable(CommandBufferHelper* helper); |
133 | 134 |
134 uint32 GetResult() const; | 135 uint32 GetResult() const; |
135 | 136 |
136 void Begin(GLES2Implementation* gl); | 137 void Begin(GLES2Implementation* gl); |
137 void End(GLES2Implementation* gl); | 138 void End(GLES2Implementation* gl); |
138 | 139 |
139 private: | 140 private: |
140 friend class QueryTracker; | 141 friend class QueryTracker; |
141 friend class QueryTrackerTest; | 142 friend class QueryTrackerTest; |
142 | 143 |
143 GLuint id_; | 144 GLuint id_; |
144 GLenum target_; | 145 GLenum target_; |
145 QuerySyncManager::QueryInfo info_; | 146 QuerySyncManager::QueryInfo info_; |
146 State state_; | 147 State state_; |
147 uint32 submit_count_; | 148 base::subtle::Atomic32 submit_count_; |
148 int32 token_; | 149 int32 token_; |
149 bool flushed_; | 150 bool flushed_; |
150 uint64 client_begin_time_us_; // Only used for latency query target. | 151 uint64 client_begin_time_us_; // Only used for latency query target. |
151 uint32 result_; | 152 uint32 result_; |
152 }; | 153 }; |
153 | 154 |
154 QueryTracker(MappedMemoryManager* manager); | 155 QueryTracker(MappedMemoryManager* manager); |
155 ~QueryTracker(); | 156 ~QueryTracker(); |
156 | 157 |
157 Query* CreateQuery(GLuint id, GLenum target); | 158 Query* CreateQuery(GLuint id, GLenum target); |
(...skipping 10 matching lines...) Expand all Loading... |
168 QueryList removed_queries_; | 169 QueryList removed_queries_; |
169 QuerySyncManager query_sync_manager_; | 170 QuerySyncManager query_sync_manager_; |
170 | 171 |
171 DISALLOW_COPY_AND_ASSIGN(QueryTracker); | 172 DISALLOW_COPY_AND_ASSIGN(QueryTracker); |
172 }; | 173 }; |
173 | 174 |
174 } // namespace gles2 | 175 } // namespace gles2 |
175 } // namespace gpu | 176 } // namespace gpu |
176 | 177 |
177 #endif // GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_ | 178 #endif // GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_ |
OLD | NEW |