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
3 // found in the LICENSE file.
5 #include "gpu/command_buffer/service/feature_info.h"
7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string_number_conversions.h"
10 #include "gpu/command_buffer/service/gpu_service_test.h"
11 #include "gpu/command_buffer/service/gpu_switches.h"
12 #include "gpu/command_buffer/service/test_helper.h"
13 #include "gpu/command_buffer/service/texture_manager.h"
14 #include "gpu/config/gpu_driver_bug_workaround_type.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/gl/gl_fence.h"
17 #include "ui/gl/gl_implementation.h"
18 #include "ui/gl/gl_mock.h"
21 using ::testing::DoAll
;
22 using ::testing::HasSubstr
;
23 using ::testing::InSequence
;
24 using ::testing::MatcherCast
;
26 using ::testing::Pointee
;
27 using ::testing::Return
;
28 using ::testing::SetArrayArgument
;
29 using ::testing::SetArgumentPointee
;
30 using ::testing::StrEq
;
36 const char kGLRendererStringANGLE
[] = "ANGLE (some renderer)";
37 } // anonymous namespace
39 class FeatureInfoTest
: public GpuServiceTest
{
44 void SetupInitExpectations(const char* extensions
) {
45 std::string extensions_str
= extensions
;
46 // Most of the tests' expectations currently assume the desktop
47 // OpenGL compatibility profile.
48 if (extensions_str
.find("GL_ARB_compatibility") == std::string::npos
) {
49 extensions_str
+= " GL_ARB_compatibility";
51 SetupInitExpectationsWithGLVersion(extensions_str
.c_str(), "", "3.0");
54 void SetupInitExpectationsWithGLVersion(
55 const char* extensions
, const char* renderer
, const char* version
) {
56 GpuServiceTest::SetUpWithGLVersion(version
, extensions
);
57 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
58 gl_
.get(), extensions
, renderer
, version
);
59 info_
= new FeatureInfo();
63 void SetupWithCommandLine(const base::CommandLine
& command_line
) {
64 GpuServiceTest::SetUp();
65 info_
= new FeatureInfo(command_line
);
68 void SetupInitExpectationsWithCommandLine(
69 const char* extensions
,
70 const base::CommandLine
& command_line
) {
71 GpuServiceTest::SetUpWithGLVersion("2.0", extensions
);
72 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
73 gl_
.get(), extensions
, "", "");
74 info_
= new FeatureInfo(command_line
);
78 void SetupWithoutInit() {
79 GpuServiceTest::SetUp();
80 info_
= new FeatureInfo();
84 void SetUp() override
{
85 // Do nothing here, since we are using the explicit Setup*() functions.
88 void TearDown() override
{
90 GpuServiceTest::TearDown();
93 scoped_refptr
<FeatureInfo
> info_
;
104 } // anonymous namespace.
106 TEST_F(FeatureInfoTest
, Basic
) {
108 // Test it starts off uninitialized.
109 EXPECT_FALSE(info_
->feature_flags().chromium_framebuffer_multisample
);
110 EXPECT_FALSE(info_
->feature_flags().use_core_framebuffer_multisample
);
111 EXPECT_FALSE(info_
->feature_flags().multisampled_render_to_texture
);
112 EXPECT_FALSE(info_
->feature_flags(
113 ).use_img_for_multisampled_render_to_texture
);
114 EXPECT_FALSE(info_
->feature_flags().oes_standard_derivatives
);
115 EXPECT_FALSE(info_
->feature_flags().npot_ok
);
116 EXPECT_FALSE(info_
->feature_flags().enable_texture_float_linear
);
117 EXPECT_FALSE(info_
->feature_flags().enable_texture_half_float_linear
);
118 EXPECT_FALSE(info_
->feature_flags().oes_egl_image_external
);
119 EXPECT_FALSE(info_
->feature_flags().oes_depth24
);
120 EXPECT_FALSE(info_
->feature_flags().packed_depth24_stencil8
);
121 EXPECT_FALSE(info_
->feature_flags().angle_translated_shader_source
);
122 EXPECT_FALSE(info_
->feature_flags().angle_pack_reverse_row_order
);
123 EXPECT_FALSE(info_
->feature_flags().arb_texture_rectangle
);
124 EXPECT_FALSE(info_
->feature_flags().angle_instanced_arrays
);
125 EXPECT_FALSE(info_
->feature_flags().occlusion_query_boolean
);
126 EXPECT_FALSE(info_
->feature_flags(
127 ).use_arb_occlusion_query2_for_occlusion_query_boolean
);
128 EXPECT_FALSE(info_
->feature_flags(
129 ).use_arb_occlusion_query_for_occlusion_query_boolean
);
130 EXPECT_FALSE(info_
->feature_flags().native_vertex_array_object
);
131 EXPECT_FALSE(info_
->feature_flags().map_buffer_range
);
132 EXPECT_FALSE(info_
->feature_flags().use_async_readpixels
);
133 EXPECT_FALSE(info_
->feature_flags().ext_draw_buffers
);
134 EXPECT_FALSE(info_
->feature_flags().nv_draw_buffers
);
135 EXPECT_FALSE(info_
->feature_flags().ext_discard_framebuffer
);
136 EXPECT_FALSE(info_
->feature_flags().angle_depth_texture
);
138 #define GPU_OP(type, name) EXPECT_FALSE(info_->workarounds().name);
139 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP
)
141 EXPECT_EQ(0, info_
->workarounds().max_texture_size
);
142 EXPECT_EQ(0, info_
->workarounds().max_cube_map_texture_size
);
143 EXPECT_FALSE(info_
->workarounds().gl_clear_broken
);
147 static const GLenum kAlphaTypes
[] = {
150 static const GLenum kRGBTypes
[] = {
152 GL_UNSIGNED_SHORT_5_6_5
,
154 static const GLenum kRGBATypes
[] = {
156 GL_UNSIGNED_SHORT_4_4_4_4
,
157 GL_UNSIGNED_SHORT_5_5_5_1
,
159 static const GLenum kLuminanceTypes
[] = {
162 static const GLenum kLuminanceAlphaTypes
[] = {
165 static const FormatInfo kFormatTypes
[] = {
166 { GL_ALPHA
, kAlphaTypes
, arraysize(kAlphaTypes
), },
167 { GL_RGB
, kRGBTypes
, arraysize(kRGBTypes
), },
168 { GL_RGBA
, kRGBATypes
, arraysize(kRGBATypes
), },
169 { GL_LUMINANCE
, kLuminanceTypes
, arraysize(kLuminanceTypes
), },
170 { GL_LUMINANCE_ALPHA
, kLuminanceAlphaTypes
,
171 arraysize(kLuminanceAlphaTypes
), } ,
173 for (size_t ii
= 0; ii
< arraysize(kFormatTypes
); ++ii
) {
174 const FormatInfo
& info
= kFormatTypes
[ii
];
175 const ValueValidator
<GLenum
>& validator
=
176 info_
->GetTextureFormatValidator(info
.format
);
177 for (size_t jj
= 0; jj
< info
.count
; ++jj
) {
178 EXPECT_TRUE(validator
.IsValid(info
.types
[jj
]));
183 // Test some bad types
185 static const GLenum kAlphaTypes
[] = {
186 GL_UNSIGNED_SHORT_5_5_5_1
,
189 static const GLenum kRGBTypes
[] = {
190 GL_UNSIGNED_SHORT_4_4_4_4
,
193 static const GLenum kRGBATypes
[] = {
194 GL_UNSIGNED_SHORT_5_6_5
,
197 static const GLenum kLuminanceTypes
[] = {
198 GL_UNSIGNED_SHORT_4_4_4_4
,
201 static const GLenum kLuminanceAlphaTypes
[] = {
202 GL_UNSIGNED_SHORT_5_5_5_1
,
205 static const GLenum kBGRATypes
[] = {
207 GL_UNSIGNED_SHORT_5_6_5
,
210 static const GLenum kDepthTypes
[] = {
216 static const FormatInfo kFormatTypes
[] = {
217 { GL_ALPHA
, kAlphaTypes
, arraysize(kAlphaTypes
), },
218 { GL_RGB
, kRGBTypes
, arraysize(kRGBTypes
), },
219 { GL_RGBA
, kRGBATypes
, arraysize(kRGBATypes
), },
220 { GL_LUMINANCE
, kLuminanceTypes
, arraysize(kLuminanceTypes
), },
221 { GL_LUMINANCE_ALPHA
, kLuminanceAlphaTypes
,
222 arraysize(kLuminanceAlphaTypes
), } ,
223 { GL_BGRA_EXT
, kBGRATypes
, arraysize(kBGRATypes
), },
224 { GL_DEPTH_COMPONENT
, kDepthTypes
, arraysize(kDepthTypes
), },
226 for (size_t ii
= 0; ii
< arraysize(kFormatTypes
); ++ii
) {
227 const FormatInfo
& info
= kFormatTypes
[ii
];
228 const ValueValidator
<GLenum
>& validator
=
229 info_
->GetTextureFormatValidator(info
.format
);
230 for (size_t jj
= 0; jj
< info
.count
; ++jj
) {
231 EXPECT_FALSE(validator
.IsValid(info
.types
[jj
]));
237 TEST_F(FeatureInfoTest
, InitializeNoExtensions
) {
238 SetupInitExpectations("");
239 // Check default extensions are there
240 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_CHROMIUM_resource_safe"));
241 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_CHROMIUM_strict_attribs"));
242 EXPECT_THAT(info_
->extensions(),
243 HasSubstr("GL_ANGLE_translated_shader_source"));
244 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_CHROMIUM_trace_marker"));
246 // Check a couple of random extensions that should not be there.
247 EXPECT_THAT(info_
->extensions(), Not(HasSubstr("GL_OES_texture_npot")));
248 EXPECT_THAT(info_
->extensions(),
249 Not(HasSubstr("GL_EXT_texture_compression_dxt1")));
250 EXPECT_THAT(info_
->extensions(),
251 Not(HasSubstr("GL_CHROMIUM_texture_compression_dxt3")));
252 EXPECT_THAT(info_
->extensions(),
253 Not(HasSubstr("GL_CHROMIUM_texture_compression_dxt5")));
254 EXPECT_THAT(info_
->extensions(),
255 Not(HasSubstr("GL_ANGLE_texture_usage")));
256 EXPECT_THAT(info_
->extensions(),
257 Not(HasSubstr("GL_EXT_texture_storage")));
258 EXPECT_THAT(info_
->extensions(),
259 Not(HasSubstr("GL_OES_compressed_ETC1_RGB8_texture")));
260 EXPECT_THAT(info_
->extensions(),
261 Not(HasSubstr("GL_AMD_compressed_ATC_texture")));
262 EXPECT_THAT(info_
->extensions(),
263 Not(HasSubstr("GL_IMG_texture_compression_pvrtc")));
264 EXPECT_THAT(info_
->extensions(),
265 Not(HasSubstr("GL_EXT_sRGB")));
266 EXPECT_FALSE(info_
->feature_flags().npot_ok
);
267 EXPECT_FALSE(info_
->validators()->compressed_texture_format
.IsValid(
268 GL_COMPRESSED_RGB_S3TC_DXT1_EXT
));
269 EXPECT_FALSE(info_
->validators()->compressed_texture_format
.IsValid(
270 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
));
271 EXPECT_FALSE(info_
->validators()->compressed_texture_format
.IsValid(
272 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
));
273 EXPECT_FALSE(info_
->validators()->compressed_texture_format
.IsValid(
274 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
));
275 EXPECT_FALSE(info_
->validators()->compressed_texture_format
.IsValid(
277 EXPECT_FALSE(info_
->validators()->compressed_texture_format
.IsValid(
279 EXPECT_FALSE(info_
->validators()->compressed_texture_format
.IsValid(
280 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD
));
281 EXPECT_FALSE(info_
->validators()->compressed_texture_format
.IsValid(
282 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
));
283 EXPECT_FALSE(info_
->validators()->compressed_texture_format
.IsValid(
284 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
));
285 EXPECT_FALSE(info_
->validators()->compressed_texture_format
.IsValid(
286 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
));
287 EXPECT_FALSE(info_
->validators()->compressed_texture_format
.IsValid(
288 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
));
289 EXPECT_FALSE(info_
->validators()->compressed_texture_format
.IsValid(
290 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
));
291 EXPECT_FALSE(info_
->validators()->read_pixel_format
.IsValid(
293 EXPECT_FALSE(info_
->validators()->texture_parameter
.IsValid(
294 GL_TEXTURE_MAX_ANISOTROPY_EXT
));
295 EXPECT_FALSE(info_
->validators()->g_l_state
.IsValid(
296 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
));
297 EXPECT_FALSE(info_
->validators()->frame_buffer_target
.IsValid(
298 GL_READ_FRAMEBUFFER_EXT
));
299 EXPECT_FALSE(info_
->validators()->frame_buffer_target
.IsValid(
300 GL_DRAW_FRAMEBUFFER_EXT
));
301 EXPECT_FALSE(info_
->validators()->g_l_state
.IsValid(
302 GL_READ_FRAMEBUFFER_BINDING_EXT
));
303 EXPECT_FALSE(info_
->validators()->render_buffer_parameter
.IsValid(
304 GL_MAX_SAMPLES_EXT
));
305 EXPECT_FALSE(info_
->validators()->texture_internal_format
.IsValid(
306 GL_DEPTH_COMPONENT
));
307 EXPECT_FALSE(info_
->validators()->texture_format
.IsValid(GL_DEPTH_COMPONENT
));
308 EXPECT_FALSE(info_
->validators()->pixel_type
.IsValid(GL_UNSIGNED_SHORT
));
309 EXPECT_FALSE(info_
->validators()->pixel_type
.IsValid(GL_UNSIGNED_INT
));
310 EXPECT_FALSE(info_
->validators()->render_buffer_format
.IsValid(
311 GL_DEPTH24_STENCIL8
));
312 EXPECT_FALSE(info_
->validators()->texture_internal_format
.IsValid(
314 EXPECT_FALSE(info_
->validators()->texture_internal_format
.IsValid(
316 EXPECT_FALSE(info_
->validators()->texture_internal_format
.IsValid(
318 EXPECT_FALSE(info_
->validators()->texture_format
.IsValid(
320 EXPECT_FALSE(info_
->validators()->pixel_type
.IsValid(
321 GL_UNSIGNED_INT_24_8
));
322 EXPECT_FALSE(info_
->validators()->render_buffer_format
.IsValid(
323 GL_DEPTH_COMPONENT24
));
324 EXPECT_FALSE(info_
->validators()->texture_parameter
.IsValid(
325 GL_TEXTURE_USAGE_ANGLE
));
326 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
327 GL_DEPTH_COMPONENT16
));
328 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
329 GL_DEPTH_COMPONENT32_OES
));
330 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
331 GL_DEPTH24_STENCIL8_OES
));
332 EXPECT_FALSE(info_
->validators()->equation
.IsValid(GL_MIN_EXT
));
333 EXPECT_FALSE(info_
->validators()->equation
.IsValid(GL_MAX_EXT
));
334 EXPECT_FALSE(info_
->feature_flags().chromium_sync_query
);
335 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_SRGB_EXT
).IsValid(
337 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_SRGB_ALPHA_EXT
).IsValid(
339 EXPECT_FALSE(info_
->validators()->texture_format
.IsValid(
341 EXPECT_FALSE(info_
->validators()->texture_format
.IsValid(
343 EXPECT_FALSE(info_
->validators()->texture_internal_format
.IsValid(
345 EXPECT_FALSE(info_
->validators()->texture_internal_format
.IsValid(
347 EXPECT_FALSE(info_
->validators()->render_buffer_format
.IsValid(
348 GL_SRGB8_ALPHA8_EXT
));
349 EXPECT_FALSE(info_
->validators()->frame_buffer_parameter
.IsValid(
350 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT
));
353 TEST_F(FeatureInfoTest
, InitializeWithANGLE
) {
354 SetupInitExpectationsWithGLVersion("", kGLRendererStringANGLE
, "");
355 EXPECT_TRUE(info_
->gl_version_info().is_angle
);
358 TEST_F(FeatureInfoTest
, InitializeNPOTExtensionGLES
) {
359 SetupInitExpectations("GL_OES_texture_npot");
360 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_OES_texture_npot"));
361 EXPECT_TRUE(info_
->feature_flags().npot_ok
);
364 TEST_F(FeatureInfoTest
, InitializeNPOTExtensionGL
) {
365 SetupInitExpectations("GL_ARB_texture_non_power_of_two");
366 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_OES_texture_npot"));
367 EXPECT_TRUE(info_
->feature_flags().npot_ok
);
370 TEST_F(FeatureInfoTest
, InitializeDXTExtensionGLES2
) {
371 SetupInitExpectations("GL_EXT_texture_compression_dxt1");
372 EXPECT_THAT(info_
->extensions(),
373 HasSubstr("GL_EXT_texture_compression_dxt1"));
374 EXPECT_TRUE(info_
->validators()->compressed_texture_format
.IsValid(
375 GL_COMPRESSED_RGB_S3TC_DXT1_EXT
));
376 EXPECT_TRUE(info_
->validators()->compressed_texture_format
.IsValid(
377 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
));
378 EXPECT_FALSE(info_
->validators()->compressed_texture_format
.IsValid(
379 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
));
380 EXPECT_FALSE(info_
->validators()->compressed_texture_format
.IsValid(
381 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
));
384 TEST_F(FeatureInfoTest
, InitializeDXTExtensionGL
) {
385 SetupInitExpectations("GL_EXT_texture_compression_s3tc");
386 EXPECT_THAT(info_
->extensions(),
387 HasSubstr("GL_EXT_texture_compression_dxt1"));
388 EXPECT_THAT(info_
->extensions(),
389 HasSubstr("GL_CHROMIUM_texture_compression_dxt3"));
390 EXPECT_THAT(info_
->extensions(),
391 HasSubstr("GL_CHROMIUM_texture_compression_dxt5"));
392 EXPECT_TRUE(info_
->validators()->compressed_texture_format
.IsValid(
393 GL_COMPRESSED_RGB_S3TC_DXT1_EXT
));
394 EXPECT_TRUE(info_
->validators()->compressed_texture_format
.IsValid(
395 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
));
396 EXPECT_TRUE(info_
->validators()->compressed_texture_format
.IsValid(
397 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
));
398 EXPECT_TRUE(info_
->validators()->compressed_texture_format
.IsValid(
399 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
));
402 TEST_F(FeatureInfoTest
, InitializeEXT_texture_format_BGRA8888GLES2
) {
403 SetupInitExpectations("GL_EXT_texture_format_BGRA8888");
404 EXPECT_THAT(info_
->extensions(),
405 HasSubstr("GL_EXT_texture_format_BGRA8888"));
406 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(
408 EXPECT_TRUE(info_
->validators()->texture_internal_format
.IsValid(
410 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_BGRA_EXT
).IsValid(
412 EXPECT_FALSE(info_
->validators()->render_buffer_format
.IsValid(
416 TEST_F(FeatureInfoTest
, InitializeEXT_texture_format_BGRA8888GL
) {
417 SetupInitExpectations("GL_EXT_bgra");
418 EXPECT_THAT(info_
->extensions(),
419 HasSubstr("GL_EXT_texture_format_BGRA8888"));
420 EXPECT_THAT(info_
->extensions(),
421 HasSubstr("GL_EXT_read_format_bgra"));
422 EXPECT_THAT(info_
->extensions(),
423 HasSubstr("GL_CHROMIUM_renderbuffer_format_BGRA8888"));
424 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(
426 EXPECT_TRUE(info_
->validators()->texture_internal_format
.IsValid(
428 EXPECT_TRUE(info_
->validators()->read_pixel_format
.IsValid(
430 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_BGRA_EXT
).IsValid(
432 EXPECT_TRUE(info_
->validators()->render_buffer_format
.IsValid(
436 TEST_F(FeatureInfoTest
, InitializeEXT_texture_format_BGRA8888Apple
) {
437 SetupInitExpectations("GL_APPLE_texture_format_BGRA8888");
438 EXPECT_THAT(info_
->extensions(),
439 HasSubstr("GL_EXT_texture_format_BGRA8888"));
440 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(
442 EXPECT_TRUE(info_
->validators()->texture_internal_format
.IsValid(
444 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_BGRA_EXT
).IsValid(
446 EXPECT_FALSE(info_
->validators()->render_buffer_format
.IsValid(
450 TEST_F(FeatureInfoTest
, InitializeEXT_read_format_bgra
) {
451 SetupInitExpectations("GL_EXT_read_format_bgra");
452 EXPECT_THAT(info_
->extensions(),
453 HasSubstr("GL_EXT_read_format_bgra"));
454 EXPECT_FALSE(info_
->validators()->texture_format
.IsValid(
456 EXPECT_FALSE(info_
->validators()->texture_internal_format
.IsValid(
458 EXPECT_TRUE(info_
->validators()->read_pixel_format
.IsValid(
460 EXPECT_FALSE(info_
->validators()->render_buffer_format
.IsValid(
464 TEST_F(FeatureInfoTest
, InitializeEXT_sRGB
) {
465 SetupInitExpectations("GL_EXT_sRGB GL_OES_rgb8_rgba8");
466 EXPECT_THAT(info_
->extensions(),
467 HasSubstr("GL_EXT_sRGB"));
468 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_SRGB_EXT
).IsValid(
470 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_SRGB_ALPHA_EXT
).IsValid(
472 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(
474 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(
476 EXPECT_TRUE(info_
->validators()->texture_internal_format
.IsValid(
478 EXPECT_TRUE(info_
->validators()->texture_internal_format
.IsValid(
480 EXPECT_TRUE(info_
->validators()->render_buffer_format
.IsValid(
481 GL_SRGB8_ALPHA8_EXT
));
482 EXPECT_TRUE(info_
->validators()->frame_buffer_parameter
.IsValid(
483 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT
));
486 TEST_F(FeatureInfoTest
, InitializeEXT_texture_storage
) {
487 SetupInitExpectations("GL_EXT_texture_storage");
488 EXPECT_TRUE(info_
->feature_flags().ext_texture_storage
);
489 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_storage"));
490 EXPECT_TRUE(info_
->validators()->texture_parameter
.IsValid(
491 GL_TEXTURE_IMMUTABLE_FORMAT_EXT
));
492 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
494 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
496 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
498 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
500 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
501 GL_LUMINANCE32F_EXT
));
502 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
503 GL_LUMINANCE_ALPHA32F_EXT
));
504 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
506 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
508 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
510 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
511 GL_LUMINANCE16F_EXT
));
512 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
513 GL_LUMINANCE_ALPHA16F_EXT
));
516 TEST_F(FeatureInfoTest
, InitializeARB_texture_storage
) {
517 SetupInitExpectations("GL_ARB_texture_storage");
518 EXPECT_TRUE(info_
->feature_flags().ext_texture_storage
);
519 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_storage"));
520 EXPECT_TRUE(info_
->validators()->texture_parameter
.IsValid(
521 GL_TEXTURE_IMMUTABLE_FORMAT_EXT
));
524 TEST_F(FeatureInfoTest
, InitializeEXT_texture_storage_BGRA
) {
525 SetupInitExpectations("GL_EXT_texture_storage GL_EXT_bgra");
526 EXPECT_TRUE(info_
->feature_flags().ext_texture_storage
);
527 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_storage"));
528 EXPECT_TRUE(info_
->validators()->texture_internal_format_storage
.IsValid(
530 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
533 TEST_F(FeatureInfoTest
, InitializeARB_texture_storage_BGRA
) {
534 SetupInitExpectations("GL_ARB_texture_storage GL_EXT_bgra");
535 EXPECT_TRUE(info_
->feature_flags().ext_texture_storage
);
536 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_storage"));
537 EXPECT_TRUE(info_
->validators()->texture_internal_format_storage
.IsValid(
539 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
542 TEST_F(FeatureInfoTest
, InitializeEXT_texture_storage_BGRA8888
) {
543 SetupInitExpectations(
544 "GL_EXT_texture_storage GL_EXT_texture_format_BGRA8888");
545 EXPECT_TRUE(info_
->feature_flags().ext_texture_storage
);
546 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_storage"));
547 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
548 EXPECT_TRUE(info_
->validators()->texture_internal_format_storage
.IsValid(
550 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
553 TEST_F(FeatureInfoTest
, InitializeEXT_texture_storage_float
) {
554 SetupInitExpectations("GL_EXT_texture_storage GL_OES_texture_float");
555 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_storage"));
556 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_OES_texture_float"));
557 EXPECT_TRUE(info_
->validators()->texture_internal_format_storage
.IsValid(
559 EXPECT_TRUE(info_
->validators()->texture_internal_format_storage
.IsValid(
561 EXPECT_TRUE(info_
->validators()->texture_internal_format_storage
.IsValid(
563 EXPECT_TRUE(info_
->validators()->texture_internal_format_storage
.IsValid(
564 GL_LUMINANCE32F_EXT
));
565 EXPECT_TRUE(info_
->validators()->texture_internal_format_storage
.IsValid(
566 GL_LUMINANCE_ALPHA32F_EXT
));
569 TEST_F(FeatureInfoTest
, InitializeEXT_texture_storage_half_float
) {
570 SetupInitExpectations("GL_EXT_texture_storage GL_OES_texture_half_float");
571 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_storage"));
572 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_OES_texture_half_float"));
573 EXPECT_TRUE(info_
->validators()->texture_internal_format_storage
.IsValid(
575 EXPECT_TRUE(info_
->validators()->texture_internal_format_storage
.IsValid(
577 EXPECT_TRUE(info_
->validators()->texture_internal_format_storage
.IsValid(
579 EXPECT_TRUE(info_
->validators()->texture_internal_format_storage
.IsValid(
580 GL_LUMINANCE16F_EXT
));
581 EXPECT_TRUE(info_
->validators()->texture_internal_format_storage
.IsValid(
582 GL_LUMINANCE_ALPHA16F_EXT
));
585 // Check how to handle ES, texture_storage and BGRA combination; 10 tests.
587 // 1- ES2 + GL_EXT_texture_storage -> GL_EXT_texture_storage (and no
588 // GL_EXT_texture_format_BGRA8888 - we don't claim to handle GL_BGRA8 in
589 // glTexStorage2DEXT)
590 TEST_F(FeatureInfoTest
, InitializeGLES2_texture_storage
) {
591 SetupInitExpectationsWithGLVersion(
592 "GL_EXT_texture_storage", "", "OpenGL ES 2.0");
593 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_storage"));
594 EXPECT_THAT(info_
->extensions(),
595 Not(HasSubstr("GL_EXT_texture_format_BGRA8888")));
598 // 2- ES2 + GL_EXT_texture_storage + (GL_EXT_texture_format_BGRA8888 or
599 // GL_APPLE_texture_format_bgra8888)
600 TEST_F(FeatureInfoTest
, InitializeGLES2_texture_storage_BGRA
) {
601 SetupInitExpectationsWithGLVersion(
602 "GL_EXT_texture_storage GL_EXT_texture_format_BGRA8888",
605 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_storage"));
606 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
609 // 3- ES2 + GL_EXT_texture_format_BGRA8888 or GL_APPLE_texture_format_bgra8888
610 TEST_F(FeatureInfoTest
, InitializeGLES2_texture_format_BGRA
) {
611 SetupInitExpectationsWithGLVersion(
612 "GL_EXT_texture_format_BGRA8888", "", "OpenGL ES 2.0");
613 EXPECT_THAT(info_
->extensions(), Not(HasSubstr("GL_EXT_texture_storage")));
614 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
617 // 4- ES2 (neither GL_EXT_texture_storage nor GL_EXT_texture_format_BGRA8888) ->
619 TEST_F(FeatureInfoTest
, InitializeGLES2_neither_texture_storage_nor_BGRA
) {
620 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 2.0");
621 EXPECT_THAT(info_
->extensions(), Not(HasSubstr("GL_EXT_texture_storage")));
622 EXPECT_THAT(info_
->extensions(),
623 Not(HasSubstr("GL_EXT_texture_format_BGRA8888")));
626 // 5- ES3 + GL_EXT_texture_format_BGRA8888 -> GL_EXT_texture_format_BGRA8888
627 // (we can't expose GL_EXT_texture_storage because we fail the GL_BGRA8
629 TEST_F(FeatureInfoTest
, InitializeGLES3_texture_storage_EXT_BGRA
) {
630 SetupInitExpectationsWithGLVersion(
631 "GL_EXT_texture_format_BGRA8888", "", "OpenGL ES 3.0");
632 EXPECT_THAT(info_
->extensions(), Not(HasSubstr("GL_EXT_texture_storage")));
633 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
636 // 6- ES3 + GL_APPLE_texture_format_bgra8888 -> GL_EXT_texture_storage +
637 // GL_EXT_texture_format_BGRA8888 (driver promises to handle GL_BGRA8 by
638 // exposing GL_APPLE_texture_format_bgra8888)
639 TEST_F(FeatureInfoTest
, InitializeGLES3_texture_storage_APPLE_BGRA
) {
640 SetupInitExpectationsWithGLVersion(
641 "GL_APPLE_texture_format_BGRA8888", "", "OpenGL ES 3.0");
642 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_storage"));
643 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
646 // 7- ES3 + GL_EXT_texture_storage + GL_EXT_texture_format_BGRA8888 ->
647 // GL_EXT_texture_storage + GL_EXT_texture_format_BGRA8888 (driver promises to
648 // handle GL_BGRA8 by exposing GL_EXT_texture_storage)
649 TEST_F(FeatureInfoTest
, InitializeGLES3_EXT_texture_storage_EXT_BGRA
) {
650 SetupInitExpectationsWithGLVersion(
651 "GL_EXT_texture_storage GL_EXT_texture_format_BGRA8888",
654 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_storage"));
655 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
658 // 8- ES3 + none of the above -> GL_EXT_texture_storage (and no
659 // GL_EXT_texture_format_BGRA8888 - we don't claim to handle GL_BGRA8)
660 TEST_F(FeatureInfoTest
, InitializeGLES3_texture_storage
) {
661 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 3.0");
662 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_texture_storage"));
663 EXPECT_THAT(info_
->extensions(),
664 Not(HasSubstr("GL_EXT_texture_format_BGRA8888")));
667 // 9- ANGLE will add the GL_CHROMIUM_renderbuffer_format_BGRA8888 extension and
668 // the GL_BGRA8_EXT render buffer format.
669 TEST_F(FeatureInfoTest
, InitializeWithANGLE_BGRA8
) {
670 SetupInitExpectationsWithGLVersion("", kGLRendererStringANGLE
, "");
671 EXPECT_TRUE(info_
->gl_version_info().is_angle
);
672 EXPECT_THAT(info_
->extensions(),
673 HasSubstr("GL_CHROMIUM_renderbuffer_format_BGRA8888"));
674 EXPECT_TRUE(info_
->validators()->render_buffer_format
.IsValid(GL_BGRA8_EXT
));
677 // 10- vanilla opengl es means no GL_CHROMIUM_renderbuffer_format_BGRA8888
678 TEST_F(FeatureInfoTest
,
679 InitializeGLES2_no_CHROMIUM_renderbuffer_format_BGRA8888
) {
680 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 2.0");
681 EXPECT_THAT(info_
->extensions(),
682 Not(HasSubstr("GL_CHROMIUM_renderbuffer_format_BGRA8888")));
685 TEST_F(FeatureInfoTest
, InitializeARB_texture_float
) {
686 SetupInitExpectations("GL_ARB_texture_float");
687 EXPECT_TRUE(info_
->feature_flags().chromium_color_buffer_float_rgba
);
688 EXPECT_TRUE(info_
->feature_flags().chromium_color_buffer_float_rgb
);
689 std::string extensions
= info_
->extensions() + " ";
690 EXPECT_THAT(extensions
, HasSubstr("GL_CHROMIUM_color_buffer_float_rgb "));
691 EXPECT_THAT(extensions
, HasSubstr("GL_CHROMIUM_color_buffer_float_rgba"));
692 EXPECT_TRUE(info_
->validators()->texture_internal_format
.IsValid(
694 EXPECT_TRUE(info_
->validators()->texture_internal_format
.IsValid(
698 TEST_F(FeatureInfoTest
, Initialize_texture_floatGLES3
) {
699 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 3.0");
700 EXPECT_THAT(info_
->extensions(), Not(HasSubstr("GL_OES_texture_float")));
701 EXPECT_THAT(info_
->extensions(), Not(HasSubstr("GL_OES_texture_half_float")));
702 EXPECT_THAT(info_
->extensions(),
703 Not(HasSubstr("GL_OES_texture_float_linear")));
704 EXPECT_THAT(info_
->extensions(),
705 Not(HasSubstr("GL_OES_texture_half_float_linear")));
706 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_RGB
).IsValid(
708 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_RGBA
).IsValid(
710 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_LUMINANCE
).IsValid(
712 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_LUMINANCE_ALPHA
).IsValid(
714 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_ALPHA
).IsValid(
718 TEST_F(FeatureInfoTest
, Initialize_sRGBGLES3
) {
719 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 3.0");
720 EXPECT_THAT(info_
->extensions(), Not(HasSubstr("GL_EXT_sRGB")));
721 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_SRGB_EXT
).IsValid(
723 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_SRGB_ALPHA_EXT
).IsValid(
725 EXPECT_FALSE(info_
->validators()->texture_format
.IsValid(
727 EXPECT_FALSE(info_
->validators()->texture_format
.IsValid(
729 EXPECT_FALSE(info_
->validators()->texture_internal_format
.IsValid(
731 EXPECT_FALSE(info_
->validators()->texture_internal_format
.IsValid(
733 EXPECT_FALSE(info_
->validators()->render_buffer_format
.IsValid(
734 GL_SRGB8_ALPHA8_EXT
));
735 EXPECT_FALSE(info_
->validators()->frame_buffer_parameter
.IsValid(
736 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT
));
739 TEST_F(FeatureInfoTest
, InitializeOES_texture_floatGLES2
) {
740 SetupInitExpectations("GL_OES_texture_float");
741 EXPECT_FALSE(info_
->feature_flags().enable_texture_float_linear
);
742 EXPECT_FALSE(info_
->feature_flags().enable_texture_half_float_linear
);
743 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_OES_texture_float"));
744 EXPECT_THAT(info_
->extensions(), Not(HasSubstr("GL_OES_texture_half_float")));
745 EXPECT_THAT(info_
->extensions(),
746 Not(HasSubstr("GL_OES_texture_float_linear")));
747 EXPECT_THAT(info_
->extensions(),
748 Not(HasSubstr("GL_OES_texture_half_float_linear")));
749 EXPECT_TRUE(info_
->validators()->pixel_type
.IsValid(GL_FLOAT
));
750 EXPECT_FALSE(info_
->validators()->pixel_type
.IsValid(GL_HALF_FLOAT_OES
));
751 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_ALPHA
).IsValid(
753 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_RGB
).IsValid(
755 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_RGBA
).IsValid(
757 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_LUMINANCE
).IsValid(
759 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_LUMINANCE_ALPHA
).IsValid(
761 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_ALPHA
).IsValid(
763 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_RGB
).IsValid(
765 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_RGBA
).IsValid(
767 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_LUMINANCE
).IsValid(
769 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_LUMINANCE_ALPHA
).IsValid(
773 TEST_F(FeatureInfoTest
, InitializeOES_texture_float_linearGLES2
) {
774 SetupInitExpectations("GL_OES_texture_float GL_OES_texture_float_linear");
775 EXPECT_TRUE(info_
->feature_flags().enable_texture_float_linear
);
776 EXPECT_FALSE(info_
->feature_flags().enable_texture_half_float_linear
);
777 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_OES_texture_float"));
778 EXPECT_THAT(info_
->extensions(), Not(HasSubstr("GL_OES_texture_half_float")));
779 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_OES_texture_float_linear"));
780 EXPECT_THAT(info_
->extensions(),
781 Not(HasSubstr("GL_OES_texture_half_float_linear")));
782 EXPECT_TRUE(info_
->validators()->pixel_type
.IsValid(GL_FLOAT
));
783 EXPECT_FALSE(info_
->validators()->pixel_type
.IsValid(GL_HALF_FLOAT_OES
));
784 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_ALPHA
).IsValid(
786 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_RGB
).IsValid(
788 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_RGBA
).IsValid(
790 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_LUMINANCE
).IsValid(
792 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_LUMINANCE_ALPHA
).IsValid(
794 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_ALPHA
).IsValid(
796 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_RGB
).IsValid(
798 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_RGBA
).IsValid(
800 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_LUMINANCE
).IsValid(
802 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_LUMINANCE_ALPHA
).IsValid(
806 TEST_F(FeatureInfoTest
, InitializeOES_texture_half_floatGLES2
) {
807 SetupInitExpectations("GL_OES_texture_half_float");
808 EXPECT_FALSE(info_
->feature_flags().enable_texture_float_linear
);
809 EXPECT_FALSE(info_
->feature_flags().enable_texture_half_float_linear
);
810 EXPECT_THAT(info_
->extensions(), Not(HasSubstr("GL_OES_texture_float")));
811 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_OES_texture_half_float"));
812 EXPECT_THAT(info_
->extensions(),
813 Not(HasSubstr("GL_OES_texture_float_linear")));
814 EXPECT_THAT(info_
->extensions(),
815 Not(HasSubstr("GL_OES_texture_half_float_linear")));
816 EXPECT_FALSE(info_
->validators()->pixel_type
.IsValid(GL_FLOAT
));
817 EXPECT_TRUE(info_
->validators()->pixel_type
.IsValid(GL_HALF_FLOAT_OES
));
818 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_ALPHA
).IsValid(
820 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_RGB
).IsValid(
822 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_RGBA
).IsValid(
824 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_LUMINANCE
).IsValid(
826 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_LUMINANCE_ALPHA
).IsValid(
828 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_ALPHA
).IsValid(
830 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_RGB
).IsValid(
832 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_RGBA
).IsValid(
834 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_LUMINANCE
).IsValid(
836 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_LUMINANCE_ALPHA
).IsValid(
840 TEST_F(FeatureInfoTest
, InitializeOES_texture_half_float_linearGLES2
) {
841 SetupInitExpectations(
842 "GL_OES_texture_half_float GL_OES_texture_half_float_linear");
843 EXPECT_FALSE(info_
->feature_flags().enable_texture_float_linear
);
844 EXPECT_TRUE(info_
->feature_flags().enable_texture_half_float_linear
);
845 EXPECT_THAT(info_
->extensions(), Not(HasSubstr("GL_OES_texture_float")));
846 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_OES_texture_half_float"));
847 EXPECT_THAT(info_
->extensions(),
848 Not(HasSubstr("GL_OES_texture_float_linear")));
849 EXPECT_THAT(info_
->extensions(),
850 HasSubstr("GL_OES_texture_half_float_linear"));
851 EXPECT_FALSE(info_
->validators()->pixel_type
.IsValid(GL_FLOAT
));
852 EXPECT_TRUE(info_
->validators()->pixel_type
.IsValid(GL_HALF_FLOAT_OES
));
853 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_ALPHA
).IsValid(
855 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_RGB
).IsValid(
857 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_RGBA
).IsValid(
859 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_LUMINANCE
).IsValid(
861 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_LUMINANCE_ALPHA
).IsValid(
863 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_ALPHA
).IsValid(
865 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_RGB
).IsValid(
867 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_RGBA
).IsValid(
869 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_LUMINANCE
).IsValid(
871 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_LUMINANCE_ALPHA
).IsValid(
875 TEST_F(FeatureInfoTest
, InitializeEXT_framebuffer_multisample
) {
876 SetupInitExpectations("GL_EXT_framebuffer_multisample");
877 EXPECT_TRUE(info_
->feature_flags().chromium_framebuffer_multisample
);
878 EXPECT_THAT(info_
->extensions(),
879 HasSubstr("GL_CHROMIUM_framebuffer_multisample"));
880 EXPECT_TRUE(info_
->validators()->frame_buffer_target
.IsValid(
881 GL_READ_FRAMEBUFFER_EXT
));
882 EXPECT_TRUE(info_
->validators()->frame_buffer_target
.IsValid(
883 GL_DRAW_FRAMEBUFFER_EXT
));
884 EXPECT_TRUE(info_
->validators()->g_l_state
.IsValid(
885 GL_READ_FRAMEBUFFER_BINDING_EXT
));
886 EXPECT_TRUE(info_
->validators()->g_l_state
.IsValid(
887 GL_MAX_SAMPLES_EXT
));
888 EXPECT_TRUE(info_
->validators()->render_buffer_parameter
.IsValid(
889 GL_RENDERBUFFER_SAMPLES_EXT
));
892 TEST_F(FeatureInfoTest
, InitializeANGLE_framebuffer_multisample
) {
893 SetupInitExpectationsWithGLVersion(
894 "GL_ANGLE_framebuffer_multisample", kGLRendererStringANGLE
, "");
895 EXPECT_TRUE(info_
->feature_flags().chromium_framebuffer_multisample
);
896 EXPECT_THAT(info_
->extensions(),
897 HasSubstr("GL_CHROMIUM_framebuffer_multisample"));
898 EXPECT_TRUE(info_
->validators()->frame_buffer_target
.IsValid(
899 GL_READ_FRAMEBUFFER_EXT
));
900 EXPECT_TRUE(info_
->validators()->frame_buffer_target
.IsValid(
901 GL_DRAW_FRAMEBUFFER_EXT
));
902 EXPECT_TRUE(info_
->validators()->g_l_state
.IsValid(
903 GL_READ_FRAMEBUFFER_BINDING_EXT
));
904 EXPECT_TRUE(info_
->validators()->g_l_state
.IsValid(
905 GL_MAX_SAMPLES_EXT
));
906 EXPECT_TRUE(info_
->validators()->render_buffer_parameter
.IsValid(
907 GL_RENDERBUFFER_SAMPLES_EXT
));
910 // We don't allow ANGLE_framebuffer_multisample on non-ANGLE implementations,
911 // because we wouldn't be choosing the right driver entry point and because the
912 // extension was falsely advertised on some Android devices (crbug.com/165736).
913 TEST_F(FeatureInfoTest
, InitializeANGLE_framebuffer_multisampleWithoutANGLE
) {
914 SetupInitExpectations("GL_ANGLE_framebuffer_multisample");
915 EXPECT_FALSE(info_
->feature_flags().chromium_framebuffer_multisample
);
916 EXPECT_THAT(info_
->extensions(),
917 Not(HasSubstr("GL_CHROMIUM_framebuffer_multisample")));
918 EXPECT_FALSE(info_
->validators()->frame_buffer_target
.IsValid(
919 GL_READ_FRAMEBUFFER_EXT
));
920 EXPECT_FALSE(info_
->validators()->frame_buffer_target
.IsValid(
921 GL_DRAW_FRAMEBUFFER_EXT
));
922 EXPECT_FALSE(info_
->validators()->g_l_state
.IsValid(
923 GL_READ_FRAMEBUFFER_BINDING_EXT
));
924 EXPECT_FALSE(info_
->validators()->g_l_state
.IsValid(
925 GL_MAX_SAMPLES_EXT
));
926 EXPECT_FALSE(info_
->validators()->render_buffer_parameter
.IsValid(
927 GL_RENDERBUFFER_SAMPLES_EXT
));
930 TEST_F(FeatureInfoTest
, InitializeEXT_multisampled_render_to_texture
) {
931 SetupInitExpectations("GL_EXT_multisampled_render_to_texture");
932 EXPECT_TRUE(info_
->feature_flags(
933 ).multisampled_render_to_texture
);
934 EXPECT_FALSE(info_
->feature_flags(
935 ).use_img_for_multisampled_render_to_texture
);
936 EXPECT_THAT(info_
->extensions(),
937 HasSubstr("GL_EXT_multisampled_render_to_texture"));
938 EXPECT_TRUE(info_
->validators()->g_l_state
.IsValid(
939 GL_MAX_SAMPLES_EXT
));
940 EXPECT_TRUE(info_
->validators()->render_buffer_parameter
.IsValid(
941 GL_RENDERBUFFER_SAMPLES_EXT
));
942 EXPECT_TRUE(info_
->validators()->frame_buffer_parameter
.IsValid(
943 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT
));
946 TEST_F(FeatureInfoTest
, InitializeIMG_multisampled_render_to_texture
) {
947 SetupInitExpectations("GL_IMG_multisampled_render_to_texture");
948 EXPECT_TRUE(info_
->feature_flags(
949 ).multisampled_render_to_texture
);
950 EXPECT_TRUE(info_
->feature_flags(
951 ).use_img_for_multisampled_render_to_texture
);
952 EXPECT_THAT(info_
->extensions(),
953 HasSubstr("GL_EXT_multisampled_render_to_texture"));
954 EXPECT_TRUE(info_
->validators()->g_l_state
.IsValid(
955 GL_MAX_SAMPLES_EXT
));
956 EXPECT_TRUE(info_
->validators()->render_buffer_parameter
.IsValid(
957 GL_RENDERBUFFER_SAMPLES_EXT
));
958 EXPECT_TRUE(info_
->validators()->frame_buffer_parameter
.IsValid(
959 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT
));
962 TEST_F(FeatureInfoTest
, InitializeEXT_texture_filter_anisotropic
) {
963 SetupInitExpectations("GL_EXT_texture_filter_anisotropic");
964 EXPECT_THAT(info_
->extensions(),
965 HasSubstr("GL_EXT_texture_filter_anisotropic"));
966 EXPECT_TRUE(info_
->validators()->texture_parameter
.IsValid(
967 GL_TEXTURE_MAX_ANISOTROPY_EXT
));
968 EXPECT_TRUE(info_
->validators()->g_l_state
.IsValid(
969 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
));
972 TEST_F(FeatureInfoTest
, InitializeEXT_ARB_depth_texture
) {
973 SetupInitExpectations("GL_ARB_depth_texture");
974 EXPECT_THAT(info_
->extensions(),
975 HasSubstr("GL_GOOGLE_depth_texture"));
976 EXPECT_THAT(info_
->extensions(),
977 HasSubstr("GL_CHROMIUM_depth_texture"));
978 EXPECT_TRUE(info_
->validators()->texture_internal_format
.IsValid(
979 GL_DEPTH_COMPONENT
));
980 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(GL_DEPTH_COMPONENT
));
981 EXPECT_FALSE(info_
->validators()->texture_format
.IsValid(GL_DEPTH_STENCIL
));
982 EXPECT_TRUE(info_
->validators()->pixel_type
.IsValid(GL_UNSIGNED_SHORT
));
983 EXPECT_TRUE(info_
->validators()->pixel_type
.IsValid(GL_UNSIGNED_INT
));
984 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_DEPTH_COMPONENT
).IsValid(
986 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_DEPTH_COMPONENT
).IsValid(
988 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_DEPTH_STENCIL
).IsValid(
989 GL_UNSIGNED_INT_24_8
));
992 TEST_F(FeatureInfoTest
, InitializeOES_ARB_depth_texture
) {
993 SetupInitExpectations("GL_OES_depth_texture");
994 EXPECT_THAT(info_
->extensions(),
995 HasSubstr("GL_GOOGLE_depth_texture"));
996 EXPECT_THAT(info_
->extensions(),
997 HasSubstr("GL_CHROMIUM_depth_texture"));
998 EXPECT_TRUE(info_
->validators()->texture_internal_format
.IsValid(
999 GL_DEPTH_COMPONENT
));
1000 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(GL_DEPTH_COMPONENT
));
1001 EXPECT_FALSE(info_
->validators()->texture_format
.IsValid(GL_DEPTH_STENCIL
));
1002 EXPECT_TRUE(info_
->validators()->pixel_type
.IsValid(GL_UNSIGNED_SHORT
));
1003 EXPECT_TRUE(info_
->validators()->pixel_type
.IsValid(GL_UNSIGNED_INT
));
1004 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_DEPTH_COMPONENT
).IsValid(
1005 GL_UNSIGNED_SHORT
));
1006 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_DEPTH_COMPONENT
).IsValid(
1008 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_DEPTH_STENCIL
).IsValid(
1009 GL_UNSIGNED_INT_24_8
));
1012 TEST_F(FeatureInfoTest
, InitializeANGLE_depth_texture
) {
1013 SetupInitExpectations("GL_ANGLE_depth_texture");
1014 EXPECT_THAT(info_
->extensions(),
1015 HasSubstr("GL_GOOGLE_depth_texture"));
1016 EXPECT_THAT(info_
->extensions(),
1017 HasSubstr("GL_CHROMIUM_depth_texture"));
1018 EXPECT_THAT(info_
->extensions(),
1019 Not(HasSubstr("GL_ANGLE_depth_texture")));
1020 EXPECT_TRUE(info_
->feature_flags().angle_depth_texture
);
1021 EXPECT_TRUE(info_
->validators()->texture_internal_format
.IsValid(
1022 GL_DEPTH_COMPONENT
));
1023 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(GL_DEPTH_COMPONENT
));
1024 EXPECT_FALSE(info_
->validators()->texture_format
.IsValid(GL_DEPTH_STENCIL
));
1025 EXPECT_TRUE(info_
->validators()->pixel_type
.IsValid(GL_UNSIGNED_SHORT
));
1026 EXPECT_TRUE(info_
->validators()->pixel_type
.IsValid(GL_UNSIGNED_INT
));
1027 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
1028 GL_DEPTH_COMPONENT16
));
1029 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
1030 GL_DEPTH_COMPONENT32_OES
));
1031 EXPECT_FALSE(info_
->validators()->texture_internal_format_storage
.IsValid(
1032 GL_DEPTH24_STENCIL8_OES
));
1033 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_DEPTH_COMPONENT
).IsValid(
1034 GL_UNSIGNED_SHORT
));
1035 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_DEPTH_COMPONENT
).IsValid(
1037 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_DEPTH_STENCIL
).IsValid(
1038 GL_UNSIGNED_INT_24_8
));
1041 TEST_F(FeatureInfoTest
, InitializeEXT_packed_depth_stencil
) {
1042 SetupInitExpectations("GL_EXT_packed_depth_stencil");
1043 EXPECT_THAT(info_
->extensions(),
1044 HasSubstr("GL_OES_packed_depth_stencil"));
1045 EXPECT_TRUE(info_
->validators()->render_buffer_format
.IsValid(
1046 GL_DEPTH24_STENCIL8
));
1047 EXPECT_FALSE(info_
->validators()->texture_internal_format
.IsValid(
1048 GL_DEPTH_COMPONENT
));
1049 EXPECT_FALSE(info_
->validators()->texture_format
.IsValid(GL_DEPTH_COMPONENT
));
1050 EXPECT_FALSE(info_
->validators()->pixel_type
.IsValid(GL_UNSIGNED_SHORT
));
1051 EXPECT_FALSE(info_
->validators()->pixel_type
.IsValid(GL_UNSIGNED_INT
));
1054 TEST_F(FeatureInfoTest
, InitializeOES_packed_depth_stencil
) {
1055 SetupInitExpectations("GL_OES_packed_depth_stencil");
1056 EXPECT_THAT(info_
->extensions(),
1057 HasSubstr("GL_OES_packed_depth_stencil"));
1058 EXPECT_TRUE(info_
->validators()->render_buffer_format
.IsValid(
1059 GL_DEPTH24_STENCIL8
));
1060 EXPECT_FALSE(info_
->validators()->texture_internal_format
.IsValid(
1061 GL_DEPTH_COMPONENT
));
1062 EXPECT_FALSE(info_
->validators()->texture_format
.IsValid(GL_DEPTH_COMPONENT
));
1063 EXPECT_FALSE(info_
->validators()->pixel_type
.IsValid(GL_UNSIGNED_SHORT
));
1064 EXPECT_FALSE(info_
->validators()->pixel_type
.IsValid(GL_UNSIGNED_INT
));
1067 TEST_F(FeatureInfoTest
,
1068 InitializeOES_packed_depth_stencil_and_GL_ARB_depth_texture
) {
1069 SetupInitExpectations("GL_OES_packed_depth_stencil GL_ARB_depth_texture");
1070 EXPECT_THAT(info_
->extensions(),
1071 HasSubstr("GL_OES_packed_depth_stencil"));
1072 EXPECT_TRUE(info_
->validators()->render_buffer_format
.IsValid(
1073 GL_DEPTH24_STENCIL8
));
1074 EXPECT_TRUE(info_
->validators()->texture_internal_format
.IsValid(
1076 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(
1078 EXPECT_TRUE(info_
->validators()->pixel_type
.IsValid(
1079 GL_UNSIGNED_INT_24_8
));
1080 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_DEPTH_COMPONENT
).IsValid(
1081 GL_UNSIGNED_SHORT
));
1082 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_DEPTH_COMPONENT
).IsValid(
1084 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_DEPTH_STENCIL
).IsValid(
1085 GL_UNSIGNED_INT_24_8
));
1088 TEST_F(FeatureInfoTest
, InitializeOES_depth24
) {
1089 SetupInitExpectations("GL_OES_depth24");
1090 EXPECT_TRUE(info_
->feature_flags().oes_depth24
);
1091 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_OES_depth24"));
1092 EXPECT_TRUE(info_
->validators()->render_buffer_format
.IsValid(
1093 GL_DEPTH_COMPONENT24
));
1096 TEST_F(FeatureInfoTest
, InitializeOES_standard_derivatives
) {
1097 SetupInitExpectations("GL_OES_standard_derivatives");
1098 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_OES_standard_derivatives"));
1099 EXPECT_TRUE(info_
->feature_flags().oes_standard_derivatives
);
1100 EXPECT_TRUE(info_
->validators()->hint_target
.IsValid(
1101 GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES
));
1102 EXPECT_TRUE(info_
->validators()->g_l_state
.IsValid(
1103 GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES
));
1106 TEST_F(FeatureInfoTest
, InitializeOES_rgb8_rgba8
) {
1107 SetupInitExpectations("GL_OES_rgb8_rgba8");
1108 EXPECT_THAT(info_
->extensions(),
1109 HasSubstr("GL_OES_rgb8_rgba8"));
1110 EXPECT_TRUE(info_
->validators()->render_buffer_format
.IsValid(
1112 EXPECT_TRUE(info_
->validators()->render_buffer_format
.IsValid(
1116 TEST_F(FeatureInfoTest
, InitializeOES_EGL_image_external
) {
1117 SetupInitExpectations("GL_OES_EGL_image_external");
1118 EXPECT_THAT(info_
->extensions(),
1119 HasSubstr("GL_OES_EGL_image_external"));
1120 EXPECT_TRUE(info_
->feature_flags().oes_egl_image_external
);
1121 EXPECT_TRUE(info_
->validators()->texture_bind_target
.IsValid(
1122 GL_TEXTURE_EXTERNAL_OES
));
1123 EXPECT_TRUE(info_
->validators()->get_tex_param_target
.IsValid(
1124 GL_TEXTURE_EXTERNAL_OES
));
1125 EXPECT_TRUE(info_
->validators()->texture_parameter
.IsValid(
1126 GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES
));
1127 EXPECT_TRUE(info_
->validators()->g_l_state
.IsValid(
1128 GL_TEXTURE_BINDING_EXTERNAL_OES
));
1131 TEST_F(FeatureInfoTest
, InitializeOES_compressed_ETC1_RGB8_texture
) {
1132 SetupInitExpectations("GL_OES_compressed_ETC1_RGB8_texture");
1133 EXPECT_THAT(info_
->extensions(),
1134 HasSubstr("GL_OES_compressed_ETC1_RGB8_texture"));
1135 EXPECT_TRUE(info_
->validators()->compressed_texture_format
.IsValid(
1137 EXPECT_FALSE(info_
->validators()->texture_internal_format
.IsValid(
1141 TEST_F(FeatureInfoTest
, InitializeAMD_compressed_ATC_texture
) {
1142 SetupInitExpectations("GL_AMD_compressed_ATC_texture");
1143 EXPECT_THAT(info_
->extensions(),
1144 HasSubstr("GL_AMD_compressed_ATC_texture"));
1145 EXPECT_TRUE(info_
->validators()->compressed_texture_format
.IsValid(
1147 EXPECT_TRUE(info_
->validators()->compressed_texture_format
.IsValid(
1148 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD
));
1149 EXPECT_TRUE(info_
->validators()->compressed_texture_format
.IsValid(
1150 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
));
1153 TEST_F(FeatureInfoTest
, InitializeIMG_texture_compression_pvrtc
) {
1154 SetupInitExpectations("GL_IMG_texture_compression_pvrtc");
1155 EXPECT_THAT(info_
->extensions(),
1156 HasSubstr("GL_IMG_texture_compression_pvrtc"));
1157 EXPECT_TRUE(info_
->validators()->compressed_texture_format
.IsValid(
1158 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
));
1159 EXPECT_TRUE(info_
->validators()->compressed_texture_format
.IsValid(
1160 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
));
1161 EXPECT_TRUE(info_
->validators()->compressed_texture_format
.IsValid(
1162 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
));
1163 EXPECT_TRUE(info_
->validators()->compressed_texture_format
.IsValid(
1164 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
));
1167 TEST_F(FeatureInfoTest
, InitializeEXT_occlusion_query_boolean
) {
1168 SetupInitExpectations("GL_EXT_occlusion_query_boolean");
1169 EXPECT_THAT(info_
->extensions(),
1170 HasSubstr("GL_EXT_occlusion_query_boolean"));
1171 EXPECT_TRUE(info_
->feature_flags().occlusion_query_boolean
);
1172 EXPECT_FALSE(info_
->feature_flags(
1173 ).use_arb_occlusion_query2_for_occlusion_query_boolean
);
1174 EXPECT_FALSE(info_
->feature_flags(
1175 ).use_arb_occlusion_query_for_occlusion_query_boolean
);
1178 TEST_F(FeatureInfoTest
, InitializeARB_occlusion_query
) {
1179 SetupInitExpectations("GL_ARB_occlusion_query");
1180 EXPECT_THAT(info_
->extensions(),
1181 HasSubstr("GL_EXT_occlusion_query_boolean"));
1182 EXPECT_TRUE(info_
->feature_flags().occlusion_query_boolean
);
1183 EXPECT_FALSE(info_
->feature_flags(
1184 ).use_arb_occlusion_query2_for_occlusion_query_boolean
);
1185 EXPECT_TRUE(info_
->feature_flags(
1186 ).use_arb_occlusion_query_for_occlusion_query_boolean
);
1189 TEST_F(FeatureInfoTest
, InitializeARB_occlusion_query2
) {
1190 SetupInitExpectations("GL_ARB_occlusion_query2 GL_ARB_occlusion_query2");
1191 EXPECT_THAT(info_
->extensions(),
1192 HasSubstr("GL_EXT_occlusion_query_boolean"));
1193 EXPECT_TRUE(info_
->feature_flags().occlusion_query_boolean
);
1194 EXPECT_TRUE(info_
->feature_flags(
1195 ).use_arb_occlusion_query2_for_occlusion_query_boolean
);
1196 EXPECT_FALSE(info_
->feature_flags(
1197 ).use_arb_occlusion_query_for_occlusion_query_boolean
);
1200 TEST_F(FeatureInfoTest
, InitializeOES_vertex_array_object
) {
1201 SetupInitExpectations("GL_OES_vertex_array_object");
1202 EXPECT_THAT(info_
->extensions(),
1203 HasSubstr("GL_OES_vertex_array_object"));
1204 EXPECT_TRUE(info_
->feature_flags().native_vertex_array_object
);
1207 TEST_F(FeatureInfoTest
, InitializeARB_vertex_array_object
) {
1208 SetupInitExpectations("GL_ARB_vertex_array_object");
1209 EXPECT_THAT(info_
->extensions(),
1210 HasSubstr("GL_OES_vertex_array_object"));
1211 EXPECT_TRUE(info_
->feature_flags().native_vertex_array_object
);
1214 TEST_F(FeatureInfoTest
, InitializeAPPLE_vertex_array_object
) {
1215 SetupInitExpectations("GL_APPLE_vertex_array_object");
1216 EXPECT_THAT(info_
->extensions(),
1217 HasSubstr("GL_OES_vertex_array_object"));
1218 EXPECT_TRUE(info_
->feature_flags().native_vertex_array_object
);
1221 TEST_F(FeatureInfoTest
, InitializeNo_vertex_array_object
) {
1222 SetupInitExpectations("");
1223 // Even if the native extensions are not available the implementation
1224 // may still emulate the GL_OES_vertex_array_object functionality. In this
1225 // scenario native_vertex_array_object must be false.
1226 EXPECT_THAT(info_
->extensions(),
1227 HasSubstr("GL_OES_vertex_array_object"));
1228 EXPECT_FALSE(info_
->feature_flags().native_vertex_array_object
);
1231 TEST_F(FeatureInfoTest
, InitializeOES_element_index_uint
) {
1232 SetupInitExpectations("GL_OES_element_index_uint");
1233 EXPECT_THAT(info_
->extensions(),
1234 HasSubstr("GL_OES_element_index_uint"));
1235 EXPECT_TRUE(info_
->validators()->index_type
.IsValid(GL_UNSIGNED_INT
));
1238 TEST_F(FeatureInfoTest
, InitializeVAOsWithClientSideArrays
) {
1239 base::CommandLine
command_line(0, NULL
);
1240 command_line
.AppendSwitchASCII(
1241 switches::kGpuDriverBugWorkarounds
,
1242 base::IntToString(gpu::USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS
));
1243 SetupInitExpectationsWithCommandLine("GL_OES_vertex_array_object",
1245 EXPECT_TRUE(info_
->workarounds().use_client_side_arrays_for_stream_buffers
);
1246 EXPECT_FALSE(info_
->feature_flags().native_vertex_array_object
);
1249 TEST_F(FeatureInfoTest
, InitializeEXT_blend_minmax
) {
1250 SetupInitExpectations("GL_EXT_blend_minmax");
1251 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_blend_minmax"));
1252 EXPECT_TRUE(info_
->validators()->equation
.IsValid(GL_MIN_EXT
));
1253 EXPECT_TRUE(info_
->validators()->equation
.IsValid(GL_MAX_EXT
));
1256 TEST_F(FeatureInfoTest
, InitializeEXT_frag_depth
) {
1257 SetupInitExpectations("GL_EXT_frag_depth");
1258 EXPECT_TRUE(info_
->feature_flags().ext_frag_depth
);
1259 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_frag_depth"));
1262 TEST_F(FeatureInfoTest
, InitializeEXT_shader_texture_lod
) {
1263 SetupInitExpectations("GL_EXT_shader_texture_lod");
1264 EXPECT_TRUE(info_
->feature_flags().ext_shader_texture_lod
);
1265 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_shader_texture_lod"));
1268 TEST_F(FeatureInfoTest
, InitializeEXT_discard_framebuffer
) {
1269 SetupInitExpectations("GL_EXT_discard_framebuffer");
1270 EXPECT_TRUE(info_
->feature_flags().ext_discard_framebuffer
);
1271 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_discard_framebuffer"));
1274 TEST_F(FeatureInfoTest
, InitializeSamplersWithARBSamplerObjects
) {
1275 SetupInitExpectationsWithGLVersion(
1276 "GL_ARB_sampler_objects", "", "OpenGL 3.0");
1277 EXPECT_TRUE(info_
->feature_flags().enable_samplers
);
1280 TEST_F(FeatureInfoTest
, InitializeWithES3
) {
1281 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 3.0");
1282 EXPECT_TRUE(info_
->feature_flags().chromium_framebuffer_multisample
);
1283 EXPECT_TRUE(info_
->feature_flags().use_core_framebuffer_multisample
);
1284 EXPECT_THAT(info_
->extensions(),
1285 HasSubstr("GL_CHROMIUM_framebuffer_multisample"));
1286 EXPECT_TRUE(info_
->feature_flags().use_async_readpixels
);
1287 EXPECT_TRUE(info_
->feature_flags().oes_standard_derivatives
);
1288 EXPECT_TRUE(info_
->feature_flags().oes_depth24
);
1289 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_GOOGLE_depth_texture"));
1290 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_CHROMIUM_depth_texture"));
1292 info_
->validators()->texture_internal_format
.IsValid(GL_DEPTH_COMPONENT
));
1294 info_
->validators()->texture_internal_format
.IsValid(GL_DEPTH_STENCIL
));
1295 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(GL_DEPTH_COMPONENT
));
1296 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(GL_DEPTH_STENCIL
));
1297 EXPECT_TRUE(info_
->validators()->pixel_type
.IsValid(GL_UNSIGNED_SHORT
));
1298 EXPECT_TRUE(info_
->validators()->pixel_type
.IsValid(GL_UNSIGNED_INT
));
1299 EXPECT_TRUE(info_
->validators()->pixel_type
.IsValid(GL_UNSIGNED_INT_24_8
));
1300 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_DEPTH_COMPONENT
)
1301 .IsValid(GL_UNSIGNED_SHORT
));
1302 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_DEPTH_COMPONENT
)
1303 .IsValid(GL_UNSIGNED_INT
));
1304 EXPECT_TRUE(info_
->GetTextureFormatValidator(GL_DEPTH_STENCIL
)
1305 .IsValid(GL_UNSIGNED_INT_24_8
));
1306 EXPECT_TRUE(info_
->feature_flags().packed_depth24_stencil8
);
1307 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_OES_depth24"));
1309 info_
->validators()->render_buffer_format
.IsValid(GL_DEPTH_COMPONENT24
));
1311 info_
->validators()->render_buffer_format
.IsValid(GL_DEPTH24_STENCIL8
));
1313 info_
->validators()->texture_internal_format
.IsValid(GL_DEPTH_STENCIL
));
1314 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(GL_DEPTH_STENCIL
));
1315 EXPECT_TRUE(info_
->feature_flags().npot_ok
);
1316 EXPECT_TRUE(info_
->feature_flags().native_vertex_array_object
);
1317 EXPECT_TRUE(info_
->feature_flags().enable_samplers
);
1318 EXPECT_TRUE(info_
->feature_flags().map_buffer_range
);
1319 EXPECT_TRUE(info_
->feature_flags().ext_discard_framebuffer
);
1320 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_EXT_discard_framebuffer"));
1321 EXPECT_TRUE(info_
->feature_flags().chromium_sync_query
);
1322 EXPECT_TRUE(gfx::GLFence::IsSupported());
1325 TEST_F(FeatureInfoTest
, InitializeWithoutSamplers
) {
1326 SetupInitExpectationsWithGLVersion("", "", "OpenGL GL 3.0");
1327 EXPECT_FALSE(info_
->feature_flags().enable_samplers
);
1330 TEST_F(FeatureInfoTest
, ParseDriverBugWorkaroundsSingle
) {
1331 base::CommandLine
command_line(0, NULL
);
1332 command_line
.AppendSwitchASCII(
1333 switches::kGpuDriverBugWorkarounds
,
1334 base::IntToString(gpu::EXIT_ON_CONTEXT_LOST
));
1335 // Workarounds should get parsed without the need for a context.
1336 SetupWithCommandLine(command_line
);
1337 EXPECT_TRUE(info_
->workarounds().exit_on_context_lost
);
1340 TEST_F(FeatureInfoTest
, ParseDriverBugWorkaroundsMultiple
) {
1341 base::CommandLine
command_line(0, NULL
);
1342 command_line
.AppendSwitchASCII(
1343 switches::kGpuDriverBugWorkarounds
,
1344 base::IntToString(gpu::EXIT_ON_CONTEXT_LOST
) + "," +
1345 base::IntToString(gpu::MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024
) + "," +
1346 base::IntToString(gpu::MAX_TEXTURE_SIZE_LIMIT_4096
));
1347 // Workarounds should get parsed without the need for a context.
1348 SetupWithCommandLine(command_line
);
1349 EXPECT_TRUE(info_
->workarounds().exit_on_context_lost
);
1350 EXPECT_EQ(1024, info_
->workarounds().max_cube_map_texture_size
);
1351 EXPECT_EQ(4096, info_
->workarounds().max_texture_size
);
1354 TEST_F(FeatureInfoTest
, InitializeWithARBSync
) {
1355 SetupInitExpectations("GL_ARB_sync");
1356 EXPECT_TRUE(info_
->feature_flags().chromium_sync_query
);
1357 EXPECT_TRUE(gfx::GLFence::IsSupported());
1360 TEST_F(FeatureInfoTest
, InitializeWithNVFence
) {
1361 SetupInitExpectations("GL_NV_fence");
1362 EXPECT_TRUE(info_
->feature_flags().chromium_sync_query
);
1363 EXPECT_TRUE(gfx::GLFence::IsSupported());
1366 TEST_F(FeatureInfoTest
, InitializeWithNVDrawBuffers
) {
1367 SetupInitExpectationsWithGLVersion("GL_NV_draw_buffers", "", "OpenGL ES 3.0");
1368 EXPECT_TRUE(info_
->feature_flags().nv_draw_buffers
);
1369 EXPECT_TRUE(info_
->feature_flags().ext_draw_buffers
);
1372 TEST_F(FeatureInfoTest
, InitializeWithPreferredEXTDrawBuffers
) {
1373 SetupInitExpectationsWithGLVersion(
1374 "GL_NV_draw_buffers GL_EXT_draw_buffers", "", "OpenGL ES 3.0");
1375 EXPECT_FALSE(info_
->feature_flags().nv_draw_buffers
);
1376 EXPECT_TRUE(info_
->feature_flags().ext_draw_buffers
);
1379 TEST_F(FeatureInfoTest
, ARBSyncDisabled
) {
1380 base::CommandLine
command_line(0, NULL
);
1381 command_line
.AppendSwitchASCII(
1382 switches::kGpuDriverBugWorkarounds
,
1383 base::IntToString(gpu::DISABLE_ARB_SYNC
));
1384 SetupInitExpectationsWithCommandLine("GL_ARB_sync", command_line
);
1385 EXPECT_FALSE(info_
->feature_flags().chromium_sync_query
);
1386 EXPECT_FALSE(gfx::GLFence::IsSupported());
1389 TEST_F(FeatureInfoTest
, InitializeCHROMIUM_path_rendering
) {
1390 SetupInitExpectationsWithGLVersion(
1391 "GL_ARB_compatibility GL_NV_path_rendering GL_EXT_direct_state_access",
1393 EXPECT_TRUE(info_
->feature_flags().chromium_path_rendering
);
1394 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_CHROMIUM_path_rendering"));
1397 TEST_F(FeatureInfoTest
, InitializeCHROMIUM_path_rendering2
) {
1398 SetupInitExpectationsWithGLVersion(
1399 "GL_NV_path_rendering", "", "OpenGL ES 3.1");
1400 EXPECT_TRUE(info_
->feature_flags().chromium_path_rendering
);
1401 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_CHROMIUM_path_rendering"));
1404 TEST_F(FeatureInfoTest
, InitializeNoCHROMIUM_path_rendering
) {
1405 SetupInitExpectationsWithGLVersion("GL_ARB_compatibility", "", "4.3");
1406 EXPECT_FALSE(info_
->feature_flags().chromium_path_rendering
);
1407 EXPECT_THAT(info_
->extensions(),
1408 Not(HasSubstr("GL_CHROMIUM_path_rendering")));
1411 TEST_F(FeatureInfoTest
, InitializeNoCHROMIUM_path_rendering2
) {
1412 SetupInitExpectationsWithGLVersion(
1413 "GL_ARB_compatibility GL_NV_path_rendering", "", "4.3");
1414 EXPECT_FALSE(info_
->feature_flags().chromium_path_rendering
);
1415 EXPECT_THAT(info_
->extensions(),
1416 Not(HasSubstr("GL_CHROMIUM_path_rendering")));
1419 TEST_F(FeatureInfoTest
, InitializeNoKHR_blend_equation_advanced
) {
1420 SetupInitExpectationsWithGLVersion("GL_ARB_compatibility", "", "4.3");
1421 EXPECT_FALSE(info_
->feature_flags().blend_equation_advanced
);
1422 EXPECT_THAT(info_
->extensions(),
1423 Not(HasSubstr("GL_KHR_blend_equation_advanced")));
1426 TEST_F(FeatureInfoTest
, InitializeKHR_blend_equations_advanced
) {
1427 SetupInitExpectations("GL_KHR_blend_equation_advanced");
1428 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_KHR_blend_equation_advanced"));
1429 EXPECT_TRUE(info_
->feature_flags().blend_equation_advanced
);
1432 TEST_F(FeatureInfoTest
, InitializeNV_blend_equations_advanced
) {
1433 SetupInitExpectations("GL_NV_blend_equation_advanced");
1434 EXPECT_THAT(info_
->extensions(), HasSubstr("GL_KHR_blend_equation_advanced"));
1435 EXPECT_TRUE(info_
->feature_flags().blend_equation_advanced
);
1438 TEST_F(FeatureInfoTest
, InitializeNoKHR_blend_equation_advanced_coherent
) {
1439 SetupInitExpectationsWithGLVersion("GL_ARB_compatibility ", "", "4.3");
1440 EXPECT_FALSE(info_
->feature_flags().blend_equation_advanced_coherent
);
1441 EXPECT_THAT(info_
->extensions(),
1442 Not(HasSubstr("GL_KHR_blend_equation_advanced_coherent")));
1445 TEST_F(FeatureInfoTest
, InitializeKHR_blend_equations_advanced_coherent
) {
1446 SetupInitExpectations("GL_KHR_blend_equation_advanced_coherent");
1447 EXPECT_THAT(info_
->extensions(),
1448 HasSubstr("GL_KHR_blend_equation_advanced_coherent"));
1449 EXPECT_TRUE(info_
->feature_flags().blend_equation_advanced
);
1450 EXPECT_TRUE(info_
->feature_flags().blend_equation_advanced_coherent
);
1453 TEST_F(FeatureInfoTest
, InitializeEXT_texture_rgWithFloat
) {
1454 SetupInitExpectations(
1455 "GL_EXT_texture_rg GL_OES_texture_float GL_OES_texture_half_float");
1456 EXPECT_TRUE(info_
->feature_flags().ext_texture_rg
);
1458 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(GL_RED_EXT
));
1459 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(GL_RG_EXT
));
1460 EXPECT_TRUE(info_
->validators()->texture_internal_format
.IsValid(GL_RED_EXT
));
1461 EXPECT_TRUE(info_
->validators()->texture_internal_format
.IsValid(GL_RG_EXT
));
1462 EXPECT_TRUE(info_
->validators()->read_pixel_format
.IsValid(GL_RED_EXT
));
1463 EXPECT_TRUE(info_
->validators()->read_pixel_format
.IsValid(GL_RG_EXT
));
1464 EXPECT_TRUE(info_
->validators()->render_buffer_format
.IsValid(GL_R8_EXT
));
1465 EXPECT_TRUE(info_
->validators()->render_buffer_format
.IsValid(GL_RG8_EXT
));
1468 info_
->GetTextureFormatValidator(GL_RED_EXT
).IsValid(GL_HALF_FLOAT_OES
));
1470 info_
->GetTextureFormatValidator(GL_RG_EXT
).IsValid(GL_HALF_FLOAT_OES
));
1472 info_
->GetTextureFormatValidator(GL_RED_EXT
).IsValid(GL_UNSIGNED_BYTE
));
1474 info_
->GetTextureFormatValidator(GL_RG_EXT
).IsValid(GL_UNSIGNED_BYTE
));
1476 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_RED_EXT
).IsValid(GL_BYTE
));
1477 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_RG_EXT
).IsValid(GL_BYTE
));
1478 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_RED_EXT
).IsValid(GL_SHORT
));
1479 EXPECT_FALSE(info_
->GetTextureFormatValidator(GL_RG_EXT
).IsValid(GL_SHORT
));
1482 TEST_F(FeatureInfoTest
, InitializeARB_texture_rgNoFloat
) {
1483 SetupInitExpectations("GL_ARB_texture_rg");
1484 EXPECT_TRUE(info_
->feature_flags().ext_texture_rg
);
1486 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(GL_RED_EXT
));
1487 EXPECT_TRUE(info_
->validators()->texture_format
.IsValid(GL_RG_EXT
));
1488 EXPECT_TRUE(info_
->validators()->texture_internal_format
.IsValid(GL_RED_EXT
));
1489 EXPECT_TRUE(info_
->validators()->texture_internal_format
.IsValid(GL_RG_EXT
));
1490 EXPECT_TRUE(info_
->validators()->read_pixel_format
.IsValid(GL_RED_EXT
));
1491 EXPECT_TRUE(info_
->validators()->read_pixel_format
.IsValid(GL_RG_EXT
));
1492 EXPECT_TRUE(info_
->validators()->render_buffer_format
.IsValid(GL_R8_EXT
));
1493 EXPECT_TRUE(info_
->validators()->render_buffer_format
.IsValid(GL_RG8_EXT
));
1496 info_
->GetTextureFormatValidator(GL_RED_EXT
).IsValid(GL_HALF_FLOAT_OES
));
1498 info_
->GetTextureFormatValidator(GL_RG_EXT
).IsValid(GL_HALF_FLOAT_OES
));
1500 info_
->GetTextureFormatValidator(GL_RED_EXT
).IsValid(GL_UNSIGNED_BYTE
));
1502 info_
->GetTextureFormatValidator(GL_RG_EXT
).IsValid(GL_UNSIGNED_BYTE
));
1505 } // namespace gles2