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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 using ::testing::StrEq; | 35 using ::testing::StrEq; |
36 | 36 |
37 namespace gpu { | 37 namespace gpu { |
38 namespace gles2 { | 38 namespace gles2 { |
39 | 39 |
40 namespace { | 40 namespace { |
41 const char kGLRendererStringANGLE[] = "ANGLE (some renderer)"; | 41 const char kGLRendererStringANGLE[] = "ANGLE (some renderer)"; |
42 } // anonymous namespace | 42 } // anonymous namespace |
43 | 43 |
44 enum MockedGLVersionKind { | 44 enum MockedGLVersionKind { |
45 Version3_0, | 45 ES2_on_Version3_0, |
46 Version3_2Compatibility | 46 ES2_on_Version3_2Compatibility, |
| 47 ES3_on_Version3_0, |
| 48 ES3_on_Version3_2Compatibility |
47 }; | 49 }; |
48 | 50 |
49 class FeatureInfoTest | 51 class FeatureInfoTest |
50 : public GpuServiceTest, | 52 : public GpuServiceTest, |
51 public ::testing::WithParamInterface<MockedGLVersionKind> { | 53 public ::testing::WithParamInterface<MockedGLVersionKind> { |
52 public: | 54 public: |
53 FeatureInfoTest() { | 55 FeatureInfoTest() { |
54 } | 56 } |
55 | 57 |
56 void SetupInitExpectations(const char* extensions) { | 58 void SetupInitExpectations(const char* extensions) { |
57 std::string extensions_str = extensions; | 59 std::string extensions_str = extensions; |
58 // Most of the tests' expectations currently assume the desktop | 60 // Most of the tests' expectations currently assume the desktop |
59 // OpenGL compatibility profile. | 61 // OpenGL compatibility profile. |
60 switch (GetParam()) { | 62 switch (GetParam()) { |
61 case Version3_0: | 63 case ES2_on_Version3_0: |
| 64 case ES3_on_Version3_0: |
62 SetupInitExpectationsWithGLVersion(extensions_str.c_str(), "", "3.0"); | 65 SetupInitExpectationsWithGLVersion(extensions_str.c_str(), "", "3.0"); |
63 break; | 66 break; |
64 case Version3_2Compatibility: | 67 case ES2_on_Version3_2Compatibility: |
| 68 case ES3_on_Version3_2Compatibility: |
65 if (extensions_str.find("GL_ARB_compatibility") == std::string::npos) { | 69 if (extensions_str.find("GL_ARB_compatibility") == std::string::npos) { |
66 extensions_str += " GL_ARB_compatibility"; | 70 extensions_str += " GL_ARB_compatibility"; |
67 } | 71 } |
68 SetupInitExpectationsWithGLVersion(extensions_str.c_str(), "", "3.2"); | 72 SetupInitExpectationsWithGLVersion(extensions_str.c_str(), "", "3.2"); |
69 break; | 73 break; |
70 default: | 74 default: |
71 NOTREACHED(); | 75 NOTREACHED(); |
72 break; | 76 break; |
73 } | 77 } |
74 } | 78 } |
75 | 79 |
| 80 ContextType GetContextType() { |
| 81 switch (GetParam()) { |
| 82 case ES2_on_Version3_0: |
| 83 case ES2_on_Version3_2Compatibility: |
| 84 return CONTEXT_TYPE_OPENGLES2; |
| 85 case ES3_on_Version3_0: |
| 86 case ES3_on_Version3_2Compatibility: |
| 87 return CONTEXT_TYPE_OPENGLES3; |
| 88 } |
| 89 } |
| 90 |
76 void SetupInitExpectationsWithGLVersion( | 91 void SetupInitExpectationsWithGLVersion( |
77 const char* extensions, const char* renderer, const char* version) { | 92 const char* extensions, const char* renderer, const char* version) { |
78 GpuServiceTest::SetUpWithGLVersion(version, extensions); | 93 GpuServiceTest::SetUpWithGLVersion(version, extensions); |
79 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( | 94 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( |
80 gl_.get(), extensions, renderer, version); | 95 gl_.get(), extensions, renderer, version); |
81 info_ = new FeatureInfo(); | 96 info_ = new FeatureInfo(); |
82 info_->InitializeForTesting(); | 97 info_->Initialize(GetContextType(), DisallowedFeatures()); |
83 } | 98 } |
84 | 99 |
85 void SetupInitExpectationsWithGLVersionAndDisallowedFeatures( | 100 void SetupInitExpectationsWithGLVersionAndDisallowedFeatures( |
86 const char* extensions, | 101 const char* extensions, |
87 const char* renderer, | 102 const char* renderer, |
88 const char* version, | 103 const char* version, |
89 const DisallowedFeatures& disallowed_features) { | 104 const DisallowedFeatures& disallowed_features) { |
90 GpuServiceTest::SetUpWithGLVersion(version, extensions); | 105 GpuServiceTest::SetUpWithGLVersion(version, extensions); |
91 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( | 106 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( |
92 gl_.get(), extensions, renderer, version); | 107 gl_.get(), extensions, renderer, version); |
93 info_ = new FeatureInfo(); | 108 info_ = new FeatureInfo(); |
94 info_->InitializeForTesting(disallowed_features); | 109 info_->Initialize(GetContextType(), disallowed_features); |
95 } | 110 } |
96 | 111 |
97 void SetupInitExpectationsWithGLVersionAndCommandLine( | 112 void SetupInitExpectationsWithGLVersionAndCommandLine( |
98 const char* extensions, | 113 const char* extensions, |
99 const char* renderer, | 114 const char* renderer, |
100 const char* version, | 115 const char* version, |
101 const base::CommandLine& command_line) { | 116 const base::CommandLine& command_line) { |
102 GpuServiceTest::SetUpWithGLVersion(version, extensions); | 117 GpuServiceTest::SetUpWithGLVersion(version, extensions); |
103 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( | 118 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( |
104 gl_.get(), extensions, renderer, version); | 119 gl_.get(), extensions, renderer, version); |
105 GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line); | 120 GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line); |
106 info_ = new FeatureInfo(command_line, gpu_driver_bug_workaround); | 121 info_ = new FeatureInfo(command_line, gpu_driver_bug_workaround); |
107 info_->InitializeForTesting(); | 122 info_->Initialize(GetContextType(), DisallowedFeatures()); |
108 } | 123 } |
109 | 124 |
110 void SetupWithCommandLine(const base::CommandLine& command_line) { | 125 void SetupWithCommandLine(const base::CommandLine& command_line) { |
111 GpuServiceTest::SetUp(); | 126 GpuServiceTest::SetUp(); |
112 GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line); | 127 GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line); |
113 info_ = new FeatureInfo(command_line, gpu_driver_bug_workaround); | 128 info_ = new FeatureInfo(command_line, gpu_driver_bug_workaround); |
114 } | 129 } |
115 | 130 |
116 void SetupInitExpectationsWithCommandLine( | 131 void SetupInitExpectationsWithCommandLine( |
117 const char* extensions, | 132 const char* extensions, |
118 const base::CommandLine& command_line) { | 133 const base::CommandLine& command_line) { |
119 GpuServiceTest::SetUpWithGLVersion("2.0", extensions); | 134 GpuServiceTest::SetUpWithGLVersion("2.0", extensions); |
120 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( | 135 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( |
121 gl_.get(), extensions, "", ""); | 136 gl_.get(), extensions, "", ""); |
122 GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line); | 137 GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line); |
123 info_ = new FeatureInfo(command_line, gpu_driver_bug_workaround); | 138 info_ = new FeatureInfo(command_line, gpu_driver_bug_workaround); |
124 info_->InitializeForTesting(); | 139 info_->Initialize(GetContextType(), DisallowedFeatures()); |
125 } | 140 } |
126 | 141 |
127 void SetupWithoutInit() { | 142 void SetupWithoutInit() { |
128 GpuServiceTest::SetUp(); | 143 GpuServiceTest::SetUp(); |
129 info_ = new FeatureInfo(); | 144 info_ = new FeatureInfo(); |
130 } | 145 } |
131 | 146 |
132 protected: | 147 protected: |
133 void SetUp() override { | 148 void SetUp() override { |
134 // Do nothing here, since we are using the explicit Setup*() functions. | 149 // Do nothing here, since we are using the explicit Setup*() functions. |
(...skipping 11 matching lines...) Expand all Loading... |
146 | 161 |
147 struct FormatInfo { | 162 struct FormatInfo { |
148 GLenum format; | 163 GLenum format; |
149 const GLenum* types; | 164 const GLenum* types; |
150 size_t count; | 165 size_t count; |
151 }; | 166 }; |
152 | 167 |
153 } // anonymous namespace. | 168 } // anonymous namespace. |
154 | 169 |
155 static const MockedGLVersionKind kGLVersionKinds[] = { | 170 static const MockedGLVersionKind kGLVersionKinds[] = { |
156 Version3_0, | 171 ES2_on_Version3_0, |
157 Version3_2Compatibility | 172 ES2_on_Version3_2Compatibility, |
| 173 ES3_on_Version3_0, |
| 174 ES3_on_Version3_2Compatibility |
158 }; | 175 }; |
159 | 176 |
160 INSTANTIATE_TEST_CASE_P(Service, | 177 INSTANTIATE_TEST_CASE_P(Service, |
161 FeatureInfoTest, | 178 FeatureInfoTest, |
162 ::testing::ValuesIn(kGLVersionKinds)); | 179 ::testing::ValuesIn(kGLVersionKinds)); |
163 | 180 |
164 TEST_P(FeatureInfoTest, Basic) { | 181 TEST_P(FeatureInfoTest, Basic) { |
165 SetupWithoutInit(); | 182 SetupWithoutInit(); |
166 // Test it starts off uninitialized. | 183 // Test it starts off uninitialized. |
167 EXPECT_FALSE(info_->feature_flags().chromium_framebuffer_multisample); | 184 EXPECT_FALSE(info_->feature_flags().chromium_framebuffer_multisample); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 468 |
452 TEST_P(FeatureInfoTest, InitializeGLES_no_EXT_read_format_bgra) { | 469 TEST_P(FeatureInfoTest, InitializeGLES_no_EXT_read_format_bgra) { |
453 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 2.0"); | 470 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 2.0"); |
454 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_read_format_bgra"))); | 471 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_read_format_bgra"))); |
455 EXPECT_FALSE(info_->feature_flags().ext_read_format_bgra); | 472 EXPECT_FALSE(info_->feature_flags().ext_read_format_bgra); |
456 EXPECT_FALSE(info_->validators()->read_pixel_format.IsValid(GL_BGRA_EXT)); | 473 EXPECT_FALSE(info_->validators()->read_pixel_format.IsValid(GL_BGRA_EXT)); |
457 } | 474 } |
458 | 475 |
459 TEST_P(FeatureInfoTest, InitializeEXT_sRGB) { | 476 TEST_P(FeatureInfoTest, InitializeEXT_sRGB) { |
460 SetupInitExpectations("GL_EXT_sRGB GL_OES_rgb8_rgba8"); | 477 SetupInitExpectations("GL_EXT_sRGB GL_OES_rgb8_rgba8"); |
461 EXPECT_THAT(info_->extensions(), | 478 |
462 HasSubstr("GL_EXT_sRGB")); | 479 if (GetContextType() == CONTEXT_TYPE_OPENGLES3) { |
463 EXPECT_TRUE(info_->validators()->texture_format.IsValid( | 480 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_sRGB"))); |
464 GL_SRGB_EXT)); | 481 EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_SRGB_EXT)); |
465 EXPECT_TRUE(info_->validators()->texture_format.IsValid( | 482 EXPECT_FALSE( |
466 GL_SRGB_ALPHA_EXT)); | 483 info_->validators()->texture_format.IsValid(GL_SRGB_ALPHA_EXT)); |
467 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid( | 484 EXPECT_FALSE( |
468 GL_SRGB_EXT)); | 485 info_->validators()->texture_internal_format.IsValid(GL_SRGB_EXT)); |
469 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid( | 486 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid( |
470 GL_SRGB_ALPHA_EXT)); | 487 GL_SRGB_ALPHA_EXT)); |
471 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid( | 488 EXPECT_FALSE( |
472 GL_SRGB8_ALPHA8_EXT)); | 489 info_->validators()->render_buffer_format.IsValid(GL_SRGB8_ALPHA8_EXT)); |
473 EXPECT_TRUE(info_->validators()->frame_buffer_parameter.IsValid( | 490 EXPECT_FALSE(info_->validators()->frame_buffer_parameter.IsValid( |
474 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT)); | 491 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT)); |
| 492 } else { |
| 493 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_sRGB")); |
| 494 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_SRGB_EXT)); |
| 495 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_SRGB_ALPHA_EXT)); |
| 496 EXPECT_TRUE( |
| 497 info_->validators()->texture_internal_format.IsValid(GL_SRGB_EXT)); |
| 498 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid( |
| 499 GL_SRGB_ALPHA_EXT)); |
| 500 EXPECT_TRUE( |
| 501 info_->validators()->render_buffer_format.IsValid(GL_SRGB8_ALPHA8_EXT)); |
| 502 EXPECT_TRUE(info_->validators()->frame_buffer_parameter.IsValid( |
| 503 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT)); |
| 504 } |
475 } | 505 } |
476 | 506 |
477 TEST_P(FeatureInfoTest, InitializeGLES2EXT_texture_storage) { | 507 TEST_P(FeatureInfoTest, InitializeGLES2EXT_texture_storage) { |
478 SetupInitExpectationsWithGLVersion( | 508 SetupInitExpectationsWithGLVersion( |
479 "GL_EXT_texture_storage", "", "OpenGL ES 2.0"); | 509 "GL_EXT_texture_storage", "", "OpenGL ES 2.0"); |
480 EXPECT_TRUE(info_->feature_flags().ext_texture_storage); | 510 EXPECT_TRUE(info_->feature_flags().ext_texture_storage); |
481 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); | 511 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); |
482 EXPECT_TRUE(info_->validators()->texture_parameter.IsValid( | 512 EXPECT_TRUE(info_->validators()->texture_parameter.IsValid( |
483 GL_TEXTURE_IMMUTABLE_FORMAT_EXT)); | 513 GL_TEXTURE_IMMUTABLE_FORMAT_EXT)); |
484 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( | 514 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 | 681 |
652 // 4- ES2 (neither GL_EXT_texture_storage nor GL_EXT_texture_format_BGRA8888) -> | 682 // 4- ES2 (neither GL_EXT_texture_storage nor GL_EXT_texture_format_BGRA8888) -> |
653 // nothing | 683 // nothing |
654 TEST_P(FeatureInfoTest, InitializeGLES2_neither_texture_storage_nor_BGRA) { | 684 TEST_P(FeatureInfoTest, InitializeGLES2_neither_texture_storage_nor_BGRA) { |
655 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 2.0"); | 685 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 2.0"); |
656 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_texture_storage"))); | 686 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_texture_storage"))); |
657 EXPECT_THAT(info_->extensions(), | 687 EXPECT_THAT(info_->extensions(), |
658 Not(HasSubstr("GL_EXT_texture_format_BGRA8888"))); | 688 Not(HasSubstr("GL_EXT_texture_format_BGRA8888"))); |
659 } | 689 } |
660 | 690 |
661 // 5- ES3 + GL_EXT_texture_format_BGRA8888 -> GL_EXT_texture_format_BGRA8888 | 691 // 5- ES3 + GL_EXT_texture_format_BGRA8888 |
662 // (we can't expose GL_EXT_texture_storage because we fail the GL_BGRA8 | 692 // If creating a GLES2 context, expose GL_EXT_texture_format_BGRA8888 |
| 693 // If creating a GLES3 context, expose GL_EXT_texture_storage |
| 694 // (we can't expose both at the same time because we fail the GL_BGRA8 |
663 // requirement) | 695 // requirement) |
664 TEST_P(FeatureInfoTest, InitializeGLES3_texture_storage_EXT_BGRA) { | 696 TEST_P(FeatureInfoTest, InitializeGLES3_texture_storage_EXT_BGRA) { |
665 SetupInitExpectationsWithGLVersion( | 697 SetupInitExpectationsWithGLVersion( |
666 "GL_EXT_texture_format_BGRA8888", "", "OpenGL ES 3.0"); | 698 "GL_EXT_texture_format_BGRA8888", "", "OpenGL ES 3.0"); |
667 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_texture_storage"))); | 699 if (GetContextType() == CONTEXT_TYPE_OPENGLES3) { |
668 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888")); | 700 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); |
| 701 EXPECT_THAT(info_->extensions(), |
| 702 Not(HasSubstr("GL_EXT_texture_format_BGRA8888"))); |
| 703 } else { |
| 704 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_texture_storage"))); |
| 705 EXPECT_THAT(info_->extensions(), |
| 706 HasSubstr("GL_EXT_texture_format_BGRA8888")); |
| 707 } |
669 } | 708 } |
670 | 709 |
671 // 6- ES3 + GL_APPLE_texture_format_bgra8888 -> GL_EXT_texture_storage + | 710 // 6- ES3 + GL_APPLE_texture_format_bgra8888 -> GL_EXT_texture_storage + |
672 // GL_EXT_texture_format_BGRA8888 (driver promises to handle GL_BGRA8 by | 711 // GL_EXT_texture_format_BGRA8888 (driver promises to handle GL_BGRA8 by |
673 // exposing GL_APPLE_texture_format_bgra8888) | 712 // exposing GL_APPLE_texture_format_bgra8888) |
674 TEST_P(FeatureInfoTest, InitializeGLES3_texture_storage_APPLE_BGRA) { | 713 TEST_P(FeatureInfoTest, InitializeGLES3_texture_storage_APPLE_BGRA) { |
675 SetupInitExpectationsWithGLVersion( | 714 SetupInitExpectationsWithGLVersion( |
676 "GL_APPLE_texture_format_BGRA8888", "", "OpenGL ES 3.0"); | 715 "GL_APPLE_texture_format_BGRA8888", "", "OpenGL ES 3.0"); |
677 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); | 716 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); |
678 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888")); | 717 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888")); |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1449 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(GL_RG8_EXT)); | 1488 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(GL_RG8_EXT)); |
1450 } | 1489 } |
1451 | 1490 |
1452 TEST_P(FeatureInfoTest, InitializeCHROMIUM_ycbcr_422_imageTrue) { | 1491 TEST_P(FeatureInfoTest, InitializeCHROMIUM_ycbcr_422_imageTrue) { |
1453 SetupInitExpectations("GL_APPLE_ycbcr_422"); | 1492 SetupInitExpectations("GL_APPLE_ycbcr_422"); |
1454 EXPECT_TRUE(info_->feature_flags().chromium_image_ycbcr_422); | 1493 EXPECT_TRUE(info_->feature_flags().chromium_image_ycbcr_422); |
1455 } | 1494 } |
1456 | 1495 |
1457 } // namespace gles2 | 1496 } // namespace gles2 |
1458 } // namespace gpu | 1497 } // namespace gpu |
OLD | NEW |