| 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/feature_info.h" | 5 #include "gpu/command_buffer/service/feature_info.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "gpu/command_buffer/service/gpu_service_test.h" | 10 #include "gpu/command_buffer/service/gpu_service_test.h" |
| 11 #include "gpu/command_buffer/service/gpu_switches.h" | 11 #include "gpu/command_buffer/service/gpu_switches.h" |
| 12 #include "gpu/command_buffer/service/test_helper.h" | 12 #include "gpu/command_buffer/service/test_helper.h" |
| 13 #include "gpu/command_buffer/service/texture_manager.h" | 13 #include "gpu/command_buffer/service/texture_manager.h" |
| 14 #include "gpu/config/gpu_driver_bug_workaround_type.h" | 14 #include "gpu/config/gpu_driver_bug_workaround_type.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "ui/gl/gl_fence.h" |
| 16 #include "ui/gl/gl_implementation.h" | 17 #include "ui/gl/gl_implementation.h" |
| 17 #include "ui/gl/gl_mock.h" | 18 #include "ui/gl/gl_mock.h" |
| 18 | 19 |
| 19 using ::testing::_; | 20 using ::testing::_; |
| 20 using ::testing::DoAll; | 21 using ::testing::DoAll; |
| 21 using ::testing::HasSubstr; | 22 using ::testing::HasSubstr; |
| 22 using ::testing::InSequence; | 23 using ::testing::InSequence; |
| 23 using ::testing::MatcherCast; | 24 using ::testing::MatcherCast; |
| 24 using ::testing::Not; | 25 using ::testing::Not; |
| 25 using ::testing::Pointee; | 26 using ::testing::Pointee; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 39 public: | 40 public: |
| 40 FeatureInfoTest() { | 41 FeatureInfoTest() { |
| 41 } | 42 } |
| 42 | 43 |
| 43 void SetupInitExpectations(const char* extensions) { | 44 void SetupInitExpectations(const char* extensions) { |
| 44 SetupInitExpectationsWithGLVersion(extensions, "", ""); | 45 SetupInitExpectationsWithGLVersion(extensions, "", ""); |
| 45 } | 46 } |
| 46 | 47 |
| 47 void SetupInitExpectationsWithGLVersion( | 48 void SetupInitExpectationsWithGLVersion( |
| 48 const char* extensions, const char* renderer, const char* version) { | 49 const char* extensions, const char* renderer, const char* version) { |
| 50 GpuServiceTest::SetUpWithGLVersion(version, extensions); |
| 49 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( | 51 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( |
| 50 gl_.get(), extensions, renderer, version); | 52 gl_.get(), extensions, renderer, version); |
| 51 info_ = new FeatureInfo(); | 53 info_ = new FeatureInfo(); |
| 52 info_->Initialize(); | 54 info_->Initialize(); |
| 53 } | 55 } |
| 54 | 56 |
| 55 void SetupWithCommandLine(const CommandLine& command_line) { | 57 void SetupWithCommandLine(const CommandLine& command_line) { |
| 58 GpuServiceTest::SetUp(); |
| 56 info_ = new FeatureInfo(command_line); | 59 info_ = new FeatureInfo(command_line); |
| 57 } | 60 } |
| 58 | 61 |
| 59 void SetupInitExpectationsWithCommandLine( | 62 void SetupInitExpectationsWithCommandLine( |
| 60 const char* extensions, const CommandLine& command_line) { | 63 const char* extensions, const CommandLine& command_line) { |
| 64 GpuServiceTest::SetUpWithGLVersion("2.0", extensions); |
| 61 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( | 65 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( |
| 62 gl_.get(), extensions, "", ""); | 66 gl_.get(), extensions, "", ""); |
| 63 info_ = new FeatureInfo(command_line); | 67 info_ = new FeatureInfo(command_line); |
| 64 info_->Initialize(); | 68 info_->Initialize(); |
| 65 } | 69 } |
| 66 | 70 |
| 67 void SetupWithoutInit() { | 71 void SetupWithoutInit() { |
| 72 GpuServiceTest::SetUp(); |
| 68 info_ = new FeatureInfo(); | 73 info_ = new FeatureInfo(); |
| 69 } | 74 } |
| 70 | 75 |
| 71 protected: | 76 protected: |
| 72 virtual void TearDown() { | 77 virtual void SetUp() OVERRIDE { |
| 78 // Do nothing here, since we are using the explicit Setup*() functions. |
| 79 } |
| 80 |
| 81 virtual void TearDown() OVERRIDE { |
| 73 info_ = NULL; | 82 info_ = NULL; |
| 74 GpuServiceTest::TearDown(); | 83 GpuServiceTest::TearDown(); |
| 75 } | 84 } |
| 76 | 85 |
| 77 scoped_refptr<FeatureInfo> info_; | 86 scoped_refptr<FeatureInfo> info_; |
| 78 }; | 87 }; |
| 79 | 88 |
| 80 namespace { | 89 namespace { |
| 81 | 90 |
| 82 struct FormatInfo { | 91 struct FormatInfo { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 EXPECT_FALSE(info_->validators()->texture_parameter.IsValid( | 312 EXPECT_FALSE(info_->validators()->texture_parameter.IsValid( |
| 304 GL_TEXTURE_USAGE_ANGLE)); | 313 GL_TEXTURE_USAGE_ANGLE)); |
| 305 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( | 314 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( |
| 306 GL_DEPTH_COMPONENT16)); | 315 GL_DEPTH_COMPONENT16)); |
| 307 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( | 316 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( |
| 308 GL_DEPTH_COMPONENT32_OES)); | 317 GL_DEPTH_COMPONENT32_OES)); |
| 309 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( | 318 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( |
| 310 GL_DEPTH24_STENCIL8_OES)); | 319 GL_DEPTH24_STENCIL8_OES)); |
| 311 EXPECT_FALSE(info_->validators()->equation.IsValid(GL_MIN_EXT)); | 320 EXPECT_FALSE(info_->validators()->equation.IsValid(GL_MIN_EXT)); |
| 312 EXPECT_FALSE(info_->validators()->equation.IsValid(GL_MAX_EXT)); | 321 EXPECT_FALSE(info_->validators()->equation.IsValid(GL_MAX_EXT)); |
| 322 EXPECT_FALSE(info_->feature_flags().chromium_sync_query); |
| 313 } | 323 } |
| 314 | 324 |
| 315 TEST_F(FeatureInfoTest, InitializeWithANGLE) { | 325 TEST_F(FeatureInfoTest, InitializeWithANGLE) { |
| 316 SetupInitExpectationsWithGLVersion("", kGLRendererStringANGLE, ""); | 326 SetupInitExpectationsWithGLVersion("", kGLRendererStringANGLE, ""); |
| 317 EXPECT_TRUE(info_->feature_flags().is_angle); | 327 EXPECT_TRUE(info_->feature_flags().is_angle); |
| 318 } | 328 } |
| 319 | 329 |
| 320 TEST_F(FeatureInfoTest, InitializeNPOTExtensionGLES) { | 330 TEST_F(FeatureInfoTest, InitializeNPOTExtensionGLES) { |
| 321 SetupInitExpectations("GL_OES_texture_npot"); | 331 SetupInitExpectations("GL_OES_texture_npot"); |
| 322 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_npot")); | 332 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_npot")); |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 .IsValid(GL_UNSIGNED_INT_24_8)); | 1010 .IsValid(GL_UNSIGNED_INT_24_8)); |
| 1001 EXPECT_TRUE(info_->feature_flags().packed_depth24_stencil8); | 1011 EXPECT_TRUE(info_->feature_flags().packed_depth24_stencil8); |
| 1002 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_depth24")); | 1012 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_depth24")); |
| 1003 EXPECT_TRUE( | 1013 EXPECT_TRUE( |
| 1004 info_->validators()->render_buffer_format.IsValid(GL_DEPTH_COMPONENT24)); | 1014 info_->validators()->render_buffer_format.IsValid(GL_DEPTH_COMPONENT24)); |
| 1005 EXPECT_TRUE( | 1015 EXPECT_TRUE( |
| 1006 info_->validators()->render_buffer_format.IsValid(GL_DEPTH24_STENCIL8)); | 1016 info_->validators()->render_buffer_format.IsValid(GL_DEPTH24_STENCIL8)); |
| 1007 EXPECT_TRUE( | 1017 EXPECT_TRUE( |
| 1008 info_->validators()->texture_internal_format.IsValid(GL_DEPTH_STENCIL)); | 1018 info_->validators()->texture_internal_format.IsValid(GL_DEPTH_STENCIL)); |
| 1009 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_STENCIL)); | 1019 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_STENCIL)); |
| 1020 EXPECT_TRUE(info_->feature_flags().chromium_sync_query); |
| 1021 EXPECT_TRUE(gfx::GLFence::IsSupported()); |
| 1010 } | 1022 } |
| 1011 | 1023 |
| 1012 TEST_F(FeatureInfoTest, InitializeWithoutSamplers) { | 1024 TEST_F(FeatureInfoTest, InitializeWithoutSamplers) { |
| 1013 SetupInitExpectationsWithGLVersion("", "", "OpenGL GL 3.0"); | 1025 SetupInitExpectationsWithGLVersion("", "", "OpenGL GL 3.0"); |
| 1014 EXPECT_FALSE(info_->feature_flags().enable_samplers); | 1026 EXPECT_FALSE(info_->feature_flags().enable_samplers); |
| 1015 } | 1027 } |
| 1016 | 1028 |
| 1017 TEST_F(FeatureInfoTest, InitializeWithES3AndFences) { | |
| 1018 SetupInitExpectationsWithGLVersion("EGL_KHR_fence_sync", "", "OpenGL ES 3.0"); | |
| 1019 EXPECT_TRUE(info_->feature_flags().use_async_readpixels); | |
| 1020 } | |
| 1021 | |
| 1022 TEST_F(FeatureInfoTest, ParseDriverBugWorkaroundsSingle) { | 1029 TEST_F(FeatureInfoTest, ParseDriverBugWorkaroundsSingle) { |
| 1023 CommandLine command_line(0, NULL); | 1030 CommandLine command_line(0, NULL); |
| 1024 command_line.AppendSwitchASCII( | 1031 command_line.AppendSwitchASCII( |
| 1025 switches::kGpuDriverBugWorkarounds, | 1032 switches::kGpuDriverBugWorkarounds, |
| 1026 base::IntToString(gpu::EXIT_ON_CONTEXT_LOST)); | 1033 base::IntToString(gpu::EXIT_ON_CONTEXT_LOST)); |
| 1027 // Workarounds should get parsed without the need for a context. | 1034 // Workarounds should get parsed without the need for a context. |
| 1028 SetupWithCommandLine(command_line); | 1035 SetupWithCommandLine(command_line); |
| 1029 EXPECT_TRUE(info_->workarounds().exit_on_context_lost); | 1036 EXPECT_TRUE(info_->workarounds().exit_on_context_lost); |
| 1030 } | 1037 } |
| 1031 | 1038 |
| 1032 TEST_F(FeatureInfoTest, ParseDriverBugWorkaroundsMultiple) { | 1039 TEST_F(FeatureInfoTest, ParseDriverBugWorkaroundsMultiple) { |
| 1033 CommandLine command_line(0, NULL); | 1040 CommandLine command_line(0, NULL); |
| 1034 command_line.AppendSwitchASCII( | 1041 command_line.AppendSwitchASCII( |
| 1035 switches::kGpuDriverBugWorkarounds, | 1042 switches::kGpuDriverBugWorkarounds, |
| 1036 base::IntToString(gpu::EXIT_ON_CONTEXT_LOST) + "," + | 1043 base::IntToString(gpu::EXIT_ON_CONTEXT_LOST) + "," + |
| 1037 base::IntToString(gpu::MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024) + "," + | 1044 base::IntToString(gpu::MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024) + "," + |
| 1038 base::IntToString(gpu::MAX_TEXTURE_SIZE_LIMIT_4096)); | 1045 base::IntToString(gpu::MAX_TEXTURE_SIZE_LIMIT_4096)); |
| 1039 // Workarounds should get parsed without the need for a context. | 1046 // Workarounds should get parsed without the need for a context. |
| 1040 SetupWithCommandLine(command_line); | 1047 SetupWithCommandLine(command_line); |
| 1041 EXPECT_TRUE(info_->workarounds().exit_on_context_lost); | 1048 EXPECT_TRUE(info_->workarounds().exit_on_context_lost); |
| 1042 EXPECT_EQ(1024, info_->workarounds().max_cube_map_texture_size); | 1049 EXPECT_EQ(1024, info_->workarounds().max_cube_map_texture_size); |
| 1043 EXPECT_EQ(4096, info_->workarounds().max_texture_size); | 1050 EXPECT_EQ(4096, info_->workarounds().max_texture_size); |
| 1044 } | 1051 } |
| 1045 | 1052 |
| 1053 TEST_F(FeatureInfoTest, InitializeWithARBSync) { |
| 1054 SetupInitExpectations("GL_ARB_sync"); |
| 1055 EXPECT_TRUE(info_->feature_flags().chromium_sync_query); |
| 1056 EXPECT_TRUE(gfx::GLFence::IsSupported()); |
| 1057 } |
| 1058 |
| 1059 TEST_F(FeatureInfoTest, InitializeWithNVFence) { |
| 1060 SetupInitExpectations("GL_NV_fence"); |
| 1061 EXPECT_TRUE(info_->feature_flags().chromium_sync_query); |
| 1062 EXPECT_TRUE(gfx::GLFence::IsSupported()); |
| 1063 } |
| 1064 |
| 1065 TEST_F(FeatureInfoTest, ARBSyncDisabled) { |
| 1066 CommandLine command_line(0, NULL); |
| 1067 command_line.AppendSwitchASCII( |
| 1068 switches::kGpuDriverBugWorkarounds, |
| 1069 base::IntToString(gpu::DISABLE_ARB_SYNC)); |
| 1070 SetupInitExpectationsWithCommandLine("GL_ARB_sync", command_line); |
| 1071 EXPECT_FALSE(info_->feature_flags().chromium_sync_query); |
| 1072 EXPECT_FALSE(gfx::GLFence::IsSupported()); |
| 1073 } |
| 1074 |
| 1046 } // namespace gles2 | 1075 } // namespace gles2 |
| 1047 } // namespace gpu | 1076 } // namespace gpu |
| OLD | NEW |