Don't add an aura tooltip to bubble close buttons on Windows.
[chromium-blink-merge.git] / gpu / command_buffer / service / feature_info_unittest.cc
blobf4b2dacd0ec9a71d25621d4e3c120c97588f3c68
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"
20 using ::testing::_;
21 using ::testing::DoAll;
22 using ::testing::HasSubstr;
23 using ::testing::InSequence;
24 using ::testing::MatcherCast;
25 using ::testing::Not;
26 using ::testing::Pointee;
27 using ::testing::Return;
28 using ::testing::SetArrayArgument;
29 using ::testing::SetArgumentPointee;
30 using ::testing::StrEq;
32 namespace gpu {
33 namespace gles2 {
35 namespace {
36 const char kGLRendererStringANGLE[] = "ANGLE (some renderer)";
37 } // anonymous namespace
39 class FeatureInfoTest : public GpuServiceTest {
40 public:
41 FeatureInfoTest() {
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();
60 info_->Initialize();
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);
75 info_->Initialize();
78 void SetupWithoutInit() {
79 GpuServiceTest::SetUp();
80 info_ = new FeatureInfo();
83 protected:
84 void SetUp() override {
85 // Do nothing here, since we are using the explicit Setup*() functions.
88 void TearDown() override {
89 info_ = NULL;
90 GpuServiceTest::TearDown();
93 scoped_refptr<FeatureInfo> info_;
96 namespace {
98 struct FormatInfo {
99 GLenum format;
100 const GLenum* types;
101 size_t count;
104 } // anonymous namespace.
106 TEST_F(FeatureInfoTest, Basic) {
107 SetupWithoutInit();
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)
140 #undef 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);
145 // Test good types.
147 static const GLenum kAlphaTypes[] = {
148 GL_UNSIGNED_BYTE,
150 static const GLenum kRGBTypes[] = {
151 GL_UNSIGNED_BYTE,
152 GL_UNSIGNED_SHORT_5_6_5,
154 static const GLenum kRGBATypes[] = {
155 GL_UNSIGNED_BYTE,
156 GL_UNSIGNED_SHORT_4_4_4_4,
157 GL_UNSIGNED_SHORT_5_5_5_1,
159 static const GLenum kLuminanceTypes[] = {
160 GL_UNSIGNED_BYTE,
162 static const GLenum kLuminanceAlphaTypes[] = {
163 GL_UNSIGNED_BYTE,
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,
187 GL_FLOAT,
189 static const GLenum kRGBTypes[] = {
190 GL_UNSIGNED_SHORT_4_4_4_4,
191 GL_FLOAT,
193 static const GLenum kRGBATypes[] = {
194 GL_UNSIGNED_SHORT_5_6_5,
195 GL_FLOAT,
197 static const GLenum kLuminanceTypes[] = {
198 GL_UNSIGNED_SHORT_4_4_4_4,
199 GL_FLOAT,
201 static const GLenum kLuminanceAlphaTypes[] = {
202 GL_UNSIGNED_SHORT_5_5_5_1,
203 GL_FLOAT,
205 static const GLenum kBGRATypes[] = {
206 GL_UNSIGNED_BYTE,
207 GL_UNSIGNED_SHORT_5_6_5,
208 GL_FLOAT,
210 static const GLenum kDepthTypes[] = {
211 GL_UNSIGNED_BYTE,
212 GL_UNSIGNED_SHORT,
213 GL_UNSIGNED_INT,
214 GL_FLOAT,
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(
276 GL_ETC1_RGB8_OES));
277 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
278 GL_ATC_RGB_AMD));
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(
292 GL_BGRA_EXT));
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(
313 GL_DEPTH_STENCIL));
314 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
315 GL_RGBA32F));
316 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
317 GL_RGB32F));
318 EXPECT_FALSE(info_->validators()->texture_format.IsValid(
319 GL_DEPTH_STENCIL));
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(
336 GL_UNSIGNED_BYTE));
337 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_SRGB_ALPHA_EXT).IsValid(
338 GL_UNSIGNED_BYTE));
339 EXPECT_FALSE(info_->validators()->texture_format.IsValid(
340 GL_SRGB_EXT));
341 EXPECT_FALSE(info_->validators()->texture_format.IsValid(
342 GL_SRGB_ALPHA_EXT));
343 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
344 GL_SRGB_EXT));
345 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
346 GL_SRGB_ALPHA_EXT));
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(
407 GL_BGRA_EXT));
408 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
409 GL_BGRA_EXT));
410 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_BGRA_EXT).IsValid(
411 GL_UNSIGNED_BYTE));
412 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
413 GL_BGRA8_EXT));
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(
425 GL_BGRA_EXT));
426 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
427 GL_BGRA_EXT));
428 EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(
429 GL_BGRA_EXT));
430 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_BGRA_EXT).IsValid(
431 GL_UNSIGNED_BYTE));
432 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
433 GL_BGRA8_EXT));
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(
441 GL_BGRA_EXT));
442 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
443 GL_BGRA_EXT));
444 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_BGRA_EXT).IsValid(
445 GL_UNSIGNED_BYTE));
446 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
447 GL_BGRA8_EXT));
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(
455 GL_BGRA_EXT));
456 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
457 GL_BGRA_EXT));
458 EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(
459 GL_BGRA_EXT));
460 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
461 GL_BGRA8_EXT));
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(
469 GL_UNSIGNED_BYTE));
470 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_SRGB_ALPHA_EXT).IsValid(
471 GL_UNSIGNED_BYTE));
472 EXPECT_TRUE(info_->validators()->texture_format.IsValid(
473 GL_SRGB_EXT));
474 EXPECT_TRUE(info_->validators()->texture_format.IsValid(
475 GL_SRGB_ALPHA_EXT));
476 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
477 GL_SRGB_EXT));
478 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
479 GL_SRGB_ALPHA_EXT));
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(
493 GL_BGRA8_EXT));
494 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
495 GL_RGBA32F_EXT));
496 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
497 GL_RGB32F_EXT));
498 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
499 GL_ALPHA32F_EXT));
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(
505 GL_RGBA16F_EXT));
506 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
507 GL_RGB16F_EXT));
508 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
509 GL_ALPHA16F_EXT));
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(
529 GL_BGRA8_EXT));
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(
538 GL_BGRA8_EXT));
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(
549 GL_BGRA8_EXT));
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(
558 GL_RGBA32F_EXT));
559 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
560 GL_RGB32F_EXT));
561 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
562 GL_ALPHA32F_EXT));
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(
574 GL_RGBA16F_EXT));
575 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
576 GL_RGB16F_EXT));
577 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
578 GL_ALPHA16F_EXT));
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",
604 "OpenGL ES 2.0");
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) ->
618 // nothing
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
628 // requirement)
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",
653 "OpenGL ES 3.0");
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(
693 GL_RGBA32F));
694 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
695 GL_RGB32F));
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(
707 GL_FLOAT));
708 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
709 GL_FLOAT));
710 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
711 GL_FLOAT));
712 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
713 GL_FLOAT));
714 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
715 GL_FLOAT));
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(
722 GL_UNSIGNED_BYTE));
723 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_SRGB_ALPHA_EXT).IsValid(
724 GL_UNSIGNED_BYTE));
725 EXPECT_FALSE(info_->validators()->texture_format.IsValid(
726 GL_SRGB_EXT));
727 EXPECT_FALSE(info_->validators()->texture_format.IsValid(
728 GL_SRGB_ALPHA_EXT));
729 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
730 GL_SRGB_EXT));
731 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
732 GL_SRGB_ALPHA_EXT));
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(
752 GL_FLOAT));
753 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
754 GL_FLOAT));
755 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
756 GL_FLOAT));
757 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
758 GL_FLOAT));
759 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
760 GL_FLOAT));
761 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
762 GL_HALF_FLOAT_OES));
763 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
764 GL_HALF_FLOAT_OES));
765 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
766 GL_HALF_FLOAT_OES));
767 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
768 GL_HALF_FLOAT_OES));
769 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
770 GL_HALF_FLOAT_OES));
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(
785 GL_FLOAT));
786 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
787 GL_FLOAT));
788 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
789 GL_FLOAT));
790 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
791 GL_FLOAT));
792 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
793 GL_FLOAT));
794 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
795 GL_HALF_FLOAT_OES));
796 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
797 GL_HALF_FLOAT_OES));
798 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
799 GL_HALF_FLOAT_OES));
800 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
801 GL_HALF_FLOAT_OES));
802 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
803 GL_HALF_FLOAT_OES));
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(
819 GL_FLOAT));
820 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
821 GL_FLOAT));
822 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
823 GL_FLOAT));
824 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
825 GL_FLOAT));
826 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
827 GL_FLOAT));
828 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
829 GL_HALF_FLOAT_OES));
830 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
831 GL_HALF_FLOAT_OES));
832 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
833 GL_HALF_FLOAT_OES));
834 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
835 GL_HALF_FLOAT_OES));
836 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
837 GL_HALF_FLOAT_OES));
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(
854 GL_FLOAT));
855 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
856 GL_FLOAT));
857 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
858 GL_FLOAT));
859 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
860 GL_FLOAT));
861 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
862 GL_FLOAT));
863 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
864 GL_HALF_FLOAT_OES));
865 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
866 GL_HALF_FLOAT_OES));
867 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
868 GL_HALF_FLOAT_OES));
869 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
870 GL_HALF_FLOAT_OES));
871 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
872 GL_HALF_FLOAT_OES));
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(
985 GL_UNSIGNED_SHORT));
986 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
987 GL_UNSIGNED_INT));
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(
1007 GL_UNSIGNED_INT));
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(
1036 GL_UNSIGNED_INT));
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(
1075 GL_DEPTH_STENCIL));
1076 EXPECT_TRUE(info_->validators()->texture_format.IsValid(
1077 GL_DEPTH_STENCIL));
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(
1083 GL_UNSIGNED_INT));
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(
1111 GL_RGB8_OES));
1112 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
1113 GL_RGBA8_OES));
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(
1136 GL_ETC1_RGB8_OES));
1137 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
1138 GL_ETC1_RGB8_OES));
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(
1146 GL_ATC_RGB_AMD));
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",
1244 command_line);
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"));
1291 EXPECT_TRUE(
1292 info_->validators()->texture_internal_format.IsValid(GL_DEPTH_COMPONENT));
1293 EXPECT_TRUE(
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"));
1308 EXPECT_TRUE(
1309 info_->validators()->render_buffer_format.IsValid(GL_DEPTH_COMPONENT24));
1310 EXPECT_TRUE(
1311 info_->validators()->render_buffer_format.IsValid(GL_DEPTH24_STENCIL8));
1312 EXPECT_TRUE(
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",
1392 "", "4.3");
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));
1467 EXPECT_TRUE(
1468 info_->GetTextureFormatValidator(GL_RED_EXT).IsValid(GL_HALF_FLOAT_OES));
1469 EXPECT_TRUE(
1470 info_->GetTextureFormatValidator(GL_RG_EXT).IsValid(GL_HALF_FLOAT_OES));
1471 EXPECT_TRUE(
1472 info_->GetTextureFormatValidator(GL_RED_EXT).IsValid(GL_UNSIGNED_BYTE));
1473 EXPECT_TRUE(
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));
1495 EXPECT_FALSE(
1496 info_->GetTextureFormatValidator(GL_RED_EXT).IsValid(GL_HALF_FLOAT_OES));
1497 EXPECT_FALSE(
1498 info_->GetTextureFormatValidator(GL_RG_EXT).IsValid(GL_HALF_FLOAT_OES));
1499 EXPECT_TRUE(
1500 info_->GetTextureFormatValidator(GL_RED_EXT).IsValid(GL_UNSIGNED_BYTE));
1501 EXPECT_TRUE(
1502 info_->GetTextureFormatValidator(GL_RG_EXT).IsValid(GL_UNSIGNED_BYTE));
1505 } // namespace gles2
1506 } // namespace gpu