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 #include "gpu/command_buffer/service/query_manager.h" | 5 #include "gpu/command_buffer/service/query_manager.h" |
6 | 6 |
7 #include "base/atomicops.h" | 7 #include "base/atomicops.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 13 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
14 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" | 14 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" |
15 #include "gpu/command_buffer/service/error_state.h" | 15 #include "gpu/command_buffer/service/error_state.h" |
16 #include "gpu/command_buffer/service/feature_info.h" | 16 #include "gpu/command_buffer/service/feature_info.h" |
17 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 17 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
18 | 18 |
19 namespace gpu { | 19 namespace gpu { |
20 namespace gles2 { | 20 namespace gles2 { |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 class AsyncPixelTransferCompletionObserverImpl | 24 class AsyncPixelTransferCompletionObserverImpl |
25 : public AsyncPixelTransferCompletionObserver { | 25 : public AsyncPixelTransferCompletionObserver { |
26 public: | 26 public: |
27 AsyncPixelTransferCompletionObserverImpl(uint32 submit_count) | 27 AsyncPixelTransferCompletionObserverImpl(int32 submit_count) |
28 : submit_count_(submit_count), | 28 : submit_count_(submit_count), |
29 cancelled_(false) {} | 29 cancelled_(false) {} |
30 | 30 |
31 void Cancel() { | 31 void Cancel() { |
32 base::AutoLock locked(lock_); | 32 base::AutoLock locked(lock_); |
33 cancelled_ = true; | 33 cancelled_ = true; |
34 } | 34 } |
35 | 35 |
36 virtual void DidComplete(const AsyncMemoryParams& mem_params) OVERRIDE { | 36 virtual void DidComplete(const AsyncMemoryParams& mem_params) OVERRIDE { |
37 base::AutoLock locked(lock_); | 37 base::AutoLock locked(lock_); |
38 if (!cancelled_) { | 38 if (!cancelled_) { |
39 DCHECK(mem_params.shared_memory); | 39 DCHECK(mem_params.shared_memory); |
40 DCHECK(mem_params.shared_memory->memory()); | 40 DCHECK(mem_params.shared_memory->memory()); |
41 void* data = static_cast<int8*>(mem_params.shared_memory->memory()) + | 41 void* data = static_cast<int8*>(mem_params.shared_memory->memory()) + |
42 mem_params.shm_data_offset; | 42 mem_params.shm_data_offset; |
43 QuerySync* sync = static_cast<QuerySync*>(data); | 43 QuerySync* sync = static_cast<QuerySync*>(data); |
44 | 44 |
45 // Need a MemoryBarrier here to ensure that upload completed before | 45 base::subtle::Release_Store(&sync->process_count, submit_count_); |
46 // submit_count was written to sync->process_count. | |
47 base::subtle::MemoryBarrier(); | |
48 sync->process_count = submit_count_; | |
49 } | 46 } |
50 } | 47 } |
51 | 48 |
52 private: | 49 private: |
53 virtual ~AsyncPixelTransferCompletionObserverImpl() {} | 50 virtual ~AsyncPixelTransferCompletionObserverImpl() {} |
54 | 51 |
55 uint32 submit_count_; | 52 int32 submit_count_; |
56 | 53 |
57 base::Lock lock_; | 54 base::Lock lock_; |
58 bool cancelled_; | 55 bool cancelled_; |
59 | 56 |
60 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferCompletionObserverImpl); | 57 DISALLOW_COPY_AND_ASSIGN(AsyncPixelTransferCompletionObserverImpl); |
61 }; | 58 }; |
62 | 59 |
63 class AsyncPixelTransfersCompletedQuery | 60 class AsyncPixelTransfersCompletedQuery |
64 : public QueryManager::Query, | 61 : public QueryManager::Query, |
65 public base::SupportsWeakPtr<AsyncPixelTransfersCompletedQuery> { | 62 public base::SupportsWeakPtr<AsyncPixelTransfersCompletedQuery> { |
66 public: | 63 public: |
67 AsyncPixelTransfersCompletedQuery( | 64 AsyncPixelTransfersCompletedQuery( |
68 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); | 65 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); |
69 | 66 |
70 virtual bool Begin() OVERRIDE; | 67 virtual bool Begin() OVERRIDE; |
71 virtual bool End(uint32 submit_count) OVERRIDE; | 68 virtual bool End(int32 submit_count) OVERRIDE; |
72 virtual bool Process() OVERRIDE; | 69 virtual bool Process() OVERRIDE; |
73 virtual void Destroy(bool have_context) OVERRIDE; | 70 virtual void Destroy(bool have_context) OVERRIDE; |
74 | 71 |
75 protected: | 72 protected: |
76 virtual ~AsyncPixelTransfersCompletedQuery(); | 73 virtual ~AsyncPixelTransfersCompletedQuery(); |
77 | 74 |
78 scoped_refptr<AsyncPixelTransferCompletionObserverImpl> observer_; | 75 scoped_refptr<AsyncPixelTransferCompletionObserverImpl> observer_; |
79 }; | 76 }; |
80 | 77 |
81 AsyncPixelTransfersCompletedQuery::AsyncPixelTransfersCompletedQuery( | 78 AsyncPixelTransfersCompletedQuery::AsyncPixelTransfersCompletedQuery( |
82 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) | 79 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) |
83 : Query(manager, target, shm_id, shm_offset) { | 80 : Query(manager, target, shm_id, shm_offset) { |
84 } | 81 } |
85 | 82 |
86 bool AsyncPixelTransfersCompletedQuery::Begin() { | 83 bool AsyncPixelTransfersCompletedQuery::Begin() { |
87 return true; | 84 return true; |
88 } | 85 } |
89 | 86 |
90 bool AsyncPixelTransfersCompletedQuery::End(uint32 submit_count) { | 87 bool AsyncPixelTransfersCompletedQuery::End(int32 submit_count) { |
91 AsyncMemoryParams mem_params; | 88 AsyncMemoryParams mem_params; |
92 // Get the real shared memory since it might need to be duped to prevent | 89 // Get the real shared memory since it might need to be duped to prevent |
93 // use-after-free of the memory. | 90 // use-after-free of the memory. |
94 Buffer buffer = manager()->decoder()->GetSharedMemoryBuffer(shm_id()); | 91 Buffer buffer = manager()->decoder()->GetSharedMemoryBuffer(shm_id()); |
95 if (!buffer.shared_memory) | 92 if (!buffer.shared_memory) |
96 return false; | 93 return false; |
97 mem_params.shared_memory = buffer.shared_memory; | 94 mem_params.shared_memory = buffer.shared_memory; |
98 mem_params.shm_size = buffer.size; | 95 mem_params.shm_size = buffer.size; |
99 mem_params.shm_data_offset = shm_offset(); | 96 mem_params.shm_data_offset = shm_offset(); |
100 mem_params.shm_data_size = sizeof(QuerySync); | 97 mem_params.shm_data_size = sizeof(QuerySync); |
(...skipping 11 matching lines...) Expand all Loading... |
112 | 109 |
113 bool AsyncPixelTransfersCompletedQuery::Process() { | 110 bool AsyncPixelTransfersCompletedQuery::Process() { |
114 QuerySync* sync = manager()->decoder()->GetSharedMemoryAs<QuerySync*>( | 111 QuerySync* sync = manager()->decoder()->GetSharedMemoryAs<QuerySync*>( |
115 shm_id(), shm_offset(), sizeof(*sync)); | 112 shm_id(), shm_offset(), sizeof(*sync)); |
116 if (!sync) | 113 if (!sync) |
117 return false; | 114 return false; |
118 | 115 |
119 // Check if completion callback has been run. sync->process_count atomicity | 116 // Check if completion callback has been run. sync->process_count atomicity |
120 // is guaranteed as this is already used to notify client of a completed | 117 // is guaranteed as this is already used to notify client of a completed |
121 // query. | 118 // query. |
122 if (sync->process_count != submit_count()) | 119 if (base::subtle::Acquire_Load(&sync->process_count) != submit_count()) |
123 return true; | 120 return true; |
124 | 121 |
125 UnmarkAsPending(); | 122 UnmarkAsPending(); |
126 return true; | 123 return true; |
127 } | 124 } |
128 | 125 |
129 void AsyncPixelTransfersCompletedQuery::Destroy(bool /* have_context */) { | 126 void AsyncPixelTransfersCompletedQuery::Destroy(bool /* have_context */) { |
130 if (!IsDeleted()) { | 127 if (!IsDeleted()) { |
131 MarkAsDeleted(); | 128 MarkAsDeleted(); |
132 } | 129 } |
133 } | 130 } |
134 | 131 |
135 AsyncPixelTransfersCompletedQuery::~AsyncPixelTransfersCompletedQuery() { | 132 AsyncPixelTransfersCompletedQuery::~AsyncPixelTransfersCompletedQuery() { |
136 if (observer_) | 133 if (observer_) |
137 observer_->Cancel(); | 134 observer_->Cancel(); |
138 } | 135 } |
139 | 136 |
140 } // namespace | 137 } // namespace |
141 | 138 |
142 class AllSamplesPassedQuery : public QueryManager::Query { | 139 class AllSamplesPassedQuery : public QueryManager::Query { |
143 public: | 140 public: |
144 AllSamplesPassedQuery( | 141 AllSamplesPassedQuery( |
145 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset, | 142 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset, |
146 GLuint service_id); | 143 GLuint service_id); |
147 virtual bool Begin() OVERRIDE; | 144 virtual bool Begin() OVERRIDE; |
148 virtual bool End(uint32 submit_count) OVERRIDE; | 145 virtual bool End(int32 submit_count) OVERRIDE; |
149 virtual bool Process() OVERRIDE; | 146 virtual bool Process() OVERRIDE; |
150 virtual void Destroy(bool have_context) OVERRIDE; | 147 virtual void Destroy(bool have_context) OVERRIDE; |
151 | 148 |
152 protected: | 149 protected: |
153 virtual ~AllSamplesPassedQuery(); | 150 virtual ~AllSamplesPassedQuery(); |
154 | 151 |
155 private: | 152 private: |
156 // Service side query id. | 153 // Service side query id. |
157 GLuint service_id_; | 154 GLuint service_id_; |
158 }; | 155 }; |
159 | 156 |
160 AllSamplesPassedQuery::AllSamplesPassedQuery( | 157 AllSamplesPassedQuery::AllSamplesPassedQuery( |
161 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset, | 158 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset, |
162 GLuint service_id) | 159 GLuint service_id) |
163 : Query(manager, target, shm_id, shm_offset), | 160 : Query(manager, target, shm_id, shm_offset), |
164 service_id_(service_id) { | 161 service_id_(service_id) { |
165 } | 162 } |
166 | 163 |
167 bool AllSamplesPassedQuery::Begin() { | 164 bool AllSamplesPassedQuery::Begin() { |
168 BeginQueryHelper(target(), service_id_); | 165 BeginQueryHelper(target(), service_id_); |
169 return true; | 166 return true; |
170 } | 167 } |
171 | 168 |
172 bool AllSamplesPassedQuery::End(uint32 submit_count) { | 169 bool AllSamplesPassedQuery::End(int32 submit_count) { |
173 EndQueryHelper(target()); | 170 EndQueryHelper(target()); |
174 return AddToPendingQueue(submit_count); | 171 return AddToPendingQueue(submit_count); |
175 } | 172 } |
176 | 173 |
177 bool AllSamplesPassedQuery::Process() { | 174 bool AllSamplesPassedQuery::Process() { |
178 GLuint available = 0; | 175 GLuint available = 0; |
179 glGetQueryObjectuivARB( | 176 glGetQueryObjectuivARB( |
180 service_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available); | 177 service_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available); |
181 if (!available) { | 178 if (!available) { |
182 return true; | 179 return true; |
(...skipping 14 matching lines...) Expand all Loading... |
197 | 194 |
198 AllSamplesPassedQuery::~AllSamplesPassedQuery() { | 195 AllSamplesPassedQuery::~AllSamplesPassedQuery() { |
199 } | 196 } |
200 | 197 |
201 class CommandsIssuedQuery : public QueryManager::Query { | 198 class CommandsIssuedQuery : public QueryManager::Query { |
202 public: | 199 public: |
203 CommandsIssuedQuery( | 200 CommandsIssuedQuery( |
204 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); | 201 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); |
205 | 202 |
206 virtual bool Begin() OVERRIDE; | 203 virtual bool Begin() OVERRIDE; |
207 virtual bool End(uint32 submit_count) OVERRIDE; | 204 virtual bool End(int32 submit_count) OVERRIDE; |
208 virtual bool Process() OVERRIDE; | 205 virtual bool Process() OVERRIDE; |
209 virtual void Destroy(bool have_context) OVERRIDE; | 206 virtual void Destroy(bool have_context) OVERRIDE; |
210 | 207 |
211 protected: | 208 protected: |
212 virtual ~CommandsIssuedQuery(); | 209 virtual ~CommandsIssuedQuery(); |
213 | 210 |
214 private: | 211 private: |
215 base::TimeTicks begin_time_; | 212 base::TimeTicks begin_time_; |
216 }; | 213 }; |
217 | 214 |
218 CommandsIssuedQuery::CommandsIssuedQuery( | 215 CommandsIssuedQuery::CommandsIssuedQuery( |
219 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) | 216 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) |
220 : Query(manager, target, shm_id, shm_offset) { | 217 : Query(manager, target, shm_id, shm_offset) { |
221 } | 218 } |
222 | 219 |
223 bool CommandsIssuedQuery::Begin() { | 220 bool CommandsIssuedQuery::Begin() { |
224 begin_time_ = base::TimeTicks::HighResNow(); | 221 begin_time_ = base::TimeTicks::HighResNow(); |
225 return true; | 222 return true; |
226 } | 223 } |
227 | 224 |
228 bool CommandsIssuedQuery::End(uint32 submit_count) { | 225 bool CommandsIssuedQuery::End(int32 submit_count) { |
229 base::TimeDelta elapsed = base::TimeTicks::HighResNow() - begin_time_; | 226 base::TimeDelta elapsed = base::TimeTicks::HighResNow() - begin_time_; |
230 MarkAsPending(submit_count); | 227 MarkAsPending(submit_count); |
231 return MarkAsCompleted(elapsed.InMicroseconds()); | 228 return MarkAsCompleted(elapsed.InMicroseconds()); |
232 } | 229 } |
233 | 230 |
234 bool CommandsIssuedQuery::Process() { | 231 bool CommandsIssuedQuery::Process() { |
235 NOTREACHED(); | 232 NOTREACHED(); |
236 return true; | 233 return true; |
237 } | 234 } |
238 | 235 |
239 void CommandsIssuedQuery::Destroy(bool /* have_context */) { | 236 void CommandsIssuedQuery::Destroy(bool /* have_context */) { |
240 if (!IsDeleted()) { | 237 if (!IsDeleted()) { |
241 MarkAsDeleted(); | 238 MarkAsDeleted(); |
242 } | 239 } |
243 } | 240 } |
244 | 241 |
245 CommandsIssuedQuery::~CommandsIssuedQuery() { | 242 CommandsIssuedQuery::~CommandsIssuedQuery() { |
246 } | 243 } |
247 | 244 |
248 class CommandLatencyQuery : public QueryManager::Query { | 245 class CommandLatencyQuery : public QueryManager::Query { |
249 public: | 246 public: |
250 CommandLatencyQuery( | 247 CommandLatencyQuery( |
251 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); | 248 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); |
252 | 249 |
253 virtual bool Begin() OVERRIDE; | 250 virtual bool Begin() OVERRIDE; |
254 virtual bool End(uint32 submit_count) OVERRIDE; | 251 virtual bool End(int32 submit_count) OVERRIDE; |
255 virtual bool Process() OVERRIDE; | 252 virtual bool Process() OVERRIDE; |
256 virtual void Destroy(bool have_context) OVERRIDE; | 253 virtual void Destroy(bool have_context) OVERRIDE; |
257 | 254 |
258 protected: | 255 protected: |
259 virtual ~CommandLatencyQuery(); | 256 virtual ~CommandLatencyQuery(); |
260 }; | 257 }; |
261 | 258 |
262 CommandLatencyQuery::CommandLatencyQuery( | 259 CommandLatencyQuery::CommandLatencyQuery( |
263 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) | 260 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) |
264 : Query(manager, target, shm_id, shm_offset) { | 261 : Query(manager, target, shm_id, shm_offset) { |
265 } | 262 } |
266 | 263 |
267 bool CommandLatencyQuery::Begin() { | 264 bool CommandLatencyQuery::Begin() { |
268 return true; | 265 return true; |
269 } | 266 } |
270 | 267 |
271 bool CommandLatencyQuery::End(uint32 submit_count) { | 268 bool CommandLatencyQuery::End(int32 submit_count) { |
272 base::TimeDelta now = base::TimeTicks::HighResNow() - base::TimeTicks(); | 269 base::TimeDelta now = base::TimeTicks::HighResNow() - base::TimeTicks(); |
273 MarkAsPending(submit_count); | 270 MarkAsPending(submit_count); |
274 return MarkAsCompleted(now.InMicroseconds()); | 271 return MarkAsCompleted(now.InMicroseconds()); |
275 } | 272 } |
276 | 273 |
277 bool CommandLatencyQuery::Process() { | 274 bool CommandLatencyQuery::Process() { |
278 NOTREACHED(); | 275 NOTREACHED(); |
279 return true; | 276 return true; |
280 } | 277 } |
281 | 278 |
282 void CommandLatencyQuery::Destroy(bool /* have_context */) { | 279 void CommandLatencyQuery::Destroy(bool /* have_context */) { |
283 if (!IsDeleted()) { | 280 if (!IsDeleted()) { |
284 MarkAsDeleted(); | 281 MarkAsDeleted(); |
285 } | 282 } |
286 } | 283 } |
287 | 284 |
288 CommandLatencyQuery::~CommandLatencyQuery() { | 285 CommandLatencyQuery::~CommandLatencyQuery() { |
289 } | 286 } |
290 | 287 |
291 | 288 |
292 class AsyncReadPixelsCompletedQuery | 289 class AsyncReadPixelsCompletedQuery |
293 : public QueryManager::Query, | 290 : public QueryManager::Query, |
294 public base::SupportsWeakPtr<AsyncReadPixelsCompletedQuery> { | 291 public base::SupportsWeakPtr<AsyncReadPixelsCompletedQuery> { |
295 public: | 292 public: |
296 AsyncReadPixelsCompletedQuery( | 293 AsyncReadPixelsCompletedQuery( |
297 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); | 294 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); |
298 | 295 |
299 virtual bool Begin() OVERRIDE; | 296 virtual bool Begin() OVERRIDE; |
300 virtual bool End(uint32 submit_count) OVERRIDE; | 297 virtual bool End(int32 submit_count) OVERRIDE; |
301 virtual bool Process() OVERRIDE; | 298 virtual bool Process() OVERRIDE; |
302 virtual void Destroy(bool have_context) OVERRIDE; | 299 virtual void Destroy(bool have_context) OVERRIDE; |
303 | 300 |
304 protected: | 301 protected: |
305 void Complete(); | 302 void Complete(); |
306 virtual ~AsyncReadPixelsCompletedQuery(); | 303 virtual ~AsyncReadPixelsCompletedQuery(); |
307 }; | 304 }; |
308 | 305 |
309 AsyncReadPixelsCompletedQuery::AsyncReadPixelsCompletedQuery( | 306 AsyncReadPixelsCompletedQuery::AsyncReadPixelsCompletedQuery( |
310 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) | 307 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) |
311 : Query(manager, target, shm_id, shm_offset) { | 308 : Query(manager, target, shm_id, shm_offset) { |
312 } | 309 } |
313 | 310 |
314 bool AsyncReadPixelsCompletedQuery::Begin() { | 311 bool AsyncReadPixelsCompletedQuery::Begin() { |
315 return true; | 312 return true; |
316 } | 313 } |
317 | 314 |
318 bool AsyncReadPixelsCompletedQuery::End(uint32 submit_count) { | 315 bool AsyncReadPixelsCompletedQuery::End(int32 submit_count) { |
319 if (!AddToPendingQueue(submit_count)) { | 316 if (!AddToPendingQueue(submit_count)) { |
320 return false; | 317 return false; |
321 } | 318 } |
322 manager()->decoder()->WaitForReadPixels( | 319 manager()->decoder()->WaitForReadPixels( |
323 base::Bind(&AsyncReadPixelsCompletedQuery::Complete, | 320 base::Bind(&AsyncReadPixelsCompletedQuery::Complete, |
324 AsWeakPtr())); | 321 AsWeakPtr())); |
325 | 322 |
326 return true; | 323 return true; |
327 } | 324 } |
328 | 325 |
(...skipping 14 matching lines...) Expand all Loading... |
343 AsyncReadPixelsCompletedQuery::~AsyncReadPixelsCompletedQuery() { | 340 AsyncReadPixelsCompletedQuery::~AsyncReadPixelsCompletedQuery() { |
344 } | 341 } |
345 | 342 |
346 | 343 |
347 class GetErrorQuery : public QueryManager::Query { | 344 class GetErrorQuery : public QueryManager::Query { |
348 public: | 345 public: |
349 GetErrorQuery( | 346 GetErrorQuery( |
350 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); | 347 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); |
351 | 348 |
352 virtual bool Begin() OVERRIDE; | 349 virtual bool Begin() OVERRIDE; |
353 virtual bool End(uint32 submit_count) OVERRIDE; | 350 virtual bool End(int32 submit_count) OVERRIDE; |
354 virtual bool Process() OVERRIDE; | 351 virtual bool Process() OVERRIDE; |
355 virtual void Destroy(bool have_context) OVERRIDE; | 352 virtual void Destroy(bool have_context) OVERRIDE; |
356 | 353 |
357 protected: | 354 protected: |
358 virtual ~GetErrorQuery(); | 355 virtual ~GetErrorQuery(); |
359 | 356 |
360 private: | 357 private: |
361 }; | 358 }; |
362 | 359 |
363 GetErrorQuery::GetErrorQuery( | 360 GetErrorQuery::GetErrorQuery( |
364 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) | 361 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) |
365 : Query(manager, target, shm_id, shm_offset) { | 362 : Query(manager, target, shm_id, shm_offset) { |
366 } | 363 } |
367 | 364 |
368 bool GetErrorQuery::Begin() { | 365 bool GetErrorQuery::Begin() { |
369 return true; | 366 return true; |
370 } | 367 } |
371 | 368 |
372 bool GetErrorQuery::End(uint32 submit_count) { | 369 bool GetErrorQuery::End(int32 submit_count) { |
373 MarkAsPending(submit_count); | 370 MarkAsPending(submit_count); |
374 return MarkAsCompleted(manager()->decoder()->GetErrorState()->GetGLError()); | 371 return MarkAsCompleted(manager()->decoder()->GetErrorState()->GetGLError()); |
375 } | 372 } |
376 | 373 |
377 bool GetErrorQuery::Process() { | 374 bool GetErrorQuery::Process() { |
378 NOTREACHED(); | 375 NOTREACHED(); |
379 return true; | 376 return true; |
380 } | 377 } |
381 | 378 |
382 void GetErrorQuery::Destroy(bool /* have_context */) { | 379 void GetErrorQuery::Destroy(bool /* have_context */) { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 bool QueryManager::Query::MarkAsCompleted(uint64 result) { | 553 bool QueryManager::Query::MarkAsCompleted(uint64 result) { |
557 DCHECK(pending_); | 554 DCHECK(pending_); |
558 QuerySync* sync = manager_->decoder_->GetSharedMemoryAs<QuerySync*>( | 555 QuerySync* sync = manager_->decoder_->GetSharedMemoryAs<QuerySync*>( |
559 shm_id_, shm_offset_, sizeof(*sync)); | 556 shm_id_, shm_offset_, sizeof(*sync)); |
560 if (!sync) { | 557 if (!sync) { |
561 return false; | 558 return false; |
562 } | 559 } |
563 | 560 |
564 pending_ = false; | 561 pending_ = false; |
565 sync->result = result; | 562 sync->result = result; |
566 // Need a MemoryBarrier here so that sync->result is written before | 563 base::subtle::Release_Store(&sync->process_count, submit_count_); |
567 // sync->process_count. | |
568 base::subtle::MemoryBarrier(); | |
569 sync->process_count = submit_count_; | |
570 | 564 |
571 return true; | 565 return true; |
572 } | 566 } |
573 | 567 |
574 bool QueryManager::ProcessPendingQueries() { | 568 bool QueryManager::ProcessPendingQueries() { |
575 while (!pending_queries_.empty()) { | 569 while (!pending_queries_.empty()) { |
576 Query* query = pending_queries_.front().get(); | 570 Query* query = pending_queries_.front().get(); |
577 if (!query->Process()) { | 571 if (!query->Process()) { |
578 return false; | 572 return false; |
579 } | 573 } |
(...skipping 24 matching lines...) Expand all Loading... |
604 pending_transfer_queries_.pop_front(); | 598 pending_transfer_queries_.pop_front(); |
605 } | 599 } |
606 | 600 |
607 return true; | 601 return true; |
608 } | 602 } |
609 | 603 |
610 bool QueryManager::HavePendingTransferQueries() { | 604 bool QueryManager::HavePendingTransferQueries() { |
611 return !pending_transfer_queries_.empty(); | 605 return !pending_transfer_queries_.empty(); |
612 } | 606 } |
613 | 607 |
614 bool QueryManager::AddPendingQuery(Query* query, uint32 submit_count) { | 608 bool QueryManager::AddPendingQuery(Query* query, int32 submit_count) { |
615 DCHECK(query); | 609 DCHECK(query); |
616 DCHECK(!query->IsDeleted()); | 610 DCHECK(!query->IsDeleted()); |
617 if (!RemovePendingQuery(query)) { | 611 if (!RemovePendingQuery(query)) { |
618 return false; | 612 return false; |
619 } | 613 } |
620 query->MarkAsPending(submit_count); | 614 query->MarkAsPending(submit_count); |
621 pending_queries_.push_back(query); | 615 pending_queries_.push_back(query); |
622 return true; | 616 return true; |
623 } | 617 } |
624 | 618 |
625 bool QueryManager::AddPendingTransferQuery(Query* query, uint32 submit_count) { | 619 bool QueryManager::AddPendingTransferQuery(Query* query, int32 submit_count) { |
626 DCHECK(query); | 620 DCHECK(query); |
627 DCHECK(!query->IsDeleted()); | 621 DCHECK(!query->IsDeleted()); |
628 if (!RemovePendingQuery(query)) { | 622 if (!RemovePendingQuery(query)) { |
629 return false; | 623 return false; |
630 } | 624 } |
631 query->MarkAsPending(submit_count); | 625 query->MarkAsPending(submit_count); |
632 pending_transfer_queries_.push_back(query); | 626 pending_transfer_queries_.push_back(query); |
633 return true; | 627 return true; |
634 } | 628 } |
635 | 629 |
(...skipping 25 matching lines...) Expand all Loading... |
661 } | 655 } |
662 | 656 |
663 bool QueryManager::BeginQuery(Query* query) { | 657 bool QueryManager::BeginQuery(Query* query) { |
664 DCHECK(query); | 658 DCHECK(query); |
665 if (!RemovePendingQuery(query)) { | 659 if (!RemovePendingQuery(query)) { |
666 return false; | 660 return false; |
667 } | 661 } |
668 return query->Begin(); | 662 return query->Begin(); |
669 } | 663 } |
670 | 664 |
671 bool QueryManager::EndQuery(Query* query, uint32 submit_count) { | 665 bool QueryManager::EndQuery(Query* query, int32 submit_count) { |
672 DCHECK(query); | 666 DCHECK(query); |
673 if (!RemovePendingQuery(query)) { | 667 if (!RemovePendingQuery(query)) { |
674 return false; | 668 return false; |
675 } | 669 } |
676 return query->End(submit_count); | 670 return query->End(submit_count); |
677 } | 671 } |
678 | 672 |
679 } // namespace gles2 | 673 } // namespace gles2 |
680 } // namespace gpu | 674 } // namespace gpu |
OLD | NEW |