Chromium Code Reviews| 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" |
| 11 #include "gpu/command_buffer/common/id_allocator.h" | 11 #include "gpu/command_buffer/common/id_allocator.h" |
| 12 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h" | 12 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h" |
| 13 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" | 13 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" |
| 14 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h" | 14 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h" |
| 15 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 15 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
| 16 #include "gpu/command_buffer/service/context_group.h" | 16 #include "gpu/command_buffer/service/context_group.h" |
| 17 #include "gpu/command_buffer/service/context_state.h" | |
| 17 #include "gpu/command_buffer/service/gl_surface_mock.h" | 18 #include "gpu/command_buffer/service/gl_surface_mock.h" |
| 18 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" | 19 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" |
| 19 #include "gpu/command_buffer/service/gpu_switches.h" | 20 #include "gpu/command_buffer/service/gpu_switches.h" |
| 20 #include "gpu/command_buffer/service/image_manager.h" | 21 #include "gpu/command_buffer/service/image_manager.h" |
| 21 #include "gpu/command_buffer/service/mailbox_manager.h" | 22 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 22 #include "gpu/command_buffer/service/mocks.h" | 23 #include "gpu/command_buffer/service/mocks.h" |
| 23 #include "gpu/command_buffer/service/program_manager.h" | 24 #include "gpu/command_buffer/service/program_manager.h" |
| 24 #include "gpu/command_buffer/service/stream_texture_manager_mock.h" | 25 #include "gpu/command_buffer/service/stream_texture_manager_mock.h" |
| 25 #include "gpu/command_buffer/service/stream_texture_mock.h" | 26 #include "gpu/command_buffer/service/stream_texture_mock.h" |
| 26 #include "gpu/command_buffer/service/test_helper.h" | 27 #include "gpu/command_buffer/service/test_helper.h" |
| (...skipping 8786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8813 DiscardFramebufferEXTImmediate& cmd = | 8814 DiscardFramebufferEXTImmediate& cmd = |
| 8814 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); | 8815 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); |
| 8815 cmd.Init(target, count, attachments); | 8816 cmd.Init(target, count, attachments); |
| 8816 | 8817 |
| 8817 // Should not result into a call into GL. | 8818 // Should not result into a call into GL. |
| 8818 EXPECT_EQ(error::kNoError, | 8819 EXPECT_EQ(error::kNoError, |
| 8819 ExecuteImmediateCmd(cmd, sizeof(attachments))); | 8820 ExecuteImmediateCmd(cmd, sizeof(attachments))); |
| 8820 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 8821 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 8821 } | 8822 } |
| 8822 | 8823 |
| 8824 TEST_F(GLES2DecoderManualInitTest, RestoreState) { | |
| 8825 InitDecoder( | |
| 8826 "", // extensions | |
| 8827 false, // has alpha | |
| 8828 false, // has depth | |
| 8829 false, // has stencil | |
| 8830 false, // request alpha | |
| 8831 false, // request depth | |
| 8832 false, // request stencil | |
| 8833 false); // bind generates resource | |
| 8834 SetupTexture(); | |
| 8835 | |
| 8836 InSequence sequence; | |
| 8837 // Expect to restore texture bindings for unit GL_TEXTURE0. | |
| 8838 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 8839 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | |
| 8840 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, | |
| 8841 TestHelper::kServiceDefaultTextureCubemapId); | |
| 8842 | |
| 8843 // Expect to restore texture bindings for remaining units. | |
| 8844 for (uint32 i = 1; i < group().max_texture_units() ; ++i) { | |
| 8845 AddExpectationsForActiveTexture(GL_TEXTURE0 + i); | |
| 8846 AddExpectationsForBindTexture(GL_TEXTURE_2D, | |
| 8847 TestHelper::kServiceDefaultTexture2dId); | |
| 8848 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, | |
| 8849 TestHelper::kServiceDefaultTextureCubemapId); | |
| 8850 } | |
| 8851 | |
| 8852 // Expect to restore the active texture unit to GL_TEXTURE0. | |
| 8853 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 8854 | |
| 8855 GetDecoder()->RestoreAllTextureUnitBindings(NULL); | |
| 8856 } | |
| 8857 | |
| 8858 TEST_F(GLES2DecoderManualInitTest, RestoreStateWithPreviousState) { | |
| 8859 InitDecoder( | |
| 8860 "", // extensions | |
| 8861 false, // has alpha | |
| 8862 false, // has depth | |
| 8863 false, // has stencil | |
| 8864 false, // request alpha | |
| 8865 false, // request depth | |
| 8866 false, // request stencil | |
| 8867 false); // bind generates resource | |
| 8868 SetupTexture(); | |
| 8869 | |
| 8870 // Construct a previous ContextState with all texture bindings | |
| 8871 // set to default textures. | |
| 8872 ContextState prev_state(NULL, NULL); | |
| 8873 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); | |
| 8874 | |
| 8875 InSequence sequence; | |
| 8876 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit, | |
| 8877 // since the rest of the bindings haven't changed between the current | |
| 8878 // state and the |prev_state|. | |
| 8879 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 8880 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | |
| 8881 | |
| 8882 // Expect to restore active texture unit to GL_TEXTURE0. | |
| 8883 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 8884 | |
| 8885 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); | |
| 8886 } | |
| 8887 | |
| 8888 TEST_F(GLES2DecoderManualInitTest, RestoreStateActiveUnit1) { | |
| 8889 InitDecoder( | |
| 8890 "", // extensions | |
| 8891 false, // has alpha | |
| 8892 false, // has depth | |
| 8893 false, // has stencil | |
| 8894 false, // request alpha | |
| 8895 false, // request depth | |
| 8896 false, // request stencil | |
| 8897 false); // bind generates resource | |
| 8898 | |
| 8899 // Bind a non-default texture to GL_TEXTURE1 unit. | |
| 8900 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); | |
| 8901 SpecializedSetup<ActiveTexture, 0>(true); | |
|
no sievers
2014/01/13 22:06:29
I don't see the specialization for this anywhere (
kaanb
2014/01/14 22:04:22
Removed.
| |
| 8902 ActiveTexture cmd; | |
| 8903 cmd.Init(GL_TEXTURE1); | |
| 8904 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 8905 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8906 SetupTexture(); | |
| 8907 | |
| 8908 // Construct a previous ContextState with all texture bindings | |
| 8909 // set to default textures. | |
| 8910 ContextState prev_state(NULL, NULL); | |
| 8911 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); | |
| 8912 | |
| 8913 InSequence sequence; | |
| 8914 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE1 unit, | |
| 8915 // since the rest of the bindings haven't changed between the current | |
| 8916 // state and the |prev_state|. | |
| 8917 AddExpectationsForActiveTexture(GL_TEXTURE1); | |
| 8918 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | |
| 8919 | |
| 8920 // Expect to restore active texture unit to GL_TEXTURE1. | |
| 8921 AddExpectationsForActiveTexture(GL_TEXTURE1); | |
| 8922 | |
| 8923 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); | |
| 8924 } | |
| 8925 | |
| 8926 TEST_F(GLES2DecoderManualInitTest, RestoreStateNonDefaultUnit0) { | |
| 8927 InitDecoder( | |
| 8928 "", // extensions | |
| 8929 false, // has alpha | |
| 8930 false, // has depth | |
| 8931 false, // has stencil | |
| 8932 false, // request alpha | |
| 8933 false, // request depth | |
| 8934 false, // request stencil | |
| 8935 false); // bind generates resource | |
| 8936 | |
| 8937 // Bind a non-default texture to GL_TEXTURE1 unit. | |
| 8938 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); | |
| 8939 SpecializedSetup<ActiveTexture, 0>(true); | |
| 8940 ActiveTexture cmd; | |
| 8941 cmd.Init(GL_TEXTURE1); | |
| 8942 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 8943 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8944 SetupTexture(); | |
| 8945 | |
| 8946 // Construct a previous ContextState with GL_TEXTURE_2D target in | |
| 8947 // GL_TEXTURE0 unit bound to a non-default texture and the rest | |
| 8948 // set to default textures. | |
| 8949 ContextState prev_state(NULL, NULL); | |
| 8950 InitializeContextState(&prev_state, 0, 0); | |
|
no sievers
2014/01/13 22:06:29
nit: This would break if kServiceDefaultTexture2dI
kaanb
2014/01/14 22:04:22
Done.
| |
| 8951 | |
| 8952 InSequence sequence; | |
| 8953 // Expect to restore GL_TEXTURE_2D binding for GL_TEXTURE0 unit to | |
| 8954 // a default texture. | |
| 8955 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 8956 AddExpectationsForBindTexture(GL_TEXTURE_2D, | |
| 8957 TestHelper::kServiceDefaultTexture2dId); | |
| 8958 | |
| 8959 // Expect to restore GL_TEXTURE_2D binding for GL_TEXTURE1 unit to | |
| 8960 // non-default. | |
| 8961 AddExpectationsForActiveTexture(GL_TEXTURE1); | |
| 8962 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | |
| 8963 | |
| 8964 // Expect to restore active texture unit to GL_TEXTURE1. | |
| 8965 AddExpectationsForActiveTexture(GL_TEXTURE1); | |
| 8966 | |
| 8967 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); | |
| 8968 } | |
| 8969 | |
| 8970 TEST_F(GLES2DecoderManualInitTest, RestoreStateNonDefaultUnit1) { | |
| 8971 InitDecoder( | |
| 8972 "", // extensions | |
| 8973 false, // has alpha | |
| 8974 false, // has depth | |
| 8975 false, // has stencil | |
| 8976 false, // request alpha | |
| 8977 false, // request depth | |
| 8978 false, // request stencil | |
| 8979 false); // bind generates resource | |
| 8980 | |
| 8981 // Bind a non-default texture to GL_TEXTURE0 unit. | |
| 8982 SetupTexture(); | |
| 8983 | |
| 8984 // Construct a previous ContextState with GL_TEXTURE_2D target in | |
| 8985 // GL_TEXTURE1 unit bound to a non-default texture and the rest | |
| 8986 // set to default textures. | |
| 8987 ContextState prev_state(NULL, NULL); | |
| 8988 InitializeContextState(&prev_state, 1, 0); | |
|
no sievers
2014/01/13 22:06:29
nit: here also use a real id (not 0).
kaanb
2014/01/14 22:04:22
Done.
| |
| 8989 | |
| 8990 InSequence sequence; | |
| 8991 // Expect to restore GL_TEXTURE_2D binding to the non-default texture | |
| 8992 // for GL_TEXTURE0 unit. | |
| 8993 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 8994 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); | |
| 8995 | |
| 8996 // Expect to restore GL_TEXTURE_2D binding to the default texture | |
| 8997 // for GL_TEXTURE1 unit. | |
| 8998 AddExpectationsForActiveTexture(GL_TEXTURE1); | |
| 8999 AddExpectationsForBindTexture(GL_TEXTURE_2D, | |
| 9000 TestHelper::kServiceDefaultTexture2dId); | |
| 9001 | |
| 9002 // Expect to restore active texture unit to GL_TEXTURE0. | |
| 9003 AddExpectationsForActiveTexture(GL_TEXTURE0); | |
| 9004 | |
| 9005 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); | |
| 9006 } | |
| 9007 | |
| 8823 // TODO(gman): Complete this test. | 9008 // TODO(gman): Complete this test. |
| 8824 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { | 9009 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { |
| 8825 // } | 9010 // } |
| 8826 | 9011 |
| 8827 // TODO(gman): BufferData | 9012 // TODO(gman): BufferData |
| 8828 | 9013 |
| 8829 // TODO(gman): BufferDataImmediate | 9014 // TODO(gman): BufferDataImmediate |
| 8830 | 9015 |
| 8831 // TODO(gman): BufferSubData | 9016 // TODO(gman): BufferSubData |
| 8832 | 9017 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 8849 // TODO(gman): TexImage2DImmediate | 9034 // TODO(gman): TexImage2DImmediate |
| 8850 | 9035 |
| 8851 // TODO(gman): TexSubImage2DImmediate | 9036 // TODO(gman): TexSubImage2DImmediate |
| 8852 | 9037 |
| 8853 // TODO(gman): UseProgram | 9038 // TODO(gman): UseProgram |
| 8854 | 9039 |
| 8855 // TODO(gman): SwapBuffers | 9040 // TODO(gman): SwapBuffers |
| 8856 | 9041 |
| 8857 } // namespace gles2 | 9042 } // namespace gles2 |
| 8858 } // namespace gpu | 9043 } // namespace gpu |
| OLD | NEW |