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 #include "base/atomicops.h" | 6 #include "base/atomicops.h" |
| 7 #include "base/bind.h" |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 #include "base/time.h" | 9 #include "base/time.h" |
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 11 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
11 #include "gpu/command_buffer/service/feature_info.h" | 12 #include "gpu/command_buffer/service/feature_info.h" |
| 13 #include "ui/gl/async_pixel_transfer_delegate.h" |
12 | 14 |
13 namespace gpu { | 15 namespace gpu { |
14 namespace gles2 { | 16 namespace gles2 { |
15 | 17 |
16 class AllSamplesPassedQuery : public QueryManager::Query { | 18 class AllSamplesPassedQuery : public QueryManager::Query { |
17 public: | 19 public: |
18 AllSamplesPassedQuery( | 20 AllSamplesPassedQuery( |
19 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset, | 21 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset, |
20 GLuint service_id); | 22 GLuint service_id); |
21 virtual bool Begin() OVERRIDE; | 23 virtual bool Begin() OVERRIDE; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 157 |
156 void CommandLatencyQuery::Destroy(bool /* have_context */) { | 158 void CommandLatencyQuery::Destroy(bool /* have_context */) { |
157 if (!IsDeleted()) { | 159 if (!IsDeleted()) { |
158 MarkAsDeleted(); | 160 MarkAsDeleted(); |
159 } | 161 } |
160 } | 162 } |
161 | 163 |
162 CommandLatencyQuery::~CommandLatencyQuery() { | 164 CommandLatencyQuery::~CommandLatencyQuery() { |
163 } | 165 } |
164 | 166 |
165 class AsyncPixelTransfersCompletedQuery : public QueryManager::Query { | 167 class AsyncPixelTransfersCompletedQuery |
| 168 : public QueryManager::Query |
| 169 , public base::SupportsWeakPtr<AsyncPixelTransfersCompletedQuery> { |
166 public: | 170 public: |
167 AsyncPixelTransfersCompletedQuery( | 171 AsyncPixelTransfersCompletedQuery( |
168 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); | 172 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); |
169 | 173 |
170 virtual bool Begin() OVERRIDE; | 174 virtual bool Begin() OVERRIDE; |
171 virtual bool End(uint32 submit_count) OVERRIDE; | 175 virtual bool End(uint32 submit_count) OVERRIDE; |
172 virtual bool Process() OVERRIDE; | 176 virtual bool Process() OVERRIDE; |
173 virtual void Destroy(bool have_context) OVERRIDE; | 177 virtual void Destroy(bool have_context) OVERRIDE; |
174 | 178 |
| 179 void MarkAsCompletedCallback() { MarkAsCompleted(1); } |
| 180 |
175 protected: | 181 protected: |
176 virtual ~AsyncPixelTransfersCompletedQuery(); | 182 virtual ~AsyncPixelTransfersCompletedQuery(); |
177 }; | 183 }; |
178 | 184 |
179 AsyncPixelTransfersCompletedQuery::AsyncPixelTransfersCompletedQuery( | 185 AsyncPixelTransfersCompletedQuery::AsyncPixelTransfersCompletedQuery( |
180 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) | 186 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) |
181 : Query(manager, target, shm_id, shm_offset) { | 187 : Query(manager, target, shm_id, shm_offset) { |
182 } | 188 } |
183 | 189 |
184 bool AsyncPixelTransfersCompletedQuery::Begin() { | 190 bool AsyncPixelTransfersCompletedQuery::Begin() { |
185 return true; | 191 return true; |
186 } | 192 } |
187 | 193 |
188 bool AsyncPixelTransfersCompletedQuery::End(uint32 submit_count) { | 194 bool AsyncPixelTransfersCompletedQuery::End(uint32 submit_count) { |
189 // TODO(epenner): Mark completion via an async task. | |
190 // TODO(epenner): This will be a boolean to start, indicating | |
191 // completion of all tasks in the query. We could change this | |
192 // to return a count of tasks completed instead. | |
193 MarkAsPending(submit_count); | 195 MarkAsPending(submit_count); |
194 return MarkAsCompleted(1); | 196 |
| 197 // This will call MarkAsCompleted(1) as a reply to a task on |
| 198 // the async upload thread, such that it occurs after all previous |
| 199 // async transfers have completed. |
| 200 manager()->decoder()->GetAsyncPixelTransferDelegate()->AsyncNotifyCompletion( |
| 201 base::Bind( |
| 202 &AsyncPixelTransfersCompletedQuery::MarkAsCompletedCallback, |
| 203 AsWeakPtr())); |
| 204 |
| 205 // TODO(epenner): The async task occurs outside the normal |
| 206 // flow, via a callback on this thread. Is there anything |
| 207 // missing or wrong with that? |
| 208 |
| 209 // TODO(epenner): Could we possibly trigger the completion on |
| 210 // the upload thread by writing to the query shared memory |
| 211 // directly? |
| 212 return true; |
195 } | 213 } |
196 | 214 |
197 bool AsyncPixelTransfersCompletedQuery::Process() { | 215 bool AsyncPixelTransfersCompletedQuery::Process() { |
198 NOTREACHED(); | 216 NOTREACHED(); |
199 return true; | 217 return true; |
200 } | 218 } |
201 | 219 |
202 void AsyncPixelTransfersCompletedQuery::Destroy(bool /* have_context */) { | 220 void AsyncPixelTransfersCompletedQuery::Destroy(bool /* have_context */) { |
203 if (!IsDeleted()) { | 221 if (!IsDeleted()) { |
204 MarkAsDeleted(); | 222 MarkAsDeleted(); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 if (!RemovePendingQuery(query)) { | 491 if (!RemovePendingQuery(query)) { |
474 return false; | 492 return false; |
475 } | 493 } |
476 return query->End(submit_count); | 494 return query->End(submit_count); |
477 } | 495 } |
478 | 496 |
479 } // namespace gles2 | 497 } // namespace gles2 |
480 } // namespace gpu | 498 } // namespace gpu |
481 | 499 |
482 | 500 |
OLD | NEW |