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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 106623008: gpu: Support parallel active queries in command buffer (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: gpu: Support parallel active queries in command buffer Created 6 years, 11 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
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 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 bound_framebuffer_(0), 103 bound_framebuffer_(0),
104 bound_read_framebuffer_(0), 104 bound_read_framebuffer_(0),
105 bound_renderbuffer_(0), 105 bound_renderbuffer_(0),
106 current_program_(0), 106 current_program_(0),
107 bound_array_buffer_id_(0), 107 bound_array_buffer_id_(0),
108 bound_pixel_pack_transfer_buffer_id_(0), 108 bound_pixel_pack_transfer_buffer_id_(0),
109 bound_pixel_unpack_transfer_buffer_id_(0), 109 bound_pixel_unpack_transfer_buffer_id_(0),
110 error_bits_(0), 110 error_bits_(0),
111 debug_(false), 111 debug_(false),
112 use_count_(0), 112 use_count_(0),
113 current_query_(NULL),
114 error_message_callback_(NULL), 113 error_message_callback_(NULL),
115 gpu_control_(gpu_control), 114 gpu_control_(gpu_control),
116 surface_visible_(true), 115 surface_visible_(true),
117 free_everything_when_invisible_(free_everything_when_invisible), 116 free_everything_when_invisible_(free_everything_when_invisible),
118 capabilities_(gpu_control->GetCapabilities()), 117 capabilities_(gpu_control->GetCapabilities()),
119 weak_ptr_factory_(this) { 118 weak_ptr_factory_(this) {
120 DCHECK(helper); 119 DCHECK(helper);
121 DCHECK(transfer_buffer); 120 DCHECK(transfer_buffer);
122 DCHECK(gpu_control); 121 DCHECK(gpu_control);
123 122
(...skipping 3159 matching lines...) Expand 10 before | Expand all | Expand 10 after
3283 return query_tracker_->GetQuery(id) != NULL; 3282 return query_tracker_->GetQuery(id) != NULL;
3284 } 3283 }
3285 3284
3286 void GLES2Implementation::BeginQueryEXT(GLenum target, GLuint id) { 3285 void GLES2Implementation::BeginQueryEXT(GLenum target, GLuint id) {
3287 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3286 GPU_CLIENT_SINGLE_THREAD_CHECK();
3288 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] BeginQueryEXT(" 3287 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] BeginQueryEXT("
3289 << GLES2Util::GetStringQueryTarget(target) 3288 << GLES2Util::GetStringQueryTarget(target)
3290 << ", " << id << ")"); 3289 << ", " << id << ")");
3291 3290
3292 // if any outstanding queries INV_OP 3291 // if any outstanding queries INV_OP
3293 if (current_query_) { 3292 QueryMap::iterator it = current_queries_.find(target);
3293 if (it != current_queries_.end()) {
3294 SetGLError( 3294 SetGLError(
3295 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress"); 3295 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress");
3296 return; 3296 return;
3297 } 3297 }
3298 3298
3299 // id = 0 INV_OP 3299 // id = 0 INV_OP
3300 if (id == 0) { 3300 if (id == 0) {
3301 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0"); 3301 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0");
3302 return; 3302 return;
3303 } 3303 }
3304 3304
3305 // TODO(gman) if id not GENned INV_OPERATION 3305 // TODO(gman) if id not GENned INV_OPERATION
3306 3306
3307 // if id does not have an object 3307 // if id does not have an object
3308 QueryTracker::Query* query = query_tracker_->GetQuery(id); 3308 QueryTracker::Query* query = query_tracker_->GetQuery(id);
3309 if (!query) { 3309 if (!query) {
3310 query = query_tracker_->CreateQuery(id, target); 3310 query = query_tracker_->CreateQuery(id, target);
3311 if (!query) { 3311 if (!query) {
3312 MustBeContextLost(); 3312 MustBeContextLost();
3313 return; 3313 return;
3314 } 3314 }
3315 } else if (query->target() != target) { 3315 } else if (query->target() != target) {
3316 SetGLError( 3316 SetGLError(
3317 GL_INVALID_OPERATION, "glBeginQueryEXT", "target does not match"); 3317 GL_INVALID_OPERATION, "glBeginQueryEXT", "target does not match");
3318 return; 3318 return;
3319 } 3319 }
3320 3320
3321 current_query_ = query; 3321 current_queries_[target] = query;
3322 3322
3323 query->Begin(this); 3323 query->Begin(this);
3324 CheckGLError(); 3324 CheckGLError();
3325 } 3325 }
3326 3326
3327 void GLES2Implementation::EndQueryEXT(GLenum target) { 3327 void GLES2Implementation::EndQueryEXT(GLenum target) {
3328 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3328 GPU_CLIENT_SINGLE_THREAD_CHECK();
3329 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] EndQueryEXT(" 3329 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] EndQueryEXT("
3330 << GLES2Util::GetStringQueryTarget(target) << ")"); 3330 << GLES2Util::GetStringQueryTarget(target) << ")");
3331 // Don't do anything if the context is lost. 3331 // Don't do anything if the context is lost.
3332 if (helper_->IsContextLost()) { 3332 if (helper_->IsContextLost()) {
3333 return; 3333 return;
3334 } 3334 }
3335 3335
3336 if (!current_query_) { 3336 QueryMap::iterator it = current_queries_.find(target);
3337 if (it == current_queries_.end()) {
3337 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT", "no active query"); 3338 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT", "no active query");
3338 return; 3339 return;
3339 } 3340 }
3340 3341
3341 if (current_query_->target() != target) { 3342 QueryTracker::Query* query = it->second;
3342 SetGLError(GL_INVALID_OPERATION, 3343 query->End(this);
3343 "glEndQueryEXT", "target does not match active query"); 3344 current_queries_.erase(it);
3344 return;
3345 }
3346
3347 current_query_->End(this);
3348 current_query_ = NULL;
3349 CheckGLError(); 3345 CheckGLError();
3350 } 3346 }
3351 3347
3352 void GLES2Implementation::GetQueryivEXT( 3348 void GLES2Implementation::GetQueryivEXT(
3353 GLenum target, GLenum pname, GLint* params) { 3349 GLenum target, GLenum pname, GLint* params) {
3354 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3350 GPU_CLIENT_SINGLE_THREAD_CHECK();
3355 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] GetQueryivEXT(" 3351 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] GetQueryivEXT("
3356 << GLES2Util::GetStringQueryTarget(target) << ", " 3352 << GLES2Util::GetStringQueryTarget(target) << ", "
3357 << GLES2Util::GetStringQueryParameter(pname) << ", " 3353 << GLES2Util::GetStringQueryParameter(pname) << ", "
3358 << static_cast<const void*>(params) << ")"); 3354 << static_cast<const void*>(params) << ")");
3359 3355
3360 if (pname != GL_CURRENT_QUERY_EXT) { 3356 if (pname != GL_CURRENT_QUERY_EXT) {
3361 SetGLErrorInvalidEnum("glGetQueryivEXT", pname, "pname"); 3357 SetGLErrorInvalidEnum("glGetQueryivEXT", pname, "pname");
3362 return; 3358 return;
3363 } 3359 }
3364 *params = (current_query_ && current_query_->target() == target) ? 3360 QueryMap::iterator it = current_queries_.find(target);
3365 current_query_->id() : 0; 3361 if (it != current_queries_.end()) {
3362 QueryTracker::Query* query = it->second;
3363 *params = query->id();
3364 } else {
3365 *params = 0;
3366 }
3366 GPU_CLIENT_LOG(" " << *params); 3367 GPU_CLIENT_LOG(" " << *params);
3367 CheckGLError(); 3368 CheckGLError();
3368 } 3369 }
3369 3370
3370 void GLES2Implementation::GetQueryObjectuivEXT( 3371 void GLES2Implementation::GetQueryObjectuivEXT(
3371 GLuint id, GLenum pname, GLuint* params) { 3372 GLuint id, GLenum pname, GLuint* params) {
3372 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3373 GPU_CLIENT_SINGLE_THREAD_CHECK();
3373 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] GetQueryivEXT(" << id << ", " 3374 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] GetQueryivEXT(" << id << ", "
3374 << GLES2Util::GetStringQueryObjectParameter(pname) << ", " 3375 << GLES2Util::GetStringQueryObjectParameter(pname) << ", "
3375 << static_cast<const void*>(params) << ")"); 3376 << static_cast<const void*>(params) << ")");
3376 3377
3377 QueryTracker::Query* query = query_tracker_->GetQuery(id); 3378 QueryTracker::Query* query = query_tracker_->GetQuery(id);
3378 if (!query) { 3379 if (!query) {
3379 SetGLError(GL_INVALID_OPERATION, "glQueryObjectuivEXT", "unknown query id"); 3380 SetGLError(GL_INVALID_OPERATION, "glQueryObjectuivEXT", "unknown query id");
3380 return; 3381 return;
3381 } 3382 }
3382 3383
3383 if (query == current_query_) { 3384 QueryMap::iterator it = current_queries_.find(query->target());
3385 if (it != current_queries_.end()) {
3384 SetGLError( 3386 SetGLError(
3385 GL_INVALID_OPERATION, 3387 GL_INVALID_OPERATION,
3386 "glQueryObjectuivEXT", "query active. Did you to call glEndQueryEXT?"); 3388 "glQueryObjectuivEXT", "query active. Did you to call glEndQueryEXT?");
3387 return; 3389 return;
3388 } 3390 }
3389 3391
3390 if (query->NeverUsed()) { 3392 if (query->NeverUsed()) {
3391 SetGLError( 3393 SetGLError(
3392 GL_INVALID_OPERATION, 3394 GL_INVALID_OPERATION,
3393 "glQueryObjectuivEXT", "Never used. Did you call glBeginQueryEXT?"); 3395 "glQueryObjectuivEXT", "Never used. Did you call glBeginQueryEXT?");
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
3915 CheckGLError(); 3917 CheckGLError();
3916 } 3918 }
3917 3919
3918 // Include the auto-generated part of this file. We split this because it means 3920 // Include the auto-generated part of this file. We split this because it means
3919 // we can easily edit the non-auto generated parts right here in this file 3921 // we can easily edit the non-auto generated parts right here in this file
3920 // instead of having to edit some template or the code generator. 3922 // instead of having to edit some template or the code generator.
3921 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 3923 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
3922 3924
3923 } // namespace gles2 3925 } // namespace gles2
3924 } // namespace gpu 3926 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | gpu/command_buffer/service/context_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698