Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: gpu/command_buffer/service/query_manager.h

Issue 10577037: Add GL_CHROMIUM_get_error_query (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "gpu/command_buffer/service/feature_info.h" 14 #include "gpu/command_buffer/service/feature_info.h"
15 #include "gpu/command_buffer/service/gl_utils.h" 15 #include "gpu/command_buffer/service/gl_utils.h"
16 #include "gpu/gpu_export.h" 16 #include "gpu/gpu_export.h"
17 17
18 namespace gpu { 18 namespace gpu {
19 19
20 class CommonDecoder; 20 class GLES2Decoder;
21 21
22 namespace gles2 { 22 namespace gles2 {
23 23
24 class FeatureInfo; 24 class FeatureInfo;
25 25
26 // This class keeps track of the queries and their state 26 // This class keeps track of the queries and their state
27 // As Queries are not shared there is one QueryManager per context. 27 // As Queries are not shared there is one QueryManager per context.
28 class GPU_EXPORT QueryManager { 28 class GPU_EXPORT QueryManager {
29 public: 29 public:
30 class GPU_EXPORT Query : public base::RefCounted<Query> { 30 class GPU_EXPORT Query : public base::RefCounted<Query> {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 uint32 submit_count_; 125 uint32 submit_count_;
126 126
127 // True if in the queue. 127 // True if in the queue.
128 bool pending_; 128 bool pending_;
129 129
130 // True if deleted. 130 // True if deleted.
131 bool deleted_; 131 bool deleted_;
132 }; 132 };
133 133
134 QueryManager( 134 QueryManager(
135 CommonDecoder* decoder, 135 GLES2Decoder* decoder,
136 FeatureInfo* feature_info); 136 FeatureInfo* feature_info);
137 ~QueryManager(); 137 ~QueryManager();
138 138
139 // Must call before destruction. 139 // Must call before destruction.
140 void Destroy(bool have_context); 140 void Destroy(bool have_context);
141 141
142 // Creates a Query for the given query. 142 // Creates a Query for the given query.
143 Query* CreateQuery( 143 Query* CreateQuery(
144 GLenum target, GLuint client_id, int32 shm_id, uint32 shm_offset); 144 GLenum target, GLuint client_id, int32 shm_id, uint32 shm_offset);
145 145
146 // Gets the query info for the given query. 146 // Gets the query info for the given query.
147 Query* GetQuery(GLuint client_id); 147 Query* GetQuery(GLuint client_id);
148 148
149 // Removes a query info for the given query. 149 // Removes a query info for the given query.
150 void RemoveQuery(GLuint client_id); 150 void RemoveQuery(GLuint client_id);
151 151
152 // Returns false if any query is pointing to invalid shared memory. 152 // Returns false if any query is pointing to invalid shared memory.
153 bool BeginQuery(Query* query); 153 bool BeginQuery(Query* query);
154 154
155 // Returns false if any query is pointing to invalid shared memory. 155 // Returns false if any query is pointing to invalid shared memory.
156 bool EndQuery(Query* query, uint32 submit_count); 156 bool EndQuery(Query* query, uint32 submit_count);
157 157
158 // Processes pending queries. Returns false if any queries are pointing 158 // Processes pending queries. Returns false if any queries are pointing
159 // to invalid shared memory. 159 // to invalid shared memory.
160 bool ProcessPendingQueries(); 160 bool ProcessPendingQueries();
161 161
162 // True if there are pending queries. 162 // True if there are pending queries.
163 bool HavePendingQueries(); 163 bool HavePendingQueries();
164 164
165 GLES2Decoder* decoder() const {
166 return decoder_;
167 }
168
165 private: 169 private:
166 void StartTracking(Query* query); 170 void StartTracking(Query* query);
167 void StopTracking(Query* query); 171 void StopTracking(Query* query);
168 172
169 // Wrappers for BeginQueryARB and EndQueryARB to hide differences between 173 // Wrappers for BeginQueryARB and EndQueryARB to hide differences between
170 // ARB_occlusion_query2 and EXT_occlusion_query_boolean. 174 // ARB_occlusion_query2 and EXT_occlusion_query_boolean.
171 void BeginQueryHelper(GLenum target, GLuint id); 175 void BeginQueryHelper(GLenum target, GLuint id);
172 void EndQueryHelper(GLenum target); 176 void EndQueryHelper(GLenum target);
173 177
174 // Adds to queue of queries waiting for completion. 178 // Adds to queue of queries waiting for completion.
175 // Returns false if any query is pointing to invalid shared memory. 179 // Returns false if any query is pointing to invalid shared memory.
176 bool AddPendingQuery(Query* query, uint32 submit_count); 180 bool AddPendingQuery(Query* query, uint32 submit_count);
177 181
178 // Removes a query from the queue of pending queries. 182 // Removes a query from the queue of pending queries.
179 // Returns false if any query is pointing to invalid shared memory. 183 // Returns false if any query is pointing to invalid shared memory.
180 bool RemovePendingQuery(Query* query); 184 bool RemovePendingQuery(Query* query);
181 185
182 // Returns a target used for the underlying GL extension 186 // Returns a target used for the underlying GL extension
183 // used to emulate a query. 187 // used to emulate a query.
184 GLenum AdjustTargetForEmulation(GLenum target); 188 GLenum AdjustTargetForEmulation(GLenum target);
185 189
186 // Used to validate shared memory. 190 // Used to validate shared memory and get GL errors.
187 CommonDecoder* decoder_; 191 GLES2Decoder* decoder_;
188 192
189 bool use_arb_occlusion_query2_for_occlusion_query_boolean_; 193 bool use_arb_occlusion_query2_for_occlusion_query_boolean_;
190 bool use_arb_occlusion_query_for_occlusion_query_boolean_; 194 bool use_arb_occlusion_query_for_occlusion_query_boolean_;
191 195
192 // Counts the number of Queries allocated with 'this' as their manager. 196 // Counts the number of Queries allocated with 'this' as their manager.
193 // Allows checking no Query will outlive this. 197 // Allows checking no Query will outlive this.
194 unsigned query_count_; 198 unsigned query_count_;
195 199
196 // Info for each query in the system. 200 // Info for each query in the system.
197 typedef base::hash_map<GLuint, Query::Ref> QueryMap; 201 typedef base::hash_map<GLuint, Query::Ref> QueryMap;
198 QueryMap queries_; 202 QueryMap queries_;
199 203
200 // Queries waiting for completion. 204 // Queries waiting for completion.
201 typedef std::deque<Query::Ref> QueryQueue; 205 typedef std::deque<Query::Ref> QueryQueue;
202 QueryQueue pending_queries_; 206 QueryQueue pending_queries_;
203 207
204 DISALLOW_COPY_AND_ASSIGN(QueryManager); 208 DISALLOW_COPY_AND_ASSIGN(QueryManager);
205 }; 209 };
206 210
207 } // namespace gles2 211 } // namespace gles2
208 } // namespace gpu 212 } // namespace gpu
209 213
210 #endif // GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_ 214 #endif // GPU_COMMAND_BUFFER_SERVICE_QUERY_MANAGER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_mock.h ('k') | gpu/command_buffer/service/query_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698