From fe04ab39c96f98362d73526d7bdaade9fe85f5ff Mon Sep 17 00:00:00 2001 From: "hubbe@chromium.org" Date: Wed, 3 Jul 2013 03:57:04 +0000 Subject: Perform glReadPixels with PBOs in the gpu, if PBOs are available. Make GL_ASYNC_READ_PIXELS_COMPLETED_CHROMIUM wait for readpixel transfers. PLEASE NOTE: glMapBuffer does not wait for the readpixels transfer to complete anymore. Nobody is currently relying on that behaviour. Update gl_helper.cc and gl_renderer.cc to use queries. This CL is the same as https://codereview.chromium.org/16831004/, which was submitted and reverted because it seemed to cause OutOfProcessPPAPITest.Graphics3D failures on XP. Since I don't have an XP box and there are no XP trybots I can't seem to reproduce the problem. Also, this particular test is flaky and has had problems even after my CL was reverted. Thus, I'm going to try to submit it again, and if that breaks OutOfProcessPPAPITest.Graphics3D again, I apologize in advance. BUG=249925 Review URL: https://chromiumcodereview.appspot.com/18555006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209873 0039d316-1c4b-4281-b951-d872f2087c98 --- gpu/command_buffer/service/query_manager.cc | 59 ++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) (limited to 'gpu/command_buffer/service/query_manager.cc') diff --git a/gpu/command_buffer/service/query_manager.cc b/gpu/command_buffer/service/query_manager.cc index e66478a..6d2f84a 100644 --- a/gpu/command_buffer/service/query_manager.cc +++ b/gpu/command_buffer/service/query_manager.cc @@ -223,9 +223,8 @@ bool AsyncPixelTransfersCompletedQuery::End(uint32 submit_count) { // on the current thread. manager()->decoder()->GetAsyncPixelTransferManager()->AsyncNotifyCompletion( mem_params, - base::Bind(AsyncPixelTransfersCompletedQuery::MarkAsCompletedThreadSafe, + base::Bind(&AsyncPixelTransfersCompletedQuery::MarkAsCompletedThreadSafe, submit_count)); - return AddToPendingTransferQueue(submit_count); } @@ -254,6 +253,58 @@ void AsyncPixelTransfersCompletedQuery::Destroy(bool /* have_context */) { AsyncPixelTransfersCompletedQuery::~AsyncPixelTransfersCompletedQuery() { } +class AsyncReadPixelsCompletedQuery + : public QueryManager::Query, + public base::SupportsWeakPtr { + public: + AsyncReadPixelsCompletedQuery( + QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset); + + virtual bool Begin() OVERRIDE; + virtual bool End(uint32 submit_count) OVERRIDE; + virtual bool Process() OVERRIDE; + virtual void Destroy(bool have_context) OVERRIDE; + + protected: + void Complete(); + virtual ~AsyncReadPixelsCompletedQuery(); +}; + +AsyncReadPixelsCompletedQuery::AsyncReadPixelsCompletedQuery( + QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset) + : Query(manager, target, shm_id, shm_offset) { +} + +bool AsyncReadPixelsCompletedQuery::Begin() { + return true; +} + +bool AsyncReadPixelsCompletedQuery::End(uint32 submit_count) { + manager()->decoder()->WaitForReadPixels( + base::Bind(&AsyncReadPixelsCompletedQuery::Complete, + AsWeakPtr())); + + return AddToPendingTransferQueue(submit_count); +} + +void AsyncReadPixelsCompletedQuery::Complete() { + MarkAsCompleted(1); +} + +bool AsyncReadPixelsCompletedQuery::Process() { + return !pending(); +} + +void AsyncReadPixelsCompletedQuery::Destroy(bool /* have_context */) { + if (!IsDeleted()) { + MarkAsDeleted(); + } +} + +AsyncReadPixelsCompletedQuery::~AsyncReadPixelsCompletedQuery() { +} + + class GetErrorQuery : public QueryManager::Query { public: GetErrorQuery( @@ -345,6 +396,10 @@ QueryManager::Query* QueryManager::CreateQuery( query = new AsyncPixelTransfersCompletedQuery( this, target, shm_id, shm_offset); break; + case GL_ASYNC_READ_PIXELS_COMPLETED_CHROMIUM: + query = new AsyncReadPixelsCompletedQuery( + this, target, shm_id, shm_offset); + break; case GL_GET_ERROR_QUERY_CHROMIUM: query = new GetErrorQuery(this, target, shm_id, shm_offset); break; -- cgit v1.1