| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Tests for GLES2Implementation. | 5 // Tests for GLES2Implementation. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 8 | 8 |
| 9 #include <GLES2/gl2ext.h> | 9 #include <GLES2/gl2ext.h> |
| 10 #include <GLES2/gl2extchromium.h> | 10 #include <GLES2/gl2extchromium.h> |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 } | 450 } |
| 451 | 451 |
| 452 // Sets the ProgramInfoManager. The manager will be owned | 452 // Sets the ProgramInfoManager. The manager will be owned |
| 453 // by the ShareGroup. | 453 // by the ShareGroup. |
| 454 void SetProgramInfoManager(ProgramInfoManager* manager) { | 454 void SetProgramInfoManager(ProgramInfoManager* manager) { |
| 455 gl_->share_group()->set_program_info_manager(manager); | 455 gl_->share_group()->set_program_info_manager(manager); |
| 456 } | 456 } |
| 457 | 457 |
| 458 int CheckError() { | 458 int CheckError() { |
| 459 ExpectedMemoryInfo result = | 459 ExpectedMemoryInfo result = |
| 460 GetExpectedResultMemory(sizeof(GetError::Result)); | 460 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 461 EXPECT_CALL(*command_buffer(), OnFlush()) | 461 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 462 .WillOnce(SetMemory(result.ptr, GLuint(GL_NO_ERROR))) | 462 .WillOnce(SetMemory(result.ptr, GLuint(GL_NO_ERROR))) |
| 463 .RetiresOnSaturation(); | 463 .RetiresOnSaturation(); |
| 464 return gl_->GetError(); | 464 return gl_->GetError(); |
| 465 } | 465 } |
| 466 | 466 |
| 467 bool GetBucketContents(uint32 bucket_id, std::vector<int8>* data) { | 467 bool GetBucketContents(uint32 bucket_id, std::vector<int8>* data) { |
| 468 return gl_->GetBucketContents(bucket_id, data); | 468 return gl_->GetBucketContents(bucket_id, data); |
| 469 } | 469 } |
| 470 | 470 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 const size_t kPaddedString3Size = | 598 const size_t kPaddedString3Size = |
| 599 transfer_buffer_->RoundToAlignment(kString3Size); | 599 transfer_buffer_->RoundToAlignment(kString3Size); |
| 600 struct Cmds { | 600 struct Cmds { |
| 601 cmd::SetBucketSize set_bucket_size; | 601 cmd::SetBucketSize set_bucket_size; |
| 602 cmd::SetBucketData set_bucket_data1; | 602 cmd::SetBucketData set_bucket_data1; |
| 603 cmd::SetToken set_token1; | 603 cmd::SetToken set_token1; |
| 604 cmd::SetBucketData set_bucket_data2; | 604 cmd::SetBucketData set_bucket_data2; |
| 605 cmd::SetToken set_token2; | 605 cmd::SetToken set_token2; |
| 606 cmd::SetBucketData set_bucket_data3; | 606 cmd::SetBucketData set_bucket_data3; |
| 607 cmd::SetToken set_token3; | 607 cmd::SetToken set_token3; |
| 608 ShaderSourceBucket shader_source_bucket; | 608 cmds::ShaderSourceBucket shader_source_bucket; |
| 609 cmd::SetBucketSize clear_bucket_size; | 609 cmd::SetBucketSize clear_bucket_size; |
| 610 }; | 610 }; |
| 611 | 611 |
| 612 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedString1Size); | 612 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedString1Size); |
| 613 ExpectedMemoryInfo mem2 = GetExpectedMemory(kPaddedString2Size); | 613 ExpectedMemoryInfo mem2 = GetExpectedMemory(kPaddedString2Size); |
| 614 ExpectedMemoryInfo mem3 = GetExpectedMemory(kPaddedString3Size); | 614 ExpectedMemoryInfo mem3 = GetExpectedMemory(kPaddedString3Size); |
| 615 | 615 |
| 616 Cmds expected; | 616 Cmds expected; |
| 617 expected.set_bucket_size.Init(kBucketId, kSourceSize); | 617 expected.set_bucket_size.Init(kBucketId, kSourceSize); |
| 618 expected.set_bucket_data1.Init( | 618 expected.set_bucket_data1.Init( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 635 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 635 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 636 } | 636 } |
| 637 | 637 |
| 638 TEST_F(GLES2ImplementationTest, GetShaderSource) { | 638 TEST_F(GLES2ImplementationTest, GetShaderSource) { |
| 639 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 639 const uint32 kBucketId = GLES2Implementation::kResultBucketId; |
| 640 const GLuint kShaderId = 456; | 640 const GLuint kShaderId = 456; |
| 641 const Str7 kString = {"foobar"}; | 641 const Str7 kString = {"foobar"}; |
| 642 const char kBad = 0x12; | 642 const char kBad = 0x12; |
| 643 struct Cmds { | 643 struct Cmds { |
| 644 cmd::SetBucketSize set_bucket_size1; | 644 cmd::SetBucketSize set_bucket_size1; |
| 645 GetShaderSource get_shader_source; | 645 cmds::GetShaderSource get_shader_source; |
| 646 cmd::GetBucketStart get_bucket_start; | 646 cmd::GetBucketStart get_bucket_start; |
| 647 cmd::SetToken set_token1; | 647 cmd::SetToken set_token1; |
| 648 cmd::SetBucketSize set_bucket_size2; | 648 cmd::SetBucketSize set_bucket_size2; |
| 649 }; | 649 }; |
| 650 | 650 |
| 651 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); | 651 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); |
| 652 ExpectedMemoryInfo result1 = GetExpectedResultMemory(sizeof(uint32)); | 652 ExpectedMemoryInfo result1 = GetExpectedResultMemory(sizeof(uint32)); |
| 653 | 653 |
| 654 Cmds expected; | 654 Cmds expected; |
| 655 expected.set_bucket_size1.Init(kBucketId, 0); | 655 expected.set_bucket_size1.Init(kBucketId, 0); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 677 | 677 |
| 678 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 678 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 679 | 679 |
| 680 TEST_F(GLES2ImplementationTest, DrawArraysClientSideBuffers) { | 680 TEST_F(GLES2ImplementationTest, DrawArraysClientSideBuffers) { |
| 681 static const float verts[][4] = { | 681 static const float verts[][4] = { |
| 682 { 12.0f, 23.0f, 34.0f, 45.0f, }, | 682 { 12.0f, 23.0f, 34.0f, 45.0f, }, |
| 683 { 56.0f, 67.0f, 78.0f, 89.0f, }, | 683 { 56.0f, 67.0f, 78.0f, 89.0f, }, |
| 684 { 13.0f, 24.0f, 35.0f, 46.0f, }, | 684 { 13.0f, 24.0f, 35.0f, 46.0f, }, |
| 685 }; | 685 }; |
| 686 struct Cmds { | 686 struct Cmds { |
| 687 EnableVertexAttribArray enable1; | 687 cmds::EnableVertexAttribArray enable1; |
| 688 EnableVertexAttribArray enable2; | 688 cmds::EnableVertexAttribArray enable2; |
| 689 BindBuffer bind_to_emu; | 689 cmds::BindBuffer bind_to_emu; |
| 690 BufferData set_size; | 690 cmds::BufferData set_size; |
| 691 BufferSubData copy_data1; | 691 cmds::BufferSubData copy_data1; |
| 692 cmd::SetToken set_token1; | 692 cmd::SetToken set_token1; |
| 693 VertexAttribPointer set_pointer1; | 693 cmds::VertexAttribPointer set_pointer1; |
| 694 BufferSubData copy_data2; | 694 cmds::BufferSubData copy_data2; |
| 695 cmd::SetToken set_token2; | 695 cmd::SetToken set_token2; |
| 696 VertexAttribPointer set_pointer2; | 696 cmds::VertexAttribPointer set_pointer2; |
| 697 DrawArrays draw; | 697 cmds::DrawArrays draw; |
| 698 BindBuffer restore; | 698 cmds::BindBuffer restore; |
| 699 }; | 699 }; |
| 700 const GLuint kEmuBufferId = GLES2Implementation::kClientSideArrayId; | 700 const GLuint kEmuBufferId = GLES2Implementation::kClientSideArrayId; |
| 701 const GLuint kAttribIndex1 = 1; | 701 const GLuint kAttribIndex1 = 1; |
| 702 const GLuint kAttribIndex2 = 3; | 702 const GLuint kAttribIndex2 = 3; |
| 703 const GLint kNumComponents1 = 3; | 703 const GLint kNumComponents1 = 3; |
| 704 const GLint kNumComponents2 = 2; | 704 const GLint kNumComponents2 = 2; |
| 705 const GLsizei kClientStride = sizeof(verts[0]); | 705 const GLsizei kClientStride = sizeof(verts[0]); |
| 706 const GLint kFirst = 1; | 706 const GLint kFirst = 1; |
| 707 const GLsizei kCount = 2; | 707 const GLsizei kCount = 2; |
| 708 const GLsizei kSize1 = | 708 const GLsizei kSize1 = |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 743 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 744 } | 744 } |
| 745 | 745 |
| 746 TEST_F(GLES2ImplementationTest, DrawArraysInstancedANGLEClientSideBuffers) { | 746 TEST_F(GLES2ImplementationTest, DrawArraysInstancedANGLEClientSideBuffers) { |
| 747 static const float verts[][4] = { | 747 static const float verts[][4] = { |
| 748 { 12.0f, 23.0f, 34.0f, 45.0f, }, | 748 { 12.0f, 23.0f, 34.0f, 45.0f, }, |
| 749 { 56.0f, 67.0f, 78.0f, 89.0f, }, | 749 { 56.0f, 67.0f, 78.0f, 89.0f, }, |
| 750 { 13.0f, 24.0f, 35.0f, 46.0f, }, | 750 { 13.0f, 24.0f, 35.0f, 46.0f, }, |
| 751 }; | 751 }; |
| 752 struct Cmds { | 752 struct Cmds { |
| 753 EnableVertexAttribArray enable1; | 753 cmds::EnableVertexAttribArray enable1; |
| 754 EnableVertexAttribArray enable2; | 754 cmds::EnableVertexAttribArray enable2; |
| 755 VertexAttribDivisorANGLE divisor; | 755 cmds::VertexAttribDivisorANGLE divisor; |
| 756 BindBuffer bind_to_emu; | 756 cmds::BindBuffer bind_to_emu; |
| 757 BufferData set_size; | 757 cmds::BufferData set_size; |
| 758 BufferSubData copy_data1; | 758 cmds::BufferSubData copy_data1; |
| 759 cmd::SetToken set_token1; | 759 cmd::SetToken set_token1; |
| 760 VertexAttribPointer set_pointer1; | 760 cmds::VertexAttribPointer set_pointer1; |
| 761 BufferSubData copy_data2; | 761 cmds::BufferSubData copy_data2; |
| 762 cmd::SetToken set_token2; | 762 cmd::SetToken set_token2; |
| 763 VertexAttribPointer set_pointer2; | 763 cmds::VertexAttribPointer set_pointer2; |
| 764 DrawArraysInstancedANGLE draw; | 764 cmds::DrawArraysInstancedANGLE draw; |
| 765 BindBuffer restore; | 765 cmds::BindBuffer restore; |
| 766 }; | 766 }; |
| 767 const GLuint kEmuBufferId = GLES2Implementation::kClientSideArrayId; | 767 const GLuint kEmuBufferId = GLES2Implementation::kClientSideArrayId; |
| 768 const GLuint kAttribIndex1 = 1; | 768 const GLuint kAttribIndex1 = 1; |
| 769 const GLuint kAttribIndex2 = 3; | 769 const GLuint kAttribIndex2 = 3; |
| 770 const GLint kNumComponents1 = 3; | 770 const GLint kNumComponents1 = 3; |
| 771 const GLint kNumComponents2 = 2; | 771 const GLint kNumComponents2 = 2; |
| 772 const GLsizei kClientStride = sizeof(verts[0]); | 772 const GLsizei kClientStride = sizeof(verts[0]); |
| 773 const GLint kFirst = 1; | 773 const GLint kFirst = 1; |
| 774 const GLsizei kCount = 2; | 774 const GLsizei kCount = 2; |
| 775 const GLuint kDivisor = 1; | 775 const GLuint kDivisor = 1; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 TEST_F(GLES2ImplementationTest, DrawElementsClientSideBuffers) { | 816 TEST_F(GLES2ImplementationTest, DrawElementsClientSideBuffers) { |
| 817 static const float verts[][4] = { | 817 static const float verts[][4] = { |
| 818 { 12.0f, 23.0f, 34.0f, 45.0f, }, | 818 { 12.0f, 23.0f, 34.0f, 45.0f, }, |
| 819 { 56.0f, 67.0f, 78.0f, 89.0f, }, | 819 { 56.0f, 67.0f, 78.0f, 89.0f, }, |
| 820 { 13.0f, 24.0f, 35.0f, 46.0f, }, | 820 { 13.0f, 24.0f, 35.0f, 46.0f, }, |
| 821 }; | 821 }; |
| 822 static const uint16 indices[] = { | 822 static const uint16 indices[] = { |
| 823 1, 2, | 823 1, 2, |
| 824 }; | 824 }; |
| 825 struct Cmds { | 825 struct Cmds { |
| 826 EnableVertexAttribArray enable1; | 826 cmds::EnableVertexAttribArray enable1; |
| 827 EnableVertexAttribArray enable2; | 827 cmds::EnableVertexAttribArray enable2; |
| 828 BindBuffer bind_to_index_emu; | 828 cmds::BindBuffer bind_to_index_emu; |
| 829 BufferData set_index_size; | 829 cmds::BufferData set_index_size; |
| 830 BufferSubData copy_data0; | 830 cmds::BufferSubData copy_data0; |
| 831 cmd::SetToken set_token0; | 831 cmd::SetToken set_token0; |
| 832 BindBuffer bind_to_emu; | 832 cmds::BindBuffer bind_to_emu; |
| 833 BufferData set_size; | 833 cmds::BufferData set_size; |
| 834 BufferSubData copy_data1; | 834 cmds::BufferSubData copy_data1; |
| 835 cmd::SetToken set_token1; | 835 cmd::SetToken set_token1; |
| 836 VertexAttribPointer set_pointer1; | 836 cmds::VertexAttribPointer set_pointer1; |
| 837 BufferSubData copy_data2; | 837 cmds::BufferSubData copy_data2; |
| 838 cmd::SetToken set_token2; | 838 cmd::SetToken set_token2; |
| 839 VertexAttribPointer set_pointer2; | 839 cmds::VertexAttribPointer set_pointer2; |
| 840 DrawElements draw; | 840 cmds::DrawElements draw; |
| 841 BindBuffer restore; | 841 cmds::BindBuffer restore; |
| 842 BindBuffer restore_element; | 842 cmds::BindBuffer restore_element; |
| 843 }; | 843 }; |
| 844 const GLsizei kIndexSize = sizeof(indices); | 844 const GLsizei kIndexSize = sizeof(indices); |
| 845 const GLuint kEmuBufferId = GLES2Implementation::kClientSideArrayId; | 845 const GLuint kEmuBufferId = GLES2Implementation::kClientSideArrayId; |
| 846 const GLuint kEmuIndexBufferId = | 846 const GLuint kEmuIndexBufferId = |
| 847 GLES2Implementation::kClientSideElementArrayId; | 847 GLES2Implementation::kClientSideElementArrayId; |
| 848 const GLuint kAttribIndex1 = 1; | 848 const GLuint kAttribIndex1 = 1; |
| 849 const GLuint kAttribIndex2 = 3; | 849 const GLuint kAttribIndex2 = 3; |
| 850 const GLint kNumComponents1 = 3; | 850 const GLint kNumComponents1 = 3; |
| 851 const GLint kNumComponents2 = 2; | 851 const GLint kNumComponents2 = 2; |
| 852 const GLsizei kClientStride = sizeof(verts[0]); | 852 const GLsizei kClientStride = sizeof(verts[0]); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 TEST_F(GLES2ImplementationTest, DrawElementsClientSideBuffersIndexUint) { | 900 TEST_F(GLES2ImplementationTest, DrawElementsClientSideBuffersIndexUint) { |
| 901 static const float verts[][4] = { | 901 static const float verts[][4] = { |
| 902 { 12.0f, 23.0f, 34.0f, 45.0f, }, | 902 { 12.0f, 23.0f, 34.0f, 45.0f, }, |
| 903 { 56.0f, 67.0f, 78.0f, 89.0f, }, | 903 { 56.0f, 67.0f, 78.0f, 89.0f, }, |
| 904 { 13.0f, 24.0f, 35.0f, 46.0f, }, | 904 { 13.0f, 24.0f, 35.0f, 46.0f, }, |
| 905 }; | 905 }; |
| 906 static const uint32 indices[] = { | 906 static const uint32 indices[] = { |
| 907 1, 2, | 907 1, 2, |
| 908 }; | 908 }; |
| 909 struct Cmds { | 909 struct Cmds { |
| 910 EnableVertexAttribArray enable1; | 910 cmds::EnableVertexAttribArray enable1; |
| 911 EnableVertexAttribArray enable2; | 911 cmds::EnableVertexAttribArray enable2; |
| 912 BindBuffer bind_to_index_emu; | 912 cmds::BindBuffer bind_to_index_emu; |
| 913 BufferData set_index_size; | 913 cmds::BufferData set_index_size; |
| 914 BufferSubData copy_data0; | 914 cmds::BufferSubData copy_data0; |
| 915 cmd::SetToken set_token0; | 915 cmd::SetToken set_token0; |
| 916 BindBuffer bind_to_emu; | 916 cmds::BindBuffer bind_to_emu; |
| 917 BufferData set_size; | 917 cmds::BufferData set_size; |
| 918 BufferSubData copy_data1; | 918 cmds::BufferSubData copy_data1; |
| 919 cmd::SetToken set_token1; | 919 cmd::SetToken set_token1; |
| 920 VertexAttribPointer set_pointer1; | 920 cmds::VertexAttribPointer set_pointer1; |
| 921 BufferSubData copy_data2; | 921 cmds::BufferSubData copy_data2; |
| 922 cmd::SetToken set_token2; | 922 cmd::SetToken set_token2; |
| 923 VertexAttribPointer set_pointer2; | 923 cmds::VertexAttribPointer set_pointer2; |
| 924 DrawElements draw; | 924 cmds::DrawElements draw; |
| 925 BindBuffer restore; | 925 cmds::BindBuffer restore; |
| 926 BindBuffer restore_element; | 926 cmds::BindBuffer restore_element; |
| 927 }; | 927 }; |
| 928 const GLsizei kIndexSize = sizeof(indices); | 928 const GLsizei kIndexSize = sizeof(indices); |
| 929 const GLuint kEmuBufferId = GLES2Implementation::kClientSideArrayId; | 929 const GLuint kEmuBufferId = GLES2Implementation::kClientSideArrayId; |
| 930 const GLuint kEmuIndexBufferId = | 930 const GLuint kEmuIndexBufferId = |
| 931 GLES2Implementation::kClientSideElementArrayId; | 931 GLES2Implementation::kClientSideElementArrayId; |
| 932 const GLuint kAttribIndex1 = 1; | 932 const GLuint kAttribIndex1 = 1; |
| 933 const GLuint kAttribIndex2 = 3; | 933 const GLuint kAttribIndex2 = 3; |
| 934 const GLint kNumComponents1 = 3; | 934 const GLint kNumComponents1 = 3; |
| 935 const GLint kNumComponents2 = 2; | 935 const GLint kNumComponents2 = 2; |
| 936 const GLsizei kClientStride = sizeof(verts[0]); | 936 const GLsizei kClientStride = sizeof(verts[0]); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 TEST_F(GLES2ImplementationTest, | 1016 TEST_F(GLES2ImplementationTest, |
| 1017 DrawElementsClientSideBuffersServiceSideIndices) { | 1017 DrawElementsClientSideBuffersServiceSideIndices) { |
| 1018 static const float verts[][4] = { | 1018 static const float verts[][4] = { |
| 1019 { 12.0f, 23.0f, 34.0f, 45.0f, }, | 1019 { 12.0f, 23.0f, 34.0f, 45.0f, }, |
| 1020 { 56.0f, 67.0f, 78.0f, 89.0f, }, | 1020 { 56.0f, 67.0f, 78.0f, 89.0f, }, |
| 1021 { 13.0f, 24.0f, 35.0f, 46.0f, }, | 1021 { 13.0f, 24.0f, 35.0f, 46.0f, }, |
| 1022 }; | 1022 }; |
| 1023 struct Cmds { | 1023 struct Cmds { |
| 1024 EnableVertexAttribArray enable1; | 1024 cmds::EnableVertexAttribArray enable1; |
| 1025 EnableVertexAttribArray enable2; | 1025 cmds::EnableVertexAttribArray enable2; |
| 1026 BindBuffer bind_to_index; | 1026 cmds::BindBuffer bind_to_index; |
| 1027 GetMaxValueInBufferCHROMIUM get_max; | 1027 cmds::GetMaxValueInBufferCHROMIUM get_max; |
| 1028 BindBuffer bind_to_emu; | 1028 cmds::BindBuffer bind_to_emu; |
| 1029 BufferData set_size; | 1029 cmds::BufferData set_size; |
| 1030 BufferSubData copy_data1; | 1030 cmds::BufferSubData copy_data1; |
| 1031 cmd::SetToken set_token1; | 1031 cmd::SetToken set_token1; |
| 1032 VertexAttribPointer set_pointer1; | 1032 cmds::VertexAttribPointer set_pointer1; |
| 1033 BufferSubData copy_data2; | 1033 cmds::BufferSubData copy_data2; |
| 1034 cmd::SetToken set_token2; | 1034 cmd::SetToken set_token2; |
| 1035 VertexAttribPointer set_pointer2; | 1035 cmds::VertexAttribPointer set_pointer2; |
| 1036 DrawElements draw; | 1036 cmds::DrawElements draw; |
| 1037 BindBuffer restore; | 1037 cmds::BindBuffer restore; |
| 1038 }; | 1038 }; |
| 1039 const GLuint kEmuBufferId = GLES2Implementation::kClientSideArrayId; | 1039 const GLuint kEmuBufferId = GLES2Implementation::kClientSideArrayId; |
| 1040 const GLuint kClientIndexBufferId = 0x789; | 1040 const GLuint kClientIndexBufferId = 0x789; |
| 1041 const GLuint kIndexOffset = 0x40; | 1041 const GLuint kIndexOffset = 0x40; |
| 1042 const GLuint kMaxIndex = 2; | 1042 const GLuint kMaxIndex = 2; |
| 1043 const GLuint kAttribIndex1 = 1; | 1043 const GLuint kAttribIndex1 = 1; |
| 1044 const GLuint kAttribIndex2 = 3; | 1044 const GLuint kAttribIndex2 = 3; |
| 1045 const GLint kNumComponents1 = 3; | 1045 const GLint kNumComponents1 = 3; |
| 1046 const GLint kNumComponents2 = 2; | 1046 const GLint kNumComponents2 = 2; |
| 1047 const GLsizei kClientStride = sizeof(verts[0]); | 1047 const GLsizei kClientStride = sizeof(verts[0]); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 TEST_F(GLES2ImplementationTest, DrawElementsInstancedANGLEClientSideBuffers) { | 1099 TEST_F(GLES2ImplementationTest, DrawElementsInstancedANGLEClientSideBuffers) { |
| 1100 static const float verts[][4] = { | 1100 static const float verts[][4] = { |
| 1101 { 12.0f, 23.0f, 34.0f, 45.0f, }, | 1101 { 12.0f, 23.0f, 34.0f, 45.0f, }, |
| 1102 { 56.0f, 67.0f, 78.0f, 89.0f, }, | 1102 { 56.0f, 67.0f, 78.0f, 89.0f, }, |
| 1103 { 13.0f, 24.0f, 35.0f, 46.0f, }, | 1103 { 13.0f, 24.0f, 35.0f, 46.0f, }, |
| 1104 }; | 1104 }; |
| 1105 static const uint16 indices[] = { | 1105 static const uint16 indices[] = { |
| 1106 1, 2, | 1106 1, 2, |
| 1107 }; | 1107 }; |
| 1108 struct Cmds { | 1108 struct Cmds { |
| 1109 EnableVertexAttribArray enable1; | 1109 cmds::EnableVertexAttribArray enable1; |
| 1110 EnableVertexAttribArray enable2; | 1110 cmds::EnableVertexAttribArray enable2; |
| 1111 VertexAttribDivisorANGLE divisor; | 1111 cmds::VertexAttribDivisorANGLE divisor; |
| 1112 BindBuffer bind_to_index_emu; | 1112 cmds::BindBuffer bind_to_index_emu; |
| 1113 BufferData set_index_size; | 1113 cmds::BufferData set_index_size; |
| 1114 BufferSubData copy_data0; | 1114 cmds::BufferSubData copy_data0; |
| 1115 cmd::SetToken set_token0; | 1115 cmd::SetToken set_token0; |
| 1116 BindBuffer bind_to_emu; | 1116 cmds::BindBuffer bind_to_emu; |
| 1117 BufferData set_size; | 1117 cmds::BufferData set_size; |
| 1118 BufferSubData copy_data1; | 1118 cmds::BufferSubData copy_data1; |
| 1119 cmd::SetToken set_token1; | 1119 cmd::SetToken set_token1; |
| 1120 VertexAttribPointer set_pointer1; | 1120 cmds::VertexAttribPointer set_pointer1; |
| 1121 BufferSubData copy_data2; | 1121 cmds::BufferSubData copy_data2; |
| 1122 cmd::SetToken set_token2; | 1122 cmd::SetToken set_token2; |
| 1123 VertexAttribPointer set_pointer2; | 1123 cmds::VertexAttribPointer set_pointer2; |
| 1124 DrawElementsInstancedANGLE draw; | 1124 cmds::DrawElementsInstancedANGLE draw; |
| 1125 BindBuffer restore; | 1125 cmds::BindBuffer restore; |
| 1126 BindBuffer restore_element; | 1126 cmds::BindBuffer restore_element; |
| 1127 }; | 1127 }; |
| 1128 const GLsizei kIndexSize = sizeof(indices); | 1128 const GLsizei kIndexSize = sizeof(indices); |
| 1129 const GLuint kEmuBufferId = GLES2Implementation::kClientSideArrayId; | 1129 const GLuint kEmuBufferId = GLES2Implementation::kClientSideArrayId; |
| 1130 const GLuint kEmuIndexBufferId = | 1130 const GLuint kEmuIndexBufferId = |
| 1131 GLES2Implementation::kClientSideElementArrayId; | 1131 GLES2Implementation::kClientSideElementArrayId; |
| 1132 const GLuint kAttribIndex1 = 1; | 1132 const GLuint kAttribIndex1 = 1; |
| 1133 const GLuint kAttribIndex2 = 3; | 1133 const GLuint kAttribIndex2 = 3; |
| 1134 const GLint kNumComponents1 = 3; | 1134 const GLint kNumComponents1 = 3; |
| 1135 const GLint kNumComponents2 = 2; | 1135 const GLint kNumComponents2 = 2; |
| 1136 const GLsizei kClientStride = sizeof(verts[0]); | 1136 const GLsizei kClientStride = sizeof(verts[0]); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 const GLuint kAttribIndex2 = 3; | 1191 const GLuint kAttribIndex2 = 3; |
| 1192 const GLint kNumComponents1 = 3; | 1192 const GLint kNumComponents1 = 3; |
| 1193 const GLint kNumComponents2 = 2; | 1193 const GLint kNumComponents2 = 2; |
| 1194 const GLsizei kStride1 = 12; | 1194 const GLsizei kStride1 = 12; |
| 1195 const GLsizei kStride2 = 0; | 1195 const GLsizei kStride2 = 0; |
| 1196 const GLuint kBufferId = 0x123; | 1196 const GLuint kBufferId = 0x123; |
| 1197 const GLint kOffset2 = 0x456; | 1197 const GLint kOffset2 = 0x456; |
| 1198 | 1198 |
| 1199 // It's all cached on the client side so no get commands are issued. | 1199 // It's all cached on the client side so no get commands are issued. |
| 1200 struct Cmds { | 1200 struct Cmds { |
| 1201 BindBuffer bind; | 1201 cmds::BindBuffer bind; |
| 1202 VertexAttribPointer set_pointer; | 1202 cmds::VertexAttribPointer set_pointer; |
| 1203 }; | 1203 }; |
| 1204 | 1204 |
| 1205 Cmds expected; | 1205 Cmds expected; |
| 1206 expected.bind.Init(GL_ARRAY_BUFFER, kBufferId); | 1206 expected.bind.Init(GL_ARRAY_BUFFER, kBufferId); |
| 1207 expected.set_pointer.Init(kAttribIndex2, kNumComponents2, GL_FLOAT, GL_FALSE, | 1207 expected.set_pointer.Init(kAttribIndex2, kNumComponents2, GL_FLOAT, GL_FALSE, |
| 1208 kStride2, kOffset2); | 1208 kStride2, kOffset2); |
| 1209 | 1209 |
| 1210 // Set one client side buffer. | 1210 // Set one client side buffer. |
| 1211 gl_->VertexAttribPointer(kAttribIndex1, kNumComponents1, | 1211 gl_->VertexAttribPointer(kAttribIndex1, kNumComponents1, |
| 1212 GL_FLOAT, GL_FALSE, kStride1, verts); | 1212 GL_FLOAT, GL_FALSE, kStride1, verts); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1236 const GLint kNumComponents1 = 3; | 1236 const GLint kNumComponents1 = 3; |
| 1237 const GLint kNumComponents2 = 2; | 1237 const GLint kNumComponents2 = 2; |
| 1238 const GLsizei kStride1 = 12; | 1238 const GLsizei kStride1 = 12; |
| 1239 const GLsizei kStride2 = 0; | 1239 const GLsizei kStride2 = 0; |
| 1240 const GLuint kBufferId = 0x123; | 1240 const GLuint kBufferId = 0x123; |
| 1241 const GLint kOffset2 = 0x456; | 1241 const GLint kOffset2 = 0x456; |
| 1242 | 1242 |
| 1243 // Only one set and one get because the client side buffer's info is stored | 1243 // Only one set and one get because the client side buffer's info is stored |
| 1244 // on the client side. | 1244 // on the client side. |
| 1245 struct Cmds { | 1245 struct Cmds { |
| 1246 EnableVertexAttribArray enable; | 1246 cmds::EnableVertexAttribArray enable; |
| 1247 BindBuffer bind; | 1247 cmds::BindBuffer bind; |
| 1248 VertexAttribPointer set_pointer; | 1248 cmds::VertexAttribPointer set_pointer; |
| 1249 GetVertexAttribfv get2; // for getting the value from attrib1 | 1249 cmds::GetVertexAttribfv get2; // for getting the value from attrib1 |
| 1250 }; | 1250 }; |
| 1251 | 1251 |
| 1252 ExpectedMemoryInfo mem2 = GetExpectedResultMemory(16); | 1252 ExpectedMemoryInfo mem2 = GetExpectedResultMemory(16); |
| 1253 | 1253 |
| 1254 Cmds expected; | 1254 Cmds expected; |
| 1255 expected.enable.Init(kAttribIndex1); | 1255 expected.enable.Init(kAttribIndex1); |
| 1256 expected.bind.Init(GL_ARRAY_BUFFER, kBufferId); | 1256 expected.bind.Init(GL_ARRAY_BUFFER, kBufferId); |
| 1257 expected.set_pointer.Init(kAttribIndex2, kNumComponents2, GL_FLOAT, GL_FALSE, | 1257 expected.set_pointer.Init(kAttribIndex2, kNumComponents2, GL_FLOAT, GL_FALSE, |
| 1258 kStride2, kOffset2); | 1258 kStride2, kOffset2); |
| 1259 expected.get2.Init(kAttribIndex1, | 1259 expected.get2.Init(kAttribIndex1, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 EXPECT_EQ(GL_FLOAT, type); | 1312 EXPECT_EQ(GL_FLOAT, type); |
| 1313 EXPECT_EQ(GL_FALSE, normalized); | 1313 EXPECT_EQ(GL_FALSE, normalized); |
| 1314 EXPECT_EQ(0, memcmp(¤t_attrib, ¤t, sizeof(current_attrib))); | 1314 EXPECT_EQ(0, memcmp(¤t_attrib, ¤t, sizeof(current_attrib))); |
| 1315 | 1315 |
| 1316 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1316 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1317 } | 1317 } |
| 1318 | 1318 |
| 1319 TEST_F(GLES2ImplementationTest, ReservedIds) { | 1319 TEST_F(GLES2ImplementationTest, ReservedIds) { |
| 1320 // Only the get error command should be issued. | 1320 // Only the get error command should be issued. |
| 1321 struct Cmds { | 1321 struct Cmds { |
| 1322 GetError get; | 1322 cmds::GetError get; |
| 1323 }; | 1323 }; |
| 1324 Cmds expected; | 1324 Cmds expected; |
| 1325 | 1325 |
| 1326 ExpectedMemoryInfo mem1 = GetExpectedResultMemory(sizeof(GetError::Result)); | 1326 ExpectedMemoryInfo mem1 = GetExpectedResultMemory( |
| 1327 sizeof(cmds::GetError::Result)); |
| 1327 | 1328 |
| 1328 expected.get.Init(mem1.id, mem1.offset); | 1329 expected.get.Init(mem1.id, mem1.offset); |
| 1329 | 1330 |
| 1330 // One call to flush to wait for GetError | 1331 // One call to flush to wait for GetError |
| 1331 EXPECT_CALL(*command_buffer(), OnFlush()) | 1332 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 1332 .WillOnce(SetMemory(mem1.ptr, GLuint(GL_NO_ERROR))) | 1333 .WillOnce(SetMemory(mem1.ptr, GLuint(GL_NO_ERROR))) |
| 1333 .RetiresOnSaturation(); | 1334 .RetiresOnSaturation(); |
| 1334 | 1335 |
| 1335 gl_->BindBuffer( | 1336 gl_->BindBuffer( |
| 1336 GL_ARRAY_BUFFER, | 1337 GL_ARRAY_BUFFER, |
| 1337 GLES2Implementation::kClientSideArrayId); | 1338 GLES2Implementation::kClientSideArrayId); |
| 1338 gl_->BindBuffer( | 1339 gl_->BindBuffer( |
| 1339 GL_ARRAY_BUFFER, | 1340 GL_ARRAY_BUFFER, |
| 1340 GLES2Implementation::kClientSideElementArrayId); | 1341 GLES2Implementation::kClientSideElementArrayId); |
| 1341 GLenum err = gl_->GetError(); | 1342 GLenum err = gl_->GetError(); |
| 1342 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), err); | 1343 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), err); |
| 1343 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1344 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1344 } | 1345 } |
| 1345 | 1346 |
| 1346 #endif // defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 1347 #endif // defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 1347 | 1348 |
| 1348 TEST_F(GLES2ImplementationTest, ReadPixels2Reads) { | 1349 TEST_F(GLES2ImplementationTest, ReadPixels2Reads) { |
| 1349 struct Cmds { | 1350 struct Cmds { |
| 1350 ReadPixels read1; | 1351 cmds::ReadPixels read1; |
| 1351 cmd::SetToken set_token1; | 1352 cmd::SetToken set_token1; |
| 1352 ReadPixels read2; | 1353 cmds::ReadPixels read2; |
| 1353 cmd::SetToken set_token2; | 1354 cmd::SetToken set_token2; |
| 1354 }; | 1355 }; |
| 1355 const GLint kBytesPerPixel = 4; | 1356 const GLint kBytesPerPixel = 4; |
| 1356 const GLint kWidth = | 1357 const GLint kWidth = |
| 1357 (kTransferBufferSize - GLES2Implementation::kStartingOffset) / | 1358 (kTransferBufferSize - GLES2Implementation::kStartingOffset) / |
| 1358 kBytesPerPixel; | 1359 kBytesPerPixel; |
| 1359 const GLint kHeight = 2; | 1360 const GLint kHeight = 2; |
| 1360 const GLenum kFormat = GL_RGBA; | 1361 const GLenum kFormat = GL_RGBA; |
| 1361 const GLenum kType = GL_UNSIGNED_BYTE; | 1362 const GLenum kType = GL_UNSIGNED_BYTE; |
| 1362 | 1363 |
| 1363 ExpectedMemoryInfo mem1 = | 1364 ExpectedMemoryInfo mem1 = |
| 1364 GetExpectedMemory(kWidth * kHeight / 2 * kBytesPerPixel); | 1365 GetExpectedMemory(kWidth * kHeight / 2 * kBytesPerPixel); |
| 1365 ExpectedMemoryInfo result1 = | 1366 ExpectedMemoryInfo result1 = |
| 1366 GetExpectedResultMemory(sizeof(ReadPixels::Result)); | 1367 GetExpectedResultMemory(sizeof(cmds::ReadPixels::Result)); |
| 1367 ExpectedMemoryInfo mem2 = | 1368 ExpectedMemoryInfo mem2 = |
| 1368 GetExpectedMemory(kWidth * kHeight / 2 * kBytesPerPixel); | 1369 GetExpectedMemory(kWidth * kHeight / 2 * kBytesPerPixel); |
| 1369 ExpectedMemoryInfo result2 = | 1370 ExpectedMemoryInfo result2 = |
| 1370 GetExpectedResultMemory(sizeof(ReadPixels::Result)); | 1371 GetExpectedResultMemory(sizeof(cmds::ReadPixels::Result)); |
| 1371 | 1372 |
| 1372 Cmds expected; | 1373 Cmds expected; |
| 1373 expected.read1.Init( | 1374 expected.read1.Init( |
| 1374 0, 0, kWidth, kHeight / 2, kFormat, kType, | 1375 0, 0, kWidth, kHeight / 2, kFormat, kType, |
| 1375 mem1.id, mem1.offset, result1.id, result1.offset); | 1376 mem1.id, mem1.offset, result1.id, result1.offset); |
| 1376 expected.set_token1.Init(GetNextToken()); | 1377 expected.set_token1.Init(GetNextToken()); |
| 1377 expected.read2.Init( | 1378 expected.read2.Init( |
| 1378 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, | 1379 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType, |
| 1379 mem2.id, mem2.offset, result2.id, result2.offset); | 1380 mem2.id, mem2.offset, result2.id, result2.offset); |
| 1380 expected.set_token2.Init(GetNextToken()); | 1381 expected.set_token2.Init(GetNextToken()); |
| 1381 scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); | 1382 scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); |
| 1382 | 1383 |
| 1383 EXPECT_CALL(*command_buffer(), OnFlush()) | 1384 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 1384 .WillOnce(SetMemory(result1.ptr, static_cast<uint32>(1))) | 1385 .WillOnce(SetMemory(result1.ptr, static_cast<uint32>(1))) |
| 1385 .WillOnce(SetMemory(result2.ptr, static_cast<uint32>(1))) | 1386 .WillOnce(SetMemory(result2.ptr, static_cast<uint32>(1))) |
| 1386 .RetiresOnSaturation(); | 1387 .RetiresOnSaturation(); |
| 1387 | 1388 |
| 1388 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); | 1389 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); |
| 1389 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1390 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1390 } | 1391 } |
| 1391 | 1392 |
| 1392 TEST_F(GLES2ImplementationTest, ReadPixelsBadFormatType) { | 1393 TEST_F(GLES2ImplementationTest, ReadPixelsBadFormatType) { |
| 1393 struct Cmds { | 1394 struct Cmds { |
| 1394 ReadPixels read; | 1395 cmds::ReadPixels read; |
| 1395 cmd::SetToken set_token; | 1396 cmd::SetToken set_token; |
| 1396 }; | 1397 }; |
| 1397 const GLint kBytesPerPixel = 4; | 1398 const GLint kBytesPerPixel = 4; |
| 1398 const GLint kWidth = 2; | 1399 const GLint kWidth = 2; |
| 1399 const GLint kHeight = 2; | 1400 const GLint kHeight = 2; |
| 1400 const GLenum kFormat = 0; | 1401 const GLenum kFormat = 0; |
| 1401 const GLenum kType = 0; | 1402 const GLenum kType = 0; |
| 1402 | 1403 |
| 1403 ExpectedMemoryInfo mem1 = | 1404 ExpectedMemoryInfo mem1 = |
| 1404 GetExpectedMemory(kWidth * kHeight * kBytesPerPixel); | 1405 GetExpectedMemory(kWidth * kHeight * kBytesPerPixel); |
| 1405 ExpectedMemoryInfo result1 = | 1406 ExpectedMemoryInfo result1 = |
| 1406 GetExpectedResultMemory(sizeof(ReadPixels::Result)); | 1407 GetExpectedResultMemory(sizeof(cmds::ReadPixels::Result)); |
| 1407 | 1408 |
| 1408 Cmds expected; | 1409 Cmds expected; |
| 1409 expected.read.Init( | 1410 expected.read.Init( |
| 1410 0, 0, kWidth, kHeight, kFormat, kType, | 1411 0, 0, kWidth, kHeight, kFormat, kType, |
| 1411 mem1.id, mem1.offset, result1.id, result1.offset); | 1412 mem1.id, mem1.offset, result1.id, result1.offset); |
| 1412 expected.set_token.Init(GetNextToken()); | 1413 expected.set_token.Init(GetNextToken()); |
| 1413 scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); | 1414 scoped_array<int8> buffer(new int8[kWidth * kHeight * kBytesPerPixel]); |
| 1414 | 1415 |
| 1415 EXPECT_CALL(*command_buffer(), OnFlush()) | 1416 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 1416 .Times(1) | 1417 .Times(1) |
| 1417 .RetiresOnSaturation(); | 1418 .RetiresOnSaturation(); |
| 1418 | 1419 |
| 1419 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); | 1420 gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get()); |
| 1420 } | 1421 } |
| 1421 | 1422 |
| 1422 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) { | 1423 TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) { |
| 1423 struct Cmds { | 1424 struct Cmds { |
| 1424 BufferSubData buf; | 1425 cmds::BufferSubData buf; |
| 1425 cmd::SetToken set_token; | 1426 cmd::SetToken set_token; |
| 1426 }; | 1427 }; |
| 1427 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; | 1428 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; |
| 1428 const GLintptr kOffset = 15; | 1429 const GLintptr kOffset = 15; |
| 1429 const GLsizeiptr kSize = 16; | 1430 const GLsizeiptr kSize = 16; |
| 1430 | 1431 |
| 1431 ExpectedMemoryInfo mem1 = GetExpectedMemory(kSize); | 1432 ExpectedMemoryInfo mem1 = GetExpectedMemory(kSize); |
| 1432 | 1433 |
| 1433 Cmds expected; | 1434 Cmds expected; |
| 1434 expected.buf.Init( | 1435 expected.buf.Init( |
| 1435 kTarget, kOffset, kSize, mem1.id, mem1.offset); | 1436 kTarget, kOffset, kSize, mem1.id, mem1.offset); |
| 1436 expected.set_token.Init(GetNextToken()); | 1437 expected.set_token.Init(GetNextToken()); |
| 1437 | 1438 |
| 1438 void* mem = gl_->MapBufferSubDataCHROMIUM( | 1439 void* mem = gl_->MapBufferSubDataCHROMIUM( |
| 1439 kTarget, kOffset, kSize, GL_WRITE_ONLY); | 1440 kTarget, kOffset, kSize, GL_WRITE_ONLY); |
| 1440 ASSERT_TRUE(mem != NULL); | 1441 ASSERT_TRUE(mem != NULL); |
| 1441 gl_->UnmapBufferSubDataCHROMIUM(mem); | 1442 gl_->UnmapBufferSubDataCHROMIUM(mem); |
| 1442 EXPECT_CALL(*command_buffer(), DestroyTransferBuffer(_)) | 1443 EXPECT_CALL(*command_buffer(), DestroyTransferBuffer(_)) |
| 1443 .Times(1) | 1444 .Times(1) |
| 1444 .RetiresOnSaturation(); | 1445 .RetiresOnSaturation(); |
| 1445 gl_->FreeUnusedSharedMemory(); | 1446 gl_->FreeUnusedSharedMemory(); |
| 1446 } | 1447 } |
| 1447 | 1448 |
| 1448 TEST_F(GLES2ImplementationTest, MapUnmapBufferSubDataCHROMIUM) { | 1449 TEST_F(GLES2ImplementationTest, MapUnmapBufferSubDataCHROMIUM) { |
| 1449 struct Cmds { | 1450 struct Cmds { |
| 1450 BufferSubData buf; | 1451 cmds::BufferSubData buf; |
| 1451 cmd::SetToken set_token; | 1452 cmd::SetToken set_token; |
| 1452 }; | 1453 }; |
| 1453 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; | 1454 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; |
| 1454 const GLintptr kOffset = 15; | 1455 const GLintptr kOffset = 15; |
| 1455 const GLsizeiptr kSize = 16; | 1456 const GLsizeiptr kSize = 16; |
| 1456 | 1457 |
| 1457 uint32 offset = 0; | 1458 uint32 offset = 0; |
| 1458 Cmds expected; | 1459 Cmds expected; |
| 1459 expected.buf.Init( | 1460 expected.buf.Init( |
| 1460 kTarget, kOffset, kSize, | 1461 kTarget, kOffset, kSize, |
| 1461 command_buffer()->GetNextFreeTransferBufferId(), offset); | 1462 command_buffer()->GetNextFreeTransferBufferId(), offset); |
| 1462 expected.set_token.Init(GetNextToken()); | 1463 expected.set_token.Init(GetNextToken()); |
| 1463 | 1464 |
| 1464 void* mem = gl_->MapBufferSubDataCHROMIUM( | 1465 void* mem = gl_->MapBufferSubDataCHROMIUM( |
| 1465 kTarget, kOffset, kSize, GL_WRITE_ONLY); | 1466 kTarget, kOffset, kSize, GL_WRITE_ONLY); |
| 1466 ASSERT_TRUE(mem != NULL); | 1467 ASSERT_TRUE(mem != NULL); |
| 1467 gl_->UnmapBufferSubDataCHROMIUM(mem); | 1468 gl_->UnmapBufferSubDataCHROMIUM(mem); |
| 1468 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 1469 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 1469 } | 1470 } |
| 1470 | 1471 |
| 1471 TEST_F(GLES2ImplementationTest, MapUnmapBufferSubDataCHROMIUMBadArgs) { | 1472 TEST_F(GLES2ImplementationTest, MapUnmapBufferSubDataCHROMIUMBadArgs) { |
| 1472 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; | 1473 const GLenum kTarget = GL_ELEMENT_ARRAY_BUFFER; |
| 1473 const GLintptr kOffset = 15; | 1474 const GLintptr kOffset = 15; |
| 1474 const GLsizeiptr kSize = 16; | 1475 const GLsizeiptr kSize = 16; |
| 1475 | 1476 |
| 1476 ExpectedMemoryInfo result1 = | 1477 ExpectedMemoryInfo result1 = |
| 1477 GetExpectedResultMemory(sizeof(GetError::Result)); | 1478 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1478 ExpectedMemoryInfo result2 = | 1479 ExpectedMemoryInfo result2 = |
| 1479 GetExpectedResultMemory(sizeof(GetError::Result)); | 1480 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1480 ExpectedMemoryInfo result3 = | 1481 ExpectedMemoryInfo result3 = |
| 1481 GetExpectedResultMemory(sizeof(GetError::Result)); | 1482 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1482 ExpectedMemoryInfo result4 = | 1483 ExpectedMemoryInfo result4 = |
| 1483 GetExpectedResultMemory(sizeof(GetError::Result)); | 1484 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1484 | 1485 |
| 1485 // Calls to flush to wait for GetError | 1486 // Calls to flush to wait for GetError |
| 1486 EXPECT_CALL(*command_buffer(), OnFlush()) | 1487 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 1487 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR))) | 1488 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR))) |
| 1488 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) | 1489 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) |
| 1489 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR))) | 1490 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR))) |
| 1490 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR))) | 1491 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR))) |
| 1491 .RetiresOnSaturation(); | 1492 .RetiresOnSaturation(); |
| 1492 | 1493 |
| 1493 void* mem; | 1494 void* mem; |
| 1494 mem = gl_->MapBufferSubDataCHROMIUM(kTarget, -1, kSize, GL_WRITE_ONLY); | 1495 mem = gl_->MapBufferSubDataCHROMIUM(kTarget, -1, kSize, GL_WRITE_ONLY); |
| 1495 ASSERT_TRUE(mem == NULL); | 1496 ASSERT_TRUE(mem == NULL); |
| 1496 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); | 1497 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); |
| 1497 mem = gl_->MapBufferSubDataCHROMIUM(kTarget, kOffset, -1, GL_WRITE_ONLY); | 1498 mem = gl_->MapBufferSubDataCHROMIUM(kTarget, kOffset, -1, GL_WRITE_ONLY); |
| 1498 ASSERT_TRUE(mem == NULL); | 1499 ASSERT_TRUE(mem == NULL); |
| 1499 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); | 1500 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); |
| 1500 mem = gl_->MapBufferSubDataCHROMIUM(kTarget, kOffset, kSize, GL_READ_ONLY); | 1501 mem = gl_->MapBufferSubDataCHROMIUM(kTarget, kOffset, kSize, GL_READ_ONLY); |
| 1501 ASSERT_TRUE(mem == NULL); | 1502 ASSERT_TRUE(mem == NULL); |
| 1502 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_ENUM), gl_->GetError()); | 1503 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_ENUM), gl_->GetError()); |
| 1503 const char* kPtr = "something"; | 1504 const char* kPtr = "something"; |
| 1504 gl_->UnmapBufferSubDataCHROMIUM(kPtr); | 1505 gl_->UnmapBufferSubDataCHROMIUM(kPtr); |
| 1505 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); | 1506 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), gl_->GetError()); |
| 1506 } | 1507 } |
| 1507 | 1508 |
| 1508 TEST_F(GLES2ImplementationTest, MapUnmapTexSubImage2DCHROMIUM) { | 1509 TEST_F(GLES2ImplementationTest, MapUnmapTexSubImage2DCHROMIUM) { |
| 1509 struct Cmds { | 1510 struct Cmds { |
| 1510 TexSubImage2D tex; | 1511 cmds::TexSubImage2D tex; |
| 1511 cmd::SetToken set_token; | 1512 cmd::SetToken set_token; |
| 1512 }; | 1513 }; |
| 1513 const GLint kLevel = 1; | 1514 const GLint kLevel = 1; |
| 1514 const GLint kXOffset = 2; | 1515 const GLint kXOffset = 2; |
| 1515 const GLint kYOffset = 3; | 1516 const GLint kYOffset = 3; |
| 1516 const GLint kWidth = 4; | 1517 const GLint kWidth = 4; |
| 1517 const GLint kHeight = 5; | 1518 const GLint kHeight = 5; |
| 1518 const GLenum kFormat = GL_RGBA; | 1519 const GLenum kFormat = GL_RGBA; |
| 1519 const GLenum kType = GL_UNSIGNED_BYTE; | 1520 const GLenum kType = GL_UNSIGNED_BYTE; |
| 1520 | 1521 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1544 TEST_F(GLES2ImplementationTest, MapUnmapTexSubImage2DCHROMIUMBadArgs) { | 1545 TEST_F(GLES2ImplementationTest, MapUnmapTexSubImage2DCHROMIUMBadArgs) { |
| 1545 const GLint kLevel = 1; | 1546 const GLint kLevel = 1; |
| 1546 const GLint kXOffset = 2; | 1547 const GLint kXOffset = 2; |
| 1547 const GLint kYOffset = 3; | 1548 const GLint kYOffset = 3; |
| 1548 const GLint kWidth = 4; | 1549 const GLint kWidth = 4; |
| 1549 const GLint kHeight = 5; | 1550 const GLint kHeight = 5; |
| 1550 const GLenum kFormat = GL_RGBA; | 1551 const GLenum kFormat = GL_RGBA; |
| 1551 const GLenum kType = GL_UNSIGNED_BYTE; | 1552 const GLenum kType = GL_UNSIGNED_BYTE; |
| 1552 | 1553 |
| 1553 ExpectedMemoryInfo result1 = | 1554 ExpectedMemoryInfo result1 = |
| 1554 GetExpectedResultMemory(sizeof(GetError::Result)); | 1555 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1555 ExpectedMemoryInfo result2 = | 1556 ExpectedMemoryInfo result2 = |
| 1556 GetExpectedResultMemory(sizeof(GetError::Result)); | 1557 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1557 ExpectedMemoryInfo result3 = | 1558 ExpectedMemoryInfo result3 = |
| 1558 GetExpectedResultMemory(sizeof(GetError::Result)); | 1559 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1559 ExpectedMemoryInfo result4 = | 1560 ExpectedMemoryInfo result4 = |
| 1560 GetExpectedResultMemory(sizeof(GetError::Result)); | 1561 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1561 ExpectedMemoryInfo result5 = | 1562 ExpectedMemoryInfo result5 = |
| 1562 GetExpectedResultMemory(sizeof(GetError::Result)); | 1563 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1563 ExpectedMemoryInfo result6 = | 1564 ExpectedMemoryInfo result6 = |
| 1564 GetExpectedResultMemory(sizeof(GetError::Result)); | 1565 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1565 ExpectedMemoryInfo result7 = | 1566 ExpectedMemoryInfo result7 = |
| 1566 GetExpectedResultMemory(sizeof(GetError::Result)); | 1567 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1567 | 1568 |
| 1568 // Calls to flush to wait for GetError | 1569 // Calls to flush to wait for GetError |
| 1569 EXPECT_CALL(*command_buffer(), OnFlush()) | 1570 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 1570 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR))) | 1571 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR))) |
| 1571 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) | 1572 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) |
| 1572 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR))) | 1573 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR))) |
| 1573 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR))) | 1574 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR))) |
| 1574 .WillOnce(SetMemory(result5.ptr, GLuint(GL_NO_ERROR))) | 1575 .WillOnce(SetMemory(result5.ptr, GLuint(GL_NO_ERROR))) |
| 1575 .WillOnce(SetMemory(result6.ptr, GLuint(GL_NO_ERROR))) | 1576 .WillOnce(SetMemory(result6.ptr, GLuint(GL_NO_ERROR))) |
| 1576 .WillOnce(SetMemory(result7.ptr, GLuint(GL_NO_ERROR))) | 1577 .WillOnce(SetMemory(result7.ptr, GLuint(GL_NO_ERROR))) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1656 | 1657 |
| 1657 TEST_F(GLES2ImplementationTest, GetMultipleIntegervCHROMIUMValidArgs) { | 1658 TEST_F(GLES2ImplementationTest, GetMultipleIntegervCHROMIUMValidArgs) { |
| 1658 const GLenum pnames[] = { | 1659 const GLenum pnames[] = { |
| 1659 GL_DEPTH_WRITEMASK, | 1660 GL_DEPTH_WRITEMASK, |
| 1660 GL_COLOR_WRITEMASK, | 1661 GL_COLOR_WRITEMASK, |
| 1661 GL_STENCIL_WRITEMASK, | 1662 GL_STENCIL_WRITEMASK, |
| 1662 }; | 1663 }; |
| 1663 const GLint num_results = 6; | 1664 const GLint num_results = 6; |
| 1664 GLint results[num_results + 1]; | 1665 GLint results[num_results + 1]; |
| 1665 struct Cmds { | 1666 struct Cmds { |
| 1666 GetMultipleIntegervCHROMIUM get_multiple; | 1667 cmds::GetMultipleIntegervCHROMIUM get_multiple; |
| 1667 cmd::SetToken set_token; | 1668 cmd::SetToken set_token; |
| 1668 }; | 1669 }; |
| 1669 const GLsizei kNumPnames = arraysize(pnames); | 1670 const GLsizei kNumPnames = arraysize(pnames); |
| 1670 const GLsizeiptr kResultsSize = num_results * sizeof(results[0]); | 1671 const GLsizeiptr kResultsSize = num_results * sizeof(results[0]); |
| 1671 const size_t kPNamesSize = kNumPnames * sizeof(pnames[0]); | 1672 const size_t kPNamesSize = kNumPnames * sizeof(pnames[0]); |
| 1672 | 1673 |
| 1673 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPNamesSize + kResultsSize); | 1674 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPNamesSize + kResultsSize); |
| 1674 ExpectedMemoryInfo result1 = GetExpectedResultMemory( | 1675 ExpectedMemoryInfo result1 = GetExpectedResultMemory( |
| 1675 sizeof(GetError::Result)); | 1676 sizeof(cmds::GetError::Result)); |
| 1676 | 1677 |
| 1677 const uint32 kPnamesOffset = mem1.offset; | 1678 const uint32 kPnamesOffset = mem1.offset; |
| 1678 const uint32 kResultsOffset = mem1.offset + kPNamesSize; | 1679 const uint32 kResultsOffset = mem1.offset + kPNamesSize; |
| 1679 Cmds expected; | 1680 Cmds expected; |
| 1680 expected.get_multiple.Init( | 1681 expected.get_multiple.Init( |
| 1681 mem1.id, kPnamesOffset, kNumPnames, | 1682 mem1.id, kPnamesOffset, kNumPnames, |
| 1682 mem1.id, kResultsOffset, kResultsSize); | 1683 mem1.id, kResultsOffset, kResultsSize); |
| 1683 expected.set_token.Init(GetNextToken()); | 1684 expected.set_token.Init(GetNextToken()); |
| 1684 | 1685 |
| 1685 const GLint kSentinel = 0x12345678; | 1686 const GLint kSentinel = 0x12345678; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1708 GL_DEPTH_WRITEMASK, | 1709 GL_DEPTH_WRITEMASK, |
| 1709 GL_COLOR_WRITEMASK, | 1710 GL_COLOR_WRITEMASK, |
| 1710 GL_STENCIL_WRITEMASK, | 1711 GL_STENCIL_WRITEMASK, |
| 1711 }; | 1712 }; |
| 1712 const GLint num_results = 6; | 1713 const GLint num_results = 6; |
| 1713 GLint results[num_results + 1]; | 1714 GLint results[num_results + 1]; |
| 1714 const GLsizei kNumPnames = arraysize(pnames); | 1715 const GLsizei kNumPnames = arraysize(pnames); |
| 1715 const GLsizeiptr kResultsSize = num_results * sizeof(results[0]); | 1716 const GLsizeiptr kResultsSize = num_results * sizeof(results[0]); |
| 1716 | 1717 |
| 1717 ExpectedMemoryInfo result1 = | 1718 ExpectedMemoryInfo result1 = |
| 1718 GetExpectedResultMemory(sizeof(GetError::Result)); | 1719 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1719 ExpectedMemoryInfo result2 = | 1720 ExpectedMemoryInfo result2 = |
| 1720 GetExpectedResultMemory(sizeof(GetError::Result)); | 1721 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1721 ExpectedMemoryInfo result3 = | 1722 ExpectedMemoryInfo result3 = |
| 1722 GetExpectedResultMemory(sizeof(GetError::Result)); | 1723 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1723 ExpectedMemoryInfo result4 = | 1724 ExpectedMemoryInfo result4 = |
| 1724 GetExpectedResultMemory(sizeof(GetError::Result)); | 1725 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1725 | 1726 |
| 1726 // Calls to flush to wait for GetError | 1727 // Calls to flush to wait for GetError |
| 1727 EXPECT_CALL(*command_buffer(), OnFlush()) | 1728 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 1728 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR))) | 1729 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR))) |
| 1729 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) | 1730 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) |
| 1730 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR))) | 1731 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR))) |
| 1731 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR))) | 1732 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR))) |
| 1732 .RetiresOnSaturation(); | 1733 .RetiresOnSaturation(); |
| 1733 | 1734 |
| 1734 const GLint kSentinel = 0x12345678; | 1735 const GLint kSentinel = 0x12345678; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1776 const char kBad = 0x12; | 1777 const char kBad = 0x12; |
| 1777 GLsizei size = 0; | 1778 GLsizei size = 0; |
| 1778 const Str7 kString = {"foobar"}; | 1779 const Str7 kString = {"foobar"}; |
| 1779 char buf[20]; | 1780 char buf[20]; |
| 1780 | 1781 |
| 1781 ExpectedMemoryInfo mem1 = | 1782 ExpectedMemoryInfo mem1 = |
| 1782 GetExpectedMemory(MaxTransferBufferSize()); | 1783 GetExpectedMemory(MaxTransferBufferSize()); |
| 1783 ExpectedMemoryInfo result1 = | 1784 ExpectedMemoryInfo result1 = |
| 1784 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); | 1785 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); |
| 1785 ExpectedMemoryInfo result2 = | 1786 ExpectedMemoryInfo result2 = |
| 1786 GetExpectedResultMemory(sizeof(GetError::Result)); | 1787 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1787 | 1788 |
| 1788 memset(buf, kBad, sizeof(buf)); | 1789 memset(buf, kBad, sizeof(buf)); |
| 1789 EXPECT_CALL(*command_buffer(), OnFlush()) | 1790 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 1790 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))), | 1791 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))), |
| 1791 SetMemory(mem1.ptr, kString))) | 1792 SetMemory(mem1.ptr, kString))) |
| 1792 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) | 1793 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) |
| 1793 .RetiresOnSaturation(); | 1794 .RetiresOnSaturation(); |
| 1794 | 1795 |
| 1795 struct Cmds { | 1796 struct Cmds { |
| 1796 cmd::SetBucketSize set_bucket_size1; | 1797 cmd::SetBucketSize set_bucket_size1; |
| 1797 GetProgramInfoCHROMIUM get_program_info; | 1798 cmds::GetProgramInfoCHROMIUM get_program_info; |
| 1798 cmd::GetBucketStart get_bucket_start; | 1799 cmd::GetBucketStart get_bucket_start; |
| 1799 cmd::SetToken set_token1; | 1800 cmd::SetToken set_token1; |
| 1800 cmd::SetBucketSize set_bucket_size2; | 1801 cmd::SetBucketSize set_bucket_size2; |
| 1801 }; | 1802 }; |
| 1802 Cmds expected; | 1803 Cmds expected; |
| 1803 expected.set_bucket_size1.Init(kBucketId, 0); | 1804 expected.set_bucket_size1.Init(kBucketId, 0); |
| 1804 expected.get_program_info.Init(kProgramId, kBucketId); | 1805 expected.get_program_info.Init(kProgramId, kBucketId); |
| 1805 expected.get_bucket_start.Init( | 1806 expected.get_bucket_start.Init( |
| 1806 kBucketId, result1.id, result1.offset, | 1807 kBucketId, result1.id, result1.offset, |
| 1807 MaxTransferBufferSize(), mem1.id, mem1.offset); | 1808 MaxTransferBufferSize(), mem1.id, mem1.offset); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1819 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 1820 const uint32 kBucketId = GLES2Implementation::kResultBucketId; |
| 1820 const GLuint kProgramId = 123; | 1821 const GLuint kProgramId = 123; |
| 1821 GLsizei size = 0; | 1822 GLsizei size = 0; |
| 1822 const Str7 kString = {"foobar"}; | 1823 const Str7 kString = {"foobar"}; |
| 1823 char buf[20]; | 1824 char buf[20]; |
| 1824 | 1825 |
| 1825 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); | 1826 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); |
| 1826 ExpectedMemoryInfo result1 = | 1827 ExpectedMemoryInfo result1 = |
| 1827 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); | 1828 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); |
| 1828 ExpectedMemoryInfo result2 = | 1829 ExpectedMemoryInfo result2 = |
| 1829 GetExpectedResultMemory(sizeof(GetError::Result)); | 1830 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1830 ExpectedMemoryInfo result3 = | 1831 ExpectedMemoryInfo result3 = |
| 1831 GetExpectedResultMemory(sizeof(GetError::Result)); | 1832 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1832 ExpectedMemoryInfo result4 = | 1833 ExpectedMemoryInfo result4 = |
| 1833 GetExpectedResultMemory(sizeof(GetError::Result)); | 1834 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1834 | 1835 |
| 1835 EXPECT_CALL(*command_buffer(), OnFlush()) | 1836 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 1836 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))), | 1837 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))), |
| 1837 SetMemory(mem1.ptr, kString))) | 1838 SetMemory(mem1.ptr, kString))) |
| 1838 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) | 1839 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) |
| 1839 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR))) | 1840 .WillOnce(SetMemory(result3.ptr, GLuint(GL_NO_ERROR))) |
| 1840 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR))) | 1841 .WillOnce(SetMemory(result4.ptr, GLuint(GL_NO_ERROR))) |
| 1841 .RetiresOnSaturation(); | 1842 .RetiresOnSaturation(); |
| 1842 | 1843 |
| 1843 // try bufsize not big enough. | 1844 // try bufsize not big enough. |
| 1844 struct Cmds { | 1845 struct Cmds { |
| 1845 cmd::SetBucketSize set_bucket_size1; | 1846 cmd::SetBucketSize set_bucket_size1; |
| 1846 GetProgramInfoCHROMIUM get_program_info; | 1847 cmds::GetProgramInfoCHROMIUM get_program_info; |
| 1847 cmd::GetBucketStart get_bucket_start; | 1848 cmd::GetBucketStart get_bucket_start; |
| 1848 cmd::SetToken set_token1; | 1849 cmd::SetToken set_token1; |
| 1849 cmd::SetBucketSize set_bucket_size2; | 1850 cmd::SetBucketSize set_bucket_size2; |
| 1850 }; | 1851 }; |
| 1851 Cmds expected; | 1852 Cmds expected; |
| 1852 expected.set_bucket_size1.Init(kBucketId, 0); | 1853 expected.set_bucket_size1.Init(kBucketId, 0); |
| 1853 expected.get_program_info.Init(kProgramId, kBucketId); | 1854 expected.get_program_info.Init(kProgramId, kBucketId); |
| 1854 expected.get_bucket_start.Init( | 1855 expected.get_bucket_start.Init( |
| 1855 kBucketId, result1.id, result1.offset, | 1856 kBucketId, result1.id, result1.offset, |
| 1856 MaxTransferBufferSize(), mem1.id, mem1.offset); | 1857 MaxTransferBufferSize(), mem1.id, mem1.offset); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 size_t num_pairs = sizeof(pairs) / sizeof(pairs[0]); | 1903 size_t num_pairs = sizeof(pairs) / sizeof(pairs[0]); |
| 1903 for (size_t ii = 0; ii < num_pairs; ++ii) { | 1904 for (size_t ii = 0; ii < num_pairs; ++ii) { |
| 1904 const PNameValue& pv = pairs[ii]; | 1905 const PNameValue& pv = pairs[ii]; |
| 1905 GLint v = -1; | 1906 GLint v = -1; |
| 1906 gl_->GetIntegerv(pv.pname, &v); | 1907 gl_->GetIntegerv(pv.pname, &v); |
| 1907 EXPECT_TRUE(NoCommandsWritten()); | 1908 EXPECT_TRUE(NoCommandsWritten()); |
| 1908 EXPECT_EQ(pv.expected, v); | 1909 EXPECT_EQ(pv.expected, v); |
| 1909 } | 1910 } |
| 1910 | 1911 |
| 1911 ExpectedMemoryInfo result1 = | 1912 ExpectedMemoryInfo result1 = |
| 1912 GetExpectedResultMemory(sizeof(GetError::Result)); | 1913 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1913 | 1914 |
| 1914 EXPECT_CALL(*command_buffer(), OnFlush()) | 1915 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 1915 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR))) | 1916 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR))) |
| 1916 .RetiresOnSaturation(); | 1917 .RetiresOnSaturation(); |
| 1917 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); | 1918 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); |
| 1918 } | 1919 } |
| 1919 | 1920 |
| 1920 TEST_F(GLES2ImplementationTest, GetIntegerCacheWrite) { | 1921 TEST_F(GLES2ImplementationTest, GetIntegerCacheWrite) { |
| 1921 struct PNameValue { | 1922 struct PNameValue { |
| 1922 GLenum pname; | 1923 GLenum pname; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1941 }; | 1942 }; |
| 1942 size_t num_pairs = sizeof(pairs) / sizeof(pairs[0]); | 1943 size_t num_pairs = sizeof(pairs) / sizeof(pairs[0]); |
| 1943 for (size_t ii = 0; ii < num_pairs; ++ii) { | 1944 for (size_t ii = 0; ii < num_pairs; ++ii) { |
| 1944 const PNameValue& pv = pairs[ii]; | 1945 const PNameValue& pv = pairs[ii]; |
| 1945 GLint v = -1; | 1946 GLint v = -1; |
| 1946 gl_->GetIntegerv(pv.pname, &v); | 1947 gl_->GetIntegerv(pv.pname, &v); |
| 1947 EXPECT_EQ(pv.expected, v); | 1948 EXPECT_EQ(pv.expected, v); |
| 1948 } | 1949 } |
| 1949 | 1950 |
| 1950 ExpectedMemoryInfo result1 = | 1951 ExpectedMemoryInfo result1 = |
| 1951 GetExpectedResultMemory(sizeof(GetError::Result)); | 1952 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 1952 | 1953 |
| 1953 EXPECT_CALL(*command_buffer(), OnFlush()) | 1954 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 1954 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR))) | 1955 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR))) |
| 1955 .RetiresOnSaturation(); | 1956 .RetiresOnSaturation(); |
| 1956 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); | 1957 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); |
| 1957 } | 1958 } |
| 1958 | 1959 |
| 1959 static bool CheckRect( | 1960 static bool CheckRect( |
| 1960 int width, int height, GLenum format, GLenum type, int alignment, | 1961 int width, int height, GLenum format, GLenum type, int alignment, |
| 1961 bool flip_y, const uint8* r1, const uint8* r2) { | 1962 bool flip_y, const uint8* r1, const uint8* r2) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1985 | 1986 |
| 1986 ACTION_P8(CheckRectAction, width, height, format, type, alignment, flip_y, | 1987 ACTION_P8(CheckRectAction, width, height, format, type, alignment, flip_y, |
| 1987 r1, r2) { | 1988 r1, r2) { |
| 1988 EXPECT_TRUE(CheckRect( | 1989 EXPECT_TRUE(CheckRect( |
| 1989 width, height, format, type, alignment, flip_y, r1, r2)); | 1990 width, height, format, type, alignment, flip_y, r1, r2)); |
| 1990 } | 1991 } |
| 1991 | 1992 |
| 1992 // Test TexImage2D with and without flip_y | 1993 // Test TexImage2D with and without flip_y |
| 1993 TEST_F(GLES2ImplementationTest, TexImage2D) { | 1994 TEST_F(GLES2ImplementationTest, TexImage2D) { |
| 1994 struct Cmds { | 1995 struct Cmds { |
| 1995 TexImage2D tex_image_2d; | 1996 cmds::TexImage2D tex_image_2d; |
| 1996 cmd::SetToken set_token; | 1997 cmd::SetToken set_token; |
| 1997 }; | 1998 }; |
| 1998 struct Cmds2 { | 1999 struct Cmds2 { |
| 1999 TexImage2D tex_image_2d; | 2000 cmds::TexImage2D tex_image_2d; |
| 2000 cmd::SetToken set_token; | 2001 cmd::SetToken set_token; |
| 2001 }; | 2002 }; |
| 2002 const GLenum kTarget = GL_TEXTURE_2D; | 2003 const GLenum kTarget = GL_TEXTURE_2D; |
| 2003 const GLint kLevel = 0; | 2004 const GLint kLevel = 0; |
| 2004 const GLenum kFormat = GL_RGB; | 2005 const GLenum kFormat = GL_RGB; |
| 2005 const GLsizei kWidth = 3; | 2006 const GLsizei kWidth = 3; |
| 2006 const GLsizei kHeight = 4; | 2007 const GLsizei kHeight = 4; |
| 2007 const GLint kBorder = 0; | 2008 const GLint kBorder = 0; |
| 2008 const GLenum kType = GL_UNSIGNED_BYTE; | 2009 const GLenum kType = GL_UNSIGNED_BYTE; |
| 2009 const GLint kPixelStoreUnpackAlignment = 4; | 2010 const GLint kPixelStoreUnpackAlignment = 4; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2044 pixels); | 2045 pixels); |
| 2045 EXPECT_EQ(0, memcmp(&expected2, commands2, sizeof(expected2))); | 2046 EXPECT_EQ(0, memcmp(&expected2, commands2, sizeof(expected2))); |
| 2046 EXPECT_TRUE(CheckRect( | 2047 EXPECT_TRUE(CheckRect( |
| 2047 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment, true, | 2048 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment, true, |
| 2048 pixels, mem2.ptr)); | 2049 pixels, mem2.ptr)); |
| 2049 } | 2050 } |
| 2050 | 2051 |
| 2051 // Test TexImage2D with 2 writes | 2052 // Test TexImage2D with 2 writes |
| 2052 TEST_F(GLES2ImplementationTest, TexImage2D2Writes) { | 2053 TEST_F(GLES2ImplementationTest, TexImage2D2Writes) { |
| 2053 struct Cmds { | 2054 struct Cmds { |
| 2054 TexImage2D tex_image_2d; | 2055 cmds::TexImage2D tex_image_2d; |
| 2055 TexSubImage2D tex_sub_image_2d1; | 2056 cmds::TexSubImage2D tex_sub_image_2d1; |
| 2056 cmd::SetToken set_token1; | 2057 cmd::SetToken set_token1; |
| 2057 TexSubImage2D tex_sub_image_2d2; | 2058 cmds::TexSubImage2D tex_sub_image_2d2; |
| 2058 cmd::SetToken set_token2; | 2059 cmd::SetToken set_token2; |
| 2059 }; | 2060 }; |
| 2060 const GLenum kTarget = GL_TEXTURE_2D; | 2061 const GLenum kTarget = GL_TEXTURE_2D; |
| 2061 const GLint kLevel = 0; | 2062 const GLint kLevel = 0; |
| 2062 const GLenum kFormat = GL_RGB; | 2063 const GLenum kFormat = GL_RGB; |
| 2063 const GLint kBorder = 0; | 2064 const GLint kBorder = 0; |
| 2064 const GLenum kType = GL_UNSIGNED_BYTE; | 2065 const GLenum kType = GL_UNSIGNED_BYTE; |
| 2065 const GLint kPixelStoreUnpackAlignment = 4; | 2066 const GLint kPixelStoreUnpackAlignment = 4; |
| 2066 const GLsizei kWidth = 3; | 2067 const GLsizei kWidth = 3; |
| 2067 | 2068 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2160 const GLint kSubImageXOffset = 1; | 2161 const GLint kSubImageXOffset = 1; |
| 2161 const GLint kSubImageYOffset = 2; | 2162 const GLint kSubImageYOffset = 2; |
| 2162 const GLenum kFormat = GL_RGBA; | 2163 const GLenum kFormat = GL_RGBA; |
| 2163 const GLenum kType = GL_UNSIGNED_BYTE; | 2164 const GLenum kType = GL_UNSIGNED_BYTE; |
| 2164 const GLenum kTarget = GL_TEXTURE_2D; | 2165 const GLenum kTarget = GL_TEXTURE_2D; |
| 2165 const GLint kLevel = 0; | 2166 const GLint kLevel = 0; |
| 2166 const GLint kBorder = 0; | 2167 const GLint kBorder = 0; |
| 2167 const GLint kPixelStoreUnpackAlignment = 4; | 2168 const GLint kPixelStoreUnpackAlignment = 4; |
| 2168 | 2169 |
| 2169 struct Cmds { | 2170 struct Cmds { |
| 2170 PixelStorei pixel_store_i1; | 2171 cmds::PixelStorei pixel_store_i1; |
| 2171 TexImage2D tex_image_2d; | 2172 cmds::TexImage2D tex_image_2d; |
| 2172 PixelStorei pixel_store_i2; | 2173 cmds::PixelStorei pixel_store_i2; |
| 2173 TexSubImage2D tex_sub_image_2d1; | 2174 cmds::TexSubImage2D tex_sub_image_2d1; |
| 2174 cmd::SetToken set_token1; | 2175 cmd::SetToken set_token1; |
| 2175 TexSubImage2D tex_sub_image_2d2; | 2176 cmds::TexSubImage2D tex_sub_image_2d2; |
| 2176 cmd::SetToken set_token2; | 2177 cmd::SetToken set_token2; |
| 2177 }; | 2178 }; |
| 2178 | 2179 |
| 2179 uint32 sub_2_high_size = 0; | 2180 uint32 sub_2_high_size = 0; |
| 2180 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2181 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2181 kSubImageWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment, | 2182 kSubImageWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment, |
| 2182 &sub_2_high_size, NULL, NULL)); | 2183 &sub_2_high_size, NULL, NULL)); |
| 2183 | 2184 |
| 2184 ExpectedMemoryInfo mem1 = GetExpectedMemory(sub_2_high_size); | 2185 ExpectedMemoryInfo mem1 = GetExpectedMemory(sub_2_high_size); |
| 2185 ExpectedMemoryInfo mem2 = GetExpectedMemory(sub_2_high_size); | 2186 ExpectedMemoryInfo mem2 = GetExpectedMemory(sub_2_high_size); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2239 static const GLint kSrcSubImageWidth = kSrcSubImageX1 - kSrcSubImageX0; | 2240 static const GLint kSrcSubImageWidth = kSrcSubImageX1 - kSrcSubImageX0; |
| 2240 static const GLint kSrcSubImageHeight = kSrcSubImageY1 - kSrcSubImageY0; | 2241 static const GLint kSrcSubImageHeight = kSrcSubImageY1 - kSrcSubImageY0; |
| 2241 | 2242 |
| 2242 // these are only used in the texsubimage tests | 2243 // these are only used in the texsubimage tests |
| 2243 static const GLint kTexWidth = 1023; | 2244 static const GLint kTexWidth = 1023; |
| 2244 static const GLint kTexHeight = 511; | 2245 static const GLint kTexHeight = 511; |
| 2245 static const GLint kTexSubXOffset = 419; | 2246 static const GLint kTexSubXOffset = 419; |
| 2246 static const GLint kTexSubYOffset = 103; | 2247 static const GLint kTexSubYOffset = 103; |
| 2247 | 2248 |
| 2248 struct { | 2249 struct { |
| 2249 PixelStorei pixel_store_i; | 2250 cmds::PixelStorei pixel_store_i; |
| 2250 PixelStorei pixel_store_i2; | 2251 cmds::PixelStorei pixel_store_i2; |
| 2251 TexImage2D tex_image_2d; | 2252 cmds::TexImage2D tex_image_2d; |
| 2252 } texImageExpected; | 2253 } texImageExpected; |
| 2253 | 2254 |
| 2254 struct { | 2255 struct { |
| 2255 PixelStorei pixel_store_i; | 2256 cmds::PixelStorei pixel_store_i; |
| 2256 PixelStorei pixel_store_i2; | 2257 cmds::PixelStorei pixel_store_i2; |
| 2257 TexImage2D tex_image_2d; | 2258 cmds::TexImage2D tex_image_2d; |
| 2258 TexSubImage2D tex_sub_image_2d; | 2259 cmds::TexSubImage2D tex_sub_image_2d; |
| 2259 } texSubImageExpected; | 2260 } texSubImageExpected; |
| 2260 | 2261 |
| 2261 uint32 src_size; | 2262 uint32 src_size; |
| 2262 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( | 2263 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( |
| 2263 kSrcWidth, kSrcSubImageY1, kFormat, kType, 8, &src_size, NULL, NULL)); | 2264 kSrcWidth, kSrcSubImageY1, kFormat, kType, 8, &src_size, NULL, NULL)); |
| 2264 scoped_array<uint8> src_pixels; | 2265 scoped_array<uint8> src_pixels; |
| 2265 src_pixels.reset(new uint8[src_size]); | 2266 src_pixels.reset(new uint8[src_size]); |
| 2266 for (size_t i = 0; i < src_size; ++i) { | 2267 for (size_t i = 0; i < src_size; ++i) { |
| 2267 src_pixels[i] = static_cast<int8>(i); | 2268 src_pixels[i] = static_cast<int8>(i); |
| 2268 } | 2269 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2355 { GL_FRAMEBUFFER_BINDING, 3, }, | 2356 { GL_FRAMEBUFFER_BINDING, 3, }, |
| 2356 { GL_RENDERBUFFER_BINDING, 4, }, | 2357 { GL_RENDERBUFFER_BINDING, 4, }, |
| 2357 { GL_ARRAY_BUFFER_BINDING, 5, }, | 2358 { GL_ARRAY_BUFFER_BINDING, 5, }, |
| 2358 { GL_ELEMENT_ARRAY_BUFFER_BINDING, 6, }, | 2359 { GL_ELEMENT_ARRAY_BUFFER_BINDING, 6, }, |
| 2359 }; | 2360 }; |
| 2360 size_t num_pairs = sizeof(pairs) / sizeof(pairs[0]); | 2361 size_t num_pairs = sizeof(pairs) / sizeof(pairs[0]); |
| 2361 for (size_t ii = 0; ii < num_pairs; ++ii) { | 2362 for (size_t ii = 0; ii < num_pairs; ++ii) { |
| 2362 const PNameValue& pv = pairs[ii]; | 2363 const PNameValue& pv = pairs[ii]; |
| 2363 GLint v = -1; | 2364 GLint v = -1; |
| 2364 ExpectedMemoryInfo result1 = | 2365 ExpectedMemoryInfo result1 = |
| 2365 GetExpectedResultMemory(sizeof(GetIntegerv::Result)); | 2366 GetExpectedResultMemory(sizeof(cmds::GetIntegerv::Result)); |
| 2366 EXPECT_CALL(*command_buffer(), OnFlush()) | 2367 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 2367 .WillOnce(SetMemory(result1.ptr, | 2368 .WillOnce(SetMemory(result1.ptr, |
| 2368 SizedResultHelper<GLuint>(pv.expected))) | 2369 SizedResultHelper<GLuint>(pv.expected))) |
| 2369 .RetiresOnSaturation(); | 2370 .RetiresOnSaturation(); |
| 2370 gl_->GetIntegerv(pv.pname, &v); | 2371 gl_->GetIntegerv(pv.pname, &v); |
| 2371 EXPECT_EQ(pv.expected, v); | 2372 EXPECT_EQ(pv.expected, v); |
| 2372 } | 2373 } |
| 2373 } | 2374 } |
| 2374 | 2375 |
| 2375 TEST_F(GLES2ImplementationTest, CreateStreamTextureCHROMIUM) { | 2376 TEST_F(GLES2ImplementationTest, CreateStreamTextureCHROMIUM) { |
| 2376 const GLuint kTextureId = 123; | 2377 const GLuint kTextureId = 123; |
| 2377 const GLuint kResult = 456; | 2378 const GLuint kResult = 456; |
| 2378 | 2379 |
| 2379 struct Cmds { | 2380 struct Cmds { |
| 2380 CreateStreamTextureCHROMIUM create_stream; | 2381 cmds::CreateStreamTextureCHROMIUM create_stream; |
| 2381 }; | 2382 }; |
| 2382 | 2383 |
| 2383 ExpectedMemoryInfo result1 = | 2384 ExpectedMemoryInfo result1 = |
| 2384 GetExpectedResultMemory(sizeof(CreateStreamTextureCHROMIUM::Result)); | 2385 GetExpectedResultMemory( |
| 2386 sizeof(cmds::CreateStreamTextureCHROMIUM::Result)); |
| 2385 ExpectedMemoryInfo result2 = | 2387 ExpectedMemoryInfo result2 = |
| 2386 GetExpectedResultMemory(sizeof(GetError::Result)); | 2388 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); |
| 2387 | 2389 |
| 2388 Cmds expected; | 2390 Cmds expected; |
| 2389 expected.create_stream.Init(kTextureId, result1.id, result1.offset); | 2391 expected.create_stream.Init(kTextureId, result1.id, result1.offset); |
| 2390 | 2392 |
| 2391 EXPECT_CALL(*command_buffer(), OnFlush()) | 2393 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 2392 .WillOnce(SetMemory(result1.ptr, kResult)) | 2394 .WillOnce(SetMemory(result1.ptr, kResult)) |
| 2393 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) | 2395 .WillOnce(SetMemory(result2.ptr, GLuint(GL_NO_ERROR))) |
| 2394 .RetiresOnSaturation(); | 2396 .RetiresOnSaturation(); |
| 2395 | 2397 |
| 2396 GLuint handle = gl_->CreateStreamTextureCHROMIUM(kTextureId); | 2398 GLuint handle = gl_->CreateStreamTextureCHROMIUM(kTextureId); |
| 2397 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 2399 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2398 EXPECT_EQ(handle, kResult); | 2400 EXPECT_EQ(handle, kResult); |
| 2399 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); | 2401 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); |
| 2400 } | 2402 } |
| 2401 | 2403 |
| 2402 TEST_F(GLES2ImplementationTest, GetString) { | 2404 TEST_F(GLES2ImplementationTest, GetString) { |
| 2403 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 2405 const uint32 kBucketId = GLES2Implementation::kResultBucketId; |
| 2404 const Str7 kString = {"foobar"}; | 2406 const Str7 kString = {"foobar"}; |
| 2405 // GL_CHROMIUM_map_sub GL_CHROMIUM_flipy are hard coded into | 2407 // GL_CHROMIUM_map_sub GL_CHROMIUM_flipy are hard coded into |
| 2406 // GLES2Implementation. | 2408 // GLES2Implementation. |
| 2407 const char* expected_str = | 2409 const char* expected_str = |
| 2408 "foobar " | 2410 "foobar " |
| 2409 "GL_CHROMIUM_flipy " | 2411 "GL_CHROMIUM_flipy " |
| 2410 "GL_CHROMIUM_map_sub " | 2412 "GL_CHROMIUM_map_sub " |
| 2411 "GL_CHROMIUM_shallow_flush " | 2413 "GL_CHROMIUM_shallow_flush " |
| 2412 "GL_EXT_unpack_subimage"; | 2414 "GL_EXT_unpack_subimage"; |
| 2413 const char kBad = 0x12; | 2415 const char kBad = 0x12; |
| 2414 struct Cmds { | 2416 struct Cmds { |
| 2415 cmd::SetBucketSize set_bucket_size1; | 2417 cmd::SetBucketSize set_bucket_size1; |
| 2416 GetString get_string; | 2418 cmds::GetString get_string; |
| 2417 cmd::GetBucketStart get_bucket_start; | 2419 cmd::GetBucketStart get_bucket_start; |
| 2418 cmd::SetToken set_token1; | 2420 cmd::SetToken set_token1; |
| 2419 cmd::SetBucketSize set_bucket_size2; | 2421 cmd::SetBucketSize set_bucket_size2; |
| 2420 }; | 2422 }; |
| 2421 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); | 2423 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); |
| 2422 ExpectedMemoryInfo result1 = | 2424 ExpectedMemoryInfo result1 = |
| 2423 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); | 2425 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); |
| 2424 Cmds expected; | 2426 Cmds expected; |
| 2425 expected.set_bucket_size1.Init(kBucketId, 0); | 2427 expected.set_bucket_size1.Init(kBucketId, 0); |
| 2426 expected.get_string.Init(GL_EXTENSIONS, kBucketId); | 2428 expected.get_string.Init(GL_EXTENSIONS, kBucketId); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2440 const GLubyte* result = gl_->GetString(GL_EXTENSIONS); | 2442 const GLubyte* result = gl_->GetString(GL_EXTENSIONS); |
| 2441 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 2443 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2442 EXPECT_STREQ(expected_str, reinterpret_cast<const char*>(result)); | 2444 EXPECT_STREQ(expected_str, reinterpret_cast<const char*>(result)); |
| 2443 } | 2445 } |
| 2444 | 2446 |
| 2445 TEST_F(GLES2ImplementationTest, PixelStoreiGLPackReverseRowOrderANGLE) { | 2447 TEST_F(GLES2ImplementationTest, PixelStoreiGLPackReverseRowOrderANGLE) { |
| 2446 const uint32 kBucketId = GLES2Implementation::kResultBucketId; | 2448 const uint32 kBucketId = GLES2Implementation::kResultBucketId; |
| 2447 const Str7 kString = {"foobar"}; | 2449 const Str7 kString = {"foobar"}; |
| 2448 struct Cmds { | 2450 struct Cmds { |
| 2449 cmd::SetBucketSize set_bucket_size1; | 2451 cmd::SetBucketSize set_bucket_size1; |
| 2450 GetString get_string; | 2452 cmds::GetString get_string; |
| 2451 cmd::GetBucketStart get_bucket_start; | 2453 cmd::GetBucketStart get_bucket_start; |
| 2452 cmd::SetToken set_token1; | 2454 cmd::SetToken set_token1; |
| 2453 cmd::SetBucketSize set_bucket_size2; | 2455 cmd::SetBucketSize set_bucket_size2; |
| 2454 PixelStorei pixel_store; | 2456 cmds::PixelStorei pixel_store; |
| 2455 }; | 2457 }; |
| 2456 | 2458 |
| 2457 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); | 2459 ExpectedMemoryInfo mem1 = GetExpectedMemory(MaxTransferBufferSize()); |
| 2458 ExpectedMemoryInfo result1 = | 2460 ExpectedMemoryInfo result1 = |
| 2459 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); | 2461 GetExpectedResultMemory(sizeof(cmd::GetBucketStart::Result)); |
| 2460 | 2462 |
| 2461 Cmds expected; | 2463 Cmds expected; |
| 2462 expected.set_bucket_size1.Init(kBucketId, 0); | 2464 expected.set_bucket_size1.Init(kBucketId, 0); |
| 2463 expected.get_string.Init(GL_EXTENSIONS, kBucketId); | 2465 expected.get_string.Init(GL_EXTENSIONS, kBucketId); |
| 2464 expected.get_bucket_start.Init( | 2466 expected.get_bucket_start.Init( |
| 2465 kBucketId, result1.id, result1.offset, | 2467 kBucketId, result1.id, result1.offset, |
| 2466 MaxTransferBufferSize(), mem1.id, mem1.offset); | 2468 MaxTransferBufferSize(), mem1.id, mem1.offset); |
| 2467 expected.set_token1.Init(GetNextToken()); | 2469 expected.set_token1.Init(GetNextToken()); |
| 2468 expected.set_bucket_size2.Init(kBucketId, 0); | 2470 expected.set_bucket_size2.Init(kBucketId, 0); |
| 2469 expected.pixel_store.Init(GL_PACK_REVERSE_ROW_ORDER_ANGLE, 1); | 2471 expected.pixel_store.Init(GL_PACK_REVERSE_ROW_ORDER_ANGLE, 1); |
| 2470 | 2472 |
| 2471 EXPECT_CALL(*command_buffer(), OnFlush()) | 2473 EXPECT_CALL(*command_buffer(), OnFlush()) |
| 2472 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))), | 2474 .WillOnce(DoAll(SetMemory(result1.ptr, uint32(sizeof(kString))), |
| 2473 SetMemory(mem1.ptr, kString))) | 2475 SetMemory(mem1.ptr, kString))) |
| 2474 .RetiresOnSaturation(); | 2476 .RetiresOnSaturation(); |
| 2475 | 2477 |
| 2476 gl_->PixelStorei(GL_PACK_REVERSE_ROW_ORDER_ANGLE, 1); | 2478 gl_->PixelStorei(GL_PACK_REVERSE_ROW_ORDER_ANGLE, 1); |
| 2477 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 2479 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2478 } | 2480 } |
| 2479 | 2481 |
| 2480 TEST_F(GLES2ImplementationTest, CreateProgram) { | 2482 TEST_F(GLES2ImplementationTest, CreateProgram) { |
| 2481 struct Cmds { | 2483 struct Cmds { |
| 2482 CreateProgram cmd; | 2484 cmds::CreateProgram cmd; |
| 2483 }; | 2485 }; |
| 2484 | 2486 |
| 2485 Cmds expected; | 2487 Cmds expected; |
| 2486 expected.cmd.Init(kProgramsAndShadersStartId); | 2488 expected.cmd.Init(kProgramsAndShadersStartId); |
| 2487 GLuint id = gl_->CreateProgram(); | 2489 GLuint id = gl_->CreateProgram(); |
| 2488 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 2490 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2489 EXPECT_EQ(kProgramsAndShadersStartId, id); | 2491 EXPECT_EQ(kProgramsAndShadersStartId, id); |
| 2490 } | 2492 } |
| 2491 | 2493 |
| 2492 TEST_F(GLES2ImplementationTest, BufferDataLargerThanTransferBuffer) { | 2494 TEST_F(GLES2ImplementationTest, BufferDataLargerThanTransferBuffer) { |
| 2493 struct Cmds { | 2495 struct Cmds { |
| 2494 BufferData set_size; | 2496 cmds::BufferData set_size; |
| 2495 BufferSubData copy_data1; | 2497 cmds::BufferSubData copy_data1; |
| 2496 cmd::SetToken set_token1; | 2498 cmd::SetToken set_token1; |
| 2497 BufferSubData copy_data2; | 2499 cmds::BufferSubData copy_data2; |
| 2498 cmd::SetToken set_token2; | 2500 cmd::SetToken set_token2; |
| 2499 }; | 2501 }; |
| 2500 const unsigned kUsableSize = | 2502 const unsigned kUsableSize = |
| 2501 kTransferBufferSize - GLES2Implementation::kStartingOffset; | 2503 kTransferBufferSize - GLES2Implementation::kStartingOffset; |
| 2502 uint8 buf[kUsableSize * 2] = { 0, }; | 2504 uint8 buf[kUsableSize * 2] = { 0, }; |
| 2503 | 2505 |
| 2504 ExpectedMemoryInfo mem1 = GetExpectedMemory(kUsableSize); | 2506 ExpectedMemoryInfo mem1 = GetExpectedMemory(kUsableSize); |
| 2505 ExpectedMemoryInfo mem2 = GetExpectedMemory(kUsableSize); | 2507 ExpectedMemoryInfo mem2 = GetExpectedMemory(kUsableSize); |
| 2506 | 2508 |
| 2507 Cmds expected; | 2509 Cmds expected; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2523 GL_BLEND, | 2525 GL_BLEND, |
| 2524 GL_CULL_FACE, | 2526 GL_CULL_FACE, |
| 2525 GL_DEPTH_TEST, | 2527 GL_DEPTH_TEST, |
| 2526 GL_POLYGON_OFFSET_FILL, | 2528 GL_POLYGON_OFFSET_FILL, |
| 2527 GL_SAMPLE_ALPHA_TO_COVERAGE, | 2529 GL_SAMPLE_ALPHA_TO_COVERAGE, |
| 2528 GL_SAMPLE_COVERAGE, | 2530 GL_SAMPLE_COVERAGE, |
| 2529 GL_SCISSOR_TEST, | 2531 GL_SCISSOR_TEST, |
| 2530 GL_STENCIL_TEST, | 2532 GL_STENCIL_TEST, |
| 2531 }; | 2533 }; |
| 2532 struct Cmds { | 2534 struct Cmds { |
| 2533 Enable enable_cmd; | 2535 cmds::Enable enable_cmd; |
| 2534 }; | 2536 }; |
| 2535 Cmds expected; | 2537 Cmds expected; |
| 2536 | 2538 |
| 2537 for (size_t ii = 0; ii < arraysize(kStates); ++ii) { | 2539 for (size_t ii = 0; ii < arraysize(kStates); ++ii) { |
| 2538 GLenum state = kStates[ii]; | 2540 GLenum state = kStates[ii]; |
| 2539 expected.enable_cmd.Init(state); | 2541 expected.enable_cmd.Init(state); |
| 2540 GLboolean result = gl_->IsEnabled(state); | 2542 GLboolean result = gl_->IsEnabled(state); |
| 2541 EXPECT_EQ(static_cast<GLboolean>(ii == 0), result); | 2543 EXPECT_EQ(static_cast<GLboolean>(ii == 0), result); |
| 2542 EXPECT_TRUE(NoCommandsWritten()); | 2544 EXPECT_TRUE(NoCommandsWritten()); |
| 2543 const void* commands = GetPut(); | 2545 const void* commands = GetPut(); |
| 2544 if (!result) { | 2546 if (!result) { |
| 2545 gl_->Enable(state); | 2547 gl_->Enable(state); |
| 2546 EXPECT_EQ(0, memcmp(&expected, commands, sizeof(expected))); | 2548 EXPECT_EQ(0, memcmp(&expected, commands, sizeof(expected))); |
| 2547 } | 2549 } |
| 2548 ClearCommands(); | 2550 ClearCommands(); |
| 2549 result = gl_->IsEnabled(state); | 2551 result = gl_->IsEnabled(state); |
| 2550 EXPECT_TRUE(result); | 2552 EXPECT_TRUE(result); |
| 2551 EXPECT_TRUE(NoCommandsWritten()); | 2553 EXPECT_TRUE(NoCommandsWritten()); |
| 2552 } | 2554 } |
| 2553 } | 2555 } |
| 2554 | 2556 |
| 2555 TEST_F(GLES2ImplementationTest, BindVertexArrayOES) { | 2557 TEST_F(GLES2ImplementationTest, BindVertexArrayOES) { |
| 2556 GLuint id = 0; | 2558 GLuint id = 0; |
| 2557 gl_->GenVertexArraysOES(1, &id); | 2559 gl_->GenVertexArraysOES(1, &id); |
| 2558 ClearCommands(); | 2560 ClearCommands(); |
| 2559 | 2561 |
| 2560 struct Cmds { | 2562 struct Cmds { |
| 2561 BindVertexArrayOES cmd; | 2563 cmds::BindVertexArrayOES cmd; |
| 2562 }; | 2564 }; |
| 2563 Cmds expected; | 2565 Cmds expected; |
| 2564 expected.cmd.Init(id); | 2566 expected.cmd.Init(id); |
| 2565 | 2567 |
| 2566 const void* commands = GetPut(); | 2568 const void* commands = GetPut(); |
| 2567 gl_->BindVertexArrayOES(id); | 2569 gl_->BindVertexArrayOES(id); |
| 2568 EXPECT_EQ(0, memcmp(&expected, commands, sizeof(expected))); | 2570 EXPECT_EQ(0, memcmp(&expected, commands, sizeof(expected))); |
| 2569 ClearCommands(); | 2571 ClearCommands(); |
| 2570 gl_->BindVertexArrayOES(id); | 2572 gl_->BindVertexArrayOES(id); |
| 2571 EXPECT_TRUE(NoCommandsWritten()); | 2573 EXPECT_TRUE(NoCommandsWritten()); |
| 2572 } | 2574 } |
| 2573 | 2575 |
| 2574 TEST_F(GLES2ImplementationTest, BeginEndQueryEXT) { | 2576 TEST_F(GLES2ImplementationTest, BeginEndQueryEXT) { |
| 2575 // Test GetQueryivEXT returns 0 if no current query. | 2577 // Test GetQueryivEXT returns 0 if no current query. |
| 2576 GLint param = -1; | 2578 GLint param = -1; |
| 2577 gl_->GetQueryivEXT(GL_ANY_SAMPLES_PASSED_EXT, GL_CURRENT_QUERY_EXT, ¶m); | 2579 gl_->GetQueryivEXT(GL_ANY_SAMPLES_PASSED_EXT, GL_CURRENT_QUERY_EXT, ¶m); |
| 2578 EXPECT_EQ(0, param); | 2580 EXPECT_EQ(0, param); |
| 2579 | 2581 |
| 2580 GLuint expected_ids[2] = { 1, 2 }; // These must match what's actually genned. | 2582 GLuint expected_ids[2] = { 1, 2 }; // These must match what's actually genned. |
| 2581 struct GenCmds { | 2583 struct GenCmds { |
| 2582 GenQueriesEXTImmediate gen; | 2584 cmds::GenQueriesEXTImmediate gen; |
| 2583 GLuint data[2]; | 2585 GLuint data[2]; |
| 2584 }; | 2586 }; |
| 2585 GenCmds expected_gen_cmds; | 2587 GenCmds expected_gen_cmds; |
| 2586 expected_gen_cmds.gen.Init(arraysize(expected_ids), &expected_ids[0]); | 2588 expected_gen_cmds.gen.Init(arraysize(expected_ids), &expected_ids[0]); |
| 2587 GLuint ids[arraysize(expected_ids)] = { 0, }; | 2589 GLuint ids[arraysize(expected_ids)] = { 0, }; |
| 2588 gl_->GenQueriesEXT(arraysize(expected_ids), &ids[0]); | 2590 gl_->GenQueriesEXT(arraysize(expected_ids), &ids[0]); |
| 2589 EXPECT_EQ(0, memcmp( | 2591 EXPECT_EQ(0, memcmp( |
| 2590 &expected_gen_cmds, commands_, sizeof(expected_gen_cmds))); | 2592 &expected_gen_cmds, commands_, sizeof(expected_gen_cmds))); |
| 2591 GLuint id1 = ids[0]; | 2593 GLuint id1 = ids[0]; |
| 2592 GLuint id2 = ids[1]; | 2594 GLuint id2 = ids[1]; |
| 2593 ClearCommands(); | 2595 ClearCommands(); |
| 2594 | 2596 |
| 2595 // Test BeginQueryEXT fails if id = 0. | 2597 // Test BeginQueryEXT fails if id = 0. |
| 2596 gl_->BeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, 0); | 2598 gl_->BeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, 0); |
| 2597 EXPECT_TRUE(NoCommandsWritten()); | 2599 EXPECT_TRUE(NoCommandsWritten()); |
| 2598 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); | 2600 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); |
| 2599 | 2601 |
| 2600 // Test BeginQueryEXT fails if id not GENed. | 2602 // Test BeginQueryEXT fails if id not GENed. |
| 2601 // TODO(gman): | 2603 // TODO(gman): |
| 2602 | 2604 |
| 2603 // Test BeginQueryEXT inserts command. | 2605 // Test BeginQueryEXT inserts command. |
| 2604 struct BeginCmds { | 2606 struct BeginCmds { |
| 2605 BeginQueryEXT begin_query; | 2607 cmds::BeginQueryEXT begin_query; |
| 2606 }; | 2608 }; |
| 2607 BeginCmds expected_begin_cmds; | 2609 BeginCmds expected_begin_cmds; |
| 2608 const void* commands = GetPut(); | 2610 const void* commands = GetPut(); |
| 2609 gl_->BeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, id1); | 2611 gl_->BeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, id1); |
| 2610 QueryTracker::Query* query = GetQuery(id1); | 2612 QueryTracker::Query* query = GetQuery(id1); |
| 2611 ASSERT_TRUE(query != NULL); | 2613 ASSERT_TRUE(query != NULL); |
| 2612 expected_begin_cmds.begin_query.Init( | 2614 expected_begin_cmds.begin_query.Init( |
| 2613 GL_ANY_SAMPLES_PASSED_EXT, id1, query->shm_id(), query->shm_offset()); | 2615 GL_ANY_SAMPLES_PASSED_EXT, id1, query->shm_id(), query->shm_offset()); |
| 2614 EXPECT_EQ(0, memcmp( | 2616 EXPECT_EQ(0, memcmp( |
| 2615 &expected_begin_cmds, commands, sizeof(expected_begin_cmds))); | 2617 &expected_begin_cmds, commands, sizeof(expected_begin_cmds))); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2629 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); | 2631 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); |
| 2630 | 2632 |
| 2631 // Test EndQueryEXT fails if target not same as current query. | 2633 // Test EndQueryEXT fails if target not same as current query. |
| 2632 ClearCommands(); | 2634 ClearCommands(); |
| 2633 gl_->EndQueryEXT(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT); | 2635 gl_->EndQueryEXT(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT); |
| 2634 EXPECT_TRUE(NoCommandsWritten()); | 2636 EXPECT_TRUE(NoCommandsWritten()); |
| 2635 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); | 2637 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); |
| 2636 | 2638 |
| 2637 // Test EndQueryEXT sends command | 2639 // Test EndQueryEXT sends command |
| 2638 struct EndCmds { | 2640 struct EndCmds { |
| 2639 EndQueryEXT end_query; | 2641 cmds::EndQueryEXT end_query; |
| 2640 }; | 2642 }; |
| 2641 EndCmds expected_end_cmds; | 2643 EndCmds expected_end_cmds; |
| 2642 expected_end_cmds.end_query.Init( | 2644 expected_end_cmds.end_query.Init( |
| 2643 GL_ANY_SAMPLES_PASSED_EXT, query->submit_count()); | 2645 GL_ANY_SAMPLES_PASSED_EXT, query->submit_count()); |
| 2644 commands = GetPut(); | 2646 commands = GetPut(); |
| 2645 gl_->EndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT); | 2647 gl_->EndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT); |
| 2646 EXPECT_EQ(0, memcmp( | 2648 EXPECT_EQ(0, memcmp( |
| 2647 &expected_end_cmds, commands, sizeof(expected_end_cmds))); | 2649 &expected_end_cmds, commands, sizeof(expected_end_cmds))); |
| 2648 | 2650 |
| 2649 // Test EndQueryEXT fails if no current query. | 2651 // Test EndQueryEXT fails if no current query. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2697 ClearCommands(); | 2699 ClearCommands(); |
| 2698 | 2700 |
| 2699 // Test BeginQueryEXT does NOT insert commands. | 2701 // Test BeginQueryEXT does NOT insert commands. |
| 2700 gl_->BeginQueryEXT(GL_GET_ERROR_QUERY_CHROMIUM, id); | 2702 gl_->BeginQueryEXT(GL_GET_ERROR_QUERY_CHROMIUM, id); |
| 2701 EXPECT_TRUE(NoCommandsWritten()); | 2703 EXPECT_TRUE(NoCommandsWritten()); |
| 2702 QueryTracker::Query* query = GetQuery(id); | 2704 QueryTracker::Query* query = GetQuery(id); |
| 2703 ASSERT_TRUE(query != NULL); | 2705 ASSERT_TRUE(query != NULL); |
| 2704 | 2706 |
| 2705 // Test EndQueryEXT sends both begin and end command | 2707 // Test EndQueryEXT sends both begin and end command |
| 2706 struct EndCmds { | 2708 struct EndCmds { |
| 2707 BeginQueryEXT begin_query; | 2709 cmds::BeginQueryEXT begin_query; |
| 2708 EndQueryEXT end_query; | 2710 cmds::EndQueryEXT end_query; |
| 2709 }; | 2711 }; |
| 2710 EndCmds expected_end_cmds; | 2712 EndCmds expected_end_cmds; |
| 2711 expected_end_cmds.begin_query.Init( | 2713 expected_end_cmds.begin_query.Init( |
| 2712 GL_GET_ERROR_QUERY_CHROMIUM, id, query->shm_id(), query->shm_offset()); | 2714 GL_GET_ERROR_QUERY_CHROMIUM, id, query->shm_id(), query->shm_offset()); |
| 2713 expected_end_cmds.end_query.Init( | 2715 expected_end_cmds.end_query.Init( |
| 2714 GL_GET_ERROR_QUERY_CHROMIUM, query->submit_count()); | 2716 GL_GET_ERROR_QUERY_CHROMIUM, query->submit_count()); |
| 2715 const void* commands = GetPut(); | 2717 const void* commands = GetPut(); |
| 2716 gl_->EndQueryEXT(GL_GET_ERROR_QUERY_CHROMIUM); | 2718 gl_->EndQueryEXT(GL_GET_ERROR_QUERY_CHROMIUM); |
| 2717 EXPECT_EQ(0, memcmp( | 2719 EXPECT_EQ(0, memcmp( |
| 2718 &expected_end_cmds, commands, sizeof(expected_end_cmds))); | 2720 &expected_end_cmds, commands, sizeof(expected_end_cmds))); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2767 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); | 2769 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); |
| 2768 | 2770 |
| 2769 gl_->VertexAttribPointer( | 2771 gl_->VertexAttribPointer( |
| 2770 kAttribIndex1, kNumComponents1, GL_FLOAT, GL_FALSE, kClientStride, NULL); | 2772 kAttribIndex1, kNumComponents1, GL_FLOAT, GL_FALSE, kClientStride, NULL); |
| 2771 EXPECT_EQ(GL_NO_ERROR, CheckError()); | 2773 EXPECT_EQ(GL_NO_ERROR, CheckError()); |
| 2772 } | 2774 } |
| 2773 #endif | 2775 #endif |
| 2774 | 2776 |
| 2775 TEST_F(GLES2ImplementationTest, Disable) { | 2777 TEST_F(GLES2ImplementationTest, Disable) { |
| 2776 struct Cmds { | 2778 struct Cmds { |
| 2777 Disable cmd; | 2779 cmds::Disable cmd; |
| 2778 }; | 2780 }; |
| 2779 Cmds expected; | 2781 Cmds expected; |
| 2780 expected.cmd.Init(GL_DITHER); // Note: DITHER defaults to enabled. | 2782 expected.cmd.Init(GL_DITHER); // Note: DITHER defaults to enabled. |
| 2781 | 2783 |
| 2782 gl_->Disable(GL_DITHER); | 2784 gl_->Disable(GL_DITHER); |
| 2783 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 2785 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2784 // Check it's cached and not called again. | 2786 // Check it's cached and not called again. |
| 2785 ClearCommands(); | 2787 ClearCommands(); |
| 2786 gl_->Disable(GL_DITHER); | 2788 gl_->Disable(GL_DITHER); |
| 2787 EXPECT_TRUE(NoCommandsWritten()); | 2789 EXPECT_TRUE(NoCommandsWritten()); |
| 2788 } | 2790 } |
| 2789 | 2791 |
| 2790 TEST_F(GLES2ImplementationTest, Enable) { | 2792 TEST_F(GLES2ImplementationTest, Enable) { |
| 2791 struct Cmds { | 2793 struct Cmds { |
| 2792 Enable cmd; | 2794 cmds::Enable cmd; |
| 2793 }; | 2795 }; |
| 2794 Cmds expected; | 2796 Cmds expected; |
| 2795 expected.cmd.Init(GL_BLEND); // Note: BLEND defaults to disabled. | 2797 expected.cmd.Init(GL_BLEND); // Note: BLEND defaults to disabled. |
| 2796 | 2798 |
| 2797 gl_->Enable(GL_BLEND); | 2799 gl_->Enable(GL_BLEND); |
| 2798 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); | 2800 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); |
| 2799 // Check it's cached and not called again. | 2801 // Check it's cached and not called again. |
| 2800 ClearCommands(); | 2802 ClearCommands(); |
| 2801 gl_->Enable(GL_BLEND); | 2803 gl_->Enable(GL_BLEND); |
| 2802 EXPECT_TRUE(NoCommandsWritten()); | 2804 EXPECT_TRUE(NoCommandsWritten()); |
| 2803 } | 2805 } |
| 2804 | 2806 |
| 2805 | 2807 |
| 2806 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 2808 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
| 2807 | 2809 |
| 2808 } // namespace gles2 | 2810 } // namespace gles2 |
| 2809 } // namespace gpu | 2811 } // namespace gpu |
| 2810 | 2812 |
| OLD | NEW |