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