Chromium Code Reviews| 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> { | |
|
apatrick
2012/12/03 21:23:59
style nit: comma wants to be on line above.
epennerAtGoogle
2012/12/04 19:56:48
Done.
| |
| 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 gfx::AsyncPixelTransferDelegate::Get()->AsyncNotifyCompletion( | |
| 201 base::Bind( | |
| 202 &AsyncPixelTransfersCompletedQuery::MarkAsCompletedCallback, | |
| 203 AsWeakPtr())); | |
| 204 | |
| 205 // TODO: Could we possibly trigger the completion on | |
| 206 // the upload thread by writing to the query shared memory | |
| 207 // directly? | |
| 208 | |
| 209 // TODO: Confirm if the above async task is sufficient. | |
| 210 // Since it is an async task, the bool return value is | |
| 211 // disregarded. It is also called outside the normal | |
| 212 // flow, and never called if this object is destroyed. | |
| 213 return true; | |
| 195 } | 214 } |
| 196 | 215 |
| 197 bool AsyncPixelTransfersCompletedQuery::Process() { | 216 bool AsyncPixelTransfersCompletedQuery::Process() { |
| 198 NOTREACHED(); | 217 NOTREACHED(); |
| 199 return true; | 218 return true; |
| 200 } | 219 } |
| 201 | 220 |
| 202 void AsyncPixelTransfersCompletedQuery::Destroy(bool /* have_context */) { | 221 void AsyncPixelTransfersCompletedQuery::Destroy(bool /* have_context */) { |
| 203 if (!IsDeleted()) { | 222 if (!IsDeleted()) { |
| 204 MarkAsDeleted(); | 223 MarkAsDeleted(); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 if (!RemovePendingQuery(query)) { | 492 if (!RemovePendingQuery(query)) { |
| 474 return false; | 493 return false; |
| 475 } | 494 } |
| 476 return query->End(submit_count); | 495 return query->End(submit_count); |
| 477 } | 496 } |
| 478 | 497 |
| 479 } // namespace gles2 | 498 } // namespace gles2 |
| 480 } // namespace gpu | 499 } // namespace gpu |
| 481 | 500 |
| 482 | 501 |
| OLD | NEW |