Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: gpu/command_buffer/service/feature_info_unittest.cc

Issue 2000923002: Only allow TexStorage2DEXT if we expose the extension (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments, build fixes Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 default:
89 NOTREACHED();
90 return CONTEXT_TYPE_OPENGLES2;
91 }
92 }
93
76 void SetupInitExpectationsWithGLVersion( 94 void SetupInitExpectationsWithGLVersion(
77 const char* extensions, const char* renderer, const char* version) { 95 const char* extensions, const char* renderer, const char* version) {
78 GpuServiceTest::SetUpWithGLVersion(version, extensions); 96 GpuServiceTest::SetUpWithGLVersion(version, extensions);
79 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( 97 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
80 gl_.get(), extensions, renderer, version); 98 gl_.get(), extensions, renderer, version);
81 info_ = new FeatureInfo(); 99 info_ = new FeatureInfo();
82 info_->InitializeForTesting(); 100 info_->Initialize(GetContextType(), DisallowedFeatures());
83 } 101 }
84 102
85 void SetupInitExpectationsWithGLVersionAndDisallowedFeatures( 103 void SetupInitExpectationsWithGLVersionAndDisallowedFeatures(
86 const char* extensions, 104 const char* extensions,
87 const char* renderer, 105 const char* renderer,
88 const char* version, 106 const char* version,
89 const DisallowedFeatures& disallowed_features) { 107 const DisallowedFeatures& disallowed_features) {
90 GpuServiceTest::SetUpWithGLVersion(version, extensions); 108 GpuServiceTest::SetUpWithGLVersion(version, extensions);
91 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( 109 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
92 gl_.get(), extensions, renderer, version); 110 gl_.get(), extensions, renderer, version);
93 info_ = new FeatureInfo(); 111 info_ = new FeatureInfo();
94 info_->InitializeForTesting(disallowed_features); 112 info_->Initialize(GetContextType(), disallowed_features);
95 } 113 }
96 114
97 void SetupInitExpectationsWithGLVersionAndCommandLine( 115 void SetupInitExpectationsWithGLVersionAndCommandLine(
98 const char* extensions, 116 const char* extensions,
99 const char* renderer, 117 const char* renderer,
100 const char* version, 118 const char* version,
101 const base::CommandLine& command_line) { 119 const base::CommandLine& command_line) {
102 GpuServiceTest::SetUpWithGLVersion(version, extensions); 120 GpuServiceTest::SetUpWithGLVersion(version, extensions);
103 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( 121 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
104 gl_.get(), extensions, renderer, version); 122 gl_.get(), extensions, renderer, version);
105 GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line); 123 GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line);
106 info_ = new FeatureInfo(command_line, gpu_driver_bug_workaround); 124 info_ = new FeatureInfo(command_line, gpu_driver_bug_workaround);
107 info_->InitializeForTesting(); 125 info_->Initialize(GetContextType(), DisallowedFeatures());
108 } 126 }
109 127
110 void SetupWithCommandLine(const base::CommandLine& command_line) { 128 void SetupWithCommandLine(const base::CommandLine& command_line) {
111 GpuServiceTest::SetUp(); 129 GpuServiceTest::SetUp();
112 GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line); 130 GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line);
113 info_ = new FeatureInfo(command_line, gpu_driver_bug_workaround); 131 info_ = new FeatureInfo(command_line, gpu_driver_bug_workaround);
114 } 132 }
115 133
116 void SetupInitExpectationsWithCommandLine( 134 void SetupInitExpectationsWithCommandLine(
117 const char* extensions, 135 const char* extensions,
118 const base::CommandLine& command_line) { 136 const base::CommandLine& command_line) {
119 GpuServiceTest::SetUpWithGLVersion("2.0", extensions); 137 GpuServiceTest::SetUpWithGLVersion("2.0", extensions);
120 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( 138 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
121 gl_.get(), extensions, "", ""); 139 gl_.get(), extensions, "", "");
122 GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line); 140 GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line);
123 info_ = new FeatureInfo(command_line, gpu_driver_bug_workaround); 141 info_ = new FeatureInfo(command_line, gpu_driver_bug_workaround);
124 info_->InitializeForTesting(); 142 info_->Initialize(GetContextType(), DisallowedFeatures());
125 } 143 }
126 144
127 void SetupWithoutInit() { 145 void SetupWithoutInit() {
128 GpuServiceTest::SetUp(); 146 GpuServiceTest::SetUp();
129 info_ = new FeatureInfo(); 147 info_ = new FeatureInfo();
130 } 148 }
131 149
132 protected: 150 protected:
133 void SetUp() override { 151 void SetUp() override {
134 // Do nothing here, since we are using the explicit Setup*() functions. 152 // Do nothing here, since we are using the explicit Setup*() functions.
(...skipping 11 matching lines...) Expand all
146 164
147 struct FormatInfo { 165 struct FormatInfo {
148 GLenum format; 166 GLenum format;
149 const GLenum* types; 167 const GLenum* types;
150 size_t count; 168 size_t count;
151 }; 169 };
152 170
153 } // anonymous namespace. 171 } // anonymous namespace.
154 172
155 static const MockedGLVersionKind kGLVersionKinds[] = { 173 static const MockedGLVersionKind kGLVersionKinds[] = {
156 Version3_0, 174 ES2_on_Version3_0,
157 Version3_2Compatibility 175 ES2_on_Version3_2Compatibility,
176 ES3_on_Version3_0,
177 ES3_on_Version3_2Compatibility
158 }; 178 };
159 179
160 INSTANTIATE_TEST_CASE_P(Service, 180 INSTANTIATE_TEST_CASE_P(Service,
161 FeatureInfoTest, 181 FeatureInfoTest,
162 ::testing::ValuesIn(kGLVersionKinds)); 182 ::testing::ValuesIn(kGLVersionKinds));
163 183
164 TEST_P(FeatureInfoTest, Basic) { 184 TEST_P(FeatureInfoTest, Basic) {
165 SetupWithoutInit(); 185 SetupWithoutInit();
166 // Test it starts off uninitialized. 186 // Test it starts off uninitialized.
167 EXPECT_FALSE(info_->feature_flags().chromium_framebuffer_multisample); 187 EXPECT_FALSE(info_->feature_flags().chromium_framebuffer_multisample);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 471
452 TEST_P(FeatureInfoTest, InitializeGLES_no_EXT_read_format_bgra) { 472 TEST_P(FeatureInfoTest, InitializeGLES_no_EXT_read_format_bgra) {
453 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 2.0"); 473 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 2.0");
454 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_read_format_bgra"))); 474 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_read_format_bgra")));
455 EXPECT_FALSE(info_->feature_flags().ext_read_format_bgra); 475 EXPECT_FALSE(info_->feature_flags().ext_read_format_bgra);
456 EXPECT_FALSE(info_->validators()->read_pixel_format.IsValid(GL_BGRA_EXT)); 476 EXPECT_FALSE(info_->validators()->read_pixel_format.IsValid(GL_BGRA_EXT));
457 } 477 }
458 478
459 TEST_P(FeatureInfoTest, InitializeEXT_sRGB) { 479 TEST_P(FeatureInfoTest, InitializeEXT_sRGB) {
460 SetupInitExpectations("GL_EXT_sRGB GL_OES_rgb8_rgba8"); 480 SetupInitExpectations("GL_EXT_sRGB GL_OES_rgb8_rgba8");
461 EXPECT_THAT(info_->extensions(), 481
462 HasSubstr("GL_EXT_sRGB")); 482 if (GetContextType() == CONTEXT_TYPE_OPENGLES3) {
463 EXPECT_TRUE(info_->validators()->texture_format.IsValid( 483 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_sRGB")));
464 GL_SRGB_EXT)); 484 EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_SRGB_EXT));
465 EXPECT_TRUE(info_->validators()->texture_format.IsValid( 485 EXPECT_FALSE(
466 GL_SRGB_ALPHA_EXT)); 486 info_->validators()->texture_format.IsValid(GL_SRGB_ALPHA_EXT));
467 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid( 487 EXPECT_FALSE(
468 GL_SRGB_EXT)); 488 info_->validators()->texture_internal_format.IsValid(GL_SRGB_EXT));
469 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid( 489 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
470 GL_SRGB_ALPHA_EXT)); 490 GL_SRGB_ALPHA_EXT));
471 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid( 491 EXPECT_FALSE(
472 GL_SRGB8_ALPHA8_EXT)); 492 info_->validators()->render_buffer_format.IsValid(GL_SRGB8_ALPHA8_EXT));
473 EXPECT_TRUE(info_->validators()->frame_buffer_parameter.IsValid( 493 EXPECT_FALSE(info_->validators()->frame_buffer_parameter.IsValid(
474 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT)); 494 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT));
495 } else {
496 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_sRGB"));
497 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_SRGB_EXT));
498 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_SRGB_ALPHA_EXT));
499 EXPECT_TRUE(
500 info_->validators()->texture_internal_format.IsValid(GL_SRGB_EXT));
501 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
502 GL_SRGB_ALPHA_EXT));
503 EXPECT_TRUE(
504 info_->validators()->render_buffer_format.IsValid(GL_SRGB8_ALPHA8_EXT));
505 EXPECT_TRUE(info_->validators()->frame_buffer_parameter.IsValid(
506 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT));
507 }
475 } 508 }
476 509
477 TEST_P(FeatureInfoTest, InitializeGLES2EXT_texture_storage) { 510 TEST_P(FeatureInfoTest, InitializeGLES2EXT_texture_storage) {
478 SetupInitExpectationsWithGLVersion( 511 SetupInitExpectationsWithGLVersion(
479 "GL_EXT_texture_storage", "", "OpenGL ES 2.0"); 512 "GL_EXT_texture_storage", "", "OpenGL ES 2.0");
480 EXPECT_TRUE(info_->feature_flags().ext_texture_storage); 513 EXPECT_TRUE(info_->feature_flags().ext_texture_storage);
481 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); 514 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
482 EXPECT_TRUE(info_->validators()->texture_parameter.IsValid( 515 EXPECT_TRUE(info_->validators()->texture_parameter.IsValid(
483 GL_TEXTURE_IMMUTABLE_FORMAT_EXT)); 516 GL_TEXTURE_IMMUTABLE_FORMAT_EXT));
484 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( 517 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 684
652 // 4- ES2 (neither GL_EXT_texture_storage nor GL_EXT_texture_format_BGRA8888) -> 685 // 4- ES2 (neither GL_EXT_texture_storage nor GL_EXT_texture_format_BGRA8888) ->
653 // nothing 686 // nothing
654 TEST_P(FeatureInfoTest, InitializeGLES2_neither_texture_storage_nor_BGRA) { 687 TEST_P(FeatureInfoTest, InitializeGLES2_neither_texture_storage_nor_BGRA) {
655 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 2.0"); 688 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 2.0");
656 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_texture_storage"))); 689 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_texture_storage")));
657 EXPECT_THAT(info_->extensions(), 690 EXPECT_THAT(info_->extensions(),
658 Not(HasSubstr("GL_EXT_texture_format_BGRA8888"))); 691 Not(HasSubstr("GL_EXT_texture_format_BGRA8888")));
659 } 692 }
660 693
661 // 5- ES3 + GL_EXT_texture_format_BGRA8888 -> GL_EXT_texture_format_BGRA8888 694 // 5- ES3 + GL_EXT_texture_format_BGRA8888
662 // (we can't expose GL_EXT_texture_storage because we fail the GL_BGRA8 695 // If creating a GLES2 context, expose GL_EXT_texture_format_BGRA8888
696 // If creating a GLES3 context, expose GL_EXT_texture_storage
697 // (we can't expose both at the same time because we fail the GL_BGRA8
663 // requirement) 698 // requirement)
664 TEST_P(FeatureInfoTest, InitializeGLES3_texture_storage_EXT_BGRA) { 699 TEST_P(FeatureInfoTest, InitializeGLES3_texture_storage_EXT_BGRA) {
665 SetupInitExpectationsWithGLVersion( 700 SetupInitExpectationsWithGLVersion(
666 "GL_EXT_texture_format_BGRA8888", "", "OpenGL ES 3.0"); 701 "GL_EXT_texture_format_BGRA8888", "", "OpenGL ES 3.0");
667 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_texture_storage"))); 702 if (GetContextType() == CONTEXT_TYPE_OPENGLES3) {
668 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888")); 703 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
704 EXPECT_THAT(info_->extensions(),
705 Not(HasSubstr("GL_EXT_texture_format_BGRA8888")));
706 } else {
707 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_texture_storage")));
708 EXPECT_THAT(info_->extensions(),
709 HasSubstr("GL_EXT_texture_format_BGRA8888"));
710 }
669 } 711 }
670 712
671 // 6- ES3 + GL_APPLE_texture_format_bgra8888 -> GL_EXT_texture_storage + 713 // 6- ES3 + GL_APPLE_texture_format_bgra8888 -> GL_EXT_texture_storage +
672 // GL_EXT_texture_format_BGRA8888 (driver promises to handle GL_BGRA8 by 714 // GL_EXT_texture_format_BGRA8888 (driver promises to handle GL_BGRA8 by
673 // exposing GL_APPLE_texture_format_bgra8888) 715 // exposing GL_APPLE_texture_format_bgra8888)
674 TEST_P(FeatureInfoTest, InitializeGLES3_texture_storage_APPLE_BGRA) { 716 TEST_P(FeatureInfoTest, InitializeGLES3_texture_storage_APPLE_BGRA) {
675 SetupInitExpectationsWithGLVersion( 717 SetupInitExpectationsWithGLVersion(
676 "GL_APPLE_texture_format_BGRA8888", "", "OpenGL ES 3.0"); 718 "GL_APPLE_texture_format_BGRA8888", "", "OpenGL ES 3.0");
677 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); 719 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
678 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888")); 720 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(GL_RG8_EXT)); 1491 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(GL_RG8_EXT));
1450 } 1492 }
1451 1493
1452 TEST_P(FeatureInfoTest, InitializeCHROMIUM_ycbcr_422_imageTrue) { 1494 TEST_P(FeatureInfoTest, InitializeCHROMIUM_ycbcr_422_imageTrue) {
1453 SetupInitExpectations("GL_APPLE_ycbcr_422"); 1495 SetupInitExpectations("GL_APPLE_ycbcr_422");
1454 EXPECT_TRUE(info_->feature_flags().chromium_image_ycbcr_422); 1496 EXPECT_TRUE(info_->feature_flags().chromium_image_ycbcr_422);
1455 } 1497 }
1456 1498
1457 } // namespace gles2 1499 } // namespace gles2
1458 } // namespace gpu 1500 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/feature_info.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698