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

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

Issue 16831004: Perform glReadPixels with PBOs in the gpu, if PBOs are available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops, did not mean to upload license.py Created 7 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 #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/shared_memory.h" 10 #include "base/shared_memory.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 DCHECK(mem_params.shared_memory->memory()); 188 DCHECK(mem_params.shared_memory->memory());
189 void *data = static_cast<int8*>(mem_params.shared_memory->memory()) + 189 void *data = static_cast<int8*>(mem_params.shared_memory->memory()) +
190 mem_params.shm_data_offset; 190 mem_params.shm_data_offset;
191 QuerySync* sync = static_cast<QuerySync*>(data); 191 QuerySync* sync = static_cast<QuerySync*>(data);
192 192
193 // Need a MemoryBarrier here to ensure that upload completed before 193 // Need a MemoryBarrier here to ensure that upload completed before
194 // submit_count was written to sync->process_count. 194 // submit_count was written to sync->process_count.
195 base::subtle::MemoryBarrier(); 195 base::subtle::MemoryBarrier();
196 sync->process_count = submit_count; 196 sync->process_count = submit_count;
197 } 197 }
198 void MarkAsCompletedStage1(
199 uint32 submit_count, const AsyncMemoryParams& mem_params);
198 }; 200 };
199 201
200 AsyncPixelTransfersCompletedQuery::AsyncPixelTransfersCompletedQuery( 202 AsyncPixelTransfersCompletedQuery::AsyncPixelTransfersCompletedQuery(
201 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) 203 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset)
202 : Query(manager, target, shm_id, shm_offset) { 204 : Query(manager, target, shm_id, shm_offset) {
203 } 205 }
204 206
205 bool AsyncPixelTransfersCompletedQuery::Begin() { 207 bool AsyncPixelTransfersCompletedQuery::Begin() {
206 return true; 208 return true;
207 } 209 }
208 210
209 bool AsyncPixelTransfersCompletedQuery::End(uint32 submit_count) { 211 bool AsyncPixelTransfersCompletedQuery::End(uint32 submit_count) {
210 AsyncMemoryParams mem_params; 212 AsyncMemoryParams mem_params;
211 // Get the real shared memory since it might need to be duped to prevent 213 // Get the real shared memory since it might need to be duped to prevent
212 // use-after-free of the memory. 214 // use-after-free of the memory.
213 Buffer buffer = manager()->decoder()->GetSharedMemoryBuffer(shm_id()); 215 Buffer buffer = manager()->decoder()->GetSharedMemoryBuffer(shm_id());
214 if (!buffer.shared_memory) 216 if (!buffer.shared_memory)
215 return false; 217 return false;
216 mem_params.shared_memory = buffer.shared_memory; 218 mem_params.shared_memory = buffer.shared_memory;
217 mem_params.shm_size = buffer.size; 219 mem_params.shm_size = buffer.size;
218 mem_params.shm_data_offset = shm_offset(); 220 mem_params.shm_data_offset = shm_offset();
219 mem_params.shm_data_size = sizeof(QuerySync); 221 mem_params.shm_data_size = sizeof(QuerySync);
220 222
223 manager()->decoder()->WaitForReadPixels(
224 base::Bind(&AsyncPixelTransfersCompletedQuery::MarkAsCompletedStage1,
225 this, submit_count, mem_params));
226 return AddToPendingTransferQueue(submit_count);
227 }
228
229 void AsyncPixelTransfersCompletedQuery::MarkAsCompletedStage1(
230 uint32 submit_count,
231 const AsyncMemoryParams& mem_params) {
232
221 // Ask AsyncPixelTransferDelegate to run completion callback after all 233 // Ask AsyncPixelTransferDelegate to run completion callback after all
222 // previous async transfers are done. No guarantee that callback is run 234 // previous async transfers are done. No guarantee that callback is run
223 // on the current thread. 235 // on the current thread.
224 manager()->decoder()->GetAsyncPixelTransferManager()->AsyncNotifyCompletion( 236 manager()->decoder()->GetAsyncPixelTransferManager()->AsyncNotifyCompletion(
225 mem_params, 237 mem_params,
226 base::Bind(AsyncPixelTransfersCompletedQuery::MarkAsCompletedThreadSafe, 238 base::Bind(AsyncPixelTransfersCompletedQuery::MarkAsCompletedThreadSafe,
227 submit_count)); 239 submit_count));
228
229 return AddToPendingTransferQueue(submit_count);
230 } 240 }
231 241
232 bool AsyncPixelTransfersCompletedQuery::Process() { 242 bool AsyncPixelTransfersCompletedQuery::Process() {
233 QuerySync* sync = manager()->decoder()->GetSharedMemoryAs<QuerySync*>( 243 QuerySync* sync = manager()->decoder()->GetSharedMemoryAs<QuerySync*>(
234 shm_id(), shm_offset(), sizeof(*sync)); 244 shm_id(), shm_offset(), sizeof(*sync));
235 if (!sync) 245 if (!sync)
236 return false; 246 return false;
237 247
238 // Check if completion callback has been run. sync->process_count atomicity 248 // Check if completion callback has been run. sync->process_count atomicity
239 // is guaranteed as this is already used to notify client of a completed 249 // is guaranteed as this is already used to notify client of a completed
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 bool QueryManager::EndQuery(Query* query, uint32 submit_count) { 586 bool QueryManager::EndQuery(Query* query, uint32 submit_count) {
577 DCHECK(query); 587 DCHECK(query);
578 if (!RemovePendingQuery(query)) { 588 if (!RemovePendingQuery(query)) {
579 return false; 589 return false;
580 } 590 }
581 return query->End(submit_count); 591 return query->End(submit_count);
582 } 592 }
583 593
584 } // namespace gles2 594 } // namespace gles2
585 } // namespace gpu 595 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698