| 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_SERVICE_QUERY_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 // Returns false if shared memory for sync is invalid. | 83 // Returns false if shared memory for sync is invalid. |
| 84 bool MarkAsCompleted(uint64 result); | 84 bool MarkAsCompleted(uint64 result); |
| 85 | 85 |
| 86 void MarkAsPending(uint32 submit_count) { | 86 void MarkAsPending(uint32 submit_count) { |
| 87 DCHECK(!pending_); | 87 DCHECK(!pending_); |
| 88 pending_ = true; | 88 pending_ = true; |
| 89 submit_count_ = submit_count; | 89 submit_count_ = submit_count; |
| 90 } | 90 } |
| 91 | 91 |
| 92 void UnmarkAsPending() { | |
| 93 DCHECK(pending_); | |
| 94 pending_ = false; | |
| 95 } | |
| 96 | |
| 97 // Returns false if shared memory for sync is invalid. | 92 // Returns false if shared memory for sync is invalid. |
| 98 bool AddToPendingQueue(uint32 submit_count) { | 93 bool AddToPendingQueue(uint32 submit_count) { |
| 99 return manager_->AddPendingQuery(this, submit_count); | 94 return manager_->AddPendingQuery(this, submit_count); |
| 100 } | 95 } |
| 101 | 96 |
| 102 // Returns false if shared memory for sync is invalid. | |
| 103 bool AddToPendingTransferQueue(uint32 submit_count) { | |
| 104 return manager_->AddPendingTransferQuery(this, submit_count); | |
| 105 } | |
| 106 | |
| 107 void BeginQueryHelper(GLenum target, GLuint id) { | 97 void BeginQueryHelper(GLenum target, GLuint id) { |
| 108 manager_->BeginQueryHelper(target, id); | 98 manager_->BeginQueryHelper(target, id); |
| 109 } | 99 } |
| 110 | 100 |
| 111 void EndQueryHelper(GLenum target) { | 101 void EndQueryHelper(GLenum target) { |
| 112 manager_->EndQueryHelper(target); | 102 manager_->EndQueryHelper(target); |
| 113 } | 103 } |
| 114 | 104 |
| 115 uint32 submit_count() const { | |
| 116 return submit_count_; | |
| 117 } | |
| 118 | |
| 119 private: | 105 private: |
| 120 friend class QueryManager; | 106 friend class QueryManager; |
| 121 friend class QueryManagerTest; | 107 friend class QueryManagerTest; |
| 122 friend class base::RefCounted<Query>; | 108 friend class base::RefCounted<Query>; |
| 123 | 109 |
| 110 uint32 submit_count() const { |
| 111 return submit_count_; |
| 112 } |
| 113 |
| 124 // The manager that owns this Query. | 114 // The manager that owns this Query. |
| 125 QueryManager* manager_; | 115 QueryManager* manager_; |
| 126 | 116 |
| 127 // The type of query. | 117 // The type of query. |
| 128 GLenum target_; | 118 GLenum target_; |
| 129 | 119 |
| 130 // The shared memory used with this Query. | 120 // The shared memory used with this Query. |
| 131 int32 shm_id_; | 121 int32 shm_id_; |
| 132 uint32 shm_offset_; | 122 uint32 shm_offset_; |
| 133 | 123 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // Returns false if any query is pointing to invalid shared memory. | 155 // Returns false if any query is pointing to invalid shared memory. |
| 166 bool EndQuery(Query* query, uint32 submit_count); | 156 bool EndQuery(Query* query, uint32 submit_count); |
| 167 | 157 |
| 168 // Processes pending queries. Returns false if any queries are pointing | 158 // Processes pending queries. Returns false if any queries are pointing |
| 169 // to invalid shared memory. | 159 // to invalid shared memory. |
| 170 bool ProcessPendingQueries(); | 160 bool ProcessPendingQueries(); |
| 171 | 161 |
| 172 // True if there are pending queries. | 162 // True if there are pending queries. |
| 173 bool HavePendingQueries(); | 163 bool HavePendingQueries(); |
| 174 | 164 |
| 175 // Processes pending transfer queries. Returns false if any queries are | |
| 176 // pointing to invalid shared memory. | |
| 177 bool ProcessPendingTransferQueries(); | |
| 178 | |
| 179 // True if there are pending transfer queries. | |
| 180 bool HavePendingTransferQueries(); | |
| 181 | |
| 182 GLES2Decoder* decoder() const { | 165 GLES2Decoder* decoder() const { |
| 183 return decoder_; | 166 return decoder_; |
| 184 } | 167 } |
| 185 | 168 |
| 186 private: | 169 private: |
| 187 void StartTracking(Query* query); | 170 void StartTracking(Query* query); |
| 188 void StopTracking(Query* query); | 171 void StopTracking(Query* query); |
| 189 | 172 |
| 190 // Wrappers for BeginQueryARB and EndQueryARB to hide differences between | 173 // Wrappers for BeginQueryARB and EndQueryARB to hide differences between |
| 191 // ARB_occlusion_query2 and EXT_occlusion_query_boolean. | 174 // ARB_occlusion_query2 and EXT_occlusion_query_boolean. |
| 192 void BeginQueryHelper(GLenum target, GLuint id); | 175 void BeginQueryHelper(GLenum target, GLuint id); |
| 193 void EndQueryHelper(GLenum target); | 176 void EndQueryHelper(GLenum target); |
| 194 | 177 |
| 195 // Adds to queue of queries waiting for completion. | 178 // Adds to queue of queries waiting for completion. |
| 196 // Returns false if any query is pointing to invalid shared memory. | 179 // Returns false if any query is pointing to invalid shared memory. |
| 197 bool AddPendingQuery(Query* query, uint32 submit_count); | 180 bool AddPendingQuery(Query* query, uint32 submit_count); |
| 198 | 181 |
| 199 // Adds to queue of transfer queries waiting for completion. | |
| 200 // Returns false if any query is pointing to invalid shared memory. | |
| 201 bool AddPendingTransferQuery(Query* query, uint32 submit_count); | |
| 202 | |
| 203 // Removes a query from the queue of pending queries. | 182 // Removes a query from the queue of pending queries. |
| 204 // Returns false if any query is pointing to invalid shared memory. | 183 // Returns false if any query is pointing to invalid shared memory. |
| 205 bool RemovePendingQuery(Query* query); | 184 bool RemovePendingQuery(Query* query); |
| 206 | 185 |
| 207 // Returns a target used for the underlying GL extension | 186 // Returns a target used for the underlying GL extension |
| 208 // used to emulate a query. | 187 // used to emulate a query. |
| 209 GLenum AdjustTargetForEmulation(GLenum target); | 188 GLenum AdjustTargetForEmulation(GLenum target); |
| 210 | 189 |
| 211 // Used to validate shared memory and get GL errors. | 190 // Used to validate shared memory and get GL errors. |
| 212 GLES2Decoder* decoder_; | 191 GLES2Decoder* decoder_; |
| 213 | 192 |
| 214 bool use_arb_occlusion_query2_for_occlusion_query_boolean_; | 193 bool use_arb_occlusion_query2_for_occlusion_query_boolean_; |
| 215 bool use_arb_occlusion_query_for_occlusion_query_boolean_; | 194 bool use_arb_occlusion_query_for_occlusion_query_boolean_; |
| 216 | 195 |
| 217 // Counts the number of Queries allocated with 'this' as their manager. | 196 // Counts the number of Queries allocated with 'this' as their manager. |
| 218 // Allows checking no Query will outlive this. | 197 // Allows checking no Query will outlive this. |
| 219 unsigned query_count_; | 198 unsigned query_count_; |
| 220 | 199 |
| 221 // Info for each query in the system. | 200 // Info for each query in the system. |
| 222 typedef base::hash_map<GLuint, Query::Ref> QueryMap; | 201 typedef base::hash_map<GLuint, Query::Ref> QueryMap; |
| 223 QueryMap queries_; | 202 QueryMap queries_; |
| 224 | 203 |
| 225 // Queries waiting for completion. | 204 // Queries waiting for completion. |
| 226 typedef std::deque<Query::Ref> QueryQueue; | 205 typedef std::deque<Query::Ref> QueryQueue; |
| 227 QueryQueue pending_queries_; | 206 QueryQueue pending_queries_; |
| 228 | 207 |
| 229 // Async pixel transfer queries waiting for completion. | |
| 230 QueryQueue pending_transfer_queries_; | |
| 231 | |
| 232 DISALLOW_COPY_AND_ASSIGN(QueryManager); | 208 DISALLOW_COPY_AND_ASSIGN(QueryManager); |
| 233 }; | 209 }; |
| 234 | 210 |
| 235 } // namespace gles2 | 211 } // namespace gles2 |
| 236 } // namespace gpu | 212 } // namespace gpu |
| 237 | 213 |
| 238 #endif // GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ | 214 #endif // GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ |
| OLD | NEW |