Chromium Code Reviews| Index: 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 9f1d3a7169c31b5c1ee640b07f6c08a71623b18b..b288c85263f4c5855017d4670b0c756aff8bdf8d 100644 |
| --- a/gpu/command_buffer/service/query_manager.cc |
| +++ b/gpu/command_buffer/service/query_manager.cc |
| @@ -389,6 +389,76 @@ void GetErrorQuery::Destroy(bool /* have_context */) { |
| GetErrorQuery::~GetErrorQuery() { |
| } |
| +class CommandsCompletedQuery : public QueryManager::Query { |
| + public: |
| + CommandsCompletedQuery(QueryManager* manager, |
| + GLenum target, |
| + int32 shm_id, |
| + uint32 shm_offset, |
| + bool use_arb_sync); |
| + |
| + // Overridden from QueryManager::Query: |
| + virtual bool Begin() OVERRIDE; |
| + virtual bool End(base::subtle::Atomic32 submit_count) OVERRIDE; |
| + virtual bool Process() OVERRIDE; |
| + virtual void Destroy(bool have_context) OVERRIDE; |
| + |
| + protected: |
| + virtual ~CommandsCompletedQuery(); |
| + |
| + private: |
| + bool use_arb_sync_; |
| + GLsync sync_; |
| +}; |
| + |
| +CommandsCompletedQuery::CommandsCompletedQuery(QueryManager* manager, |
| + GLenum target, |
| + int32 shm_id, |
| + uint32 shm_offset, |
| + bool use_arb_sync) |
| + : Query(manager, target, shm_id, shm_offset), |
| + use_arb_sync_(use_arb_sync), |
| + sync_(NULL) {} |
| + |
| +bool CommandsCompletedQuery::Begin() { |
| + if (sync_) { |
| + glDeleteSync(sync_); |
| + sync_ = NULL; |
| + } |
| + return true; |
| +} |
| + |
| +bool CommandsCompletedQuery::End(base::subtle::Atomic32 submit_count) { |
| + if (use_arb_sync_) { |
| + sync_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); |
|
no sievers
2014/04/15 18:41:15
You have to glFlush() somewhere or the commands mi
no sievers
2014/04/15 18:48:44
"Querying the GL_QUERY_RESULT implicitly flushes t
reveman
2014/04/15 22:29:28
As I mentioned above, the idea is to make the clie
|
| + DCHECK(sync_); |
| + } else { |
| + TRACE_EVENT0("gpu", "CommandsCompletedQuery::End"); |
| + glFinish(); // Poor man's GPU fence. |
|
no sievers
2014/04/15 18:41:15
Do we need this fallback, or can we not support th
reveman
2014/04/15 22:29:28
We'll need a fall-back somewhere but maybe it shou
|
| + } |
| + return AddToPendingQueue(submit_count); |
| +} |
| + |
| +bool CommandsCompletedQuery::Process() { |
| + if (sync_) { |
| + int value = GL_UNSIGNALED; |
| + glGetSynciv(sync_, GL_SYNC_STATUS, 1, NULL, &value); |
|
no sievers
2014/04/15 18:41:15
See comment in gl_fence.cc that this does not work
reveman
2014/04/15 22:29:28
Ok, makes sense to use GLFence and handle these ty
|
| + if (value == GL_UNSIGNALED) |
| + return true; |
| + } |
| + return MarkAsCompleted(0); |
| +} |
| + |
| +void CommandsCompletedQuery::Destroy(bool have_context) { |
| + if (have_context && !IsDeleted()) { |
| + if (sync_) |
| + glDeleteSync(sync_); |
| + MarkAsDeleted(); |
| + } |
| +} |
| + |
| +CommandsCompletedQuery::~CommandsCompletedQuery() {} |
| + |
| QueryManager::QueryManager( |
| GLES2Decoder* decoder, |
| FeatureInfo* feature_info) |
| @@ -399,6 +469,7 @@ QueryManager::QueryManager( |
| use_arb_occlusion_query_for_occlusion_query_boolean_( |
| feature_info->feature_flags( |
| ).use_arb_occlusion_query_for_occlusion_query_boolean), |
| + use_arb_sync_(feature_info->feature_flags().arb_sync), |
| query_count_(0) { |
| DCHECK(!(use_arb_occlusion_query_for_occlusion_query_boolean_ && |
| use_arb_occlusion_query2_for_occlusion_query_boolean_)); |
| @@ -444,6 +515,10 @@ QueryManager::Query* QueryManager::CreateQuery( |
| case GL_GET_ERROR_QUERY_CHROMIUM: |
| query = new GetErrorQuery(this, target, shm_id, shm_offset); |
| break; |
| + case GL_COMMANDS_COMPLETED_CHROMIUM: |
| + query = new CommandsCompletedQuery( |
| + this, target, shm_id, shm_offset, use_arb_sync_); |
| + break; |
| default: { |
| GLuint service_id = 0; |
| glGenQueriesARB(1, &service_id); |