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> |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 95 } |
96 | 96 |
97 int32 shm_id() const { | 97 int32 shm_id() const { |
98 return info_.shm_id; | 98 return info_.shm_id; |
99 } | 99 } |
100 | 100 |
101 uint32 shm_offset() const { | 101 uint32 shm_offset() const { |
102 return info_.shm_offset; | 102 return info_.shm_offset; |
103 } | 103 } |
104 | 104 |
| 105 uint32 serial() const { |
| 106 return serial_; |
| 107 } |
| 108 |
| 109 void set_serial(uint32 serial) { |
| 110 serial_ = serial; |
| 111 } |
| 112 |
105 void MarkAsActive() { | 113 void MarkAsActive() { |
106 state_ = kActive; | 114 state_ = kActive; |
107 ++submit_count_; | 115 ++submit_count_; |
108 } | 116 } |
109 | 117 |
110 void MarkAsPending(int32 token) { | 118 void MarkAsPending(int32 token) { |
111 token_ = token; | 119 token_ = token; |
112 state_ = kPending; | 120 state_ = kPending; |
113 flushed_ = false; | 121 flushed_ = false; |
114 } | 122 } |
(...skipping 11 matching lines...) Expand all Loading... |
126 } | 134 } |
127 | 135 |
128 bool Pending() const { | 136 bool Pending() const { |
129 return state_ == kPending; | 137 return state_ == kPending; |
130 } | 138 } |
131 | 139 |
132 bool CheckResultsAvailable(CommandBufferHelper* helper); | 140 bool CheckResultsAvailable(CommandBufferHelper* helper); |
133 | 141 |
134 uint32 GetResult() const; | 142 uint32 GetResult() const; |
135 | 143 |
| 144 bool IsInternal() const { |
| 145 return serial_ != 0; |
| 146 } |
| 147 |
136 void Begin(GLES2Implementation* gl); | 148 void Begin(GLES2Implementation* gl); |
137 void End(GLES2Implementation* gl); | 149 void End(GLES2Implementation* gl); |
138 | 150 |
139 private: | 151 private: |
140 friend class QueryTracker; | 152 friend class QueryTracker; |
141 friend class QueryTrackerTest; | 153 friend class QueryTrackerTest; |
142 | 154 |
143 GLuint id_; | 155 GLuint id_; |
144 GLenum target_; | 156 GLenum target_; |
145 QuerySyncManager::QueryInfo info_; | 157 QuerySyncManager::QueryInfo info_; |
146 State state_; | 158 State state_; |
147 uint32 submit_count_; | 159 uint32 submit_count_; |
148 int32 token_; | 160 int32 token_; |
149 bool flushed_; | 161 bool flushed_; |
| 162 uint32 serial_; // Only used for internal queries, 0 means not internal. |
150 uint64 client_begin_time_us_; // Only used for latency query target. | 163 uint64 client_begin_time_us_; // Only used for latency query target. |
151 uint32 result_; | 164 uint32 result_; |
152 }; | 165 }; |
153 | 166 |
154 QueryTracker(MappedMemoryManager* manager); | 167 QueryTracker(MappedMemoryManager* manager); |
155 ~QueryTracker(); | 168 ~QueryTracker(); |
156 | 169 |
157 Query* CreateQuery(GLuint id, GLenum target); | 170 Query* CreateQuery(GLuint id, GLenum target); |
| 171 Query* CreateInternalQuery(GLuint id, GLenum target); |
158 Query* GetQuery(GLuint id); | 172 Query* GetQuery(GLuint id); |
159 void RemoveQuery(GLuint id); | 173 void RemoveQuery(GLuint id); |
160 void Shrink(); | 174 void Shrink(); |
161 void FreeCompletedQueries(); | 175 void FreeCompletedQueries(); |
162 | 176 |
163 private: | 177 private: |
| 178 uint32 NextSerial(); |
| 179 |
164 typedef base::hash_map<GLuint, Query*> QueryMap; | 180 typedef base::hash_map<GLuint, Query*> QueryMap; |
165 typedef std::list<Query*> QueryList; | 181 typedef std::list<Query*> QueryList; |
166 | 182 |
167 QueryMap queries_; | 183 QueryMap queries_; |
168 QueryList removed_queries_; | 184 QueryList removed_queries_; |
169 QuerySyncManager query_sync_manager_; | 185 QuerySyncManager query_sync_manager_; |
170 | 186 |
| 187 uint32 next_serial_; |
| 188 |
171 DISALLOW_COPY_AND_ASSIGN(QueryTracker); | 189 DISALLOW_COPY_AND_ASSIGN(QueryTracker); |
172 }; | 190 }; |
173 | 191 |
174 } // namespace gles2 | 192 } // namespace gles2 |
175 } // namespace gpu | 193 } // namespace gpu |
176 | 194 |
177 #endif // GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_ | 195 #endif // GPU_COMMAND_BUFFER_CLIENT_QUERY_TRACKER_H_ |
OLD | NEW |