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

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

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

Powered by Google App Engine
This is Rietveld 408576698