| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" |
| 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
| 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 11 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 11 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 12 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
| 12 #include "gpu/command_buffer/service/context_group.h" | 13 #include "gpu/command_buffer/service/context_group.h" |
| 13 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" | 14 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" |
| 14 #include "gpu/command_buffer/service/program_manager.h" | 15 #include "gpu/command_buffer/service/program_manager.h" |
| 15 #include "gpu/command_buffer/service/test_helper.h" | 16 #include "gpu/command_buffer/service/test_helper.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/gl/gl_mock.h" | 18 #include "ui/gl/gl_mock.h" |
| 18 | 19 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 36 } | 37 } |
| 37 } // namespace | 38 } // namespace |
| 38 | 39 |
| 39 class GLES2DecoderTest2 : public GLES2DecoderTestBase { | 40 class GLES2DecoderTest2 : public GLES2DecoderTestBase { |
| 40 public: | 41 public: |
| 41 GLES2DecoderTest2() { } | 42 GLES2DecoderTest2() { } |
| 42 | 43 |
| 43 void TestAcceptedUniform(GLenum uniform_type, | 44 void TestAcceptedUniform(GLenum uniform_type, |
| 44 uint32_t accepts_apis, | 45 uint32_t accepts_apis, |
| 45 bool es3_enabled) { | 46 bool es3_enabled) { |
| 46 decoder_->set_unsafe_es3_apis_enabled(es3_enabled); | |
| 47 | |
| 48 SetupShaderForUniform(uniform_type); | 47 SetupShaderForUniform(uniform_type); |
| 49 bool valid_uniform = false; | 48 bool valid_uniform = false; |
| 50 | 49 |
| 51 EXPECT_CALL(*gl_, Uniform1i(1, _)).Times(AnyNumber()); | 50 EXPECT_CALL(*gl_, Uniform1i(1, _)).Times(AnyNumber()); |
| 52 EXPECT_CALL(*gl_, Uniform1iv(1, _, _)).Times(AnyNumber()); | 51 EXPECT_CALL(*gl_, Uniform1iv(1, _, _)).Times(AnyNumber()); |
| 53 EXPECT_CALL(*gl_, Uniform2iv(1, _, _)).Times(AnyNumber()); | 52 EXPECT_CALL(*gl_, Uniform2iv(1, _, _)).Times(AnyNumber()); |
| 54 EXPECT_CALL(*gl_, Uniform3iv(1, _, _)).Times(AnyNumber()); | 53 EXPECT_CALL(*gl_, Uniform3iv(1, _, _)).Times(AnyNumber()); |
| 55 EXPECT_CALL(*gl_, Uniform4iv(1, _, _)).Times(AnyNumber()); | 54 EXPECT_CALL(*gl_, Uniform4iv(1, _, _)).Times(AnyNumber()); |
| 56 EXPECT_CALL(*gl_, Uniform1f(1, _)).Times(AnyNumber()); | 55 EXPECT_CALL(*gl_, Uniform1f(1, _)).Times(AnyNumber()); |
| 57 EXPECT_CALL(*gl_, Uniform1fv(1, _, _)).Times(AnyNumber()); | 56 EXPECT_CALL(*gl_, Uniform1fv(1, _, _)).Times(AnyNumber()); |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 | 560 |
| 562 cmd.Init(1, 2, true, &data[0][0]); | 561 cmd.Init(1, 2, true, &data[0][0]); |
| 563 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(data))); | 562 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(data))); |
| 564 EXPECT_EQ(valid_uniform ? GL_NO_ERROR : GL_INVALID_OPERATION, | 563 EXPECT_EQ(valid_uniform ? GL_NO_ERROR : GL_INVALID_OPERATION, |
| 565 GetGLError()); | 564 GetGLError()); |
| 566 } | 565 } |
| 567 } | 566 } |
| 568 } | 567 } |
| 569 }; | 568 }; |
| 570 | 569 |
| 570 class GLES3DecoderTest2 : public GLES2DecoderTest2 { |
| 571 public: |
| 572 GLES3DecoderTest2() { shader_language_version_ = 300; } |
| 573 protected: |
| 574 void SetUp() override { |
| 575 base::CommandLine command_line(0, nullptr); |
| 576 command_line.AppendSwitch(switches::kEnableUnsafeES3APIs); |
| 577 InitState init; |
| 578 init.gl_version = "OpenGL ES 3.0"; |
| 579 init.bind_generates_resource = true; |
| 580 init.context_type = CONTEXT_TYPE_OPENGLES3; |
| 581 InitDecoderWithCommandLine(init, &command_line); |
| 582 } |
| 583 }; |
| 584 |
| 571 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest2, ::testing::Bool()); | 585 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest2, ::testing::Bool()); |
| 586 INSTANTIATE_TEST_CASE_P(Service, GLES3DecoderTest2, ::testing::Bool()); |
| 572 | 587 |
| 573 template <> | 588 template <> |
| 574 void GLES2DecoderTestBase::SpecializedSetup<cmds::GetProgramInfoLog, 0>( | 589 void GLES2DecoderTestBase::SpecializedSetup<cmds::GetProgramInfoLog, 0>( |
| 575 bool /* valid */) { | 590 bool /* valid */) { |
| 576 const GLuint kClientVertexShaderId = 5001; | 591 const GLuint kClientVertexShaderId = 5001; |
| 577 const GLuint kServiceVertexShaderId = 6001; | 592 const GLuint kServiceVertexShaderId = 6001; |
| 578 const GLuint kClientFragmentShaderId = 5002; | 593 const GLuint kClientFragmentShaderId = 5002; |
| 579 const GLuint kServiceFragmentShaderId = 6002; | 594 const GLuint kServiceFragmentShaderId = 6002; |
| 580 const char* log = "hello"; // Matches auto-generated unit test. | 595 const char* log = "hello"; // Matches auto-generated unit test. |
| 581 DoCreateShader( | 596 DoCreateShader( |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 | 949 |
| 935 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_INT_VEC4) { | 950 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_INT_VEC4) { |
| 936 TestAcceptedUniform(GL_INT_VEC4, Program::kUniform4i, false); | 951 TestAcceptedUniform(GL_INT_VEC4, Program::kUniform4i, false); |
| 937 } | 952 } |
| 938 | 953 |
| 939 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_BOOL) { | 954 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_BOOL) { |
| 940 TestAcceptedUniform( | 955 TestAcceptedUniform( |
| 941 GL_BOOL, Program::kUniform1i | Program::kUniform1f, false); | 956 GL_BOOL, Program::kUniform1i | Program::kUniform1f, false); |
| 942 } | 957 } |
| 943 | 958 |
| 944 TEST_P(GLES2DecoderTest2, AcceptsUniformES3_GL_BOOL) { | 959 TEST_P(GLES3DecoderTest2, AcceptsUniformES3_GL_BOOL) { |
| 945 TestAcceptedUniform( | 960 TestAcceptedUniform( |
| 946 GL_BOOL, | 961 GL_BOOL, |
| 947 Program::kUniform1i | Program::kUniform1f | Program::kUniform1ui, | 962 Program::kUniform1i | Program::kUniform1f | Program::kUniform1ui, |
| 948 true); | 963 true); |
| 949 } | 964 } |
| 950 | 965 |
| 951 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_BOOL_VEC2) { | 966 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_BOOL_VEC2) { |
| 952 TestAcceptedUniform( | 967 TestAcceptedUniform( |
| 953 GL_BOOL_VEC2, Program::kUniform2i | Program::kUniform2f, false); | 968 GL_BOOL_VEC2, Program::kUniform2i | Program::kUniform2f, false); |
| 954 } | 969 } |
| 955 | 970 |
| 956 TEST_P(GLES2DecoderTest2, AcceptsUniformES3_GL_BOOL_VEC2) { | 971 TEST_P(GLES3DecoderTest2, AcceptsUniformES3_GL_BOOL_VEC2) { |
| 957 TestAcceptedUniform( | 972 TestAcceptedUniform( |
| 958 GL_BOOL_VEC2, | 973 GL_BOOL_VEC2, |
| 959 Program::kUniform2i | Program::kUniform2f | Program::kUniform2ui, | 974 Program::kUniform2i | Program::kUniform2f | Program::kUniform2ui, |
| 960 true); | 975 true); |
| 961 } | 976 } |
| 962 | 977 |
| 963 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_BOOL_VEC3) { | 978 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_BOOL_VEC3) { |
| 964 TestAcceptedUniform( | 979 TestAcceptedUniform( |
| 965 GL_BOOL_VEC3, Program::kUniform3i | Program::kUniform3f, false); | 980 GL_BOOL_VEC3, Program::kUniform3i | Program::kUniform3f, false); |
| 966 } | 981 } |
| 967 | 982 |
| 968 TEST_P(GLES2DecoderTest2, AcceptsUniformES3_GL_BOOL_VEC3) { | 983 TEST_P(GLES3DecoderTest2, AcceptsUniformES3_GL_BOOL_VEC3) { |
| 969 TestAcceptedUniform( | 984 TestAcceptedUniform( |
| 970 GL_BOOL_VEC3, | 985 GL_BOOL_VEC3, |
| 971 Program::kUniform3i | Program::kUniform3f | Program::kUniform3ui, | 986 Program::kUniform3i | Program::kUniform3f | Program::kUniform3ui, |
| 972 true); | 987 true); |
| 973 } | 988 } |
| 974 | 989 |
| 975 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_BOOL_VEC4) { | 990 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_BOOL_VEC4) { |
| 976 TestAcceptedUniform( | 991 TestAcceptedUniform( |
| 977 GL_BOOL_VEC4, Program::kUniform4i | Program::kUniform4f, false); | 992 GL_BOOL_VEC4, Program::kUniform4i | Program::kUniform4f, false); |
| 978 } | 993 } |
| 979 | 994 |
| 980 TEST_P(GLES2DecoderTest2, AcceptsUniformES3_GL_BOOL_VEC4) { | 995 TEST_P(GLES3DecoderTest2, AcceptsUniformES3_GL_BOOL_VEC4) { |
| 981 TestAcceptedUniform( | 996 TestAcceptedUniform( |
| 982 GL_BOOL_VEC4, | 997 GL_BOOL_VEC4, |
| 983 Program::kUniform4i | Program::kUniform4f | Program::kUniform4ui, | 998 Program::kUniform4i | Program::kUniform4f | Program::kUniform4ui, |
| 984 true); | 999 true); |
| 985 } | 1000 } |
| 986 | 1001 |
| 987 TEST_P(GLES2DecoderTest2, AcceptsUniformTypeFLOAT) { | 1002 TEST_P(GLES2DecoderTest2, AcceptsUniformTypeFLOAT) { |
| 988 TestAcceptedUniform(GL_FLOAT, Program::kUniform1f, false); | 1003 TestAcceptedUniform(GL_FLOAT, Program::kUniform1f, false); |
| 989 } | 1004 } |
| 990 | 1005 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1005 } | 1020 } |
| 1006 | 1021 |
| 1007 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_FLOAT_MAT3) { | 1022 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_FLOAT_MAT3) { |
| 1008 TestAcceptedUniform(GL_FLOAT_MAT3, Program::kUniformMatrix3f, false); | 1023 TestAcceptedUniform(GL_FLOAT_MAT3, Program::kUniformMatrix3f, false); |
| 1009 } | 1024 } |
| 1010 | 1025 |
| 1011 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_FLOAT_MAT4) { | 1026 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_FLOAT_MAT4) { |
| 1012 TestAcceptedUniform(GL_FLOAT_MAT4, Program::kUniformMatrix4f, false); | 1027 TestAcceptedUniform(GL_FLOAT_MAT4, Program::kUniformMatrix4f, false); |
| 1013 } | 1028 } |
| 1014 | 1029 |
| 1015 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_UNSIGNED_INT) { | 1030 TEST_P(GLES3DecoderTest2, AcceptsUniform_GL_UNSIGNED_INT) { |
| 1016 TestAcceptedUniform(GL_UNSIGNED_INT, Program::kUniform1ui, true); | 1031 TestAcceptedUniform(GL_UNSIGNED_INT, Program::kUniform1ui, true); |
| 1017 } | 1032 } |
| 1018 | 1033 |
| 1019 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_UNSIGNED_INT_VEC2) { | 1034 TEST_P(GLES3DecoderTest2, AcceptsUniform_GL_UNSIGNED_INT_VEC2) { |
| 1020 TestAcceptedUniform(GL_UNSIGNED_INT_VEC2, Program::kUniform2ui, true); | 1035 TestAcceptedUniform(GL_UNSIGNED_INT_VEC2, Program::kUniform2ui, true); |
| 1021 } | 1036 } |
| 1022 | 1037 |
| 1023 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_UNSIGNED_INT_VEC3) { | 1038 TEST_P(GLES3DecoderTest2, AcceptsUniform_GL_UNSIGNED_INT_VEC3) { |
| 1024 TestAcceptedUniform(GL_UNSIGNED_INT_VEC3, Program::kUniform3ui, true); | 1039 TestAcceptedUniform(GL_UNSIGNED_INT_VEC3, Program::kUniform3ui, true); |
| 1025 } | 1040 } |
| 1026 | 1041 |
| 1027 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_UNSIGNED_INT_VEC4) { | 1042 TEST_P(GLES3DecoderTest2, AcceptsUniform_GL_UNSIGNED_INT_VEC4) { |
| 1028 TestAcceptedUniform(GL_UNSIGNED_INT_VEC4, Program::kUniform4ui, true); | 1043 TestAcceptedUniform(GL_UNSIGNED_INT_VEC4, Program::kUniform4ui, true); |
| 1029 } | 1044 } |
| 1030 | 1045 |
| 1031 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_FLOAT_MAT2x3) { | 1046 TEST_P(GLES3DecoderTest2, AcceptsUniform_GL_FLOAT_MAT2x3) { |
| 1032 TestAcceptedUniform(GL_FLOAT_MAT2x3, Program::kUniformMatrix2x3f, true); | 1047 TestAcceptedUniform(GL_FLOAT_MAT2x3, Program::kUniformMatrix2x3f, true); |
| 1033 } | 1048 } |
| 1034 | 1049 |
| 1035 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_FLOAT_MAT2x4) { | 1050 TEST_P(GLES3DecoderTest2, AcceptsUniform_GL_FLOAT_MAT2x4) { |
| 1036 TestAcceptedUniform(GL_FLOAT_MAT2x4, Program::kUniformMatrix2x4f, true); | 1051 TestAcceptedUniform(GL_FLOAT_MAT2x4, Program::kUniformMatrix2x4f, true); |
| 1037 } | 1052 } |
| 1038 | 1053 |
| 1039 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_FLOAT_MAT3x2) { | 1054 TEST_P(GLES3DecoderTest2, AcceptsUniform_GL_FLOAT_MAT3x2) { |
| 1040 TestAcceptedUniform(GL_FLOAT_MAT3x2, Program::kUniformMatrix3x2f, true); | 1055 TestAcceptedUniform(GL_FLOAT_MAT3x2, Program::kUniformMatrix3x2f, true); |
| 1041 } | 1056 } |
| 1042 | 1057 |
| 1043 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_FLOAT_MAT3x4) { | 1058 TEST_P(GLES3DecoderTest2, AcceptsUniform_GL_FLOAT_MAT3x4) { |
| 1044 TestAcceptedUniform(GL_FLOAT_MAT3x4, Program::kUniformMatrix3x4f, true); | 1059 TestAcceptedUniform(GL_FLOAT_MAT3x4, Program::kUniformMatrix3x4f, true); |
| 1045 } | 1060 } |
| 1046 | 1061 |
| 1047 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_FLOAT_MAT4x2) { | 1062 TEST_P(GLES3DecoderTest2, AcceptsUniform_GL_FLOAT_MAT4x2) { |
| 1048 TestAcceptedUniform(GL_FLOAT_MAT4x2, Program::kUniformMatrix4x2f, true); | 1063 TestAcceptedUniform(GL_FLOAT_MAT4x2, Program::kUniformMatrix4x2f, true); |
| 1049 } | 1064 } |
| 1050 | 1065 |
| 1051 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_FLOAT_MAT4x3) { | 1066 TEST_P(GLES3DecoderTest2, AcceptsUniform_GL_FLOAT_MAT4x3) { |
| 1052 TestAcceptedUniform(GL_FLOAT_MAT4x3, Program::kUniformMatrix4x3f, true); | 1067 TestAcceptedUniform(GL_FLOAT_MAT4x3, Program::kUniformMatrix4x3f, true); |
| 1053 } | 1068 } |
| 1054 | 1069 |
| 1055 } // namespace gles2 | 1070 } // namespace gles2 |
| 1056 } // namespace gpu | 1071 } // namespace gpu |
| 1057 | 1072 |
| OLD | NEW |