OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 shared_memory_offset_); | 674 shared_memory_offset_); |
675 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 675 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
676 cmd.Init(client_program_id_, | 676 cmd.Init(client_program_id_, |
677 0, | 677 0, |
678 kBucketId, | 678 kBucketId, |
679 shared_memory_id_, | 679 shared_memory_id_, |
680 kInvalidSharedMemoryOffset); | 680 kInvalidSharedMemoryOffset); |
681 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 681 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
682 } | 682 } |
683 | 683 |
| 684 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformBlockivSucceeds) { |
| 685 GetActiveUniformBlockiv cmd; |
| 686 typedef GetActiveUniformBlockiv::Result Result; |
| 687 Result* result = static_cast<Result*>(shared_memory_address_); |
| 688 GLenum kPname[] { |
| 689 GL_UNIFORM_BLOCK_BINDING, |
| 690 GL_UNIFORM_BLOCK_DATA_SIZE, |
| 691 GL_UNIFORM_BLOCK_NAME_LENGTH, |
| 692 GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, |
| 693 GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, |
| 694 GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER, |
| 695 GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER, |
| 696 }; |
| 697 for (size_t ii = 0; ii < arraysize(kPname); ++ii) { |
| 698 result->SetNumResults(0); |
| 699 cmd.Init(client_program_id_, |
| 700 0, |
| 701 kPname[ii], |
| 702 shared_memory_id_, |
| 703 shared_memory_offset_); |
| 704 EXPECT_CALL(*gl_, GetError()) |
| 705 .WillOnce(Return(GL_NO_ERROR)) |
| 706 .WillOnce(Return(GL_NO_ERROR)) |
| 707 .RetiresOnSaturation(); |
| 708 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _)) |
| 709 .WillOnce(SetArgPointee<2>(GL_TRUE)) |
| 710 .RetiresOnSaturation(); |
| 711 if (kPname[ii] == GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) { |
| 712 EXPECT_CALL(*gl_, GetError()) |
| 713 .WillOnce(Return(GL_NO_ERROR)) |
| 714 .RetiresOnSaturation(); |
| 715 EXPECT_CALL(*gl_, |
| 716 GetActiveUniformBlockiv(kServiceProgramId, 0, |
| 717 GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, _)) |
| 718 .WillOnce(SetArgPointee<3>(1)) |
| 719 .RetiresOnSaturation(); |
| 720 } |
| 721 EXPECT_CALL(*gl_, |
| 722 GetActiveUniformBlockiv( |
| 723 kServiceProgramId, 0, kPname[ii], _)) |
| 724 .WillOnce(SetArgPointee<3>(1976)) |
| 725 .RetiresOnSaturation(); |
| 726 decoder_->set_unsafe_es3_apis_enabled(true); |
| 727 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 728 EXPECT_EQ(1, result->GetNumResults()); |
| 729 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 730 EXPECT_EQ(1976, result->GetData()[0]); |
| 731 decoder_->set_unsafe_es3_apis_enabled(false); |
| 732 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); |
| 733 } |
| 734 } |
| 735 |
| 736 TEST_P(GLES2DecoderWithShaderTest, |
| 737 GetActiveUniformBlockivSucceedsZeroUniforms) { |
| 738 GetActiveUniformBlockiv cmd; |
| 739 typedef GetActiveUniformBlockiv::Result Result; |
| 740 Result* result = static_cast<Result*>(shared_memory_address_); |
| 741 result->SetNumResults(0); |
| 742 cmd.Init(client_program_id_, |
| 743 0, |
| 744 GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, |
| 745 shared_memory_id_, |
| 746 shared_memory_offset_); |
| 747 EXPECT_CALL(*gl_, GetError()) |
| 748 .WillOnce(Return(GL_NO_ERROR)) |
| 749 .WillOnce(Return(GL_NO_ERROR)) |
| 750 .WillOnce(Return(GL_NO_ERROR)) |
| 751 .RetiresOnSaturation(); |
| 752 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _)) |
| 753 .WillOnce(SetArgPointee<2>(GL_TRUE)) |
| 754 .RetiresOnSaturation(); |
| 755 EXPECT_CALL(*gl_, |
| 756 GetActiveUniformBlockiv( |
| 757 kServiceProgramId, 0, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, _)) |
| 758 .WillOnce(SetArgPointee<3>(0)) |
| 759 .RetiresOnSaturation(); |
| 760 EXPECT_CALL(*gl_, |
| 761 GetActiveUniformBlockiv(kServiceProgramId, 0, |
| 762 GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, _)) |
| 763 .Times(1) |
| 764 .RetiresOnSaturation(); |
| 765 decoder_->set_unsafe_es3_apis_enabled(true); |
| 766 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 767 EXPECT_EQ(0, result->GetNumResults()); |
| 768 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 769 } |
| 770 |
| 771 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformBlockivUnlinkedProgram) { |
| 772 GetActiveUniformBlockiv cmd; |
| 773 typedef GetActiveUniformBlockiv::Result Result; |
| 774 Result* result = static_cast<Result*>(shared_memory_address_); |
| 775 result->SetNumResults(0); |
| 776 cmd.Init(client_program_id_, |
| 777 0, |
| 778 GL_UNIFORM_BLOCK_BINDING, |
| 779 shared_memory_id_, |
| 780 shared_memory_offset_); |
| 781 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _)) |
| 782 .WillOnce(SetArgPointee<2>(GL_FALSE)) |
| 783 .RetiresOnSaturation(); |
| 784 decoder_->set_unsafe_es3_apis_enabled(true); |
| 785 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 786 EXPECT_EQ(0, result->GetNumResults()); |
| 787 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 788 } |
| 789 |
| 790 TEST_P(GLES2DecoderWithShaderTest, |
| 791 GetActiveUniformBlockivResultNotInitFails) { |
| 792 GetActiveUniformBlockiv cmd; |
| 793 typedef GetActiveUniformBlockiv::Result Result; |
| 794 Result* result = static_cast<Result*>(shared_memory_address_); |
| 795 result->SetNumResults(1); // Should be initialized to 0. |
| 796 cmd.Init(client_program_id_, |
| 797 0, |
| 798 GL_UNIFORM_BLOCK_BINDING, |
| 799 shared_memory_id_, |
| 800 shared_memory_offset_); |
| 801 decoder_->set_unsafe_es3_apis_enabled(true); |
| 802 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _)) |
| 803 .WillOnce(SetArgPointee<2>(GL_TRUE)) |
| 804 .RetiresOnSaturation(); |
| 805 EXPECT_CALL(*gl_, GetError()) |
| 806 .WillOnce(Return(GL_NO_ERROR)) |
| 807 .RetiresOnSaturation(); |
| 808 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 809 } |
| 810 |
| 811 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformBlockivBadProgramFails) { |
| 812 GetActiveUniformBlockiv cmd; |
| 813 typedef GetActiveUniformBlockiv::Result Result; |
| 814 Result* result = static_cast<Result*>(shared_memory_address_); |
| 815 result->SetNumResults(0); |
| 816 cmd.Init(kInvalidClientId, |
| 817 0, |
| 818 GL_UNIFORM_BLOCK_BINDING, |
| 819 shared_memory_id_, |
| 820 shared_memory_offset_); |
| 821 decoder_->set_unsafe_es3_apis_enabled(true); |
| 822 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 823 EXPECT_EQ(0, result->GetNumResults()); |
| 824 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 825 } |
| 826 |
| 827 TEST_P(GLES2DecoderWithShaderTest, |
| 828 GetActiveUniformBlockivBadSharedMemoryFails) { |
| 829 GetActiveUniformBlockiv cmd; |
| 830 decoder_->set_unsafe_es3_apis_enabled(true); |
| 831 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _)) |
| 832 .WillOnce(SetArgPointee<2>(GL_TRUE)) |
| 833 .WillOnce(SetArgPointee<2>(GL_TRUE)) |
| 834 .RetiresOnSaturation(); |
| 835 EXPECT_CALL(*gl_, GetError()) |
| 836 .WillOnce(Return(GL_NO_ERROR)) |
| 837 .WillOnce(Return(GL_NO_ERROR)) |
| 838 .RetiresOnSaturation(); |
| 839 cmd.Init(client_program_id_, |
| 840 0, |
| 841 GL_UNIFORM_BLOCK_BINDING, |
| 842 kInvalidSharedMemoryId, |
| 843 shared_memory_offset_); |
| 844 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 845 cmd.Init(client_program_id_, |
| 846 0, |
| 847 GL_UNIFORM_BLOCK_BINDING, |
| 848 shared_memory_id_, |
| 849 kInvalidSharedMemoryOffset); |
| 850 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
| 851 } |
| 852 |
684 TEST_P(GLES2DecoderWithShaderTest, GetActiveAttribSucceeds) { | 853 TEST_P(GLES2DecoderWithShaderTest, GetActiveAttribSucceeds) { |
685 const GLuint kAttribIndex = 1; | 854 const GLuint kAttribIndex = 1; |
686 const uint32 kBucketId = 123; | 855 const uint32 kBucketId = 123; |
687 GetActiveAttrib cmd; | 856 GetActiveAttrib cmd; |
688 typedef GetActiveAttrib::Result Result; | 857 typedef GetActiveAttrib::Result Result; |
689 Result* result = static_cast<Result*>(shared_memory_address_); | 858 Result* result = static_cast<Result*>(shared_memory_address_); |
690 result->success = 0; | 859 result->success = 0; |
691 cmd.Init(client_program_id_, | 860 cmd.Init(client_program_id_, |
692 kAttribIndex, | 861 kAttribIndex, |
693 kBucketId, | 862 kBucketId, |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 } | 1453 } |
1285 | 1454 |
1286 // TODO(gman): DeleteProgram | 1455 // TODO(gman): DeleteProgram |
1287 | 1456 |
1288 // TODO(gman): UseProgram | 1457 // TODO(gman): UseProgram |
1289 | 1458 |
1290 // TODO(gman): DeleteShader | 1459 // TODO(gman): DeleteShader |
1291 | 1460 |
1292 } // namespace gles2 | 1461 } // namespace gles2 |
1293 } // namespace gpu | 1462 } // namespace gpu |
OLD | NEW |