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

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

Issue 6955006: Revert 84486 - Merge gpu_trace_event back into base/debug/trace_event.Initial land attempt at htt... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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
« no previous file with comments | « gpu/command_buffer/client/cmd_buffer_helper.cc ('k') | gpu/command_buffer/common/trace_event.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include <GLES2/gles2_command_buffer.h> 8 #include <GLES2/gles2_command_buffer.h>
9 #include "../client/mapped_memory.h" 9 #include "../client/mapped_memory.h"
10 #include "../common/gles2_cmd_utils.h" 10 #include "../common/gles2_cmd_utils.h"
11 #include "../common/id_allocator.h" 11 #include "../common/id_allocator.h"
12 #include "../common/trace_event.h" 12 #include "gpu/common/gpu_trace_event.h"
13 13
14 #if defined(__native_client__) && !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 14 #if defined(__native_client__) && !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
15 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS 15 #define GLES2_SUPPORT_CLIENT_SIDE_ARRAYS
16 #endif 16 #endif
17 17
18 namespace gpu { 18 namespace gpu {
19 namespace gles2 { 19 namespace gles2 {
20 20
21 // A 32-bit and 64-bit compatible way of converting a pointer to a GLuint. 21 // A 32-bit and 64-bit compatible way of converting a pointer to a GLuint.
22 static GLuint ToGLuint(const void* ptr) { 22 static GLuint ToGLuint(const void* ptr) {
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 #endif 484 #endif
485 } 485 }
486 486
487 GLES2Implementation::~GLES2Implementation() { 487 GLES2Implementation::~GLES2Implementation() {
488 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 488 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
489 DeleteBuffers(arraysize(reserved_ids_), &reserved_ids_[0]); 489 DeleteBuffers(arraysize(reserved_ids_), &reserved_ids_[0]);
490 #endif 490 #endif
491 } 491 }
492 492
493 void GLES2Implementation::WaitForCmd() { 493 void GLES2Implementation::WaitForCmd() {
494 TRACE_EVENT0("gpu", "GLES2::WaitForCmd"); 494 GPU_TRACE_EVENT0("gpu", "GLES2::WaitForCmd");
495 helper_->CommandBufferHelper::Finish(); 495 helper_->CommandBufferHelper::Finish();
496 } 496 }
497 497
498 GLenum GLES2Implementation::GetError() { 498 GLenum GLES2Implementation::GetError() {
499 return GetGLError(); 499 return GetGLError();
500 } 500 }
501 501
502 GLenum GLES2Implementation::GetGLError() { 502 GLenum GLES2Implementation::GetGLError() {
503 TRACE_EVENT0("gpu", "GLES2::GetGLError"); 503 GPU_TRACE_EVENT0("gpu", "GLES2::GetGLError");
504 // Check the GL error first, then our wrapped error. 504 // Check the GL error first, then our wrapped error.
505 typedef gles2::GetError::Result Result; 505 typedef gles2::GetError::Result Result;
506 Result* result = GetResultAs<Result*>(); 506 Result* result = GetResultAs<Result*>();
507 *result = GL_NO_ERROR; 507 *result = GL_NO_ERROR;
508 helper_->GetError(result_shm_id(), result_shm_offset()); 508 helper_->GetError(result_shm_id(), result_shm_offset());
509 WaitForCmd(); 509 WaitForCmd();
510 GLenum error = *result; 510 GLenum error = *result;
511 if (error == GL_NO_ERROR && error_bits_ != 0) { 511 if (error == GL_NO_ERROR && error_bits_ != 0) {
512 for (uint32 mask = 1; mask != 0; mask = mask << 1) { 512 for (uint32 mask = 1; mask != 0; mask = mask << 1) {
513 if ((error_bits_ & mask) != 0) { 513 if ((error_bits_ & mask) != 0) {
(...skipping 12 matching lines...) Expand all
526 526
527 void GLES2Implementation::SetGLError(GLenum error, const char* msg) { 527 void GLES2Implementation::SetGLError(GLenum error, const char* msg) {
528 if (msg) { 528 if (msg) {
529 last_error_ = msg; 529 last_error_ = msg;
530 } 530 }
531 error_bits_ |= GLES2Util::GLErrorToErrorBit(error); 531 error_bits_ |= GLES2Util::GLErrorToErrorBit(error);
532 } 532 }
533 533
534 void GLES2Implementation::GetBucketContents(uint32 bucket_id, 534 void GLES2Implementation::GetBucketContents(uint32 bucket_id,
535 std::vector<int8>* data) { 535 std::vector<int8>* data) {
536 TRACE_EVENT0("gpu", "GLES2::GetBucketContents"); 536 GPU_TRACE_EVENT0("gpu", "GLES2::GetBucketContents");
537 GPU_DCHECK(data); 537 GPU_DCHECK(data);
538 typedef cmd::GetBucketSize::Result Result; 538 typedef cmd::GetBucketSize::Result Result;
539 Result* result = GetResultAs<Result*>(); 539 Result* result = GetResultAs<Result*>();
540 *result = 0; 540 *result = 0;
541 helper_->GetBucketSize(bucket_id, result_shm_id(), result_shm_offset()); 541 helper_->GetBucketSize(bucket_id, result_shm_id(), result_shm_offset());
542 WaitForCmd(); 542 WaitForCmd();
543 uint32 size = *result; 543 uint32 size = *result;
544 data->resize(size); 544 data->resize(size);
545 if (size > 0u) { 545 if (size > 0u) {
546 uint32 max_size = transfer_buffer_.GetLargestFreeOrPendingSize(); 546 uint32 max_size = transfer_buffer_.GetLargestFreeOrPendingSize();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 667
668 void GLES2Implementation::Flush() { 668 void GLES2Implementation::Flush() {
669 // Insert the cmd to call glFlush 669 // Insert the cmd to call glFlush
670 helper_->Flush(); 670 helper_->Flush();
671 // Flush our command buffer 671 // Flush our command buffer
672 // (tell the service to execute up to the flush cmd.) 672 // (tell the service to execute up to the flush cmd.)
673 helper_->CommandBufferHelper::Flush(); 673 helper_->CommandBufferHelper::Flush();
674 } 674 }
675 675
676 void GLES2Implementation::Finish() { 676 void GLES2Implementation::Finish() {
677 TRACE_EVENT0("gpu", "GLES2::Finish"); 677 GPU_TRACE_EVENT0("gpu", "GLES2::Finish");
678 // Insert the cmd to call glFinish 678 // Insert the cmd to call glFinish
679 helper_->Finish(); 679 helper_->Finish();
680 // Finish our command buffer 680 // Finish our command buffer
681 // (tell the service to execute up to the Finish cmd and wait for it to 681 // (tell the service to execute up to the Finish cmd and wait for it to
682 // execute.) 682 // execute.)
683 helper_->CommandBufferHelper::Finish(); 683 helper_->CommandBufferHelper::Finish();
684 } 684 }
685 685
686 void GLES2Implementation::SwapBuffers() { 686 void GLES2Implementation::SwapBuffers() {
687 // TODO(piman): Strictly speaking we'd want to insert the token after the 687 // TODO(piman): Strictly speaking we'd want to insert the token after the
(...skipping 22 matching lines...) Expand all
710 swap_buffers_tokens_.pop(); 710 swap_buffers_tokens_.pop();
711 } 711 }
712 helper_->CopyTextureToParentTextureCHROMIUM(client_child_id, 712 helper_->CopyTextureToParentTextureCHROMIUM(client_child_id,
713 client_parent_id); 713 client_parent_id);
714 swap_buffers_tokens_.push(helper_->InsertToken()); 714 swap_buffers_tokens_.push(helper_->InsertToken());
715 Flush(); 715 Flush();
716 } 716 }
717 717
718 void GLES2Implementation::GenSharedIdsCHROMIUM( 718 void GLES2Implementation::GenSharedIdsCHROMIUM(
719 GLuint namespace_id, GLuint id_offset, GLsizei n, GLuint* ids) { 719 GLuint namespace_id, GLuint id_offset, GLsizei n, GLuint* ids) {
720 TRACE_EVENT0("gpu", "GLES2::GenSharedIdsCHROMIUM"); 720 GPU_TRACE_EVENT0("gpu", "GLES2::GenSharedIdsCHROMIUM");
721 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n); 721 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n);
722 helper_->GenSharedIdsCHROMIUM(namespace_id, id_offset, n, 722 helper_->GenSharedIdsCHROMIUM(namespace_id, id_offset, n,
723 transfer_buffer_id_, 723 transfer_buffer_id_,
724 transfer_buffer_.GetOffset(id_buffer)); 724 transfer_buffer_.GetOffset(id_buffer));
725 WaitForCmd(); 725 WaitForCmd();
726 memcpy(ids, id_buffer, sizeof(*ids) * n); 726 memcpy(ids, id_buffer, sizeof(*ids) * n);
727 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken()); 727 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken());
728 } 728 }
729 729
730 void GLES2Implementation::DeleteSharedIdsCHROMIUM( 730 void GLES2Implementation::DeleteSharedIdsCHROMIUM(
731 GLuint namespace_id, GLsizei n, const GLuint* ids) { 731 GLuint namespace_id, GLsizei n, const GLuint* ids) {
732 TRACE_EVENT0("gpu", "GLES2::DeleteSharedIdsCHROMIUM"); 732 GPU_TRACE_EVENT0("gpu", "GLES2::DeleteSharedIdsCHROMIUM");
733 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n); 733 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n);
734 memcpy(id_buffer, ids, sizeof(*ids) * n); 734 memcpy(id_buffer, ids, sizeof(*ids) * n);
735 helper_->DeleteSharedIdsCHROMIUM(namespace_id, n, 735 helper_->DeleteSharedIdsCHROMIUM(namespace_id, n,
736 transfer_buffer_id_, 736 transfer_buffer_id_,
737 transfer_buffer_.GetOffset(id_buffer)); 737 transfer_buffer_.GetOffset(id_buffer));
738 WaitForCmd(); 738 WaitForCmd();
739 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken()); 739 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken());
740 } 740 }
741 741
742 void GLES2Implementation::RegisterSharedIdsCHROMIUM( 742 void GLES2Implementation::RegisterSharedIdsCHROMIUM(
743 GLuint namespace_id, GLsizei n, const GLuint* ids) { 743 GLuint namespace_id, GLsizei n, const GLuint* ids) {
744 TRACE_EVENT0("gpu", "GLES2::RegisterSharedIdsCHROMIUM"); 744 GPU_TRACE_EVENT0("gpu", "GLES2::RegisterSharedIdsCHROMIUM");
745 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n); 745 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n);
746 memcpy(id_buffer, ids, sizeof(*ids) * n); 746 memcpy(id_buffer, ids, sizeof(*ids) * n);
747 helper_->RegisterSharedIdsCHROMIUM(namespace_id, n, 747 helper_->RegisterSharedIdsCHROMIUM(namespace_id, n,
748 transfer_buffer_id_, 748 transfer_buffer_id_,
749 transfer_buffer_.GetOffset(id_buffer)); 749 transfer_buffer_.GetOffset(id_buffer));
750 WaitForCmd(); 750 WaitForCmd();
751 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken()); 751 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken());
752 } 752 }
753 753
754 void GLES2Implementation::BindAttribLocation( 754 void GLES2Implementation::BindAttribLocation(
755 GLuint program, GLuint index, const char* name) { 755 GLuint program, GLuint index, const char* name) {
756 SetBucketAsString(kResultBucketId, name); 756 SetBucketAsString(kResultBucketId, name);
757 helper_->BindAttribLocationBucket(program, index, kResultBucketId); 757 helper_->BindAttribLocationBucket(program, index, kResultBucketId);
758 helper_->SetBucketSize(kResultBucketId, 0); 758 helper_->SetBucketSize(kResultBucketId, 0);
759 } 759 }
760 760
761 void GLES2Implementation::GetVertexAttribPointerv( 761 void GLES2Implementation::GetVertexAttribPointerv(
762 GLuint index, GLenum pname, void** ptr) { 762 GLuint index, GLenum pname, void** ptr) {
763 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 763 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
764 // If it's a client side buffer the client has the data. 764 // If it's a client side buffer the client has the data.
765 if (client_side_buffer_helper_->GetAttribPointer(index, pname, ptr)) { 765 if (client_side_buffer_helper_->GetAttribPointer(index, pname, ptr)) {
766 return; 766 return;
767 } 767 }
768 #endif // defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 768 #endif // defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
769 769
770 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribPointerv"); 770 GPU_TRACE_EVENT0("gpu", "GLES2::GetVertexAttribPointerv");
771 typedef gles2::GetVertexAttribPointerv::Result Result; 771 typedef gles2::GetVertexAttribPointerv::Result Result;
772 Result* result = GetResultAs<Result*>(); 772 Result* result = GetResultAs<Result*>();
773 result->SetNumResults(0); 773 result->SetNumResults(0);
774 helper_->GetVertexAttribPointerv( 774 helper_->GetVertexAttribPointerv(
775 index, pname, result_shm_id(), result_shm_offset()); 775 index, pname, result_shm_id(), result_shm_offset());
776 WaitForCmd(); 776 WaitForCmd();
777 result->CopyResult(ptr); 777 result->CopyResult(ptr);
778 } 778 }
779 779
780 GLint GLES2Implementation::GetAttribLocation( 780 GLint GLES2Implementation::GetAttribLocation(
781 GLuint program, const char* name) { 781 GLuint program, const char* name) {
782 TRACE_EVENT0("gpu", "GLES2::GetAttribLocation"); 782 GPU_TRACE_EVENT0("gpu", "GLES2::GetAttribLocation");
783 typedef GetAttribLocationBucket::Result Result; 783 typedef GetAttribLocationBucket::Result Result;
784 Result* result = GetResultAs<Result*>(); 784 Result* result = GetResultAs<Result*>();
785 *result = -1; 785 *result = -1;
786 SetBucketAsCString(kResultBucketId, name); 786 SetBucketAsCString(kResultBucketId, name);
787 helper_->GetAttribLocationBucket(program, kResultBucketId, 787 helper_->GetAttribLocationBucket(program, kResultBucketId,
788 result_shm_id(), result_shm_offset()); 788 result_shm_id(), result_shm_offset());
789 WaitForCmd(); 789 WaitForCmd();
790 helper_->SetBucketSize(kResultBucketId, 0); 790 helper_->SetBucketSize(kResultBucketId, 0);
791 return *result; 791 return *result;
792 } 792 }
793 793
794 GLint GLES2Implementation::GetUniformLocation( 794 GLint GLES2Implementation::GetUniformLocation(
795 GLuint program, const char* name) { 795 GLuint program, const char* name) {
796 TRACE_EVENT0("gpu", "GLES2::GetUniformLocation"); 796 GPU_TRACE_EVENT0("gpu", "GLES2::GetUniformLocation");
797 typedef GetUniformLocationBucket::Result Result; 797 typedef GetUniformLocationBucket::Result Result;
798 Result* result = GetResultAs<Result*>(); 798 Result* result = GetResultAs<Result*>();
799 *result = -1; 799 *result = -1;
800 SetBucketAsCString(kResultBucketId, name); 800 SetBucketAsCString(kResultBucketId, name);
801 helper_->GetUniformLocationBucket(program, kResultBucketId, 801 helper_->GetUniformLocationBucket(program, kResultBucketId,
802 result_shm_id(), result_shm_offset()); 802 result_shm_id(), result_shm_offset());
803 WaitForCmd(); 803 WaitForCmd();
804 helper_->SetBucketSize(kResultBucketId, 0); 804 helper_->SetBucketSize(kResultBucketId, 0);
805 return *result; 805 return *result;
806 } 806 }
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 } 1097 }
1098 } 1098 }
1099 1099
1100 void GLES2Implementation::GetActiveAttrib( 1100 void GLES2Implementation::GetActiveAttrib(
1101 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, 1101 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
1102 GLenum* type, char* name) { 1102 GLenum* type, char* name) {
1103 if (bufsize < 0) { 1103 if (bufsize < 0) {
1104 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: bufsize < 0"); 1104 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: bufsize < 0");
1105 return; 1105 return;
1106 } 1106 }
1107 TRACE_EVENT0("gpu", "GLES2::GetActiveAttrib"); 1107 GPU_TRACE_EVENT0("gpu", "GLES2::GetActiveAttrib");
1108 // Clear the bucket so if we the command fails nothing will be in it. 1108 // Clear the bucket so if we the command fails nothing will be in it.
1109 helper_->SetBucketSize(kResultBucketId, 0); 1109 helper_->SetBucketSize(kResultBucketId, 0);
1110 typedef gles2::GetActiveAttrib::Result Result; 1110 typedef gles2::GetActiveAttrib::Result Result;
1111 Result* result = static_cast<Result*>(result_buffer_); 1111 Result* result = static_cast<Result*>(result_buffer_);
1112 // Set as failed so if the command fails we'll recover. 1112 // Set as failed so if the command fails we'll recover.
1113 result->success = false; 1113 result->success = false;
1114 helper_->GetActiveAttrib(program, index, kResultBucketId, 1114 helper_->GetActiveAttrib(program, index, kResultBucketId,
1115 result_shm_id(), result_shm_offset()); 1115 result_shm_id(), result_shm_offset());
1116 WaitForCmd(); 1116 WaitForCmd();
1117 if (result->success) { 1117 if (result->success) {
(...skipping 20 matching lines...) Expand all
1138 } 1138 }
1139 } 1139 }
1140 1140
1141 void GLES2Implementation::GetActiveUniform( 1141 void GLES2Implementation::GetActiveUniform(
1142 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, 1142 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
1143 GLenum* type, char* name) { 1143 GLenum* type, char* name) {
1144 if (bufsize < 0) { 1144 if (bufsize < 0) {
1145 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: bufsize < 0"); 1145 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: bufsize < 0");
1146 return; 1146 return;
1147 } 1147 }
1148 TRACE_EVENT0("gpu", "GLES2::GetActiveUniform"); 1148 GPU_TRACE_EVENT0("gpu", "GLES2::GetActiveUniform");
1149 // Clear the bucket so if we the command fails nothing will be in it. 1149 // Clear the bucket so if we the command fails nothing will be in it.
1150 helper_->SetBucketSize(kResultBucketId, 0); 1150 helper_->SetBucketSize(kResultBucketId, 0);
1151 typedef gles2::GetActiveUniform::Result Result; 1151 typedef gles2::GetActiveUniform::Result Result;
1152 Result* result = static_cast<Result*>(result_buffer_); 1152 Result* result = static_cast<Result*>(result_buffer_);
1153 // Set as failed so if the command fails we'll recover. 1153 // Set as failed so if the command fails we'll recover.
1154 result->success = false; 1154 result->success = false;
1155 helper_->GetActiveUniform(program, index, kResultBucketId, 1155 helper_->GetActiveUniform(program, index, kResultBucketId,
1156 result_shm_id(), result_shm_offset()); 1156 result_shm_id(), result_shm_offset());
1157 WaitForCmd(); 1157 WaitForCmd();
1158 if (result->success) { 1158 if (result->success) {
(...skipping 19 matching lines...) Expand all
1178 } 1178 }
1179 } 1179 }
1180 } 1180 }
1181 1181
1182 void GLES2Implementation::GetAttachedShaders( 1182 void GLES2Implementation::GetAttachedShaders(
1183 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { 1183 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) {
1184 if (maxcount < 0) { 1184 if (maxcount < 0) {
1185 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders: maxcount < 0"); 1185 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders: maxcount < 0");
1186 return; 1186 return;
1187 } 1187 }
1188 TRACE_EVENT0("gpu", "GLES2::GetAttachedShaders"); 1188 GPU_TRACE_EVENT0("gpu", "GLES2::GetAttachedShaders");
1189 typedef gles2::GetAttachedShaders::Result Result; 1189 typedef gles2::GetAttachedShaders::Result Result;
1190 uint32 size = Result::ComputeSize(maxcount); 1190 uint32 size = Result::ComputeSize(maxcount);
1191 Result* result = transfer_buffer_.AllocTyped<Result>(size); 1191 Result* result = transfer_buffer_.AllocTyped<Result>(size);
1192 result->SetNumResults(0); 1192 result->SetNumResults(0);
1193 helper_->GetAttachedShaders( 1193 helper_->GetAttachedShaders(
1194 program, 1194 program,
1195 transfer_buffer_id_, 1195 transfer_buffer_id_,
1196 transfer_buffer_.GetOffset(result), 1196 transfer_buffer_.GetOffset(result),
1197 size); 1197 size);
1198 int32 token = helper_->InsertToken(); 1198 int32 token = helper_->InsertToken();
1199 WaitForCmd(); 1199 WaitForCmd();
1200 if (count) { 1200 if (count) {
1201 *count = result->GetNumResults(); 1201 *count = result->GetNumResults();
1202 } 1202 }
1203 result->CopyResult(shaders); 1203 result->CopyResult(shaders);
1204 transfer_buffer_.FreePendingToken(result, token); 1204 transfer_buffer_.FreePendingToken(result, token);
1205 } 1205 }
1206 1206
1207 void GLES2Implementation::GetShaderPrecisionFormat( 1207 void GLES2Implementation::GetShaderPrecisionFormat(
1208 GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { 1208 GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
1209 TRACE_EVENT0("gpu", "GLES2::GetShaderPrecisionFormat"); 1209 GPU_TRACE_EVENT0("gpu", "GLES2::GetShaderPrecisionFormat");
1210 typedef gles2::GetShaderPrecisionFormat::Result Result; 1210 typedef gles2::GetShaderPrecisionFormat::Result Result;
1211 Result* result = static_cast<Result*>(result_buffer_); 1211 Result* result = static_cast<Result*>(result_buffer_);
1212 result->success = false; 1212 result->success = false;
1213 helper_->GetShaderPrecisionFormat( 1213 helper_->GetShaderPrecisionFormat(
1214 shadertype, precisiontype, result_shm_id(), result_shm_offset()); 1214 shadertype, precisiontype, result_shm_id(), result_shm_offset());
1215 WaitForCmd(); 1215 WaitForCmd();
1216 if (result->success) { 1216 if (result->success) {
1217 if (range) { 1217 if (range) {
1218 range[0] = result->min_range; 1218 range[0] = result->min_range;
1219 range[1] = result->max_range; 1219 range[1] = result->max_range;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 string_set.insert(str); 1251 string_set.insert(str);
1252 GPU_DCHECK(insert_result.second); 1252 GPU_DCHECK(insert_result.second);
1253 result = insert_result.first->c_str(); 1253 result = insert_result.first->c_str();
1254 } 1254 }
1255 } 1255 }
1256 return reinterpret_cast<const GLubyte*>(result); 1256 return reinterpret_cast<const GLubyte*>(result);
1257 } 1257 }
1258 1258
1259 void GLES2Implementation::GetUniformfv( 1259 void GLES2Implementation::GetUniformfv(
1260 GLuint program, GLint location, GLfloat* params) { 1260 GLuint program, GLint location, GLfloat* params) {
1261 TRACE_EVENT0("gpu", "GLES2::GetUniformfv"); 1261 GPU_TRACE_EVENT0("gpu", "GLES2::GetUniformfv");
1262 typedef gles2::GetUniformfv::Result Result; 1262 typedef gles2::GetUniformfv::Result Result;
1263 Result* result = static_cast<Result*>(result_buffer_); 1263 Result* result = static_cast<Result*>(result_buffer_);
1264 result->SetNumResults(0); 1264 result->SetNumResults(0);
1265 helper_->GetUniformfv( 1265 helper_->GetUniformfv(
1266 program, location, result_shm_id(), result_shm_offset()); 1266 program, location, result_shm_id(), result_shm_offset());
1267 WaitForCmd(); 1267 WaitForCmd();
1268 result->CopyResult(params); 1268 result->CopyResult(params);
1269 } 1269 }
1270 1270
1271 void GLES2Implementation::GetUniformiv( 1271 void GLES2Implementation::GetUniformiv(
1272 GLuint program, GLint location, GLint* params) { 1272 GLuint program, GLint location, GLint* params) {
1273 TRACE_EVENT0("gpu", "GLES2::GetUniformiv"); 1273 GPU_TRACE_EVENT0("gpu", "GLES2::GetUniformiv");
1274 typedef gles2::GetUniformiv::Result Result; 1274 typedef gles2::GetUniformiv::Result Result;
1275 Result* result = static_cast<Result*>(result_buffer_); 1275 Result* result = static_cast<Result*>(result_buffer_);
1276 result->SetNumResults(0); 1276 result->SetNumResults(0);
1277 helper_->GetUniformiv( 1277 helper_->GetUniformiv(
1278 program, location, result_shm_id(), result_shm_offset()); 1278 program, location, result_shm_id(), result_shm_offset());
1279 WaitForCmd(); 1279 WaitForCmd();
1280 static_cast<gles2::GetUniformfv::Result*>(result_buffer_)->CopyResult(params); 1280 static_cast<gles2::GetUniformfv::Result*>(result_buffer_)->CopyResult(params);
1281 } 1281 }
1282 1282
1283 void GLES2Implementation::ReadPixels( 1283 void GLES2Implementation::ReadPixels(
1284 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, 1284 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format,
1285 GLenum type, void* pixels) { 1285 GLenum type, void* pixels) {
1286 if (width < 0 || height < 0) { 1286 if (width < 0 || height < 0) {
1287 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions < 0"); 1287 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions < 0");
1288 return; 1288 return;
1289 } 1289 }
1290 if (width == 0 || height == 0) { 1290 if (width == 0 || height == 0) {
1291 return; 1291 return;
1292 } 1292 }
1293 1293
1294 // glReadPixel pads the size of each row of pixels by an amount specified by 1294 // glReadPixel pads the size of each row of pixels by an amount specified by
1295 // glPixelStorei. So, we have to take that into account both in the fact that 1295 // glPixelStorei. So, we have to take that into account both in the fact that
1296 // the pixels returned from the ReadPixel command will include that padding 1296 // the pixels returned from the ReadPixel command will include that padding
1297 // and that when we copy the results to the user's buffer we need to not 1297 // and that when we copy the results to the user's buffer we need to not
1298 // write those padding bytes but leave them as they are. 1298 // write those padding bytes but leave them as they are.
1299 1299
1300 TRACE_EVENT0("gpu", "GLES2::ReadPixels"); 1300 GPU_TRACE_EVENT0("gpu", "GLES2::ReadPixels");
1301 typedef gles2::ReadPixels::Result Result; 1301 typedef gles2::ReadPixels::Result Result;
1302 Result* result = static_cast<Result*>(result_buffer_); 1302 Result* result = static_cast<Result*>(result_buffer_);
1303 int8* dest = reinterpret_cast<int8*>(pixels); 1303 int8* dest = reinterpret_cast<int8*>(pixels);
1304 GLsizeiptr max_size = transfer_buffer_.GetLargestFreeOrPendingSize(); 1304 GLsizeiptr max_size = transfer_buffer_.GetLargestFreeOrPendingSize();
1305 uint32 temp_size; 1305 uint32 temp_size;
1306 if (!GLES2Util::ComputeImageDataSize( 1306 if (!GLES2Util::ComputeImageDataSize(
1307 width, 1, format, type, pack_alignment_, &temp_size)) { 1307 width, 1, format, type, pack_alignment_, &temp_size)) {
1308 SetGLError(GL_INVALID_VALUE, "glReadPixels: size too large."); 1308 SetGLError(GL_INVALID_VALUE, "glReadPixels: size too large.");
1309 return; 1309 return;
1310 } 1310 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 1530
1531 void GLES2Implementation::GetVertexAttribfv( 1531 void GLES2Implementation::GetVertexAttribfv(
1532 GLuint index, GLenum pname, GLfloat* params) { 1532 GLuint index, GLenum pname, GLfloat* params) {
1533 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 1533 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
1534 uint32 value = 0; 1534 uint32 value = 0;
1535 if (GetVertexAttribHelper(index, pname, &value)) { 1535 if (GetVertexAttribHelper(index, pname, &value)) {
1536 *params = static_cast<float>(value); 1536 *params = static_cast<float>(value);
1537 return; 1537 return;
1538 } 1538 }
1539 #endif 1539 #endif
1540 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribfv"); 1540 GPU_TRACE_EVENT0("gpu", "GLES2::GetVertexAttribfv");
1541 typedef GetVertexAttribfv::Result Result; 1541 typedef GetVertexAttribfv::Result Result;
1542 Result* result = GetResultAs<Result*>(); 1542 Result* result = GetResultAs<Result*>();
1543 result->SetNumResults(0); 1543 result->SetNumResults(0);
1544 helper_->GetVertexAttribfv( 1544 helper_->GetVertexAttribfv(
1545 index, pname, result_shm_id(), result_shm_offset()); 1545 index, pname, result_shm_id(), result_shm_offset());
1546 WaitForCmd(); 1546 WaitForCmd();
1547 result->CopyResult(params); 1547 result->CopyResult(params);
1548 } 1548 }
1549 1549
1550 void GLES2Implementation::GetVertexAttribiv( 1550 void GLES2Implementation::GetVertexAttribiv(
1551 GLuint index, GLenum pname, GLint* params) { 1551 GLuint index, GLenum pname, GLint* params) {
1552 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 1552 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
1553 uint32 value = 0; 1553 uint32 value = 0;
1554 if (GetVertexAttribHelper(index, pname, &value)) { 1554 if (GetVertexAttribHelper(index, pname, &value)) {
1555 *params = value; 1555 *params = value;
1556 return; 1556 return;
1557 } 1557 }
1558 #endif 1558 #endif
1559 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribiv"); 1559 GPU_TRACE_EVENT0("gpu", "GLES2::GetVertexAttribiv");
1560 typedef GetVertexAttribiv::Result Result; 1560 typedef GetVertexAttribiv::Result Result;
1561 Result* result = GetResultAs<Result*>(); 1561 Result* result = GetResultAs<Result*>();
1562 result->SetNumResults(0); 1562 result->SetNumResults(0);
1563 helper_->GetVertexAttribiv( 1563 helper_->GetVertexAttribiv(
1564 index, pname, result_shm_id(), result_shm_offset()); 1564 index, pname, result_shm_id(), result_shm_offset());
1565 WaitForCmd(); 1565 WaitForCmd();
1566 result->CopyResult(params); 1566 result->CopyResult(params);
1567 } 1567 }
1568 1568
1569 GLboolean GLES2Implementation::CommandBufferEnableCHROMIUM( 1569 GLboolean GLES2Implementation::CommandBufferEnableCHROMIUM(
1570 const char* feature) { 1570 const char* feature) {
1571 TRACE_EVENT0("gpu", "GLES2::CommandBufferEnableCHROMIUM"); 1571 GPU_TRACE_EVENT0("gpu", "GLES2::CommandBufferEnableCHROMIUM");
1572 typedef CommandBufferEnableCHROMIUM::Result Result; 1572 typedef CommandBufferEnableCHROMIUM::Result Result;
1573 Result* result = GetResultAs<Result*>(); 1573 Result* result = GetResultAs<Result*>();
1574 *result = 0; 1574 *result = 0;
1575 SetBucketAsCString(kResultBucketId, feature); 1575 SetBucketAsCString(kResultBucketId, feature);
1576 helper_->CommandBufferEnableCHROMIUM( 1576 helper_->CommandBufferEnableCHROMIUM(
1577 kResultBucketId, result_shm_id(), result_shm_offset()); 1577 kResultBucketId, result_shm_id(), result_shm_offset());
1578 WaitForCmd(); 1578 WaitForCmd();
1579 helper_->SetBucketSize(kResultBucketId, 0); 1579 helper_->SetBucketSize(kResultBucketId, 0);
1580 return *result; 1580 return *result;
1581 } 1581 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 } 1707 }
1708 1708
1709 void GLES2Implementation::RequestExtensionCHROMIUM(const char* extension) { 1709 void GLES2Implementation::RequestExtensionCHROMIUM(const char* extension) {
1710 SetBucketAsCString(kResultBucketId, extension); 1710 SetBucketAsCString(kResultBucketId, extension);
1711 helper_->RequestExtensionCHROMIUM(kResultBucketId); 1711 helper_->RequestExtensionCHROMIUM(kResultBucketId);
1712 helper_->SetBucketSize(kResultBucketId, 0); 1712 helper_->SetBucketSize(kResultBucketId, 0);
1713 } 1713 }
1714 1714
1715 } // namespace gles2 1715 } // namespace gles2
1716 } // namespace gpu 1716 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/cmd_buffer_helper.cc ('k') | gpu/command_buffer/common/trace_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698