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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.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 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "../client/gles2_implementation.h" 7 #include "../client/gles2_implementation.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 #endif 496 #endif
497 // The share group needs to be able to use a command buffer to talk 497 // The share group needs to be able to use a command buffer to talk
498 // to service if it's destroyed so set one for it then release the reference. 498 // to service if it's destroyed so set one for it then release the reference.
499 // If it's destroyed it will use this GLES2Implemenation. 499 // If it's destroyed it will use this GLES2Implemenation.
500 share_group_->SetGLES2ImplementationForDestruction(this); 500 share_group_->SetGLES2ImplementationForDestruction(this);
501 share_group_ = NULL; 501 share_group_ = NULL;
502 // Make sure the commands make it the service. 502 // Make sure the commands make it the service.
503 Finish(); 503 Finish();
504 } 504 }
505 505
506 GLES2CmdHelper* GLES2Implementation::helper() const {
507 return helper_;
508 }
509
506 GLuint GLES2Implementation::MakeTextureId() { 510 GLuint GLES2Implementation::MakeTextureId() {
507 GLuint id; 511 GLuint id;
508 GetIdHandler(id_namespaces::kTextures)->MakeIds(this, 0, 1, &id); 512 GetIdHandler(id_namespaces::kTextures)->MakeIds(this, 0, 1, &id);
509 return id; 513 return id;
510 } 514 }
511 515
512 void GLES2Implementation::FreeTextureId(GLuint id) { 516 void GLES2Implementation::FreeTextureId(GLuint id) {
513 GetIdHandler(id_namespaces::kTextures)->FreeIds( 517 GetIdHandler(id_namespaces::kTextures)->FreeIds(
514 this, 1, &id, &GLES2Implementation::DeleteTexturesStub); 518 this, 1, &id, &GLES2Implementation::DeleteTexturesStub);
515 } 519 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 } 589 }
586 590
587 GLenum GLES2Implementation::GetError() { 591 GLenum GLES2Implementation::GetError() {
588 GPU_CLIENT_SINGLE_THREAD_CHECK(); 592 GPU_CLIENT_SINGLE_THREAD_CHECK();
589 GPU_CLIENT_LOG("[" << this << "] glGetError()"); 593 GPU_CLIENT_LOG("[" << this << "] glGetError()");
590 GLenum err = GetGLError(); 594 GLenum err = GetGLError();
591 GPU_CLIENT_LOG("returned " << GLES2Util::GetStringError(err)); 595 GPU_CLIENT_LOG("returned " << GLES2Util::GetStringError(err));
592 return err; 596 return err;
593 } 597 }
594 598
599 GLenum GLES2Implementation::GetClientSideGLError() {
600 if (error_bits_ == 0) {
601 return GL_NO_ERROR;
602 }
603
604 GLenum error = GL_NO_ERROR;
605 for (uint32 mask = 1; mask != 0; mask = mask << 1) {
606 if ((error_bits_ & mask) != 0) {
607 error = GLES2Util::GLErrorBitToGLError(mask);
608 break;
609 }
610 }
611 error_bits_ &= ~GLES2Util::GLErrorToErrorBit(error);
612 return error;
613 }
614
595 GLenum GLES2Implementation::GetGLError() { 615 GLenum GLES2Implementation::GetGLError() {
596 TRACE_EVENT0("gpu", "GLES2::GetGLError"); 616 TRACE_EVENT0("gpu", "GLES2::GetGLError");
597 // Check the GL error first, then our wrapped error. 617 // Check the GL error first, then our wrapped error.
598 typedef gles2::GetError::Result Result; 618 typedef gles2::GetError::Result Result;
599 Result* result = GetResultAs<Result*>(); 619 Result* result = GetResultAs<Result*>();
620 // If we couldn't allocate a result the context is lost.
600 if (!result) { 621 if (!result) {
601 return GL_NO_ERROR; 622 return GL_NO_ERROR;
602 } 623 }
603 *result = GL_NO_ERROR; 624 *result = GL_NO_ERROR;
604 helper_->GetError(GetResultShmId(), GetResultShmOffset()); 625 helper_->GetError(GetResultShmId(), GetResultShmOffset());
605 WaitForCmd(); 626 WaitForCmd();
606 GLenum error = *result; 627 GLenum error = *result;
607 if (error == GL_NO_ERROR && error_bits_ != 0) { 628 if (error == GL_NO_ERROR) {
608 for (uint32 mask = 1; mask != 0; mask = mask << 1) { 629 error = GetClientSideGLError();
609 if ((error_bits_ & mask) != 0) { 630 } else {
610 error = GLES2Util::GLErrorBitToGLError(mask);
611 break;
612 }
613 }
614 }
615
616 if (error != GL_NO_ERROR) {
617 // There was an error, clear the corresponding wrapped error. 631 // There was an error, clear the corresponding wrapped error.
618 error_bits_ &= ~GLES2Util::GLErrorToErrorBit(error); 632 error_bits_ &= ~GLES2Util::GLErrorToErrorBit(error);
619 } 633 }
620 return error; 634 return error;
621 } 635 }
622 636
623 void GLES2Implementation::SetGLError( 637 void GLES2Implementation::SetGLError(
624 GLenum error, const char* function_name, const char* msg) { 638 GLenum error, const char* function_name, const char* msg) {
625 GPU_CLIENT_LOG("[" << this << "] Client Synthesized Error: " 639 GPU_CLIENT_LOG("[" << this << "] Client Synthesized Error: "
626 << GLES2Util::GetStringError(error) << ": " 640 << GLES2Util::GetStringError(error) << ": "
(...skipping 2451 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 if (!query) { 3092 if (!query) {
3079 query = query_tracker_->CreateQuery(id, target); 3093 query = query_tracker_->CreateQuery(id, target);
3080 } else if (query->target() != target) { 3094 } else if (query->target() != target) {
3081 SetGLError( 3095 SetGLError(
3082 GL_INVALID_OPERATION, "glBeginQueryEXT", "target does not match"); 3096 GL_INVALID_OPERATION, "glBeginQueryEXT", "target does not match");
3083 return; 3097 return;
3084 } 3098 }
3085 3099
3086 current_query_ = query; 3100 current_query_ = query;
3087 3101
3088 // init memory, inc count 3102 query->Begin(this);
3089 query->MarkAsActive();
3090
3091 // tell service about id, shared memory and count
3092 helper_->BeginQueryEXT(target, id, query->shm_id(), query->shm_offset());
3093 } 3103 }
3094 3104
3095 void GLES2Implementation::EndQueryEXT(GLenum target) { 3105 void GLES2Implementation::EndQueryEXT(GLenum target) {
3096 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3106 GPU_CLIENT_SINGLE_THREAD_CHECK();
3097 GPU_CLIENT_LOG("[" << this << "] EndQueryEXT(" 3107 GPU_CLIENT_LOG("[" << this << "] EndQueryEXT("
3098 << GLES2Util::GetStringQueryTarget(target) << ")"); 3108 << GLES2Util::GetStringQueryTarget(target) << ")");
3099 3109
3100 if (!current_query_) { 3110 if (!current_query_) {
3101 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT", "no active query"); 3111 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT", "no active query");
3102 return; 3112 return;
3103 } 3113 }
3104 3114
3105 if (current_query_->target() != target) { 3115 if (current_query_->target() != target) {
3106 SetGLError(GL_INVALID_OPERATION, 3116 SetGLError(GL_INVALID_OPERATION,
3107 "glEndQueryEXT", "target does not match active query"); 3117 "glEndQueryEXT", "target does not match active query");
3108 return; 3118 return;
3109 } 3119 }
3110 3120
3111 helper_->EndQueryEXT(target, current_query_->submit_count()); 3121 current_query_->End(this);
3112 current_query_->MarkAsPending(helper_->InsertToken());
3113 current_query_ = NULL; 3122 current_query_ = NULL;
3114 } 3123 }
3115 3124
3116 void GLES2Implementation::GetQueryivEXT( 3125 void GLES2Implementation::GetQueryivEXT(
3117 GLenum target, GLenum pname, GLint* params) { 3126 GLenum target, GLenum pname, GLint* params) {
3118 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3127 GPU_CLIENT_SINGLE_THREAD_CHECK();
3119 GPU_CLIENT_LOG("[" << this << "] GetQueryivEXT(" 3128 GPU_CLIENT_LOG("[" << this << "] GetQueryivEXT("
3120 << GLES2Util::GetStringQueryTarget(target) << ", " 3129 << GLES2Util::GetStringQueryTarget(target) << ", "
3121 << GLES2Util::GetStringQueryParameter(pname) << ", " 3130 << GLES2Util::GetStringQueryParameter(pname) << ", "
3122 << static_cast<const void*>(params) << ")"); 3131 << static_cast<const void*>(params) << ")");
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
3289 helper_->GenMailboxCHROMIUM(kResultBucketId); 3298 helper_->GenMailboxCHROMIUM(kResultBucketId);
3290 3299
3291 std::vector<GLbyte> result; 3300 std::vector<GLbyte> result;
3292 GetBucketContents(kResultBucketId, &result); 3301 GetBucketContents(kResultBucketId, &result);
3293 3302
3294 std::copy(result.begin(), result.end(), mailbox); 3303 std::copy(result.begin(), result.end(), mailbox);
3295 } 3304 }
3296 3305
3297 } // namespace gles2 3306 } // namespace gles2
3298 } // namespace gpu 3307 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | gpu/command_buffer/client/gles2_implementation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698