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

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

Issue 10577037: Add GL_CHROMIUM_get_error_query (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 #include "base/atomicops.h" 6 #include "base/atomicops.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" 9 #include "gpu/command_buffer/common/gles2_cmd_format.h"
10 #include "gpu/command_buffer/service/common_decoder.h" 10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
11 #include "gpu/command_buffer/service/feature_info.h" 11 #include "gpu/command_buffer/service/feature_info.h"
12 12
13 namespace gpu { 13 namespace gpu {
14 namespace gles2 { 14 namespace gles2 {
15 15
16 class AllSamplesPassedQuery : public QueryManager::Query { 16 class AllSamplesPassedQuery : public QueryManager::Query {
17 public: 17 public:
18 AllSamplesPassedQuery( 18 AllSamplesPassedQuery(
19 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset, 19 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset,
20 GLuint service_id); 20 GLuint service_id);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 void CommandsIssuedQuery::Destroy(bool /* have_context */) { 114 void CommandsIssuedQuery::Destroy(bool /* have_context */) {
115 if (!IsDeleted()) { 115 if (!IsDeleted()) {
116 MarkAsDeleted(); 116 MarkAsDeleted();
117 } 117 }
118 } 118 }
119 119
120 CommandsIssuedQuery::~CommandsIssuedQuery() { 120 CommandsIssuedQuery::~CommandsIssuedQuery() {
121 } 121 }
122 122
123 class GetErrorQuery : public QueryManager::Query {
124 public:
125 GetErrorQuery(
126 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset);
127
128 virtual bool Begin() OVERRIDE;
129 virtual bool End(uint32 submit_count) OVERRIDE;
130 virtual bool Process() OVERRIDE;
131 virtual void Destroy(bool have_context) OVERRIDE;
132
133 protected:
134 virtual ~GetErrorQuery();
135
136 private:
137 };
138
139 GetErrorQuery::GetErrorQuery(
140 QueryManager* manager, GLenum target, int32 shm_id, uint32 shm_offset)
141 : Query(manager, target, shm_id, shm_offset) {
142 }
143
144 bool GetErrorQuery::Begin() {
145 return true;
146 }
147
148 bool GetErrorQuery::End(uint32 submit_count) {
149 MarkAsPending(submit_count);
150 return MarkAsCompleted(manager()->decoder()->GetGLError());
151 }
152
153 bool GetErrorQuery::Process() {
154 NOTREACHED();
155 return true;
156 }
157
158 void GetErrorQuery::Destroy(bool /* have_context */) {
159 if (!IsDeleted()) {
160 MarkAsDeleted();
161 }
162 }
163
164 GetErrorQuery::~GetErrorQuery() {
165 }
166
123 QueryManager::QueryManager( 167 QueryManager::QueryManager(
124 CommonDecoder* decoder, 168 GLES2Decoder* decoder,
125 FeatureInfo* feature_info) 169 FeatureInfo* feature_info)
126 : decoder_(decoder), 170 : decoder_(decoder),
127 use_arb_occlusion_query2_for_occlusion_query_boolean_( 171 use_arb_occlusion_query2_for_occlusion_query_boolean_(
128 feature_info->feature_flags( 172 feature_info->feature_flags(
129 ).use_arb_occlusion_query2_for_occlusion_query_boolean), 173 ).use_arb_occlusion_query2_for_occlusion_query_boolean),
130 use_arb_occlusion_query_for_occlusion_query_boolean_( 174 use_arb_occlusion_query_for_occlusion_query_boolean_(
131 feature_info->feature_flags( 175 feature_info->feature_flags(
132 ).use_arb_occlusion_query_for_occlusion_query_boolean), 176 ).use_arb_occlusion_query_for_occlusion_query_boolean),
133 query_count_(0) { 177 query_count_(0) {
134 DCHECK(!(use_arb_occlusion_query_for_occlusion_query_boolean_ && 178 DCHECK(!(use_arb_occlusion_query_for_occlusion_query_boolean_ &&
(...skipping 17 matching lines...) Expand all
152 } 196 }
153 } 197 }
154 198
155 QueryManager::Query* QueryManager::CreateQuery( 199 QueryManager::Query* QueryManager::CreateQuery(
156 GLenum target, GLuint client_id, int32 shm_id, uint32 shm_offset) { 200 GLenum target, GLuint client_id, int32 shm_id, uint32 shm_offset) {
157 Query::Ref query; 201 Query::Ref query;
158 switch (target) { 202 switch (target) {
159 case GL_COMMANDS_ISSUED_CHROMIUM: 203 case GL_COMMANDS_ISSUED_CHROMIUM:
160 query = new CommandsIssuedQuery(this, target, shm_id, shm_offset); 204 query = new CommandsIssuedQuery(this, target, shm_id, shm_offset);
161 break; 205 break;
206 case GL_GET_ERROR_QUERY_CHROMIUM:
207 query = new GetErrorQuery(this, target, shm_id, shm_offset);
208 break;
162 default: { 209 default: {
163 GLuint service_id = 0; 210 GLuint service_id = 0;
164 glGenQueriesARB(1, &service_id); 211 glGenQueriesARB(1, &service_id);
165 DCHECK_NE(0u, service_id); 212 DCHECK_NE(0u, service_id);
166 query = new AllSamplesPassedQuery( 213 query = new AllSamplesPassedQuery(
167 this, target, shm_id, shm_offset, service_id); 214 this, target, shm_id, shm_offset, service_id);
168 break; 215 break;
169 } 216 }
170 } 217 }
171 std::pair<QueryMap::iterator, bool> result = 218 std::pair<QueryMap::iterator, bool> result =
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 QueryManager::Query::~Query() { 293 QueryManager::Query::~Query() {
247 if (manager_) { 294 if (manager_) {
248 manager_->StopTracking(this); 295 manager_->StopTracking(this);
249 manager_ = NULL; 296 manager_ = NULL;
250 } 297 }
251 } 298 }
252 299
253 bool QueryManager::Query::MarkAsCompleted(GLuint result) { 300 bool QueryManager::Query::MarkAsCompleted(GLuint result) {
254 DCHECK(pending_); 301 DCHECK(pending_);
255 QuerySync* sync = manager_->decoder_->GetSharedMemoryAs<QuerySync*>( 302 QuerySync* sync = manager_->decoder_->GetSharedMemoryAs<QuerySync*>(
256 shm_id_, shm_offset_, sizeof(*sync)); 303 shm_id_, shm_offset_, sizeof(*sync));
257 if (!sync) { 304 if (!sync) {
258 return false; 305 return false;
259 } 306 }
260 307
261 pending_ = false; 308 pending_ = false;
262 sync->result = result; 309 sync->result = result;
263 // Need a MemoryBarrier here so that sync->result is written before 310 // Need a MemoryBarrier here so that sync->result is written before
264 // sync->process_count. 311 // sync->process_count.
265 base::subtle::MemoryBarrier(); 312 base::subtle::MemoryBarrier();
266 sync->process_count = submit_count_; 313 sync->process_count = submit_count_;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 if (!RemovePendingQuery(query)) { 378 if (!RemovePendingQuery(query)) {
332 return false; 379 return false;
333 } 380 }
334 return query->End(submit_count); 381 return query->End(submit_count);
335 } 382 }
336 383
337 } // namespace gles2 384 } // namespace gles2
338 } // namespace gpu 385 } // namespace gpu
339 386
340 387
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/query_manager.h ('k') | gpu/command_buffer/service/query_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698