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 #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 5644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5655 cmd3.Init(GL_FRAMEBUFFER, kInvalidClientId); | 5655 cmd3.Init(GL_FRAMEBUFFER, kInvalidClientId); |
5656 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd3)); | 5656 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd3)); |
5657 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 5657 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
5658 | 5658 |
5659 BindRenderbuffer cmd4; | 5659 BindRenderbuffer cmd4; |
5660 cmd4.Init(GL_RENDERBUFFER, kInvalidClientId); | 5660 cmd4.Init(GL_RENDERBUFFER, kInvalidClientId); |
5661 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd4)); | 5661 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd4)); |
5662 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 5662 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
5663 } | 5663 } |
5664 | 5664 |
| 5665 TEST_F(GLES2DecoderManualInitTest, DefaultTextureZero) { |
| 5666 InitState init; |
| 5667 init.gl_version = "3.0"; |
| 5668 InitDecoder(init); |
| 5669 |
| 5670 BindTexture cmd1; |
| 5671 cmd1.Init(GL_TEXTURE_2D, 0); |
| 5672 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); |
| 5673 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 5674 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5675 |
| 5676 BindTexture cmd2; |
| 5677 cmd2.Init(GL_TEXTURE_CUBE_MAP, 0); |
| 5678 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); |
| 5679 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 5680 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5681 } |
| 5682 |
| 5683 TEST_F(GLES2DecoderManualInitTest, DefaultTextureBGR) { |
| 5684 InitState init; |
| 5685 init.gl_version = "3.0"; |
| 5686 init.bind_generates_resource = true; |
| 5687 InitDecoder(init); |
| 5688 |
| 5689 BindTexture cmd1; |
| 5690 cmd1.Init(GL_TEXTURE_2D, 0); |
| 5691 EXPECT_CALL( |
| 5692 *gl_, BindTexture(GL_TEXTURE_2D, TestHelper::kServiceDefaultTexture2dId)); |
| 5693 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 5694 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5695 |
| 5696 BindTexture cmd2; |
| 5697 cmd2.Init(GL_TEXTURE_CUBE_MAP, 0); |
| 5698 EXPECT_CALL(*gl_, |
| 5699 BindTexture(GL_TEXTURE_CUBE_MAP, |
| 5700 TestHelper::kServiceDefaultTextureCubemapId)); |
| 5701 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 5702 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5703 } |
| 5704 |
| 5705 // Test that default texture 0 is immutable. |
| 5706 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameterf) { |
| 5707 InitState init; |
| 5708 init.gl_version = "3.0"; |
| 5709 InitDecoder(init); |
| 5710 |
| 5711 { |
| 5712 BindTexture cmd1; |
| 5713 cmd1.Init(GL_TEXTURE_2D, 0); |
| 5714 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); |
| 5715 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 5716 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5717 |
| 5718 TexParameterf cmd2; |
| 5719 cmd2.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 5720 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 5721 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 5722 } |
| 5723 |
| 5724 { |
| 5725 BindTexture cmd1; |
| 5726 cmd1.Init(GL_TEXTURE_CUBE_MAP, 0); |
| 5727 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); |
| 5728 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 5729 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5730 |
| 5731 TexParameterf cmd2; |
| 5732 cmd2.Init(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 5733 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 5734 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 5735 } |
| 5736 } |
| 5737 |
| 5738 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameteri) { |
| 5739 InitState init; |
| 5740 init.gl_version = "3.0"; |
| 5741 InitDecoder(init); |
| 5742 |
| 5743 { |
| 5744 BindTexture cmd1; |
| 5745 cmd1.Init(GL_TEXTURE_2D, 0); |
| 5746 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); |
| 5747 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 5748 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5749 |
| 5750 TexParameteri cmd2; |
| 5751 cmd2.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 5752 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 5753 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 5754 } |
| 5755 |
| 5756 { |
| 5757 BindTexture cmd1; |
| 5758 cmd1.Init(GL_TEXTURE_CUBE_MAP, 0); |
| 5759 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); |
| 5760 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 5761 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5762 |
| 5763 TexParameteri cmd2; |
| 5764 cmd2.Init(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 5765 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 5766 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 5767 } |
| 5768 } |
| 5769 |
| 5770 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameterfv) { |
| 5771 InitState init; |
| 5772 init.gl_version = "3.0"; |
| 5773 InitDecoder(init); |
| 5774 |
| 5775 { |
| 5776 BindTexture cmd1; |
| 5777 cmd1.Init(GL_TEXTURE_2D, 0); |
| 5778 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); |
| 5779 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 5780 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5781 |
| 5782 TexParameterfv cmd2; |
| 5783 cmd2.Init(GL_TEXTURE_2D, |
| 5784 GL_TEXTURE_MAG_FILTER, |
| 5785 shared_memory_id_, |
| 5786 shared_memory_offset_); |
| 5787 GetSharedMemoryAs<GLfloat*>()[0] = GL_NEAREST; |
| 5788 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 5789 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 5790 } |
| 5791 |
| 5792 { |
| 5793 BindTexture cmd1; |
| 5794 cmd1.Init(GL_TEXTURE_CUBE_MAP, 0); |
| 5795 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); |
| 5796 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 5797 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5798 |
| 5799 TexParameterfv cmd2; |
| 5800 cmd2.Init(GL_TEXTURE_CUBE_MAP, |
| 5801 GL_TEXTURE_MAG_FILTER, |
| 5802 shared_memory_id_, |
| 5803 shared_memory_offset_); |
| 5804 GetSharedMemoryAs<GLfloat*>()[0] = GL_NEAREST; |
| 5805 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 5806 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 5807 } |
| 5808 } |
| 5809 |
| 5810 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameteriv) { |
| 5811 InitState init; |
| 5812 init.gl_version = "3.0"; |
| 5813 InitDecoder(init); |
| 5814 |
| 5815 { |
| 5816 BindTexture cmd1; |
| 5817 cmd1.Init(GL_TEXTURE_2D, 0); |
| 5818 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); |
| 5819 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 5820 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5821 |
| 5822 TexParameteriv cmd2; |
| 5823 cmd2.Init(GL_TEXTURE_2D, |
| 5824 GL_TEXTURE_MAG_FILTER, |
| 5825 shared_memory_id_, |
| 5826 shared_memory_offset_); |
| 5827 GetSharedMemoryAs<GLint*>()[0] = GL_NEAREST; |
| 5828 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 5829 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 5830 } |
| 5831 |
| 5832 { |
| 5833 BindTexture cmd1; |
| 5834 cmd1.Init(GL_TEXTURE_CUBE_MAP, 0); |
| 5835 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); |
| 5836 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 5837 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5838 |
| 5839 TexParameteriv cmd2; |
| 5840 cmd2.Init(GL_TEXTURE_CUBE_MAP, |
| 5841 GL_TEXTURE_MAG_FILTER, |
| 5842 shared_memory_id_, |
| 5843 shared_memory_offset_); |
| 5844 GetSharedMemoryAs<GLint*>()[0] = GL_NEAREST; |
| 5845 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 5846 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 5847 } |
| 5848 } |
| 5849 |
| 5850 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexImage2D) { |
| 5851 InitState init; |
| 5852 init.gl_version = "3.0"; |
| 5853 InitDecoder(init); |
| 5854 |
| 5855 BindTexture cmd1; |
| 5856 cmd1.Init(GL_TEXTURE_2D, 0); |
| 5857 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); |
| 5858 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 5859 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5860 |
| 5861 TexImage2D cmd2; |
| 5862 cmd2.Init(GL_TEXTURE_2D, |
| 5863 0, |
| 5864 GL_RGBA, |
| 5865 2, |
| 5866 2, |
| 5867 0, |
| 5868 GL_RGBA, |
| 5869 GL_UNSIGNED_BYTE, |
| 5870 kSharedMemoryId, |
| 5871 kSharedMemoryOffset); |
| 5872 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 5873 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 5874 } |
| 5875 |
| 5876 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexSubImage2D) { |
| 5877 InitState init; |
| 5878 init.gl_version = "3.0"; |
| 5879 InitDecoder(init); |
| 5880 |
| 5881 BindTexture cmd1; |
| 5882 cmd1.Init(GL_TEXTURE_2D, 0); |
| 5883 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); |
| 5884 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); |
| 5885 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5886 |
| 5887 TexSubImage2D cmd2; |
| 5888 cmd2.Init(GL_TEXTURE_2D, |
| 5889 0, |
| 5890 1, |
| 5891 1, |
| 5892 1, |
| 5893 1, |
| 5894 GL_RGBA, |
| 5895 GL_UNSIGNED_BYTE, |
| 5896 kSharedMemoryId, |
| 5897 kSharedMemoryOffset, |
| 5898 GL_FALSE); |
| 5899 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
| 5900 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 5901 } |
| 5902 |
5665 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleBindTexture) { | 5903 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleBindTexture) { |
5666 InitState init; | 5904 InitState init; |
5667 init.extensions = "GL_ARB_texture_rectangle"; | 5905 init.extensions = "GL_ARB_texture_rectangle"; |
5668 init.gl_version = "3.0"; | 5906 init.gl_version = "3.0"; |
5669 init.bind_generates_resource = true; | 5907 init.bind_generates_resource = true; |
5670 InitDecoder(init); | 5908 InitDecoder(init); |
5671 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_RECTANGLE_ARB, kNewServiceId)); | 5909 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_RECTANGLE_ARB, kNewServiceId)); |
5672 EXPECT_CALL(*gl_, GenTextures(1, _)) | 5910 EXPECT_CALL(*gl_, GenTextures(1, _)) |
5673 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); | 5911 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); |
5674 BindTexture cmd; | 5912 BindTexture cmd; |
(...skipping 2952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8627 DiscardFramebufferEXTImmediate& cmd = | 8865 DiscardFramebufferEXTImmediate& cmd = |
8628 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); | 8866 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); |
8629 cmd.Init(target, count, attachments); | 8867 cmd.Init(target, count, attachments); |
8630 | 8868 |
8631 // Should not result into a call into GL. | 8869 // Should not result into a call into GL. |
8632 EXPECT_EQ(error::kNoError, | 8870 EXPECT_EQ(error::kNoError, |
8633 ExecuteImmediateCmd(cmd, sizeof(attachments))); | 8871 ExecuteImmediateCmd(cmd, sizeof(attachments))); |
8634 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 8872 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
8635 } | 8873 } |
8636 | 8874 |
8637 TEST_F(GLES2DecoderRestoreStateTest, NullPreviousState) { | 8875 TEST_F(GLES2DecoderRestoreStateTest, NullPreviousStateBGR) { |
8638 InitState init; | 8876 InitState init; |
8639 init.gl_version = "3.0"; | 8877 init.gl_version = "3.0"; |
| 8878 init.bind_generates_resource = true; |
8640 InitDecoder(init); | 8879 InitDecoder(init); |
8641 SetupTexture(); | 8880 SetupTexture(); |
8642 | 8881 |
8643 InSequence sequence; | 8882 InSequence sequence; |
8644 // Expect to restore texture bindings for unit GL_TEXTURE0. | 8883 // Expect to restore texture bindings for unit GL_TEXTURE0. |
8645 AddExpectationsForActiveTexture(GL_TEXTURE0); | 8884 AddExpectationsForActiveTexture(GL_TEXTURE0); |
8646 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | 8885 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); |
8647 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, | 8886 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, |
8648 TestHelper::kServiceDefaultTextureCubemapId); | 8887 TestHelper::kServiceDefaultTextureCubemapId); |
8649 | 8888 |
8650 // Expect to restore texture bindings for remaining units. | 8889 // Expect to restore texture bindings for remaining units. |
8651 for (uint32 i = 1; i < group().max_texture_units() ; ++i) { | 8890 for (uint32 i = 1; i < group().max_texture_units() ; ++i) { |
8652 AddExpectationsForActiveTexture(GL_TEXTURE0 + i); | 8891 AddExpectationsForActiveTexture(GL_TEXTURE0 + i); |
8653 AddExpectationsForBindTexture(GL_TEXTURE_2D, | 8892 AddExpectationsForBindTexture(GL_TEXTURE_2D, |
8654 TestHelper::kServiceDefaultTexture2dId); | 8893 TestHelper::kServiceDefaultTexture2dId); |
8655 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, | 8894 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, |
8656 TestHelper::kServiceDefaultTextureCubemapId); | 8895 TestHelper::kServiceDefaultTextureCubemapId); |
8657 } | 8896 } |
8658 | 8897 |
8659 // Expect to restore the active texture unit to GL_TEXTURE0. | 8898 // Expect to restore the active texture unit to GL_TEXTURE0. |
8660 AddExpectationsForActiveTexture(GL_TEXTURE0); | 8899 AddExpectationsForActiveTexture(GL_TEXTURE0); |
8661 | 8900 |
8662 GetDecoder()->RestoreAllTextureUnitBindings(NULL); | 8901 GetDecoder()->RestoreAllTextureUnitBindings(NULL); |
8663 } | 8902 } |
8664 | 8903 |
| 8904 TEST_F(GLES2DecoderRestoreStateTest, NullPreviousState) { |
| 8905 InitState init; |
| 8906 init.gl_version = "3.0"; |
| 8907 InitDecoder(init); |
| 8908 SetupTexture(); |
| 8909 |
| 8910 InSequence sequence; |
| 8911 // Expect to restore texture bindings for unit GL_TEXTURE0. |
| 8912 AddExpectationsForActiveTexture(GL_TEXTURE0); |
| 8913 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); |
| 8914 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0); |
| 8915 |
| 8916 // Expect to restore texture bindings for remaining units. |
| 8917 for (uint32 i = 1; i < group().max_texture_units(); ++i) { |
| 8918 AddExpectationsForActiveTexture(GL_TEXTURE0 + i); |
| 8919 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0); |
| 8920 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0); |
| 8921 } |
| 8922 |
| 8923 // Expect to restore the active texture unit to GL_TEXTURE0. |
| 8924 AddExpectationsForActiveTexture(GL_TEXTURE0); |
| 8925 |
| 8926 GetDecoder()->RestoreAllTextureUnitBindings(NULL); |
| 8927 } |
| 8928 |
| 8929 TEST_F(GLES2DecoderRestoreStateTest, WithPreviousStateBGR) { |
| 8930 InitState init; |
| 8931 init.gl_version = "3.0"; |
| 8932 init.bind_generates_resource = true; |
| 8933 InitDecoder(init); |
| 8934 SetupTexture(); |
| 8935 |
| 8936 // Construct a previous ContextState with all texture bindings |
| 8937 // set to default textures. |
| 8938 ContextState prev_state(NULL, NULL, NULL); |
| 8939 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); |
| 8940 |
| 8941 InSequence sequence; |
| 8942 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit, |
| 8943 // since the rest of the bindings haven't changed between the current |
| 8944 // state and the |prev_state|. |
| 8945 AddExpectationsForActiveTexture(GL_TEXTURE0); |
| 8946 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); |
| 8947 |
| 8948 // Expect to restore active texture unit to GL_TEXTURE0. |
| 8949 AddExpectationsForActiveTexture(GL_TEXTURE0); |
| 8950 |
| 8951 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); |
| 8952 } |
| 8953 |
8665 TEST_F(GLES2DecoderRestoreStateTest, WithPreviousState) { | 8954 TEST_F(GLES2DecoderRestoreStateTest, WithPreviousState) { |
8666 InitState init; | 8955 InitState init; |
8667 init.gl_version = "3.0"; | 8956 init.gl_version = "3.0"; |
8668 InitDecoder(init); | 8957 InitDecoder(init); |
8669 SetupTexture(); | 8958 SetupTexture(); |
8670 | 8959 |
8671 // Construct a previous ContextState with all texture bindings | 8960 // Construct a previous ContextState with all texture bindings |
8672 // set to default textures. | 8961 // set to default textures. |
8673 ContextState prev_state(NULL, NULL, NULL); | 8962 ContextState prev_state(NULL, NULL, NULL); |
8674 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); | 8963 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8710 // state and the |prev_state|. | 8999 // state and the |prev_state|. |
8711 AddExpectationsForActiveTexture(GL_TEXTURE1); | 9000 AddExpectationsForActiveTexture(GL_TEXTURE1); |
8712 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | 9001 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); |
8713 | 9002 |
8714 // Expect to restore active texture unit to GL_TEXTURE1. | 9003 // Expect to restore active texture unit to GL_TEXTURE1. |
8715 AddExpectationsForActiveTexture(GL_TEXTURE1); | 9004 AddExpectationsForActiveTexture(GL_TEXTURE1); |
8716 | 9005 |
8717 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); | 9006 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); |
8718 } | 9007 } |
8719 | 9008 |
8720 TEST_F(GLES2DecoderRestoreStateTest, NonDefaultUnit0) { | 9009 TEST_F(GLES2DecoderRestoreStateTest, NonDefaultUnit0BGR) { |
8721 InitState init; | 9010 InitState init; |
8722 init.gl_version = "3.0"; | 9011 init.gl_version = "3.0"; |
| 9012 init.bind_generates_resource = true; |
8723 InitDecoder(init); | 9013 InitDecoder(init); |
8724 | 9014 |
8725 // Bind a non-default texture to GL_TEXTURE1 unit. | 9015 // Bind a non-default texture to GL_TEXTURE1 unit. |
8726 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); | 9016 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); |
8727 SpecializedSetup<ActiveTexture, 0>(true); | 9017 SpecializedSetup<ActiveTexture, 0>(true); |
8728 ActiveTexture cmd; | 9018 ActiveTexture cmd; |
8729 cmd.Init(GL_TEXTURE1); | 9019 cmd.Init(GL_TEXTURE1); |
8730 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 9020 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
8731 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 9021 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
8732 SetupTexture(); | 9022 SetupTexture(); |
(...skipping 15 matching lines...) Expand all Loading... |
8748 // non-default. | 9038 // non-default. |
8749 AddExpectationsForActiveTexture(GL_TEXTURE1); | 9039 AddExpectationsForActiveTexture(GL_TEXTURE1); |
8750 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | 9040 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); |
8751 | 9041 |
8752 // Expect to restore active texture unit to GL_TEXTURE1. | 9042 // Expect to restore active texture unit to GL_TEXTURE1. |
8753 AddExpectationsForActiveTexture(GL_TEXTURE1); | 9043 AddExpectationsForActiveTexture(GL_TEXTURE1); |
8754 | 9044 |
8755 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); | 9045 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); |
8756 } | 9046 } |
8757 | 9047 |
8758 TEST_F(GLES2DecoderRestoreStateTest, NonDefaultUnit1) { | 9048 TEST_F(GLES2DecoderRestoreStateTest, NonDefaultUnit1BGR) { |
8759 InitState init; | 9049 InitState init; |
8760 init.gl_version = "3.0"; | 9050 init.gl_version = "3.0"; |
| 9051 init.bind_generates_resource = true; |
8761 InitDecoder(init); | 9052 InitDecoder(init); |
8762 | 9053 |
8763 // Bind a non-default texture to GL_TEXTURE0 unit. | 9054 // Bind a non-default texture to GL_TEXTURE0 unit. |
8764 SetupTexture(); | 9055 SetupTexture(); |
8765 | 9056 |
8766 // Construct a previous ContextState with GL_TEXTURE_2D target in | 9057 // Construct a previous ContextState with GL_TEXTURE_2D target in |
8767 // GL_TEXTURE1 unit bound to a non-default texture and the rest | 9058 // GL_TEXTURE1 unit bound to a non-default texture and the rest |
8768 // set to default textures. | 9059 // set to default textures. |
8769 ContextState prev_state(NULL, NULL, NULL); | 9060 ContextState prev_state(NULL, NULL, NULL); |
8770 InitializeContextState(&prev_state, 1, kServiceTextureId); | 9061 InitializeContextState(&prev_state, 1, kServiceTextureId); |
8771 | 9062 |
8772 InSequence sequence; | 9063 InSequence sequence; |
8773 // Expect to restore GL_TEXTURE_2D binding to the non-default texture | 9064 // Expect to restore GL_TEXTURE_2D binding to the non-default texture |
8774 // for GL_TEXTURE0 unit. | 9065 // for GL_TEXTURE0 unit. |
8775 AddExpectationsForActiveTexture(GL_TEXTURE0); | 9066 AddExpectationsForActiveTexture(GL_TEXTURE0); |
8776 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | 9067 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); |
8777 | 9068 |
8778 // Expect to restore GL_TEXTURE_2D binding to the default texture | 9069 // Expect to restore GL_TEXTURE_2D binding to the default texture |
8779 // for GL_TEXTURE1 unit. | 9070 // for GL_TEXTURE1 unit. |
8780 AddExpectationsForActiveTexture(GL_TEXTURE1); | 9071 AddExpectationsForActiveTexture(GL_TEXTURE1); |
8781 AddExpectationsForBindTexture(GL_TEXTURE_2D, | 9072 AddExpectationsForBindTexture(GL_TEXTURE_2D, |
8782 TestHelper::kServiceDefaultTexture2dId); | 9073 TestHelper::kServiceDefaultTexture2dId); |
8783 | 9074 |
8784 // Expect to restore active texture unit to GL_TEXTURE0. | 9075 // Expect to restore active texture unit to GL_TEXTURE0. |
8785 AddExpectationsForActiveTexture(GL_TEXTURE0); | 9076 AddExpectationsForActiveTexture(GL_TEXTURE0); |
8786 | 9077 |
8787 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); | 9078 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); |
8788 } | 9079 } |
8789 | 9080 |
| 9081 TEST_F(GLES2DecoderRestoreStateTest, DefaultUnit0) { |
| 9082 InitState init; |
| 9083 init.gl_version = "3.0"; |
| 9084 InitDecoder(init); |
| 9085 |
| 9086 // Bind a non-default texture to GL_TEXTURE1 unit. |
| 9087 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); |
| 9088 SpecializedSetup<ActiveTexture, 0>(true); |
| 9089 ActiveTexture cmd; |
| 9090 cmd.Init(GL_TEXTURE1); |
| 9091 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 9092 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 9093 SetupTexture(); |
| 9094 |
| 9095 // Construct a previous ContextState with GL_TEXTURE_2D target in |
| 9096 // GL_TEXTURE0 unit bound to a non-default texture and the rest |
| 9097 // set to default textures. |
| 9098 ContextState prev_state(NULL, NULL, NULL); |
| 9099 InitializeContextState(&prev_state, 0, kServiceTextureId); |
| 9100 |
| 9101 InSequence sequence; |
| 9102 // Expect to restore GL_TEXTURE_2D binding for GL_TEXTURE0 unit to |
| 9103 // the 0 texture. |
| 9104 AddExpectationsForActiveTexture(GL_TEXTURE0); |
| 9105 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0); |
| 9106 |
| 9107 // Expect to restore GL_TEXTURE_2D binding for GL_TEXTURE1 unit to |
| 9108 // non-default. |
| 9109 AddExpectationsForActiveTexture(GL_TEXTURE1); |
| 9110 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); |
| 9111 |
| 9112 // Expect to restore active texture unit to GL_TEXTURE1. |
| 9113 AddExpectationsForActiveTexture(GL_TEXTURE1); |
| 9114 |
| 9115 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); |
| 9116 } |
| 9117 |
| 9118 TEST_F(GLES2DecoderRestoreStateTest, DefaultUnit1) { |
| 9119 InitState init; |
| 9120 init.gl_version = "3.0"; |
| 9121 InitDecoder(init); |
| 9122 |
| 9123 // Bind a non-default texture to GL_TEXTURE0 unit. |
| 9124 SetupTexture(); |
| 9125 |
| 9126 // Construct a previous ContextState with GL_TEXTURE_2D target in |
| 9127 // GL_TEXTURE1 unit bound to a non-default texture and the rest |
| 9128 // set to default textures. |
| 9129 ContextState prev_state(NULL, NULL, NULL); |
| 9130 InitializeContextState(&prev_state, 1, kServiceTextureId); |
| 9131 |
| 9132 InSequence sequence; |
| 9133 // Expect to restore GL_TEXTURE_2D binding to the non-default texture |
| 9134 // for GL_TEXTURE0 unit. |
| 9135 AddExpectationsForActiveTexture(GL_TEXTURE0); |
| 9136 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); |
| 9137 |
| 9138 // Expect to restore GL_TEXTURE_2D binding to the 0 texture |
| 9139 // for GL_TEXTURE1 unit. |
| 9140 AddExpectationsForActiveTexture(GL_TEXTURE1); |
| 9141 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0); |
| 9142 |
| 9143 // Expect to restore active texture unit to GL_TEXTURE0. |
| 9144 AddExpectationsForActiveTexture(GL_TEXTURE0); |
| 9145 |
| 9146 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); |
| 9147 } |
| 9148 |
8790 TEST_F(GLES2DecoderManualInitTest, ClearUniformsBeforeFirstProgramUse) { | 9149 TEST_F(GLES2DecoderManualInitTest, ClearUniformsBeforeFirstProgramUse) { |
8791 CommandLine command_line(0, NULL); | 9150 CommandLine command_line(0, NULL); |
8792 command_line.AppendSwitchASCII( | 9151 command_line.AppendSwitchASCII( |
8793 switches::kGpuDriverBugWorkarounds, | 9152 switches::kGpuDriverBugWorkarounds, |
8794 base::IntToString(gpu::CLEAR_UNIFORMS_BEFORE_FIRST_PROGRAM_USE)); | 9153 base::IntToString(gpu::CLEAR_UNIFORMS_BEFORE_FIRST_PROGRAM_USE)); |
8795 InitState init; | 9154 InitState init; |
8796 init.gl_version = "3.0"; | 9155 init.gl_version = "3.0"; |
8797 init.has_alpha = true; | 9156 init.has_alpha = true; |
8798 init.request_alpha = true; | 9157 init.request_alpha = true; |
8799 init.bind_generates_resource = true; | 9158 init.bind_generates_resource = true; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9088 // TODO(gman): TexImage2DImmediate | 9447 // TODO(gman): TexImage2DImmediate |
9089 | 9448 |
9090 // TODO(gman): TexSubImage2DImmediate | 9449 // TODO(gman): TexSubImage2DImmediate |
9091 | 9450 |
9092 // TODO(gman): UseProgram | 9451 // TODO(gman): UseProgram |
9093 | 9452 |
9094 // TODO(gman): SwapBuffers | 9453 // TODO(gman): SwapBuffers |
9095 | 9454 |
9096 } // namespace gles2 | 9455 } // namespace gles2 |
9097 } // namespace gpu | 9456 } // namespace gpu |
OLD | NEW |