Performance histograms for extension content verification
[chromium-blink-merge.git] / gpu / command_buffer / service / feature_info_unittest.cc
blob3b32f7a5bae6f7061a34080b5b78604ebcb57564
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 SetupInitExpectationsWithGLVersion(extensions, "", "");
48 void SetupInitExpectationsWithGLVersion(
49 const char* extensions, const char* renderer, const char* version) {
50 GpuServiceTest::SetUpWithGLVersion(version, extensions);
51 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
52 gl_.get(), extensions, renderer, version);
53 info_ = new FeatureInfo();
54 info_->Initialize();
57 void SetupWithCommandLine(const CommandLine& command_line) {
58 GpuServiceTest::SetUp();
59 info_ = new FeatureInfo(command_line);
62 void SetupInitExpectationsWithCommandLine(
63 const char* extensions, const CommandLine& command_line) {
64 GpuServiceTest::SetUpWithGLVersion("2.0", extensions);
65 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
66 gl_.get(), extensions, "", "");
67 info_ = new FeatureInfo(command_line);
68 info_->Initialize();
71 void SetupWithoutInit() {
72 GpuServiceTest::SetUp();
73 info_ = new FeatureInfo();
76 protected:
77 virtual void SetUp() OVERRIDE {
78 // Do nothing here, since we are using the explicit Setup*() functions.
81 virtual void TearDown() OVERRIDE {
82 info_ = NULL;
83 GpuServiceTest::TearDown();
86 scoped_refptr<FeatureInfo> info_;
89 namespace {
91 struct FormatInfo {
92 GLenum format;
93 const GLenum* types;
94 size_t count;
97 } // anonymous namespace.
99 TEST_F(FeatureInfoTest, Basic) {
100 SetupWithoutInit();
101 // Test it starts off uninitialized.
102 EXPECT_FALSE(info_->feature_flags().chromium_framebuffer_multisample);
103 EXPECT_FALSE(info_->feature_flags().use_core_framebuffer_multisample);
104 EXPECT_FALSE(info_->feature_flags().multisampled_render_to_texture);
105 EXPECT_FALSE(info_->feature_flags(
106 ).use_img_for_multisampled_render_to_texture);
107 EXPECT_FALSE(info_->feature_flags().oes_standard_derivatives);
108 EXPECT_FALSE(info_->feature_flags().npot_ok);
109 EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
110 EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
111 EXPECT_FALSE(info_->feature_flags().oes_egl_image_external);
112 EXPECT_FALSE(info_->feature_flags().oes_depth24);
113 EXPECT_FALSE(info_->feature_flags().packed_depth24_stencil8);
114 EXPECT_FALSE(info_->feature_flags().angle_translated_shader_source);
115 EXPECT_FALSE(info_->feature_flags().angle_pack_reverse_row_order);
116 EXPECT_FALSE(info_->feature_flags().arb_texture_rectangle);
117 EXPECT_FALSE(info_->feature_flags().angle_instanced_arrays);
118 EXPECT_FALSE(info_->feature_flags().occlusion_query_boolean);
119 EXPECT_FALSE(info_->feature_flags(
120 ).use_arb_occlusion_query2_for_occlusion_query_boolean);
121 EXPECT_FALSE(info_->feature_flags(
122 ).use_arb_occlusion_query_for_occlusion_query_boolean);
123 EXPECT_FALSE(info_->feature_flags().native_vertex_array_object);
124 EXPECT_FALSE(info_->feature_flags().map_buffer_range);
125 EXPECT_FALSE(info_->feature_flags().use_async_readpixels);
126 EXPECT_FALSE(info_->feature_flags().ext_discard_framebuffer);
127 EXPECT_FALSE(info_->feature_flags().angle_depth_texture);
128 EXPECT_FALSE(info_->feature_flags().is_angle);
130 #define GPU_OP(type, name) EXPECT_FALSE(info_->workarounds().name);
131 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
132 #undef GPU_OP
133 EXPECT_EQ(0, info_->workarounds().max_texture_size);
134 EXPECT_EQ(0, info_->workarounds().max_cube_map_texture_size);
136 // Test good types.
138 static const GLenum kAlphaTypes[] = {
139 GL_UNSIGNED_BYTE,
141 static const GLenum kRGBTypes[] = {
142 GL_UNSIGNED_BYTE,
143 GL_UNSIGNED_SHORT_5_6_5,
145 static const GLenum kRGBATypes[] = {
146 GL_UNSIGNED_BYTE,
147 GL_UNSIGNED_SHORT_4_4_4_4,
148 GL_UNSIGNED_SHORT_5_5_5_1,
150 static const GLenum kLuminanceTypes[] = {
151 GL_UNSIGNED_BYTE,
153 static const GLenum kLuminanceAlphaTypes[] = {
154 GL_UNSIGNED_BYTE,
156 static const FormatInfo kFormatTypes[] = {
157 { GL_ALPHA, kAlphaTypes, arraysize(kAlphaTypes), },
158 { GL_RGB, kRGBTypes, arraysize(kRGBTypes), },
159 { GL_RGBA, kRGBATypes, arraysize(kRGBATypes), },
160 { GL_LUMINANCE, kLuminanceTypes, arraysize(kLuminanceTypes), },
161 { GL_LUMINANCE_ALPHA, kLuminanceAlphaTypes,
162 arraysize(kLuminanceAlphaTypes), } ,
164 for (size_t ii = 0; ii < arraysize(kFormatTypes); ++ii) {
165 const FormatInfo& info = kFormatTypes[ii];
166 const ValueValidator<GLenum>& validator =
167 info_->GetTextureFormatValidator(info.format);
168 for (size_t jj = 0; jj < info.count; ++jj) {
169 EXPECT_TRUE(validator.IsValid(info.types[jj]));
174 // Test some bad types
176 static const GLenum kAlphaTypes[] = {
177 GL_UNSIGNED_SHORT_5_5_5_1,
178 GL_FLOAT,
180 static const GLenum kRGBTypes[] = {
181 GL_UNSIGNED_SHORT_4_4_4_4,
182 GL_FLOAT,
184 static const GLenum kRGBATypes[] = {
185 GL_UNSIGNED_SHORT_5_6_5,
186 GL_FLOAT,
188 static const GLenum kLuminanceTypes[] = {
189 GL_UNSIGNED_SHORT_4_4_4_4,
190 GL_FLOAT,
192 static const GLenum kLuminanceAlphaTypes[] = {
193 GL_UNSIGNED_SHORT_5_5_5_1,
194 GL_FLOAT,
196 static const GLenum kBGRATypes[] = {
197 GL_UNSIGNED_BYTE,
198 GL_UNSIGNED_SHORT_5_6_5,
199 GL_FLOAT,
201 static const GLenum kDepthTypes[] = {
202 GL_UNSIGNED_BYTE,
203 GL_UNSIGNED_SHORT,
204 GL_UNSIGNED_INT,
205 GL_FLOAT,
207 static const FormatInfo kFormatTypes[] = {
208 { GL_ALPHA, kAlphaTypes, arraysize(kAlphaTypes), },
209 { GL_RGB, kRGBTypes, arraysize(kRGBTypes), },
210 { GL_RGBA, kRGBATypes, arraysize(kRGBATypes), },
211 { GL_LUMINANCE, kLuminanceTypes, arraysize(kLuminanceTypes), },
212 { GL_LUMINANCE_ALPHA, kLuminanceAlphaTypes,
213 arraysize(kLuminanceAlphaTypes), } ,
214 { GL_BGRA_EXT, kBGRATypes, arraysize(kBGRATypes), },
215 { GL_DEPTH_COMPONENT, kDepthTypes, arraysize(kDepthTypes), },
217 for (size_t ii = 0; ii < arraysize(kFormatTypes); ++ii) {
218 const FormatInfo& info = kFormatTypes[ii];
219 const ValueValidator<GLenum>& validator =
220 info_->GetTextureFormatValidator(info.format);
221 for (size_t jj = 0; jj < info.count; ++jj) {
222 EXPECT_FALSE(validator.IsValid(info.types[jj]));
228 TEST_F(FeatureInfoTest, InitializeNoExtensions) {
229 SetupInitExpectations("");
230 // Check default extensions are there
231 EXPECT_THAT(info_->extensions(), HasSubstr("GL_CHROMIUM_resource_safe"));
232 EXPECT_THAT(info_->extensions(), HasSubstr("GL_CHROMIUM_strict_attribs"));
233 EXPECT_THAT(info_->extensions(),
234 HasSubstr("GL_ANGLE_translated_shader_source"));
236 // Check a couple of random extensions that should not be there.
237 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_npot")));
238 EXPECT_THAT(info_->extensions(),
239 Not(HasSubstr("GL_EXT_texture_compression_dxt1")));
240 EXPECT_THAT(info_->extensions(),
241 Not(HasSubstr("GL_CHROMIUM_texture_compression_dxt3")));
242 EXPECT_THAT(info_->extensions(),
243 Not(HasSubstr("GL_CHROMIUM_texture_compression_dxt5")));
244 EXPECT_THAT(info_->extensions(),
245 Not(HasSubstr("GL_ANGLE_texture_usage")));
246 EXPECT_THAT(info_->extensions(),
247 Not(HasSubstr("GL_EXT_texture_storage")));
248 EXPECT_THAT(info_->extensions(),
249 Not(HasSubstr("GL_OES_compressed_ETC1_RGB8_texture")));
250 EXPECT_THAT(info_->extensions(),
251 Not(HasSubstr("GL_AMD_compressed_ATC_texture")));
252 EXPECT_THAT(info_->extensions(),
253 Not(HasSubstr("GL_IMG_texture_compression_pvrtc")));
254 EXPECT_FALSE(info_->feature_flags().npot_ok);
255 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
256 GL_COMPRESSED_RGB_S3TC_DXT1_EXT));
257 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
258 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
259 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
260 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
261 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
262 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
263 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
264 GL_ETC1_RGB8_OES));
265 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
266 GL_ATC_RGB_AMD));
267 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
268 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD));
269 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
270 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD));
271 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
272 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG));
273 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
274 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG));
275 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
276 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG));
277 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
278 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG));
279 EXPECT_FALSE(info_->validators()->read_pixel_format.IsValid(
280 GL_BGRA_EXT));
281 EXPECT_FALSE(info_->validators()->texture_parameter.IsValid(
282 GL_TEXTURE_MAX_ANISOTROPY_EXT));
283 EXPECT_FALSE(info_->validators()->g_l_state.IsValid(
284 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
285 EXPECT_FALSE(info_->validators()->frame_buffer_target.IsValid(
286 GL_READ_FRAMEBUFFER_EXT));
287 EXPECT_FALSE(info_->validators()->frame_buffer_target.IsValid(
288 GL_DRAW_FRAMEBUFFER_EXT));
289 EXPECT_FALSE(info_->validators()->g_l_state.IsValid(
290 GL_READ_FRAMEBUFFER_BINDING_EXT));
291 EXPECT_FALSE(info_->validators()->render_buffer_parameter.IsValid(
292 GL_MAX_SAMPLES_EXT));
293 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
294 GL_DEPTH_COMPONENT));
295 EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
296 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
297 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
298 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
299 GL_DEPTH24_STENCIL8));
300 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
301 GL_DEPTH_STENCIL));
302 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
303 GL_RGBA32F));
304 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
305 GL_RGB32F));
306 EXPECT_FALSE(info_->validators()->texture_format.IsValid(
307 GL_DEPTH_STENCIL));
308 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(
309 GL_UNSIGNED_INT_24_8));
310 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
311 GL_DEPTH_COMPONENT24));
312 EXPECT_FALSE(info_->validators()->texture_parameter.IsValid(
313 GL_TEXTURE_USAGE_ANGLE));
314 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
315 GL_DEPTH_COMPONENT16));
316 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
317 GL_DEPTH_COMPONENT32_OES));
318 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
319 GL_DEPTH24_STENCIL8_OES));
320 EXPECT_FALSE(info_->validators()->equation.IsValid(GL_MIN_EXT));
321 EXPECT_FALSE(info_->validators()->equation.IsValid(GL_MAX_EXT));
322 EXPECT_FALSE(info_->feature_flags().chromium_sync_query);
325 TEST_F(FeatureInfoTest, InitializeWithANGLE) {
326 SetupInitExpectationsWithGLVersion("", kGLRendererStringANGLE, "");
327 EXPECT_TRUE(info_->feature_flags().is_angle);
330 TEST_F(FeatureInfoTest, InitializeNPOTExtensionGLES) {
331 SetupInitExpectations("GL_OES_texture_npot");
332 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_npot"));
333 EXPECT_TRUE(info_->feature_flags().npot_ok);
336 TEST_F(FeatureInfoTest, InitializeNPOTExtensionGL) {
337 SetupInitExpectations("GL_ARB_texture_non_power_of_two");
338 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_npot"));
339 EXPECT_TRUE(info_->feature_flags().npot_ok);
342 TEST_F(FeatureInfoTest, InitializeDXTExtensionGLES2) {
343 SetupInitExpectations("GL_EXT_texture_compression_dxt1");
344 EXPECT_THAT(info_->extensions(),
345 HasSubstr("GL_EXT_texture_compression_dxt1"));
346 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
347 GL_COMPRESSED_RGB_S3TC_DXT1_EXT));
348 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
349 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
350 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
351 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
352 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
353 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
356 TEST_F(FeatureInfoTest, InitializeDXTExtensionGL) {
357 SetupInitExpectations("GL_EXT_texture_compression_s3tc");
358 EXPECT_THAT(info_->extensions(),
359 HasSubstr("GL_EXT_texture_compression_dxt1"));
360 EXPECT_THAT(info_->extensions(),
361 HasSubstr("GL_CHROMIUM_texture_compression_dxt3"));
362 EXPECT_THAT(info_->extensions(),
363 HasSubstr("GL_CHROMIUM_texture_compression_dxt5"));
364 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
365 GL_COMPRESSED_RGB_S3TC_DXT1_EXT));
366 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
367 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
368 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
369 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
370 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
371 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
374 TEST_F(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888GLES2) {
375 SetupInitExpectations("GL_EXT_texture_format_BGRA8888");
376 EXPECT_THAT(info_->extensions(),
377 HasSubstr("GL_EXT_texture_format_BGRA8888"));
378 EXPECT_TRUE(info_->validators()->texture_format.IsValid(
379 GL_BGRA_EXT));
380 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
381 GL_BGRA_EXT));
382 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_BGRA_EXT).IsValid(
383 GL_UNSIGNED_BYTE));
384 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
385 GL_BGRA8_EXT));
388 TEST_F(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888GL) {
389 SetupInitExpectations("GL_EXT_bgra");
390 EXPECT_THAT(info_->extensions(),
391 HasSubstr("GL_EXT_texture_format_BGRA8888"));
392 EXPECT_THAT(info_->extensions(),
393 HasSubstr("GL_EXT_read_format_bgra"));
394 EXPECT_THAT(info_->extensions(),
395 HasSubstr("GL_CHROMIUM_renderbuffer_format_BGRA8888"));
396 EXPECT_TRUE(info_->validators()->texture_format.IsValid(
397 GL_BGRA_EXT));
398 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
399 GL_BGRA_EXT));
400 EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(
401 GL_BGRA_EXT));
402 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_BGRA_EXT).IsValid(
403 GL_UNSIGNED_BYTE));
404 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
405 GL_BGRA8_EXT));
408 TEST_F(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888Apple) {
409 SetupInitExpectations("GL_APPLE_texture_format_BGRA8888");
410 EXPECT_THAT(info_->extensions(),
411 HasSubstr("GL_EXT_texture_format_BGRA8888"));
412 EXPECT_TRUE(info_->validators()->texture_format.IsValid(
413 GL_BGRA_EXT));
414 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
415 GL_BGRA_EXT));
416 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_BGRA_EXT).IsValid(
417 GL_UNSIGNED_BYTE));
418 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
419 GL_BGRA8_EXT));
422 TEST_F(FeatureInfoTest, InitializeEXT_read_format_bgra) {
423 SetupInitExpectations("GL_EXT_read_format_bgra");
424 EXPECT_THAT(info_->extensions(),
425 HasSubstr("GL_EXT_read_format_bgra"));
426 EXPECT_FALSE(info_->validators()->texture_format.IsValid(
427 GL_BGRA_EXT));
428 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
429 GL_BGRA_EXT));
430 EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(
431 GL_BGRA_EXT));
432 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
433 GL_BGRA8_EXT));
436 TEST_F(FeatureInfoTest, InitializeARB_texture_float) {
437 SetupInitExpectations("GL_ARB_texture_float");
438 EXPECT_TRUE(info_->feature_flags().chromium_color_buffer_float_rgba);
439 EXPECT_TRUE(info_->feature_flags().chromium_color_buffer_float_rgb);
440 std::string extensions = info_->extensions() + " ";
441 EXPECT_THAT(extensions, HasSubstr("GL_CHROMIUM_color_buffer_float_rgb "));
442 EXPECT_THAT(extensions, HasSubstr("GL_CHROMIUM_color_buffer_float_rgba"));
443 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
444 GL_RGBA32F));
445 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
446 GL_RGB32F));
449 TEST_F(FeatureInfoTest, InitializeOES_texture_floatGLES2) {
450 SetupInitExpectations("GL_OES_texture_float");
451 EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
452 EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
453 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_float"));
454 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_half_float")));
455 EXPECT_THAT(info_->extensions(),
456 Not(HasSubstr("GL_OES_texture_float_linear")));
457 EXPECT_THAT(info_->extensions(),
458 Not(HasSubstr("GL_OES_texture_half_float_linear")));
459 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
460 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
461 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
462 GL_FLOAT));
463 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
464 GL_FLOAT));
465 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
466 GL_FLOAT));
467 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
468 GL_FLOAT));
469 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
470 GL_FLOAT));
471 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
472 GL_HALF_FLOAT_OES));
473 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
474 GL_HALF_FLOAT_OES));
475 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
476 GL_HALF_FLOAT_OES));
477 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
478 GL_HALF_FLOAT_OES));
479 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
480 GL_HALF_FLOAT_OES));
483 TEST_F(FeatureInfoTest, InitializeOES_texture_float_linearGLES2) {
484 SetupInitExpectations("GL_OES_texture_float GL_OES_texture_float_linear");
485 EXPECT_TRUE(info_->feature_flags().enable_texture_float_linear);
486 EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
487 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_float"));
488 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_half_float")));
489 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_float_linear"));
490 EXPECT_THAT(info_->extensions(),
491 Not(HasSubstr("GL_OES_texture_half_float_linear")));
492 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
493 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
494 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
495 GL_FLOAT));
496 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
497 GL_FLOAT));
498 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
499 GL_FLOAT));
500 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
501 GL_FLOAT));
502 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
503 GL_FLOAT));
504 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
505 GL_HALF_FLOAT_OES));
506 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
507 GL_HALF_FLOAT_OES));
508 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
509 GL_HALF_FLOAT_OES));
510 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
511 GL_HALF_FLOAT_OES));
512 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
513 GL_HALF_FLOAT_OES));
516 TEST_F(FeatureInfoTest, InitializeOES_texture_half_floatGLES2) {
517 SetupInitExpectations("GL_OES_texture_half_float");
518 EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
519 EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
520 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_float")));
521 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_half_float"));
522 EXPECT_THAT(info_->extensions(),
523 Not(HasSubstr("GL_OES_texture_float_linear")));
524 EXPECT_THAT(info_->extensions(),
525 Not(HasSubstr("GL_OES_texture_half_float_linear")));
526 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
527 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
528 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
529 GL_FLOAT));
530 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
531 GL_FLOAT));
532 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
533 GL_FLOAT));
534 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
535 GL_FLOAT));
536 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
537 GL_FLOAT));
538 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
539 GL_HALF_FLOAT_OES));
540 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
541 GL_HALF_FLOAT_OES));
542 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
543 GL_HALF_FLOAT_OES));
544 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
545 GL_HALF_FLOAT_OES));
546 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
547 GL_HALF_FLOAT_OES));
550 TEST_F(FeatureInfoTest, InitializeOES_texture_half_float_linearGLES2) {
551 SetupInitExpectations(
552 "GL_OES_texture_half_float GL_OES_texture_half_float_linear");
553 EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
554 EXPECT_TRUE(info_->feature_flags().enable_texture_half_float_linear);
555 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_float")));
556 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_half_float"));
557 EXPECT_THAT(info_->extensions(),
558 Not(HasSubstr("GL_OES_texture_float_linear")));
559 EXPECT_THAT(info_->extensions(),
560 HasSubstr("GL_OES_texture_half_float_linear"));
561 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
562 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
563 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
564 GL_FLOAT));
565 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
566 GL_FLOAT));
567 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
568 GL_FLOAT));
569 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
570 GL_FLOAT));
571 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
572 GL_FLOAT));
573 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
574 GL_HALF_FLOAT_OES));
575 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
576 GL_HALF_FLOAT_OES));
577 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
578 GL_HALF_FLOAT_OES));
579 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
580 GL_HALF_FLOAT_OES));
581 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
582 GL_HALF_FLOAT_OES));
585 TEST_F(FeatureInfoTest, InitializeEXT_framebuffer_multisample) {
586 SetupInitExpectations("GL_EXT_framebuffer_multisample");
587 EXPECT_TRUE(info_->feature_flags().chromium_framebuffer_multisample);
588 EXPECT_THAT(info_->extensions(),
589 HasSubstr("GL_CHROMIUM_framebuffer_multisample"));
590 EXPECT_TRUE(info_->validators()->frame_buffer_target.IsValid(
591 GL_READ_FRAMEBUFFER_EXT));
592 EXPECT_TRUE(info_->validators()->frame_buffer_target.IsValid(
593 GL_DRAW_FRAMEBUFFER_EXT));
594 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
595 GL_READ_FRAMEBUFFER_BINDING_EXT));
596 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
597 GL_MAX_SAMPLES_EXT));
598 EXPECT_TRUE(info_->validators()->render_buffer_parameter.IsValid(
599 GL_RENDERBUFFER_SAMPLES_EXT));
602 TEST_F(FeatureInfoTest, InitializeANGLE_framebuffer_multisample) {
603 SetupInitExpectationsWithGLVersion(
604 "GL_ANGLE_framebuffer_multisample", kGLRendererStringANGLE, "");
605 EXPECT_TRUE(info_->feature_flags().chromium_framebuffer_multisample);
606 EXPECT_THAT(info_->extensions(),
607 HasSubstr("GL_CHROMIUM_framebuffer_multisample"));
608 EXPECT_TRUE(info_->validators()->frame_buffer_target.IsValid(
609 GL_READ_FRAMEBUFFER_EXT));
610 EXPECT_TRUE(info_->validators()->frame_buffer_target.IsValid(
611 GL_DRAW_FRAMEBUFFER_EXT));
612 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
613 GL_READ_FRAMEBUFFER_BINDING_EXT));
614 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
615 GL_MAX_SAMPLES_EXT));
616 EXPECT_TRUE(info_->validators()->render_buffer_parameter.IsValid(
617 GL_RENDERBUFFER_SAMPLES_EXT));
620 // We don't allow ANGLE_framebuffer_multisample on non-ANGLE implementations,
621 // because we wouldn't be choosing the right driver entry point and because the
622 // extension was falsely advertised on some Android devices (crbug.com/165736).
623 TEST_F(FeatureInfoTest, InitializeANGLE_framebuffer_multisampleWithoutANGLE) {
624 SetupInitExpectations("GL_ANGLE_framebuffer_multisample");
625 EXPECT_FALSE(info_->feature_flags().chromium_framebuffer_multisample);
626 EXPECT_THAT(info_->extensions(),
627 Not(HasSubstr("GL_CHROMIUM_framebuffer_multisample")));
628 EXPECT_FALSE(info_->validators()->frame_buffer_target.IsValid(
629 GL_READ_FRAMEBUFFER_EXT));
630 EXPECT_FALSE(info_->validators()->frame_buffer_target.IsValid(
631 GL_DRAW_FRAMEBUFFER_EXT));
632 EXPECT_FALSE(info_->validators()->g_l_state.IsValid(
633 GL_READ_FRAMEBUFFER_BINDING_EXT));
634 EXPECT_FALSE(info_->validators()->g_l_state.IsValid(
635 GL_MAX_SAMPLES_EXT));
636 EXPECT_FALSE(info_->validators()->render_buffer_parameter.IsValid(
637 GL_RENDERBUFFER_SAMPLES_EXT));
640 TEST_F(FeatureInfoTest, InitializeEXT_multisampled_render_to_texture) {
641 SetupInitExpectations("GL_EXT_multisampled_render_to_texture");
642 EXPECT_TRUE(info_->feature_flags(
643 ).multisampled_render_to_texture);
644 EXPECT_FALSE(info_->feature_flags(
645 ).use_img_for_multisampled_render_to_texture);
646 EXPECT_THAT(info_->extensions(),
647 HasSubstr("GL_EXT_multisampled_render_to_texture"));
648 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
649 GL_MAX_SAMPLES_EXT));
650 EXPECT_TRUE(info_->validators()->render_buffer_parameter.IsValid(
651 GL_RENDERBUFFER_SAMPLES_EXT));
652 EXPECT_TRUE(info_->validators()->frame_buffer_parameter.IsValid(
653 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT));
656 TEST_F(FeatureInfoTest, InitializeIMG_multisampled_render_to_texture) {
657 SetupInitExpectations("GL_IMG_multisampled_render_to_texture");
658 EXPECT_TRUE(info_->feature_flags(
659 ).multisampled_render_to_texture);
660 EXPECT_TRUE(info_->feature_flags(
661 ).use_img_for_multisampled_render_to_texture);
662 EXPECT_THAT(info_->extensions(),
663 HasSubstr("GL_EXT_multisampled_render_to_texture"));
664 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
665 GL_MAX_SAMPLES_EXT));
666 EXPECT_TRUE(info_->validators()->render_buffer_parameter.IsValid(
667 GL_RENDERBUFFER_SAMPLES_EXT));
668 EXPECT_TRUE(info_->validators()->frame_buffer_parameter.IsValid(
669 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT));
672 TEST_F(FeatureInfoTest, InitializeEXT_texture_filter_anisotropic) {
673 SetupInitExpectations("GL_EXT_texture_filter_anisotropic");
674 EXPECT_THAT(info_->extensions(),
675 HasSubstr("GL_EXT_texture_filter_anisotropic"));
676 EXPECT_TRUE(info_->validators()->texture_parameter.IsValid(
677 GL_TEXTURE_MAX_ANISOTROPY_EXT));
678 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
679 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
682 TEST_F(FeatureInfoTest, InitializeEXT_ARB_depth_texture) {
683 SetupInitExpectations("GL_ARB_depth_texture");
684 EXPECT_THAT(info_->extensions(),
685 HasSubstr("GL_GOOGLE_depth_texture"));
686 EXPECT_THAT(info_->extensions(),
687 HasSubstr("GL_CHROMIUM_depth_texture"));
688 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
689 GL_DEPTH_COMPONENT));
690 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
691 EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_STENCIL));
692 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
693 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
694 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
695 GL_UNSIGNED_SHORT));
696 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
697 GL_UNSIGNED_INT));
698 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_DEPTH_STENCIL).IsValid(
699 GL_UNSIGNED_INT_24_8));
702 TEST_F(FeatureInfoTest, InitializeOES_ARB_depth_texture) {
703 SetupInitExpectations("GL_OES_depth_texture");
704 EXPECT_THAT(info_->extensions(),
705 HasSubstr("GL_GOOGLE_depth_texture"));
706 EXPECT_THAT(info_->extensions(),
707 HasSubstr("GL_CHROMIUM_depth_texture"));
708 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
709 GL_DEPTH_COMPONENT));
710 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
711 EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_STENCIL));
712 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
713 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
714 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
715 GL_UNSIGNED_SHORT));
716 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
717 GL_UNSIGNED_INT));
718 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_DEPTH_STENCIL).IsValid(
719 GL_UNSIGNED_INT_24_8));
722 TEST_F(FeatureInfoTest, InitializeANGLE_depth_texture) {
723 SetupInitExpectations("GL_ANGLE_depth_texture");
724 EXPECT_THAT(info_->extensions(),
725 HasSubstr("GL_GOOGLE_depth_texture"));
726 EXPECT_THAT(info_->extensions(),
727 HasSubstr("GL_CHROMIUM_depth_texture"));
728 EXPECT_THAT(info_->extensions(),
729 Not(HasSubstr("GL_ANGLE_depth_texture")));
730 EXPECT_TRUE(info_->feature_flags().angle_depth_texture);
731 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
732 GL_DEPTH_COMPONENT));
733 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
734 EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_STENCIL));
735 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
736 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
737 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
738 GL_DEPTH_COMPONENT16));
739 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
740 GL_DEPTH_COMPONENT32_OES));
741 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
742 GL_DEPTH24_STENCIL8_OES));
743 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
744 GL_UNSIGNED_SHORT));
745 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
746 GL_UNSIGNED_INT));
747 EXPECT_FALSE(info_->GetTextureFormatValidator(GL_DEPTH_STENCIL).IsValid(
748 GL_UNSIGNED_INT_24_8));
751 TEST_F(FeatureInfoTest, InitializeEXT_packed_depth_stencil) {
752 SetupInitExpectations("GL_EXT_packed_depth_stencil");
753 EXPECT_THAT(info_->extensions(),
754 HasSubstr("GL_OES_packed_depth_stencil"));
755 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
756 GL_DEPTH24_STENCIL8));
757 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
758 GL_DEPTH_COMPONENT));
759 EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
760 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
761 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
764 TEST_F(FeatureInfoTest, InitializeOES_packed_depth_stencil) {
765 SetupInitExpectations("GL_OES_packed_depth_stencil");
766 EXPECT_THAT(info_->extensions(),
767 HasSubstr("GL_OES_packed_depth_stencil"));
768 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
769 GL_DEPTH24_STENCIL8));
770 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
771 GL_DEPTH_COMPONENT));
772 EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
773 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
774 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
777 TEST_F(FeatureInfoTest,
778 InitializeOES_packed_depth_stencil_and_GL_ARB_depth_texture) {
779 SetupInitExpectations("GL_OES_packed_depth_stencil GL_ARB_depth_texture");
780 EXPECT_THAT(info_->extensions(),
781 HasSubstr("GL_OES_packed_depth_stencil"));
782 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
783 GL_DEPTH24_STENCIL8));
784 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
785 GL_DEPTH_STENCIL));
786 EXPECT_TRUE(info_->validators()->texture_format.IsValid(
787 GL_DEPTH_STENCIL));
788 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(
789 GL_UNSIGNED_INT_24_8));
790 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
791 GL_UNSIGNED_SHORT));
792 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
793 GL_UNSIGNED_INT));
794 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_STENCIL).IsValid(
795 GL_UNSIGNED_INT_24_8));
798 TEST_F(FeatureInfoTest, InitializeOES_depth24) {
799 SetupInitExpectations("GL_OES_depth24");
800 EXPECT_TRUE(info_->feature_flags().oes_depth24);
801 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_depth24"));
802 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
803 GL_DEPTH_COMPONENT24));
806 TEST_F(FeatureInfoTest, InitializeOES_standard_derivatives) {
807 SetupInitExpectations("GL_OES_standard_derivatives");
808 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_standard_derivatives"));
809 EXPECT_TRUE(info_->feature_flags().oes_standard_derivatives);
810 EXPECT_TRUE(info_->validators()->hint_target.IsValid(
811 GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES));
812 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
813 GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES));
816 TEST_F(FeatureInfoTest, InitializeOES_rgb8_rgba8) {
817 SetupInitExpectations("GL_OES_rgb8_rgba8");
818 EXPECT_THAT(info_->extensions(),
819 HasSubstr("GL_OES_rgb8_rgba8"));
820 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
821 GL_RGB8_OES));
822 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
823 GL_RGBA8_OES));
826 TEST_F(FeatureInfoTest, InitializeOES_EGL_image_external) {
827 SetupInitExpectations("GL_OES_EGL_image_external");
828 EXPECT_THAT(info_->extensions(),
829 HasSubstr("GL_OES_EGL_image_external"));
830 EXPECT_TRUE(info_->feature_flags().oes_egl_image_external);
831 EXPECT_TRUE(info_->validators()->texture_bind_target.IsValid(
832 GL_TEXTURE_EXTERNAL_OES));
833 EXPECT_TRUE(info_->validators()->get_tex_param_target.IsValid(
834 GL_TEXTURE_EXTERNAL_OES));
835 EXPECT_TRUE(info_->validators()->texture_parameter.IsValid(
836 GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES));
837 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
838 GL_TEXTURE_BINDING_EXTERNAL_OES));
841 TEST_F(FeatureInfoTest, InitializeOES_compressed_ETC1_RGB8_texture) {
842 SetupInitExpectations("GL_OES_compressed_ETC1_RGB8_texture");
843 EXPECT_THAT(info_->extensions(),
844 HasSubstr("GL_OES_compressed_ETC1_RGB8_texture"));
845 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
846 GL_ETC1_RGB8_OES));
847 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
848 GL_ETC1_RGB8_OES));
851 TEST_F(FeatureInfoTest, InitializeAMD_compressed_ATC_texture) {
852 SetupInitExpectations("GL_AMD_compressed_ATC_texture");
853 EXPECT_THAT(info_->extensions(),
854 HasSubstr("GL_AMD_compressed_ATC_texture"));
855 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
856 GL_ATC_RGB_AMD));
857 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
858 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD));
859 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
860 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD));
863 TEST_F(FeatureInfoTest, InitializeIMG_texture_compression_pvrtc) {
864 SetupInitExpectations("GL_IMG_texture_compression_pvrtc");
865 EXPECT_THAT(info_->extensions(),
866 HasSubstr("GL_IMG_texture_compression_pvrtc"));
867 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
868 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG));
869 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
870 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG));
871 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
872 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG));
873 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
874 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG));
877 TEST_F(FeatureInfoTest, InitializeEXT_occlusion_query_boolean) {
878 SetupInitExpectations("GL_EXT_occlusion_query_boolean");
879 EXPECT_THAT(info_->extensions(),
880 HasSubstr("GL_EXT_occlusion_query_boolean"));
881 EXPECT_TRUE(info_->feature_flags().occlusion_query_boolean);
882 EXPECT_FALSE(info_->feature_flags(
883 ).use_arb_occlusion_query2_for_occlusion_query_boolean);
884 EXPECT_FALSE(info_->feature_flags(
885 ).use_arb_occlusion_query_for_occlusion_query_boolean);
888 TEST_F(FeatureInfoTest, InitializeARB_occlusion_query) {
889 SetupInitExpectations("GL_ARB_occlusion_query");
890 EXPECT_THAT(info_->extensions(),
891 HasSubstr("GL_EXT_occlusion_query_boolean"));
892 EXPECT_TRUE(info_->feature_flags().occlusion_query_boolean);
893 EXPECT_FALSE(info_->feature_flags(
894 ).use_arb_occlusion_query2_for_occlusion_query_boolean);
895 EXPECT_TRUE(info_->feature_flags(
896 ).use_arb_occlusion_query_for_occlusion_query_boolean);
899 TEST_F(FeatureInfoTest, InitializeARB_occlusion_query2) {
900 SetupInitExpectations("GL_ARB_occlusion_query2 GL_ARB_occlusion_query2");
901 EXPECT_THAT(info_->extensions(),
902 HasSubstr("GL_EXT_occlusion_query_boolean"));
903 EXPECT_TRUE(info_->feature_flags().occlusion_query_boolean);
904 EXPECT_TRUE(info_->feature_flags(
905 ).use_arb_occlusion_query2_for_occlusion_query_boolean);
906 EXPECT_FALSE(info_->feature_flags(
907 ).use_arb_occlusion_query_for_occlusion_query_boolean);
910 TEST_F(FeatureInfoTest, InitializeOES_vertex_array_object) {
911 SetupInitExpectations("GL_OES_vertex_array_object");
912 EXPECT_THAT(info_->extensions(),
913 HasSubstr("GL_OES_vertex_array_object"));
914 EXPECT_TRUE(info_->feature_flags().native_vertex_array_object);
917 TEST_F(FeatureInfoTest, InitializeARB_vertex_array_object) {
918 SetupInitExpectations("GL_ARB_vertex_array_object");
919 EXPECT_THAT(info_->extensions(),
920 HasSubstr("GL_OES_vertex_array_object"));
921 EXPECT_TRUE(info_->feature_flags().native_vertex_array_object);
924 TEST_F(FeatureInfoTest, InitializeAPPLE_vertex_array_object) {
925 SetupInitExpectations("GL_APPLE_vertex_array_object");
926 EXPECT_THAT(info_->extensions(),
927 HasSubstr("GL_OES_vertex_array_object"));
928 EXPECT_TRUE(info_->feature_flags().native_vertex_array_object);
931 TEST_F(FeatureInfoTest, InitializeNo_vertex_array_object) {
932 SetupInitExpectations("");
933 // Even if the native extensions are not available the implementation
934 // may still emulate the GL_OES_vertex_array_object functionality. In this
935 // scenario native_vertex_array_object must be false.
936 EXPECT_THAT(info_->extensions(),
937 HasSubstr("GL_OES_vertex_array_object"));
938 EXPECT_FALSE(info_->feature_flags().native_vertex_array_object);
941 TEST_F(FeatureInfoTest, InitializeOES_element_index_uint) {
942 SetupInitExpectations("GL_OES_element_index_uint");
943 EXPECT_THAT(info_->extensions(),
944 HasSubstr("GL_OES_element_index_uint"));
945 EXPECT_TRUE(info_->validators()->index_type.IsValid(GL_UNSIGNED_INT));
948 TEST_F(FeatureInfoTest, InitializeVAOsWithClientSideArrays) {
949 CommandLine command_line(0, NULL);
950 command_line.AppendSwitchASCII(
951 switches::kGpuDriverBugWorkarounds,
952 base::IntToString(gpu::USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS));
953 SetupInitExpectationsWithCommandLine("GL_OES_vertex_array_object",
954 command_line);
955 EXPECT_TRUE(info_->workarounds().use_client_side_arrays_for_stream_buffers);
956 EXPECT_FALSE(info_->feature_flags().native_vertex_array_object);
959 TEST_F(FeatureInfoTest, InitializeEXT_blend_minmax) {
960 SetupInitExpectations("GL_EXT_blend_minmax");
961 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_blend_minmax"));
962 EXPECT_TRUE(info_->validators()->equation.IsValid(GL_MIN_EXT));
963 EXPECT_TRUE(info_->validators()->equation.IsValid(GL_MAX_EXT));
966 TEST_F(FeatureInfoTest, InitializeEXT_frag_depth) {
967 SetupInitExpectations("GL_EXT_frag_depth");
968 EXPECT_TRUE(info_->feature_flags().ext_frag_depth);
969 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_frag_depth"));
972 TEST_F(FeatureInfoTest, InitializeEXT_shader_texture_lod) {
973 SetupInitExpectations("GL_EXT_shader_texture_lod");
974 EXPECT_TRUE(info_->feature_flags().ext_shader_texture_lod);
975 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_shader_texture_lod"));
978 TEST_F(FeatureInfoTest, InitializeEXT_discard_framebuffer) {
979 SetupInitExpectations("GL_EXT_discard_framebuffer");
980 EXPECT_TRUE(info_->feature_flags().ext_discard_framebuffer);
981 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_discard_framebuffer"));
984 TEST_F(FeatureInfoTest, InitializeSamplersWithARBSamplerObjects) {
985 SetupInitExpectationsWithGLVersion(
986 "GL_ARB_sampler_objects", "", "OpenGL 3.0");
987 EXPECT_TRUE(info_->feature_flags().enable_samplers);
990 TEST_F(FeatureInfoTest, InitializeWithES3) {
991 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 3.0");
992 EXPECT_TRUE(info_->feature_flags().enable_samplers);
993 EXPECT_TRUE(info_->feature_flags().map_buffer_range);
994 EXPECT_TRUE(info_->feature_flags().ext_discard_framebuffer);
995 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_discard_framebuffer"));
996 EXPECT_TRUE(info_->feature_flags().chromium_framebuffer_multisample);
997 EXPECT_TRUE(info_->feature_flags().use_core_framebuffer_multisample);
998 EXPECT_THAT(info_->extensions(),
999 HasSubstr("GL_CHROMIUM_framebuffer_multisample"));
1000 EXPECT_TRUE(info_->feature_flags().use_async_readpixels);
1001 EXPECT_TRUE(info_->feature_flags().oes_depth24);
1002 EXPECT_THAT(info_->extensions(), HasSubstr("GL_GOOGLE_depth_texture"));
1003 EXPECT_THAT(info_->extensions(), HasSubstr("GL_CHROMIUM_depth_texture"));
1004 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT_24_8));
1005 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT)
1006 .IsValid(GL_UNSIGNED_SHORT));
1007 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT)
1008 .IsValid(GL_UNSIGNED_INT));
1009 EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_STENCIL)
1010 .IsValid(GL_UNSIGNED_INT_24_8));
1011 EXPECT_TRUE(info_->feature_flags().packed_depth24_stencil8);
1012 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_depth24"));
1013 EXPECT_TRUE(
1014 info_->validators()->render_buffer_format.IsValid(GL_DEPTH_COMPONENT24));
1015 EXPECT_TRUE(
1016 info_->validators()->render_buffer_format.IsValid(GL_DEPTH24_STENCIL8));
1017 EXPECT_TRUE(
1018 info_->validators()->texture_internal_format.IsValid(GL_DEPTH_STENCIL));
1019 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_STENCIL));
1020 EXPECT_TRUE(info_->feature_flags().chromium_sync_query);
1021 EXPECT_TRUE(gfx::GLFence::IsSupported());
1024 TEST_F(FeatureInfoTest, InitializeWithoutSamplers) {
1025 SetupInitExpectationsWithGLVersion("", "", "OpenGL GL 3.0");
1026 EXPECT_FALSE(info_->feature_flags().enable_samplers);
1029 TEST_F(FeatureInfoTest, ParseDriverBugWorkaroundsSingle) {
1030 CommandLine command_line(0, NULL);
1031 command_line.AppendSwitchASCII(
1032 switches::kGpuDriverBugWorkarounds,
1033 base::IntToString(gpu::EXIT_ON_CONTEXT_LOST));
1034 // Workarounds should get parsed without the need for a context.
1035 SetupWithCommandLine(command_line);
1036 EXPECT_TRUE(info_->workarounds().exit_on_context_lost);
1039 TEST_F(FeatureInfoTest, ParseDriverBugWorkaroundsMultiple) {
1040 CommandLine command_line(0, NULL);
1041 command_line.AppendSwitchASCII(
1042 switches::kGpuDriverBugWorkarounds,
1043 base::IntToString(gpu::EXIT_ON_CONTEXT_LOST) + "," +
1044 base::IntToString(gpu::MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024) + "," +
1045 base::IntToString(gpu::MAX_TEXTURE_SIZE_LIMIT_4096));
1046 // Workarounds should get parsed without the need for a context.
1047 SetupWithCommandLine(command_line);
1048 EXPECT_TRUE(info_->workarounds().exit_on_context_lost);
1049 EXPECT_EQ(1024, info_->workarounds().max_cube_map_texture_size);
1050 EXPECT_EQ(4096, info_->workarounds().max_texture_size);
1053 TEST_F(FeatureInfoTest, InitializeWithARBSync) {
1054 SetupInitExpectations("GL_ARB_sync");
1055 EXPECT_TRUE(info_->feature_flags().chromium_sync_query);
1056 EXPECT_TRUE(gfx::GLFence::IsSupported());
1059 TEST_F(FeatureInfoTest, InitializeWithNVFence) {
1060 SetupInitExpectations("GL_NV_fence");
1061 EXPECT_TRUE(info_->feature_flags().chromium_sync_query);
1062 EXPECT_TRUE(gfx::GLFence::IsSupported());
1065 TEST_F(FeatureInfoTest, ARBSyncDisabled) {
1066 CommandLine command_line(0, NULL);
1067 command_line.AppendSwitchASCII(
1068 switches::kGpuDriverBugWorkarounds,
1069 base::IntToString(gpu::DISABLE_ARB_SYNC));
1070 SetupInitExpectationsWithCommandLine("GL_ARB_sync", command_line);
1071 EXPECT_FALSE(info_->feature_flags().chromium_sync_query);
1072 EXPECT_FALSE(gfx::GLFence::IsSupported());
1075 } // namespace gles2
1076 } // namespace gpu