OLD | NEW |
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 "gpu/common/gpu_trace_event.h" | 12 #include "../common/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 Loading... |
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 GPU_TRACE_EVENT0("gpu", "GLES2::WaitForCmd"); | 494 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 GPU_TRACE_EVENT0("gpu", "GLES2::GetGLError"); | 503 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 Loading... |
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 GPU_TRACE_EVENT0("gpu", "GLES2::GetBucketContents"); | 536 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 Loading... |
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 GPU_TRACE_EVENT0("gpu", "GLES2::Finish"); | 677 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 // Wait if this would add too many swap buffers. | 687 // Wait if this would add too many swap buffers. |
(...skipping 15 matching lines...) Expand all Loading... |
703 swap_buffers_tokens_.pop(); | 703 swap_buffers_tokens_.pop(); |
704 } | 704 } |
705 helper_->CopyTextureToParentTextureCHROMIUM(client_child_id, | 705 helper_->CopyTextureToParentTextureCHROMIUM(client_child_id, |
706 client_parent_id); | 706 client_parent_id); |
707 swap_buffers_tokens_.push(helper_->InsertToken()); | 707 swap_buffers_tokens_.push(helper_->InsertToken()); |
708 Flush(); | 708 Flush(); |
709 } | 709 } |
710 | 710 |
711 void GLES2Implementation::GenSharedIdsCHROMIUM( | 711 void GLES2Implementation::GenSharedIdsCHROMIUM( |
712 GLuint namespace_id, GLuint id_offset, GLsizei n, GLuint* ids) { | 712 GLuint namespace_id, GLuint id_offset, GLsizei n, GLuint* ids) { |
713 GPU_TRACE_EVENT0("gpu", "GLES2::GenSharedIdsCHROMIUM"); | 713 TRACE_EVENT0("gpu", "GLES2::GenSharedIdsCHROMIUM"); |
714 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n); | 714 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n); |
715 helper_->GenSharedIdsCHROMIUM(namespace_id, id_offset, n, | 715 helper_->GenSharedIdsCHROMIUM(namespace_id, id_offset, n, |
716 transfer_buffer_id_, | 716 transfer_buffer_id_, |
717 transfer_buffer_.GetOffset(id_buffer)); | 717 transfer_buffer_.GetOffset(id_buffer)); |
718 WaitForCmd(); | 718 WaitForCmd(); |
719 memcpy(ids, id_buffer, sizeof(*ids) * n); | 719 memcpy(ids, id_buffer, sizeof(*ids) * n); |
720 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken()); | 720 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken()); |
721 } | 721 } |
722 | 722 |
723 void GLES2Implementation::DeleteSharedIdsCHROMIUM( | 723 void GLES2Implementation::DeleteSharedIdsCHROMIUM( |
724 GLuint namespace_id, GLsizei n, const GLuint* ids) { | 724 GLuint namespace_id, GLsizei n, const GLuint* ids) { |
725 GPU_TRACE_EVENT0("gpu", "GLES2::DeleteSharedIdsCHROMIUM"); | 725 TRACE_EVENT0("gpu", "GLES2::DeleteSharedIdsCHROMIUM"); |
726 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n); | 726 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n); |
727 memcpy(id_buffer, ids, sizeof(*ids) * n); | 727 memcpy(id_buffer, ids, sizeof(*ids) * n); |
728 helper_->DeleteSharedIdsCHROMIUM(namespace_id, n, | 728 helper_->DeleteSharedIdsCHROMIUM(namespace_id, n, |
729 transfer_buffer_id_, | 729 transfer_buffer_id_, |
730 transfer_buffer_.GetOffset(id_buffer)); | 730 transfer_buffer_.GetOffset(id_buffer)); |
731 WaitForCmd(); | 731 WaitForCmd(); |
732 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken()); | 732 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken()); |
733 } | 733 } |
734 | 734 |
735 void GLES2Implementation::RegisterSharedIdsCHROMIUM( | 735 void GLES2Implementation::RegisterSharedIdsCHROMIUM( |
736 GLuint namespace_id, GLsizei n, const GLuint* ids) { | 736 GLuint namespace_id, GLsizei n, const GLuint* ids) { |
737 GPU_TRACE_EVENT0("gpu", "GLES2::RegisterSharedIdsCHROMIUM"); | 737 TRACE_EVENT0("gpu", "GLES2::RegisterSharedIdsCHROMIUM"); |
738 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n); | 738 GLint* id_buffer = transfer_buffer_.AllocTyped<GLint>(n); |
739 memcpy(id_buffer, ids, sizeof(*ids) * n); | 739 memcpy(id_buffer, ids, sizeof(*ids) * n); |
740 helper_->RegisterSharedIdsCHROMIUM(namespace_id, n, | 740 helper_->RegisterSharedIdsCHROMIUM(namespace_id, n, |
741 transfer_buffer_id_, | 741 transfer_buffer_id_, |
742 transfer_buffer_.GetOffset(id_buffer)); | 742 transfer_buffer_.GetOffset(id_buffer)); |
743 WaitForCmd(); | 743 WaitForCmd(); |
744 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken()); | 744 transfer_buffer_.FreePendingToken(id_buffer, helper_->InsertToken()); |
745 } | 745 } |
746 | 746 |
747 void GLES2Implementation::BindAttribLocation( | 747 void GLES2Implementation::BindAttribLocation( |
748 GLuint program, GLuint index, const char* name) { | 748 GLuint program, GLuint index, const char* name) { |
749 SetBucketAsString(kResultBucketId, name); | 749 SetBucketAsString(kResultBucketId, name); |
750 helper_->BindAttribLocationBucket(program, index, kResultBucketId); | 750 helper_->BindAttribLocationBucket(program, index, kResultBucketId); |
751 helper_->SetBucketSize(kResultBucketId, 0); | 751 helper_->SetBucketSize(kResultBucketId, 0); |
752 } | 752 } |
753 | 753 |
754 void GLES2Implementation::GetVertexAttribPointerv( | 754 void GLES2Implementation::GetVertexAttribPointerv( |
755 GLuint index, GLenum pname, void** ptr) { | 755 GLuint index, GLenum pname, void** ptr) { |
756 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 756 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
757 // If it's a client side buffer the client has the data. | 757 // If it's a client side buffer the client has the data. |
758 if (client_side_buffer_helper_->GetAttribPointer(index, pname, ptr)) { | 758 if (client_side_buffer_helper_->GetAttribPointer(index, pname, ptr)) { |
759 return; | 759 return; |
760 } | 760 } |
761 #endif // defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 761 #endif // defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
762 | 762 |
763 GPU_TRACE_EVENT0("gpu", "GLES2::GetVertexAttribPointerv"); | 763 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribPointerv"); |
764 typedef gles2::GetVertexAttribPointerv::Result Result; | 764 typedef gles2::GetVertexAttribPointerv::Result Result; |
765 Result* result = GetResultAs<Result*>(); | 765 Result* result = GetResultAs<Result*>(); |
766 result->SetNumResults(0); | 766 result->SetNumResults(0); |
767 helper_->GetVertexAttribPointerv( | 767 helper_->GetVertexAttribPointerv( |
768 index, pname, result_shm_id(), result_shm_offset()); | 768 index, pname, result_shm_id(), result_shm_offset()); |
769 WaitForCmd(); | 769 WaitForCmd(); |
770 result->CopyResult(ptr); | 770 result->CopyResult(ptr); |
771 } | 771 } |
772 | 772 |
773 GLint GLES2Implementation::GetAttribLocation( | 773 GLint GLES2Implementation::GetAttribLocation( |
774 GLuint program, const char* name) { | 774 GLuint program, const char* name) { |
775 GPU_TRACE_EVENT0("gpu", "GLES2::GetAttribLocation"); | 775 TRACE_EVENT0("gpu", "GLES2::GetAttribLocation"); |
776 typedef GetAttribLocationBucket::Result Result; | 776 typedef GetAttribLocationBucket::Result Result; |
777 Result* result = GetResultAs<Result*>(); | 777 Result* result = GetResultAs<Result*>(); |
778 *result = -1; | 778 *result = -1; |
779 SetBucketAsCString(kResultBucketId, name); | 779 SetBucketAsCString(kResultBucketId, name); |
780 helper_->GetAttribLocationBucket(program, kResultBucketId, | 780 helper_->GetAttribLocationBucket(program, kResultBucketId, |
781 result_shm_id(), result_shm_offset()); | 781 result_shm_id(), result_shm_offset()); |
782 WaitForCmd(); | 782 WaitForCmd(); |
783 helper_->SetBucketSize(kResultBucketId, 0); | 783 helper_->SetBucketSize(kResultBucketId, 0); |
784 return *result; | 784 return *result; |
785 } | 785 } |
786 | 786 |
787 GLint GLES2Implementation::GetUniformLocation( | 787 GLint GLES2Implementation::GetUniformLocation( |
788 GLuint program, const char* name) { | 788 GLuint program, const char* name) { |
789 GPU_TRACE_EVENT0("gpu", "GLES2::GetUniformLocation"); | 789 TRACE_EVENT0("gpu", "GLES2::GetUniformLocation"); |
790 typedef GetUniformLocationBucket::Result Result; | 790 typedef GetUniformLocationBucket::Result Result; |
791 Result* result = GetResultAs<Result*>(); | 791 Result* result = GetResultAs<Result*>(); |
792 *result = -1; | 792 *result = -1; |
793 SetBucketAsCString(kResultBucketId, name); | 793 SetBucketAsCString(kResultBucketId, name); |
794 helper_->GetUniformLocationBucket(program, kResultBucketId, | 794 helper_->GetUniformLocationBucket(program, kResultBucketId, |
795 result_shm_id(), result_shm_offset()); | 795 result_shm_id(), result_shm_offset()); |
796 WaitForCmd(); | 796 WaitForCmd(); |
797 helper_->SetBucketSize(kResultBucketId, 0); | 797 helper_->SetBucketSize(kResultBucketId, 0); |
798 return *result; | 798 return *result; |
799 } | 799 } |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 } | 1090 } |
1091 } | 1091 } |
1092 | 1092 |
1093 void GLES2Implementation::GetActiveAttrib( | 1093 void GLES2Implementation::GetActiveAttrib( |
1094 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, | 1094 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, |
1095 GLenum* type, char* name) { | 1095 GLenum* type, char* name) { |
1096 if (bufsize < 0) { | 1096 if (bufsize < 0) { |
1097 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: bufsize < 0"); | 1097 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: bufsize < 0"); |
1098 return; | 1098 return; |
1099 } | 1099 } |
1100 GPU_TRACE_EVENT0("gpu", "GLES2::GetActiveAttrib"); | 1100 TRACE_EVENT0("gpu", "GLES2::GetActiveAttrib"); |
1101 // Clear the bucket so if we the command fails nothing will be in it. | 1101 // Clear the bucket so if we the command fails nothing will be in it. |
1102 helper_->SetBucketSize(kResultBucketId, 0); | 1102 helper_->SetBucketSize(kResultBucketId, 0); |
1103 typedef gles2::GetActiveAttrib::Result Result; | 1103 typedef gles2::GetActiveAttrib::Result Result; |
1104 Result* result = static_cast<Result*>(result_buffer_); | 1104 Result* result = static_cast<Result*>(result_buffer_); |
1105 // Set as failed so if the command fails we'll recover. | 1105 // Set as failed so if the command fails we'll recover. |
1106 result->success = false; | 1106 result->success = false; |
1107 helper_->GetActiveAttrib(program, index, kResultBucketId, | 1107 helper_->GetActiveAttrib(program, index, kResultBucketId, |
1108 result_shm_id(), result_shm_offset()); | 1108 result_shm_id(), result_shm_offset()); |
1109 WaitForCmd(); | 1109 WaitForCmd(); |
1110 if (result->success) { | 1110 if (result->success) { |
(...skipping 20 matching lines...) Expand all Loading... |
1131 } | 1131 } |
1132 } | 1132 } |
1133 | 1133 |
1134 void GLES2Implementation::GetActiveUniform( | 1134 void GLES2Implementation::GetActiveUniform( |
1135 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, | 1135 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, |
1136 GLenum* type, char* name) { | 1136 GLenum* type, char* name) { |
1137 if (bufsize < 0) { | 1137 if (bufsize < 0) { |
1138 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: bufsize < 0"); | 1138 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: bufsize < 0"); |
1139 return; | 1139 return; |
1140 } | 1140 } |
1141 GPU_TRACE_EVENT0("gpu", "GLES2::GetActiveUniform"); | 1141 TRACE_EVENT0("gpu", "GLES2::GetActiveUniform"); |
1142 // Clear the bucket so if we the command fails nothing will be in it. | 1142 // Clear the bucket so if we the command fails nothing will be in it. |
1143 helper_->SetBucketSize(kResultBucketId, 0); | 1143 helper_->SetBucketSize(kResultBucketId, 0); |
1144 typedef gles2::GetActiveUniform::Result Result; | 1144 typedef gles2::GetActiveUniform::Result Result; |
1145 Result* result = static_cast<Result*>(result_buffer_); | 1145 Result* result = static_cast<Result*>(result_buffer_); |
1146 // Set as failed so if the command fails we'll recover. | 1146 // Set as failed so if the command fails we'll recover. |
1147 result->success = false; | 1147 result->success = false; |
1148 helper_->GetActiveUniform(program, index, kResultBucketId, | 1148 helper_->GetActiveUniform(program, index, kResultBucketId, |
1149 result_shm_id(), result_shm_offset()); | 1149 result_shm_id(), result_shm_offset()); |
1150 WaitForCmd(); | 1150 WaitForCmd(); |
1151 if (result->success) { | 1151 if (result->success) { |
(...skipping 19 matching lines...) Expand all Loading... |
1171 } | 1171 } |
1172 } | 1172 } |
1173 } | 1173 } |
1174 | 1174 |
1175 void GLES2Implementation::GetAttachedShaders( | 1175 void GLES2Implementation::GetAttachedShaders( |
1176 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { | 1176 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { |
1177 if (maxcount < 0) { | 1177 if (maxcount < 0) { |
1178 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders: maxcount < 0"); | 1178 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders: maxcount < 0"); |
1179 return; | 1179 return; |
1180 } | 1180 } |
1181 GPU_TRACE_EVENT0("gpu", "GLES2::GetAttachedShaders"); | 1181 TRACE_EVENT0("gpu", "GLES2::GetAttachedShaders"); |
1182 typedef gles2::GetAttachedShaders::Result Result; | 1182 typedef gles2::GetAttachedShaders::Result Result; |
1183 uint32 size = Result::ComputeSize(maxcount); | 1183 uint32 size = Result::ComputeSize(maxcount); |
1184 Result* result = transfer_buffer_.AllocTyped<Result>(size); | 1184 Result* result = transfer_buffer_.AllocTyped<Result>(size); |
1185 result->SetNumResults(0); | 1185 result->SetNumResults(0); |
1186 helper_->GetAttachedShaders( | 1186 helper_->GetAttachedShaders( |
1187 program, | 1187 program, |
1188 transfer_buffer_id_, | 1188 transfer_buffer_id_, |
1189 transfer_buffer_.GetOffset(result), | 1189 transfer_buffer_.GetOffset(result), |
1190 size); | 1190 size); |
1191 int32 token = helper_->InsertToken(); | 1191 int32 token = helper_->InsertToken(); |
1192 WaitForCmd(); | 1192 WaitForCmd(); |
1193 if (count) { | 1193 if (count) { |
1194 *count = result->GetNumResults(); | 1194 *count = result->GetNumResults(); |
1195 } | 1195 } |
1196 result->CopyResult(shaders); | 1196 result->CopyResult(shaders); |
1197 transfer_buffer_.FreePendingToken(result, token); | 1197 transfer_buffer_.FreePendingToken(result, token); |
1198 } | 1198 } |
1199 | 1199 |
1200 void GLES2Implementation::GetShaderPrecisionFormat( | 1200 void GLES2Implementation::GetShaderPrecisionFormat( |
1201 GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { | 1201 GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { |
1202 GPU_TRACE_EVENT0("gpu", "GLES2::GetShaderPrecisionFormat"); | 1202 TRACE_EVENT0("gpu", "GLES2::GetShaderPrecisionFormat"); |
1203 typedef gles2::GetShaderPrecisionFormat::Result Result; | 1203 typedef gles2::GetShaderPrecisionFormat::Result Result; |
1204 Result* result = static_cast<Result*>(result_buffer_); | 1204 Result* result = static_cast<Result*>(result_buffer_); |
1205 result->success = false; | 1205 result->success = false; |
1206 helper_->GetShaderPrecisionFormat( | 1206 helper_->GetShaderPrecisionFormat( |
1207 shadertype, precisiontype, result_shm_id(), result_shm_offset()); | 1207 shadertype, precisiontype, result_shm_id(), result_shm_offset()); |
1208 WaitForCmd(); | 1208 WaitForCmd(); |
1209 if (result->success) { | 1209 if (result->success) { |
1210 if (range) { | 1210 if (range) { |
1211 range[0] = result->min_range; | 1211 range[0] = result->min_range; |
1212 range[1] = result->max_range; | 1212 range[1] = result->max_range; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 string_set.insert(str); | 1244 string_set.insert(str); |
1245 GPU_DCHECK(insert_result.second); | 1245 GPU_DCHECK(insert_result.second); |
1246 result = insert_result.first->c_str(); | 1246 result = insert_result.first->c_str(); |
1247 } | 1247 } |
1248 } | 1248 } |
1249 return reinterpret_cast<const GLubyte*>(result); | 1249 return reinterpret_cast<const GLubyte*>(result); |
1250 } | 1250 } |
1251 | 1251 |
1252 void GLES2Implementation::GetUniformfv( | 1252 void GLES2Implementation::GetUniformfv( |
1253 GLuint program, GLint location, GLfloat* params) { | 1253 GLuint program, GLint location, GLfloat* params) { |
1254 GPU_TRACE_EVENT0("gpu", "GLES2::GetUniformfv"); | 1254 TRACE_EVENT0("gpu", "GLES2::GetUniformfv"); |
1255 typedef gles2::GetUniformfv::Result Result; | 1255 typedef gles2::GetUniformfv::Result Result; |
1256 Result* result = static_cast<Result*>(result_buffer_); | 1256 Result* result = static_cast<Result*>(result_buffer_); |
1257 result->SetNumResults(0); | 1257 result->SetNumResults(0); |
1258 helper_->GetUniformfv( | 1258 helper_->GetUniformfv( |
1259 program, location, result_shm_id(), result_shm_offset()); | 1259 program, location, result_shm_id(), result_shm_offset()); |
1260 WaitForCmd(); | 1260 WaitForCmd(); |
1261 result->CopyResult(params); | 1261 result->CopyResult(params); |
1262 } | 1262 } |
1263 | 1263 |
1264 void GLES2Implementation::GetUniformiv( | 1264 void GLES2Implementation::GetUniformiv( |
1265 GLuint program, GLint location, GLint* params) { | 1265 GLuint program, GLint location, GLint* params) { |
1266 GPU_TRACE_EVENT0("gpu", "GLES2::GetUniformiv"); | 1266 TRACE_EVENT0("gpu", "GLES2::GetUniformiv"); |
1267 typedef gles2::GetUniformiv::Result Result; | 1267 typedef gles2::GetUniformiv::Result Result; |
1268 Result* result = static_cast<Result*>(result_buffer_); | 1268 Result* result = static_cast<Result*>(result_buffer_); |
1269 result->SetNumResults(0); | 1269 result->SetNumResults(0); |
1270 helper_->GetUniformiv( | 1270 helper_->GetUniformiv( |
1271 program, location, result_shm_id(), result_shm_offset()); | 1271 program, location, result_shm_id(), result_shm_offset()); |
1272 WaitForCmd(); | 1272 WaitForCmd(); |
1273 static_cast<gles2::GetUniformfv::Result*>(result_buffer_)->CopyResult(params); | 1273 static_cast<gles2::GetUniformfv::Result*>(result_buffer_)->CopyResult(params); |
1274 } | 1274 } |
1275 | 1275 |
1276 void GLES2Implementation::ReadPixels( | 1276 void GLES2Implementation::ReadPixels( |
1277 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, | 1277 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, |
1278 GLenum type, void* pixels) { | 1278 GLenum type, void* pixels) { |
1279 if (width < 0 || height < 0) { | 1279 if (width < 0 || height < 0) { |
1280 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions < 0"); | 1280 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions < 0"); |
1281 return; | 1281 return; |
1282 } | 1282 } |
1283 if (width == 0 || height == 0) { | 1283 if (width == 0 || height == 0) { |
1284 return; | 1284 return; |
1285 } | 1285 } |
1286 | 1286 |
1287 // glReadPixel pads the size of each row of pixels by an amount specified by | 1287 // glReadPixel pads the size of each row of pixels by an amount specified by |
1288 // glPixelStorei. So, we have to take that into account both in the fact that | 1288 // glPixelStorei. So, we have to take that into account both in the fact that |
1289 // the pixels returned from the ReadPixel command will include that padding | 1289 // the pixels returned from the ReadPixel command will include that padding |
1290 // and that when we copy the results to the user's buffer we need to not | 1290 // and that when we copy the results to the user's buffer we need to not |
1291 // write those padding bytes but leave them as they are. | 1291 // write those padding bytes but leave them as they are. |
1292 | 1292 |
1293 GPU_TRACE_EVENT0("gpu", "GLES2::ReadPixels"); | 1293 TRACE_EVENT0("gpu", "GLES2::ReadPixels"); |
1294 typedef gles2::ReadPixels::Result Result; | 1294 typedef gles2::ReadPixels::Result Result; |
1295 Result* result = static_cast<Result*>(result_buffer_); | 1295 Result* result = static_cast<Result*>(result_buffer_); |
1296 int8* dest = reinterpret_cast<int8*>(pixels); | 1296 int8* dest = reinterpret_cast<int8*>(pixels); |
1297 GLsizeiptr max_size = transfer_buffer_.GetLargestFreeOrPendingSize(); | 1297 GLsizeiptr max_size = transfer_buffer_.GetLargestFreeOrPendingSize(); |
1298 uint32 temp_size; | 1298 uint32 temp_size; |
1299 if (!GLES2Util::ComputeImageDataSize( | 1299 if (!GLES2Util::ComputeImageDataSize( |
1300 width, 1, format, type, pack_alignment_, &temp_size)) { | 1300 width, 1, format, type, pack_alignment_, &temp_size)) { |
1301 SetGLError(GL_INVALID_VALUE, "glReadPixels: size too large."); | 1301 SetGLError(GL_INVALID_VALUE, "glReadPixels: size too large."); |
1302 return; | 1302 return; |
1303 } | 1303 } |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 | 1523 |
1524 void GLES2Implementation::GetVertexAttribfv( | 1524 void GLES2Implementation::GetVertexAttribfv( |
1525 GLuint index, GLenum pname, GLfloat* params) { | 1525 GLuint index, GLenum pname, GLfloat* params) { |
1526 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 1526 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
1527 uint32 value = 0; | 1527 uint32 value = 0; |
1528 if (GetVertexAttribHelper(index, pname, &value)) { | 1528 if (GetVertexAttribHelper(index, pname, &value)) { |
1529 *params = static_cast<float>(value); | 1529 *params = static_cast<float>(value); |
1530 return; | 1530 return; |
1531 } | 1531 } |
1532 #endif | 1532 #endif |
1533 GPU_TRACE_EVENT0("gpu", "GLES2::GetVertexAttribfv"); | 1533 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribfv"); |
1534 typedef GetVertexAttribfv::Result Result; | 1534 typedef GetVertexAttribfv::Result Result; |
1535 Result* result = GetResultAs<Result*>(); | 1535 Result* result = GetResultAs<Result*>(); |
1536 result->SetNumResults(0); | 1536 result->SetNumResults(0); |
1537 helper_->GetVertexAttribfv( | 1537 helper_->GetVertexAttribfv( |
1538 index, pname, result_shm_id(), result_shm_offset()); | 1538 index, pname, result_shm_id(), result_shm_offset()); |
1539 WaitForCmd(); | 1539 WaitForCmd(); |
1540 result->CopyResult(params); | 1540 result->CopyResult(params); |
1541 } | 1541 } |
1542 | 1542 |
1543 void GLES2Implementation::GetVertexAttribiv( | 1543 void GLES2Implementation::GetVertexAttribiv( |
1544 GLuint index, GLenum pname, GLint* params) { | 1544 GLuint index, GLenum pname, GLint* params) { |
1545 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 1545 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
1546 uint32 value = 0; | 1546 uint32 value = 0; |
1547 if (GetVertexAttribHelper(index, pname, &value)) { | 1547 if (GetVertexAttribHelper(index, pname, &value)) { |
1548 *params = value; | 1548 *params = value; |
1549 return; | 1549 return; |
1550 } | 1550 } |
1551 #endif | 1551 #endif |
1552 GPU_TRACE_EVENT0("gpu", "GLES2::GetVertexAttribiv"); | 1552 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribiv"); |
1553 typedef GetVertexAttribiv::Result Result; | 1553 typedef GetVertexAttribiv::Result Result; |
1554 Result* result = GetResultAs<Result*>(); | 1554 Result* result = GetResultAs<Result*>(); |
1555 result->SetNumResults(0); | 1555 result->SetNumResults(0); |
1556 helper_->GetVertexAttribiv( | 1556 helper_->GetVertexAttribiv( |
1557 index, pname, result_shm_id(), result_shm_offset()); | 1557 index, pname, result_shm_id(), result_shm_offset()); |
1558 WaitForCmd(); | 1558 WaitForCmd(); |
1559 result->CopyResult(params); | 1559 result->CopyResult(params); |
1560 } | 1560 } |
1561 | 1561 |
1562 GLboolean GLES2Implementation::CommandBufferEnableCHROMIUM( | 1562 GLboolean GLES2Implementation::CommandBufferEnableCHROMIUM( |
1563 const char* feature) { | 1563 const char* feature) { |
1564 GPU_TRACE_EVENT0("gpu", "GLES2::CommandBufferEnableCHROMIUM"); | 1564 TRACE_EVENT0("gpu", "GLES2::CommandBufferEnableCHROMIUM"); |
1565 typedef CommandBufferEnableCHROMIUM::Result Result; | 1565 typedef CommandBufferEnableCHROMIUM::Result Result; |
1566 Result* result = GetResultAs<Result*>(); | 1566 Result* result = GetResultAs<Result*>(); |
1567 *result = 0; | 1567 *result = 0; |
1568 SetBucketAsCString(kResultBucketId, feature); | 1568 SetBucketAsCString(kResultBucketId, feature); |
1569 helper_->CommandBufferEnableCHROMIUM( | 1569 helper_->CommandBufferEnableCHROMIUM( |
1570 kResultBucketId, result_shm_id(), result_shm_offset()); | 1570 kResultBucketId, result_shm_id(), result_shm_offset()); |
1571 WaitForCmd(); | 1571 WaitForCmd(); |
1572 helper_->SetBucketSize(kResultBucketId, 0); | 1572 helper_->SetBucketSize(kResultBucketId, 0); |
1573 return *result; | 1573 return *result; |
1574 } | 1574 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 } | 1700 } |
1701 | 1701 |
1702 void GLES2Implementation::RequestExtensionCHROMIUM(const char* extension) { | 1702 void GLES2Implementation::RequestExtensionCHROMIUM(const char* extension) { |
1703 SetBucketAsCString(kResultBucketId, extension); | 1703 SetBucketAsCString(kResultBucketId, extension); |
1704 helper_->RequestExtensionCHROMIUM(kResultBucketId); | 1704 helper_->RequestExtensionCHROMIUM(kResultBucketId); |
1705 helper_->SetBucketSize(kResultBucketId, 0); | 1705 helper_->SetBucketSize(kResultBucketId, 0); |
1706 } | 1706 } |
1707 | 1707 |
1708 } // namespace gles2 | 1708 } // namespace gles2 |
1709 } // namespace gpu | 1709 } // namespace gpu |
OLD | NEW |