Elim cr-checkbox
[chromium-blink-merge.git] / gpu / command_buffer / service / feature_info_unittest.cc
blob47a1999879fd51b7c02faf91c91d05ebd12bb688
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 "gpu/config/gpu_switches.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "ui/gl/gl_fence.h"
18 #include "ui/gl/gl_implementation.h"
19 #include "ui/gl/gl_mock.h"
20 #include "ui/gl/gl_version_info.h"
22 using ::testing::_;
23 using ::testing::DoAll;
24 using ::testing::HasSubstr;
25 using ::testing::InSequence;
26 using ::testing::MatcherCast;
27 using ::testing::Not;
28 using ::testing::Pointee;
29 using ::testing::Return;
30 using ::testing::SetArrayArgument;
31 using ::testing::SetArgumentPointee;
32 using ::testing::StrEq;
34 namespace gpu {
35 namespace gles2 {
37 namespace {
38 const char kGLRendererStringANGLE[] = "ANGLE (some renderer)";
39 } // anonymous namespace
41 enum MockedGLVersionKind {
42 Version3_0,
43 Version3_2Compatibility
46 class FeatureInfoTest
47 : public GpuServiceTest,
48 public ::testing::WithParamInterface<MockedGLVersionKind> {
49 public:
50 FeatureInfoTest() {
53 void SetupInitExpectations(const char* extensions) {
54 std::string extensions_str = extensions;
55 // Most of the tests' expectations currently assume the desktop
56 // OpenGL compatibility profile.
57 switch (GetParam()) {
58 case Version3_0:
59 SetupInitExpectationsWithGLVersion(extensions_str.c_str(), "", "3.0");
60 break;
61 case Version3_2Compatibility:
62 if (extensions_str.find("GL_ARB_compatibility") == std::string::npos) {
63 extensions_str += " GL_ARB_compatibility";
65 SetupInitExpectationsWithGLVersion(extensions_str.c_str(), "", "3.2");
66 break;
67 default:
68 NOTREACHED();
69 break;
73 void SetupInitExpectationsWithGLVersion(
74 const char* extensions, const char* renderer, const char* version) {
75 GpuServiceTest::SetUpWithGLVersion(version, extensions);
76 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
77 gl_.get(), extensions, renderer, version);
78 info_ = new FeatureInfo();
79 info_->Initialize();
82 void SetupInitExpectationsWithGLVersionAndCommandLine(
83 const char* extensions,
84 const char* renderer,
85 const char* version,
86 const base::CommandLine& command_line) {
87 GpuServiceTest::SetUpWithGLVersion(version, extensions);
88 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
89 gl_.get(), extensions, renderer, version);
90 info_ = new FeatureInfo(command_line);
91 info_->Initialize();
94 void SetupWithCommandLine(const base::CommandLine& command_line) {
95 GpuServiceTest::SetUp();
96 info_ = new FeatureInfo(command_line);
99 void SetupInitExpectationsWithCommandLine(
100 const char* extensions,
101 const base::CommandLine& command_line) {
102 GpuServiceTest::SetUpWithGLVersion("2.0", extensions);
103 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
104 gl_.get(), extensions, "", "");
105 info_ = new FeatureInfo(command_line);
106 info_->Initialize();
109 void SetupWithoutInit() {
110 GpuServiceTest::SetUp();
111 info_ = new FeatureInfo();
114 protected:
115 void SetUp() override {
116 // Do nothing here, since we are using the explicit Setup*() functions.
119 void TearDown() override {
120 info_ = NULL;
121 GpuServiceTest::TearDown();
124 scoped_refptr<FeatureInfo> info_;
127 namespace {
129 struct FormatInfo {
130 GLenum format;
131 const GLenum* types;
132 size_t count;
135 } // anonymous namespace.
137 static const MockedGLVersionKind kGLVersionKinds[] = {
138 Version3_0,
139 Version3_2Compatibility
142 INSTANTIATE_TEST_CASE_P(Service,
143 FeatureInfoTest,
144 ::testing::ValuesIn(kGLVersionKinds));
146 TEST_P(FeatureInfoTest, Basic) {
147 SetupWithoutInit();
148 // Test it starts off uninitialized.
149 EXPECT_FALSE(info_->feature_flags().chromium_framebuffer_multisample);
150 EXPECT_FALSE(info_->feature_flags().use_core_framebuffer_multisample);
151 EXPECT_FALSE(info_->feature_flags().multisampled_render_to_texture);
152 EXPECT_FALSE(info_->feature_flags(
153 ).use_img_for_multisampled_render_to_texture);
154 EXPECT_FALSE(info_->feature_flags().oes_standard_derivatives);
155 EXPECT_FALSE(info_->feature_flags().npot_ok);
156 EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
157 EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
158 EXPECT_FALSE(info_->feature_flags().oes_egl_image_external);
159 EXPECT_FALSE(info_->feature_flags().oes_depth24);
160 EXPECT_FALSE(info_->feature_flags().packed_depth24_stencil8);
161 EXPECT_FALSE(info_->feature_flags().angle_translated_shader_source);
162 EXPECT_FALSE(info_->feature_flags().angle_pack_reverse_row_order);
163 EXPECT_FALSE(info_->feature_flags().arb_texture_rectangle);
164 EXPECT_FALSE(info_->feature_flags().angle_instanced_arrays);
165 EXPECT_FALSE(info_->feature_flags().occlusion_query_boolean);
166 EXPECT_FALSE(info_->feature_flags(
167 ).use_arb_occlusion_query2_for_occlusion_query_boolean);
168 EXPECT_FALSE(info_->feature_flags(
169 ).use_arb_occlusion_query_for_occlusion_query_boolean);
170 EXPECT_FALSE(info_->feature_flags().native_vertex_array_object);
171 EXPECT_FALSE(info_->feature_flags().map_buffer_range);
172 EXPECT_FALSE(info_->feature_flags().use_async_readpixels);
173 EXPECT_FALSE(info_->feature_flags().ext_draw_buffers);
174 EXPECT_FALSE(info_->feature_flags().nv_draw_buffers);
175 EXPECT_FALSE(info_->feature_flags().ext_discard_framebuffer);
176 EXPECT_FALSE(info_->feature_flags().angle_depth_texture);
178 #define GPU_OP(type, name) EXPECT_FALSE(info_->workarounds().name);
179 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
180 #undef GPU_OP
181 EXPECT_EQ(0, info_->workarounds().max_texture_size);
182 EXPECT_EQ(0, info_->workarounds().max_cube_map_texture_size);
183 EXPECT_FALSE(info_->workarounds().gl_clear_broken);
186 TEST_P(FeatureInfoTest, InitializeNoExtensions) {
187 SetupInitExpectations("");
188 // Check default extensions are there
189 EXPECT_THAT(info_->extensions(), HasSubstr("GL_CHROMIUM_resource_safe"));
190 EXPECT_THAT(info_->extensions(), HasSubstr("GL_CHROMIUM_strict_attribs"));
191 EXPECT_THAT(info_->extensions(),
192 HasSubstr("GL_ANGLE_translated_shader_source"));
193 EXPECT_THAT(info_->extensions(), HasSubstr("GL_CHROMIUM_trace_marker"));
195 // Check a couple of random extensions that should not be there.
196 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_npot")));
197 EXPECT_THAT(info_->extensions(),
198 Not(HasSubstr("GL_EXT_texture_compression_dxt1")));
199 EXPECT_THAT(info_->extensions(),
200 Not(HasSubstr("GL_CHROMIUM_texture_compression_dxt3")));
201 EXPECT_THAT(info_->extensions(),
202 Not(HasSubstr("GL_CHROMIUM_texture_compression_dxt5")));
203 EXPECT_THAT(info_->extensions(),
204 Not(HasSubstr("GL_ANGLE_texture_usage")));
205 EXPECT_THAT(info_->extensions(),
206 Not(HasSubstr("GL_EXT_texture_storage")));
207 EXPECT_THAT(info_->extensions(),
208 Not(HasSubstr("GL_OES_compressed_ETC1_RGB8_texture")));
209 EXPECT_THAT(info_->extensions(),
210 Not(HasSubstr("GL_AMD_compressed_ATC_texture")));
211 EXPECT_THAT(info_->extensions(),
212 Not(HasSubstr("GL_IMG_texture_compression_pvrtc")));
213 EXPECT_THAT(info_->extensions(),
214 Not(HasSubstr("GL_EXT_sRGB")));
215 EXPECT_FALSE(info_->feature_flags().npot_ok);
216 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
217 GL_COMPRESSED_RGB_S3TC_DXT1_EXT));
218 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
219 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
220 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
221 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
222 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
223 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
224 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
225 GL_ETC1_RGB8_OES));
226 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
227 GL_ATC_RGB_AMD));
228 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
229 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD));
230 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
231 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD));
232 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
233 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG));
234 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
235 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG));
236 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
237 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG));
238 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
239 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG));
240 EXPECT_FALSE(info_->validators()->read_pixel_format.IsValid(
241 GL_BGRA_EXT));
242 EXPECT_FALSE(info_->validators()->texture_parameter.IsValid(
243 GL_TEXTURE_MAX_ANISOTROPY_EXT));
244 EXPECT_FALSE(info_->validators()->g_l_state.IsValid(
245 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
246 EXPECT_FALSE(info_->validators()->frame_buffer_target.IsValid(
247 GL_READ_FRAMEBUFFER_EXT));
248 EXPECT_FALSE(info_->validators()->frame_buffer_target.IsValid(
249 GL_DRAW_FRAMEBUFFER_EXT));
250 EXPECT_FALSE(info_->validators()->g_l_state.IsValid(
251 GL_READ_FRAMEBUFFER_BINDING_EXT));
252 EXPECT_FALSE(info_->validators()->render_buffer_parameter.IsValid(
253 GL_MAX_SAMPLES_EXT));
254 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
255 GL_DEPTH_COMPONENT));
256 EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
257 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
258 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
259 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
260 GL_DEPTH24_STENCIL8));
261 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
262 GL_DEPTH_STENCIL));
263 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
264 GL_RGBA32F));
265 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
266 GL_RGB32F));
267 EXPECT_FALSE(info_->validators()->texture_format.IsValid(
268 GL_DEPTH_STENCIL));
269 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(
270 GL_UNSIGNED_INT_24_8));
271 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
272 GL_DEPTH_COMPONENT24));
273 EXPECT_FALSE(info_->validators()->texture_parameter.IsValid(
274 GL_TEXTURE_USAGE_ANGLE));
275 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
276 GL_DEPTH_COMPONENT16));
277 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
278 GL_DEPTH_COMPONENT32_OES));
279 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
280 GL_DEPTH24_STENCIL8_OES));
281 EXPECT_FALSE(info_->validators()->equation.IsValid(GL_MIN_EXT));
282 EXPECT_FALSE(info_->validators()->equation.IsValid(GL_MAX_EXT));
283 EXPECT_FALSE(info_->feature_flags().chromium_sync_query);
284 EXPECT_FALSE(info_->validators()->texture_format.IsValid(
285 GL_SRGB_EXT));
286 EXPECT_FALSE(info_->validators()->texture_format.IsValid(
287 GL_SRGB_ALPHA_EXT));
288 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
289 GL_SRGB_EXT));
290 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
291 GL_SRGB_ALPHA_EXT));
292 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
293 GL_SRGB8_ALPHA8_EXT));
294 EXPECT_FALSE(info_->validators()->frame_buffer_parameter.IsValid(
295 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT));
296 EXPECT_FALSE(info_->feature_flags().chromium_image_ycbcr_422);
299 TEST_P(FeatureInfoTest, InitializeWithANGLE) {
300 SetupInitExpectationsWithGLVersion("", kGLRendererStringANGLE, "");
301 EXPECT_TRUE(info_->gl_version_info().is_angle);
304 TEST_P(FeatureInfoTest, InitializeNPOTExtensionGLES) {
305 SetupInitExpectations("GL_OES_texture_npot");
306 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_npot"));
307 EXPECT_TRUE(info_->feature_flags().npot_ok);
310 TEST_P(FeatureInfoTest, InitializeNPOTExtensionGL) {
311 SetupInitExpectations("GL_ARB_texture_non_power_of_two");
312 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_npot"));
313 EXPECT_TRUE(info_->feature_flags().npot_ok);
316 TEST_P(FeatureInfoTest, InitializeDXTExtensionGLES2) {
317 SetupInitExpectations("GL_EXT_texture_compression_dxt1");
318 EXPECT_THAT(info_->extensions(),
319 HasSubstr("GL_EXT_texture_compression_dxt1"));
320 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
321 GL_COMPRESSED_RGB_S3TC_DXT1_EXT));
322 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
323 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
324 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
325 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
326 EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
327 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
330 TEST_P(FeatureInfoTest, InitializeDXTExtensionGL) {
331 SetupInitExpectations("GL_EXT_texture_compression_s3tc");
332 EXPECT_THAT(info_->extensions(),
333 HasSubstr("GL_EXT_texture_compression_dxt1"));
334 EXPECT_THAT(info_->extensions(),
335 HasSubstr("GL_CHROMIUM_texture_compression_dxt3"));
336 EXPECT_THAT(info_->extensions(),
337 HasSubstr("GL_CHROMIUM_texture_compression_dxt5"));
338 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
339 GL_COMPRESSED_RGB_S3TC_DXT1_EXT));
340 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
341 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
342 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
343 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
344 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
345 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
348 TEST_P(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888GLES2) {
349 SetupInitExpectations("GL_EXT_texture_format_BGRA8888");
350 EXPECT_THAT(info_->extensions(),
351 HasSubstr("GL_EXT_texture_format_BGRA8888"));
352 EXPECT_TRUE(info_->validators()->texture_format.IsValid(
353 GL_BGRA_EXT));
354 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
355 GL_BGRA_EXT));
356 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
357 GL_BGRA8_EXT));
358 EXPECT_FALSE(info_->feature_flags().ext_render_buffer_format_bgra8888);
361 TEST_P(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888GL) {
362 SetupInitExpectations("GL_EXT_bgra");
363 EXPECT_THAT(info_->extensions(),
364 HasSubstr("GL_EXT_texture_format_BGRA8888"));
365 EXPECT_THAT(info_->extensions(),
366 HasSubstr("GL_EXT_read_format_bgra"));
367 EXPECT_THAT(info_->extensions(),
368 HasSubstr("GL_CHROMIUM_renderbuffer_format_BGRA8888"));
369 EXPECT_TRUE(info_->feature_flags().ext_render_buffer_format_bgra8888);
370 EXPECT_TRUE(info_->validators()->texture_format.IsValid(
371 GL_BGRA_EXT));
372 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
373 GL_BGRA_EXT));
374 EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(
375 GL_BGRA_EXT));
376 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
377 GL_BGRA8_EXT));
380 TEST_P(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888Apple) {
381 SetupInitExpectations("GL_APPLE_texture_format_BGRA8888");
382 EXPECT_THAT(info_->extensions(),
383 HasSubstr("GL_EXT_texture_format_BGRA8888"));
384 EXPECT_TRUE(info_->validators()->texture_format.IsValid(
385 GL_BGRA_EXT));
386 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
387 GL_BGRA_EXT));
388 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
389 GL_BGRA8_EXT));
390 EXPECT_FALSE(info_->feature_flags().ext_render_buffer_format_bgra8888);
393 TEST_P(FeatureInfoTest, InitializeGLES2EXT_read_format_bgra) {
394 SetupInitExpectationsWithGLVersion(
395 "GL_EXT_read_format_bgra", "", "OpenGL ES 2.0");
396 EXPECT_THAT(info_->extensions(),
397 HasSubstr("GL_EXT_read_format_bgra"));
398 EXPECT_FALSE(info_->validators()->texture_format.IsValid(
399 GL_BGRA_EXT));
400 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
401 GL_BGRA_EXT));
402 EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(
403 GL_BGRA_EXT));
404 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
405 GL_BGRA8_EXT));
406 EXPECT_FALSE(info_->feature_flags().ext_render_buffer_format_bgra8888);
409 TEST_P(FeatureInfoTest, InitializeEXT_read_format_bgra) {
410 SetupInitExpectations("GL_EXT_read_format_bgra");
411 EXPECT_THAT(info_->extensions(),
412 HasSubstr("GL_EXT_read_format_bgra"));
413 EXPECT_TRUE(info_->validators()->texture_format.IsValid(
414 GL_BGRA_EXT));
415 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
416 GL_BGRA_EXT));
417 EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(
418 GL_BGRA_EXT));
419 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
420 GL_BGRA8_EXT));
421 EXPECT_FALSE(info_->feature_flags().ext_render_buffer_format_bgra8888);
424 TEST_P(FeatureInfoTest, InitializeEXT_sRGB) {
425 SetupInitExpectations("GL_EXT_sRGB GL_OES_rgb8_rgba8");
426 EXPECT_THAT(info_->extensions(),
427 HasSubstr("GL_EXT_sRGB"));
428 EXPECT_TRUE(info_->validators()->texture_format.IsValid(
429 GL_SRGB_EXT));
430 EXPECT_TRUE(info_->validators()->texture_format.IsValid(
431 GL_SRGB_ALPHA_EXT));
432 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
433 GL_SRGB_EXT));
434 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
435 GL_SRGB_ALPHA_EXT));
436 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
437 GL_SRGB8_ALPHA8_EXT));
438 EXPECT_TRUE(info_->validators()->frame_buffer_parameter.IsValid(
439 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT));
442 TEST_P(FeatureInfoTest, InitializeGLES2EXT_texture_storage) {
443 SetupInitExpectationsWithGLVersion(
444 "GL_EXT_texture_storage", "", "OpenGL ES 2.0");
445 EXPECT_TRUE(info_->feature_flags().ext_texture_storage);
446 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
447 EXPECT_TRUE(info_->validators()->texture_parameter.IsValid(
448 GL_TEXTURE_IMMUTABLE_FORMAT_EXT));
449 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
450 GL_BGRA8_EXT));
451 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
452 GL_RGBA32F_EXT));
453 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
454 GL_RGB32F_EXT));
455 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
456 GL_ALPHA32F_EXT));
457 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
458 GL_LUMINANCE32F_EXT));
459 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
460 GL_LUMINANCE_ALPHA32F_EXT));
461 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
462 GL_RGBA16F_EXT));
463 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
464 GL_RGB16F_EXT));
465 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
466 GL_ALPHA16F_EXT));
467 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
468 GL_LUMINANCE16F_EXT));
469 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
470 GL_LUMINANCE_ALPHA16F_EXT));
473 TEST_P(FeatureInfoTest, InitializeEXT_texture_storage) {
474 SetupInitExpectations("GL_EXT_texture_storage");
475 EXPECT_TRUE(info_->feature_flags().ext_texture_storage);
476 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
477 EXPECT_TRUE(info_->validators()->texture_parameter.IsValid(
478 GL_TEXTURE_IMMUTABLE_FORMAT_EXT));
479 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
480 GL_BGRA8_EXT));
481 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
482 GL_RGBA32F_EXT));
483 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
484 GL_RGB32F_EXT));
485 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
486 GL_ALPHA32F_EXT));
487 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
488 GL_LUMINANCE32F_EXT));
489 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
490 GL_LUMINANCE_ALPHA32F_EXT));
491 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
492 GL_RGBA16F_EXT));
493 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
494 GL_RGB16F_EXT));
495 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
496 GL_ALPHA16F_EXT));
497 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
498 GL_LUMINANCE16F_EXT));
499 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
500 GL_LUMINANCE_ALPHA16F_EXT));
503 TEST_P(FeatureInfoTest, InitializeARB_texture_storage) {
504 SetupInitExpectations("GL_ARB_texture_storage");
505 EXPECT_TRUE(info_->feature_flags().ext_texture_storage);
506 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
507 EXPECT_TRUE(info_->validators()->texture_parameter.IsValid(
508 GL_TEXTURE_IMMUTABLE_FORMAT_EXT));
511 TEST_P(FeatureInfoTest, InitializeEXT_texture_storage_BGRA) {
512 SetupInitExpectations("GL_EXT_texture_storage GL_EXT_bgra");
513 EXPECT_TRUE(info_->feature_flags().ext_texture_storage);
514 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
515 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
516 GL_BGRA8_EXT));
517 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
520 TEST_P(FeatureInfoTest, InitializeARB_texture_storage_BGRA) {
521 SetupInitExpectations("GL_ARB_texture_storage GL_EXT_bgra");
522 EXPECT_TRUE(info_->feature_flags().ext_texture_storage);
523 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
524 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
525 GL_BGRA8_EXT));
526 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
529 TEST_P(FeatureInfoTest, InitializeEXT_texture_storage_BGRA8888) {
530 SetupInitExpectations(
531 "GL_EXT_texture_storage GL_EXT_texture_format_BGRA8888");
532 EXPECT_TRUE(info_->feature_flags().ext_texture_storage);
533 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
534 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
535 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
536 GL_BGRA8_EXT));
537 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
540 TEST_P(FeatureInfoTest, InitializeEXT_texture_storage_float) {
541 SetupInitExpectations("GL_EXT_texture_storage GL_OES_texture_float");
542 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
543 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_float"));
544 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
545 GL_RGBA32F_EXT));
546 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
547 GL_RGB32F_EXT));
548 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
549 GL_ALPHA32F_EXT));
550 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
551 GL_LUMINANCE32F_EXT));
552 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
553 GL_LUMINANCE_ALPHA32F_EXT));
556 TEST_P(FeatureInfoTest, InitializeEXT_texture_storage_half_float) {
557 SetupInitExpectations("GL_EXT_texture_storage GL_OES_texture_half_float");
558 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
559 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_half_float"));
560 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
561 GL_RGBA16F_EXT));
562 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
563 GL_RGB16F_EXT));
564 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
565 GL_ALPHA16F_EXT));
566 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
567 GL_LUMINANCE16F_EXT));
568 EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid(
569 GL_LUMINANCE_ALPHA16F_EXT));
572 // Check how to handle ES, texture_storage and BGRA combination; 10 tests.
574 // 1- ES2 + GL_EXT_texture_storage -> GL_EXT_texture_storage (and no
575 // GL_EXT_texture_format_BGRA8888 - we don't claim to handle GL_BGRA8 in
576 // glTexStorage2DEXT)
577 TEST_P(FeatureInfoTest, InitializeGLES2_texture_storage) {
578 SetupInitExpectationsWithGLVersion(
579 "GL_EXT_texture_storage", "", "OpenGL ES 2.0");
580 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
581 EXPECT_THAT(info_->extensions(),
582 Not(HasSubstr("GL_EXT_texture_format_BGRA8888")));
585 // 2- ES2 + GL_EXT_texture_storage + (GL_EXT_texture_format_BGRA8888 or
586 // GL_APPLE_texture_format_bgra8888)
587 TEST_P(FeatureInfoTest, InitializeGLES2_texture_storage_BGRA) {
588 SetupInitExpectationsWithGLVersion(
589 "GL_EXT_texture_storage GL_EXT_texture_format_BGRA8888",
591 "OpenGL ES 2.0");
592 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
593 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
596 // 3- ES2 + GL_EXT_texture_format_BGRA8888 or GL_APPLE_texture_format_bgra8888
597 TEST_P(FeatureInfoTest, InitializeGLES2_texture_format_BGRA) {
598 SetupInitExpectationsWithGLVersion(
599 "GL_EXT_texture_format_BGRA8888", "", "OpenGL ES 2.0");
600 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_texture_storage")));
601 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
604 // 4- ES2 (neither GL_EXT_texture_storage nor GL_EXT_texture_format_BGRA8888) ->
605 // nothing
606 TEST_P(FeatureInfoTest, InitializeGLES2_neither_texture_storage_nor_BGRA) {
607 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 2.0");
608 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_texture_storage")));
609 EXPECT_THAT(info_->extensions(),
610 Not(HasSubstr("GL_EXT_texture_format_BGRA8888")));
613 // 5- ES3 + GL_EXT_texture_format_BGRA8888 -> GL_EXT_texture_format_BGRA8888
614 // (we can't expose GL_EXT_texture_storage because we fail the GL_BGRA8
615 // requirement)
616 TEST_P(FeatureInfoTest, InitializeGLES3_texture_storage_EXT_BGRA) {
617 SetupInitExpectationsWithGLVersion(
618 "GL_EXT_texture_format_BGRA8888", "", "OpenGL ES 3.0");
619 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_texture_storage")));
620 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
623 // 6- ES3 + GL_APPLE_texture_format_bgra8888 -> GL_EXT_texture_storage +
624 // GL_EXT_texture_format_BGRA8888 (driver promises to handle GL_BGRA8 by
625 // exposing GL_APPLE_texture_format_bgra8888)
626 TEST_P(FeatureInfoTest, InitializeGLES3_texture_storage_APPLE_BGRA) {
627 SetupInitExpectationsWithGLVersion(
628 "GL_APPLE_texture_format_BGRA8888", "", "OpenGL ES 3.0");
629 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
630 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
633 // 7- ES3 + GL_EXT_texture_storage + GL_EXT_texture_format_BGRA8888 ->
634 // GL_EXT_texture_storage + GL_EXT_texture_format_BGRA8888 (driver promises to
635 // handle GL_BGRA8 by exposing GL_EXT_texture_storage)
636 TEST_P(FeatureInfoTest, InitializeGLES3_EXT_texture_storage_EXT_BGRA) {
637 SetupInitExpectationsWithGLVersion(
638 "GL_EXT_texture_storage GL_EXT_texture_format_BGRA8888",
640 "OpenGL ES 3.0");
641 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
642 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888"));
645 // 8- ES3 + none of the above -> GL_EXT_texture_storage (and no
646 // GL_EXT_texture_format_BGRA8888 - we don't claim to handle GL_BGRA8)
647 TEST_P(FeatureInfoTest, InitializeGLES3_texture_storage) {
648 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 3.0");
649 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage"));
650 EXPECT_THAT(info_->extensions(),
651 Not(HasSubstr("GL_EXT_texture_format_BGRA8888")));
654 // 9- ANGLE will add the GL_CHROMIUM_renderbuffer_format_BGRA8888 extension and
655 // the GL_BGRA8_EXT render buffer format.
656 TEST_P(FeatureInfoTest, InitializeWithANGLE_BGRA8) {
657 SetupInitExpectationsWithGLVersion("", kGLRendererStringANGLE, "");
658 EXPECT_TRUE(info_->gl_version_info().is_angle);
659 EXPECT_THAT(info_->extensions(),
660 HasSubstr("GL_CHROMIUM_renderbuffer_format_BGRA8888"));
661 EXPECT_TRUE(info_->feature_flags().ext_render_buffer_format_bgra8888);
662 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(GL_BGRA8_EXT));
665 // 10- vanilla opengl es means no GL_CHROMIUM_renderbuffer_format_BGRA8888
666 TEST_P(FeatureInfoTest,
667 InitializeGLES2_no_CHROMIUM_renderbuffer_format_BGRA8888) {
668 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 2.0");
669 EXPECT_FALSE(info_->feature_flags().ext_render_buffer_format_bgra8888);
670 EXPECT_THAT(info_->extensions(),
671 Not(HasSubstr("GL_CHROMIUM_renderbuffer_format_BGRA8888")));
674 TEST_P(FeatureInfoTest, InitializeARB_texture_float) {
675 SetupInitExpectations("GL_ARB_texture_float");
676 EXPECT_TRUE(info_->feature_flags().chromium_color_buffer_float_rgba);
677 EXPECT_TRUE(info_->feature_flags().chromium_color_buffer_float_rgb);
678 std::string extensions = info_->extensions() + " ";
679 EXPECT_THAT(extensions, HasSubstr("GL_CHROMIUM_color_buffer_float_rgb "));
680 EXPECT_THAT(extensions, HasSubstr("GL_CHROMIUM_color_buffer_float_rgba"));
681 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
682 GL_RGBA32F));
683 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
684 GL_RGB32F));
687 TEST_P(FeatureInfoTest, Initialize_texture_floatGLES3) {
688 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 3.0");
689 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_float")));
690 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_half_float")));
691 EXPECT_THAT(info_->extensions(),
692 Not(HasSubstr("GL_OES_texture_float_linear")));
693 EXPECT_THAT(info_->extensions(),
694 Not(HasSubstr("GL_OES_texture_half_float_linear")));
697 TEST_P(FeatureInfoTest, Initialize_sRGBGLES3) {
698 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 3.0");
699 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_sRGB")));
700 EXPECT_FALSE(info_->validators()->texture_format.IsValid(
701 GL_SRGB_EXT));
702 EXPECT_FALSE(info_->validators()->texture_format.IsValid(
703 GL_SRGB_ALPHA_EXT));
704 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
705 GL_SRGB_EXT));
706 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
707 GL_SRGB_ALPHA_EXT));
708 EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
709 GL_SRGB8_ALPHA8_EXT));
710 EXPECT_FALSE(info_->validators()->frame_buffer_parameter.IsValid(
711 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT));
714 TEST_P(FeatureInfoTest, InitializeOES_texture_floatGLES2) {
715 SetupInitExpectations("GL_OES_texture_float");
716 EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
717 EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
718 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_float"));
719 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_half_float")));
720 EXPECT_THAT(info_->extensions(),
721 Not(HasSubstr("GL_OES_texture_float_linear")));
722 EXPECT_THAT(info_->extensions(),
723 Not(HasSubstr("GL_OES_texture_half_float_linear")));
724 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
725 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
728 TEST_P(FeatureInfoTest, InitializeOES_texture_float_linearGLES2) {
729 SetupInitExpectations("GL_OES_texture_float GL_OES_texture_float_linear");
730 EXPECT_TRUE(info_->feature_flags().enable_texture_float_linear);
731 EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
732 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_float"));
733 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_half_float")));
734 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_float_linear"));
735 EXPECT_THAT(info_->extensions(),
736 Not(HasSubstr("GL_OES_texture_half_float_linear")));
737 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
738 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
741 TEST_P(FeatureInfoTest, InitializeOES_texture_half_floatGLES2) {
742 SetupInitExpectations("GL_OES_texture_half_float");
743 EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
744 EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
745 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_float")));
746 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_half_float"));
747 EXPECT_THAT(info_->extensions(),
748 Not(HasSubstr("GL_OES_texture_float_linear")));
749 EXPECT_THAT(info_->extensions(),
750 Not(HasSubstr("GL_OES_texture_half_float_linear")));
751 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
752 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
755 TEST_P(FeatureInfoTest, InitializeOES_texture_half_float_linearGLES2) {
756 SetupInitExpectations(
757 "GL_OES_texture_half_float GL_OES_texture_half_float_linear");
758 EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
759 EXPECT_TRUE(info_->feature_flags().enable_texture_half_float_linear);
760 EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_float")));
761 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_half_float"));
762 EXPECT_THAT(info_->extensions(),
763 Not(HasSubstr("GL_OES_texture_float_linear")));
764 EXPECT_THAT(info_->extensions(),
765 HasSubstr("GL_OES_texture_half_float_linear"));
766 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
767 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
770 TEST_P(FeatureInfoTest, InitializeEXT_framebuffer_multisample) {
771 SetupInitExpectations("GL_EXT_framebuffer_multisample");
772 EXPECT_TRUE(info_->feature_flags().chromium_framebuffer_multisample);
773 EXPECT_THAT(info_->extensions(),
774 HasSubstr("GL_CHROMIUM_framebuffer_multisample"));
775 EXPECT_TRUE(info_->validators()->frame_buffer_target.IsValid(
776 GL_READ_FRAMEBUFFER_EXT));
777 EXPECT_TRUE(info_->validators()->frame_buffer_target.IsValid(
778 GL_DRAW_FRAMEBUFFER_EXT));
779 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
780 GL_READ_FRAMEBUFFER_BINDING_EXT));
781 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
782 GL_MAX_SAMPLES_EXT));
783 EXPECT_TRUE(info_->validators()->render_buffer_parameter.IsValid(
784 GL_RENDERBUFFER_SAMPLES_EXT));
787 TEST_P(FeatureInfoTest, InitializeANGLE_framebuffer_multisample) {
788 SetupInitExpectationsWithGLVersion(
789 "GL_ANGLE_framebuffer_multisample", kGLRendererStringANGLE, "");
790 EXPECT_TRUE(info_->feature_flags().chromium_framebuffer_multisample);
791 EXPECT_THAT(info_->extensions(),
792 HasSubstr("GL_CHROMIUM_framebuffer_multisample"));
793 EXPECT_TRUE(info_->validators()->frame_buffer_target.IsValid(
794 GL_READ_FRAMEBUFFER_EXT));
795 EXPECT_TRUE(info_->validators()->frame_buffer_target.IsValid(
796 GL_DRAW_FRAMEBUFFER_EXT));
797 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
798 GL_READ_FRAMEBUFFER_BINDING_EXT));
799 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
800 GL_MAX_SAMPLES_EXT));
801 EXPECT_TRUE(info_->validators()->render_buffer_parameter.IsValid(
802 GL_RENDERBUFFER_SAMPLES_EXT));
805 // We don't allow ANGLE_framebuffer_multisample on non-ANGLE implementations,
806 // because we wouldn't be choosing the right driver entry point and because the
807 // extension was falsely advertised on some Android devices (crbug.com/165736).
808 TEST_P(FeatureInfoTest, InitializeANGLE_framebuffer_multisampleWithoutANGLE) {
809 SetupInitExpectations("GL_ANGLE_framebuffer_multisample");
810 EXPECT_FALSE(info_->feature_flags().chromium_framebuffer_multisample);
811 EXPECT_THAT(info_->extensions(),
812 Not(HasSubstr("GL_CHROMIUM_framebuffer_multisample")));
813 EXPECT_FALSE(info_->validators()->frame_buffer_target.IsValid(
814 GL_READ_FRAMEBUFFER_EXT));
815 EXPECT_FALSE(info_->validators()->frame_buffer_target.IsValid(
816 GL_DRAW_FRAMEBUFFER_EXT));
817 EXPECT_FALSE(info_->validators()->g_l_state.IsValid(
818 GL_READ_FRAMEBUFFER_BINDING_EXT));
819 EXPECT_FALSE(info_->validators()->g_l_state.IsValid(
820 GL_MAX_SAMPLES_EXT));
821 EXPECT_FALSE(info_->validators()->render_buffer_parameter.IsValid(
822 GL_RENDERBUFFER_SAMPLES_EXT));
825 TEST_P(FeatureInfoTest, InitializeEXT_multisampled_render_to_texture) {
826 SetupInitExpectations("GL_EXT_multisampled_render_to_texture");
827 EXPECT_TRUE(info_->feature_flags(
828 ).multisampled_render_to_texture);
829 EXPECT_FALSE(info_->feature_flags(
830 ).use_img_for_multisampled_render_to_texture);
831 EXPECT_THAT(info_->extensions(),
832 HasSubstr("GL_EXT_multisampled_render_to_texture"));
833 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
834 GL_MAX_SAMPLES_EXT));
835 EXPECT_TRUE(info_->validators()->render_buffer_parameter.IsValid(
836 GL_RENDERBUFFER_SAMPLES_EXT));
837 EXPECT_TRUE(info_->validators()->frame_buffer_parameter.IsValid(
838 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT));
841 TEST_P(FeatureInfoTest, InitializeIMG_multisampled_render_to_texture) {
842 SetupInitExpectations("GL_IMG_multisampled_render_to_texture");
843 EXPECT_TRUE(info_->feature_flags(
844 ).multisampled_render_to_texture);
845 EXPECT_TRUE(info_->feature_flags(
846 ).use_img_for_multisampled_render_to_texture);
847 EXPECT_THAT(info_->extensions(),
848 HasSubstr("GL_EXT_multisampled_render_to_texture"));
849 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
850 GL_MAX_SAMPLES_EXT));
851 EXPECT_TRUE(info_->validators()->render_buffer_parameter.IsValid(
852 GL_RENDERBUFFER_SAMPLES_EXT));
853 EXPECT_TRUE(info_->validators()->frame_buffer_parameter.IsValid(
854 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT));
857 TEST_P(FeatureInfoTest, InitializeEXT_texture_filter_anisotropic) {
858 SetupInitExpectations("GL_EXT_texture_filter_anisotropic");
859 EXPECT_THAT(info_->extensions(),
860 HasSubstr("GL_EXT_texture_filter_anisotropic"));
861 EXPECT_TRUE(info_->validators()->texture_parameter.IsValid(
862 GL_TEXTURE_MAX_ANISOTROPY_EXT));
863 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
864 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
867 TEST_P(FeatureInfoTest, InitializeEXT_ARB_depth_texture) {
868 SetupInitExpectations("GL_ARB_depth_texture");
869 EXPECT_THAT(info_->extensions(),
870 HasSubstr("GL_GOOGLE_depth_texture"));
871 EXPECT_THAT(info_->extensions(),
872 HasSubstr("GL_CHROMIUM_depth_texture"));
873 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
874 GL_DEPTH_COMPONENT));
875 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
876 EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_STENCIL));
877 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
878 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
881 TEST_P(FeatureInfoTest, InitializeOES_ARB_depth_texture) {
882 SetupInitExpectations("GL_OES_depth_texture");
883 EXPECT_THAT(info_->extensions(),
884 HasSubstr("GL_GOOGLE_depth_texture"));
885 EXPECT_THAT(info_->extensions(),
886 HasSubstr("GL_CHROMIUM_depth_texture"));
887 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
888 GL_DEPTH_COMPONENT));
889 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
890 EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_STENCIL));
891 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
892 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
895 TEST_P(FeatureInfoTest, InitializeANGLE_depth_texture) {
896 SetupInitExpectations("GL_ANGLE_depth_texture");
897 EXPECT_THAT(info_->extensions(),
898 HasSubstr("GL_GOOGLE_depth_texture"));
899 EXPECT_THAT(info_->extensions(),
900 HasSubstr("GL_CHROMIUM_depth_texture"));
901 EXPECT_THAT(info_->extensions(),
902 Not(HasSubstr("GL_ANGLE_depth_texture")));
903 EXPECT_TRUE(info_->feature_flags().angle_depth_texture);
904 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
905 GL_DEPTH_COMPONENT));
906 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
907 EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_STENCIL));
908 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
909 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
910 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
911 GL_DEPTH_COMPONENT16));
912 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
913 GL_DEPTH_COMPONENT32_OES));
914 EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
915 GL_DEPTH24_STENCIL8_OES));
918 TEST_P(FeatureInfoTest, InitializeEXT_packed_depth_stencil) {
919 SetupInitExpectations("GL_EXT_packed_depth_stencil");
920 EXPECT_THAT(info_->extensions(),
921 HasSubstr("GL_OES_packed_depth_stencil"));
922 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
923 GL_DEPTH24_STENCIL8));
924 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
925 GL_DEPTH_COMPONENT));
926 EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
927 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
928 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
931 TEST_P(FeatureInfoTest, InitializeOES_packed_depth_stencil) {
932 SetupInitExpectations("GL_OES_packed_depth_stencil");
933 EXPECT_THAT(info_->extensions(),
934 HasSubstr("GL_OES_packed_depth_stencil"));
935 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
936 GL_DEPTH24_STENCIL8));
937 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
938 GL_DEPTH_COMPONENT));
939 EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
940 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
941 EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
944 TEST_P(FeatureInfoTest,
945 InitializeOES_packed_depth_stencil_and_GL_ARB_depth_texture) {
946 SetupInitExpectations("GL_OES_packed_depth_stencil GL_ARB_depth_texture");
947 EXPECT_THAT(info_->extensions(),
948 HasSubstr("GL_OES_packed_depth_stencil"));
949 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
950 GL_DEPTH24_STENCIL8));
951 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
952 GL_DEPTH_STENCIL));
953 EXPECT_TRUE(info_->validators()->texture_format.IsValid(
954 GL_DEPTH_STENCIL));
955 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(
956 GL_UNSIGNED_INT_24_8));
959 TEST_P(FeatureInfoTest, InitializeOES_depth24) {
960 SetupInitExpectations("GL_OES_depth24");
961 EXPECT_TRUE(info_->feature_flags().oes_depth24);
962 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_depth24"));
963 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
964 GL_DEPTH_COMPONENT24));
967 TEST_P(FeatureInfoTest, InitializeOES_standard_derivatives) {
968 SetupInitExpectations("GL_OES_standard_derivatives");
969 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_standard_derivatives"));
970 EXPECT_TRUE(info_->feature_flags().oes_standard_derivatives);
971 EXPECT_TRUE(info_->validators()->hint_target.IsValid(
972 GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES));
973 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
974 GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES));
977 TEST_P(FeatureInfoTest, InitializeOES_rgb8_rgba8) {
978 SetupInitExpectations("GL_OES_rgb8_rgba8");
979 EXPECT_THAT(info_->extensions(),
980 HasSubstr("GL_OES_rgb8_rgba8"));
981 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
982 GL_RGB8_OES));
983 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
984 GL_RGBA8_OES));
987 TEST_P(FeatureInfoTest, InitializeOES_EGL_image_external) {
988 SetupInitExpectations("GL_OES_EGL_image_external");
989 EXPECT_THAT(info_->extensions(),
990 HasSubstr("GL_OES_EGL_image_external"));
991 EXPECT_TRUE(info_->feature_flags().oes_egl_image_external);
992 EXPECT_TRUE(info_->validators()->texture_bind_target.IsValid(
993 GL_TEXTURE_EXTERNAL_OES));
994 EXPECT_TRUE(info_->validators()->get_tex_param_target.IsValid(
995 GL_TEXTURE_EXTERNAL_OES));
996 EXPECT_TRUE(info_->validators()->texture_parameter.IsValid(
997 GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES));
998 EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
999 GL_TEXTURE_BINDING_EXTERNAL_OES));
1002 TEST_P(FeatureInfoTest, InitializeOES_compressed_ETC1_RGB8_texture) {
1003 SetupInitExpectations("GL_OES_compressed_ETC1_RGB8_texture");
1004 EXPECT_THAT(info_->extensions(),
1005 HasSubstr("GL_OES_compressed_ETC1_RGB8_texture"));
1006 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
1007 GL_ETC1_RGB8_OES));
1008 EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
1009 GL_ETC1_RGB8_OES));
1012 TEST_P(FeatureInfoTest, InitializeAMD_compressed_ATC_texture) {
1013 SetupInitExpectations("GL_AMD_compressed_ATC_texture");
1014 EXPECT_THAT(info_->extensions(),
1015 HasSubstr("GL_AMD_compressed_ATC_texture"));
1016 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
1017 GL_ATC_RGB_AMD));
1018 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
1019 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD));
1020 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
1021 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD));
1024 TEST_P(FeatureInfoTest, InitializeIMG_texture_compression_pvrtc) {
1025 SetupInitExpectations("GL_IMG_texture_compression_pvrtc");
1026 EXPECT_THAT(info_->extensions(),
1027 HasSubstr("GL_IMG_texture_compression_pvrtc"));
1028 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
1029 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG));
1030 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
1031 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG));
1032 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
1033 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG));
1034 EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
1035 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG));
1038 TEST_P(FeatureInfoTest, InitializeEXT_occlusion_query_boolean) {
1039 SetupInitExpectations("GL_EXT_occlusion_query_boolean");
1040 EXPECT_THAT(info_->extensions(),
1041 HasSubstr("GL_EXT_occlusion_query_boolean"));
1042 EXPECT_TRUE(info_->feature_flags().occlusion_query_boolean);
1043 EXPECT_FALSE(info_->feature_flags(
1044 ).use_arb_occlusion_query2_for_occlusion_query_boolean);
1045 EXPECT_FALSE(info_->feature_flags(
1046 ).use_arb_occlusion_query_for_occlusion_query_boolean);
1049 TEST_P(FeatureInfoTest, InitializeARB_occlusion_query) {
1050 SetupInitExpectations("GL_ARB_occlusion_query");
1051 EXPECT_THAT(info_->extensions(),
1052 HasSubstr("GL_EXT_occlusion_query_boolean"));
1053 EXPECT_TRUE(info_->feature_flags().occlusion_query_boolean);
1054 EXPECT_FALSE(info_->feature_flags(
1055 ).use_arb_occlusion_query2_for_occlusion_query_boolean);
1056 EXPECT_TRUE(info_->feature_flags(
1057 ).use_arb_occlusion_query_for_occlusion_query_boolean);
1060 TEST_P(FeatureInfoTest, InitializeARB_occlusion_query2) {
1061 SetupInitExpectations("GL_ARB_occlusion_query2 GL_ARB_occlusion_query2");
1062 EXPECT_THAT(info_->extensions(),
1063 HasSubstr("GL_EXT_occlusion_query_boolean"));
1064 EXPECT_TRUE(info_->feature_flags().occlusion_query_boolean);
1065 EXPECT_TRUE(info_->feature_flags(
1066 ).use_arb_occlusion_query2_for_occlusion_query_boolean);
1067 EXPECT_FALSE(info_->feature_flags(
1068 ).use_arb_occlusion_query_for_occlusion_query_boolean);
1071 TEST_P(FeatureInfoTest, InitializeOES_vertex_array_object) {
1072 SetupInitExpectations("GL_OES_vertex_array_object");
1073 EXPECT_THAT(info_->extensions(),
1074 HasSubstr("GL_OES_vertex_array_object"));
1075 EXPECT_TRUE(info_->feature_flags().native_vertex_array_object);
1078 TEST_P(FeatureInfoTest, InitializeARB_vertex_array_object) {
1079 SetupInitExpectations("GL_ARB_vertex_array_object");
1080 EXPECT_THAT(info_->extensions(),
1081 HasSubstr("GL_OES_vertex_array_object"));
1082 EXPECT_TRUE(info_->feature_flags().native_vertex_array_object);
1085 TEST_P(FeatureInfoTest, InitializeAPPLE_vertex_array_object) {
1086 SetupInitExpectations("GL_APPLE_vertex_array_object");
1087 EXPECT_THAT(info_->extensions(),
1088 HasSubstr("GL_OES_vertex_array_object"));
1089 EXPECT_TRUE(info_->feature_flags().native_vertex_array_object);
1092 TEST_P(FeatureInfoTest, InitializeNo_vertex_array_object) {
1093 SetupInitExpectations("");
1094 // Even if the native extensions are not available the implementation
1095 // may still emulate the GL_OES_vertex_array_object functionality. In this
1096 // scenario native_vertex_array_object must be false.
1097 EXPECT_THAT(info_->extensions(),
1098 HasSubstr("GL_OES_vertex_array_object"));
1099 EXPECT_FALSE(info_->feature_flags().native_vertex_array_object);
1102 TEST_P(FeatureInfoTest, InitializeOES_element_index_uint) {
1103 SetupInitExpectations("GL_OES_element_index_uint");
1104 EXPECT_THAT(info_->extensions(),
1105 HasSubstr("GL_OES_element_index_uint"));
1106 EXPECT_TRUE(info_->validators()->index_type.IsValid(GL_UNSIGNED_INT));
1109 TEST_P(FeatureInfoTest, InitializeVAOsWithClientSideArrays) {
1110 base::CommandLine command_line(0, NULL);
1111 command_line.AppendSwitchASCII(
1112 switches::kGpuDriverBugWorkarounds,
1113 base::IntToString(gpu::USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS));
1114 SetupInitExpectationsWithCommandLine("GL_OES_vertex_array_object",
1115 command_line);
1116 EXPECT_TRUE(info_->workarounds().use_client_side_arrays_for_stream_buffers);
1117 EXPECT_FALSE(info_->feature_flags().native_vertex_array_object);
1120 TEST_P(FeatureInfoTest, InitializeEXT_blend_minmax) {
1121 SetupInitExpectations("GL_EXT_blend_minmax");
1122 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_blend_minmax"));
1123 EXPECT_TRUE(info_->validators()->equation.IsValid(GL_MIN_EXT));
1124 EXPECT_TRUE(info_->validators()->equation.IsValid(GL_MAX_EXT));
1127 TEST_P(FeatureInfoTest, InitializeEXT_frag_depth) {
1128 SetupInitExpectations("GL_EXT_frag_depth");
1129 EXPECT_TRUE(info_->feature_flags().ext_frag_depth);
1130 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_frag_depth"));
1133 TEST_P(FeatureInfoTest, InitializeEXT_shader_texture_lod) {
1134 SetupInitExpectations("GL_EXT_shader_texture_lod");
1135 EXPECT_TRUE(info_->feature_flags().ext_shader_texture_lod);
1136 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_shader_texture_lod"));
1139 TEST_P(FeatureInfoTest, InitializeEXT_discard_framebuffer) {
1140 SetupInitExpectations("GL_EXT_discard_framebuffer");
1141 EXPECT_TRUE(info_->feature_flags().ext_discard_framebuffer);
1142 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_discard_framebuffer"));
1145 TEST_P(FeatureInfoTest, InitializeSamplersWithARBSamplerObjects) {
1146 SetupInitExpectationsWithGLVersion(
1147 "GL_ARB_sampler_objects", "", "OpenGL 3.0");
1148 EXPECT_TRUE(info_->feature_flags().enable_samplers);
1151 TEST_P(FeatureInfoTest, InitializeWithES3) {
1152 SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 3.0");
1153 EXPECT_TRUE(info_->feature_flags().chromium_framebuffer_multisample);
1154 EXPECT_TRUE(info_->feature_flags().use_core_framebuffer_multisample);
1155 EXPECT_THAT(info_->extensions(),
1156 HasSubstr("GL_CHROMIUM_framebuffer_multisample"));
1157 EXPECT_TRUE(info_->feature_flags().use_async_readpixels);
1158 EXPECT_TRUE(info_->feature_flags().oes_standard_derivatives);
1159 EXPECT_TRUE(info_->feature_flags().oes_depth24);
1160 EXPECT_THAT(info_->extensions(), HasSubstr("GL_GOOGLE_depth_texture"));
1161 EXPECT_THAT(info_->extensions(), HasSubstr("GL_CHROMIUM_depth_texture"));
1162 EXPECT_TRUE(
1163 info_->validators()->texture_internal_format.IsValid(GL_DEPTH_COMPONENT));
1164 EXPECT_TRUE(
1165 info_->validators()->texture_internal_format.IsValid(GL_DEPTH_STENCIL));
1166 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
1167 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_STENCIL));
1168 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
1169 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
1170 EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT_24_8));
1171 EXPECT_TRUE(info_->feature_flags().packed_depth24_stencil8);
1172 EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_depth24"));
1173 EXPECT_TRUE(
1174 info_->validators()->render_buffer_format.IsValid(GL_DEPTH_COMPONENT24));
1175 EXPECT_TRUE(
1176 info_->validators()->render_buffer_format.IsValid(GL_DEPTH24_STENCIL8));
1177 EXPECT_TRUE(
1178 info_->validators()->texture_internal_format.IsValid(GL_DEPTH_STENCIL));
1179 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_STENCIL));
1180 EXPECT_TRUE(info_->feature_flags().npot_ok);
1181 EXPECT_TRUE(info_->feature_flags().native_vertex_array_object);
1182 EXPECT_TRUE(info_->feature_flags().enable_samplers);
1183 EXPECT_TRUE(info_->feature_flags().map_buffer_range);
1184 EXPECT_TRUE(info_->feature_flags().ext_discard_framebuffer);
1185 EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_discard_framebuffer"));
1186 EXPECT_TRUE(info_->feature_flags().chromium_sync_query);
1187 EXPECT_TRUE(gfx::GLFence::IsSupported());
1190 TEST_P(FeatureInfoTest, InitializeWithoutSamplers) {
1191 SetupInitExpectationsWithGLVersion("", "", "OpenGL GL 3.0");
1192 EXPECT_FALSE(info_->feature_flags().enable_samplers);
1195 TEST_P(FeatureInfoTest, ParseDriverBugWorkaroundsSingle) {
1196 base::CommandLine command_line(0, NULL);
1197 command_line.AppendSwitchASCII(
1198 switches::kGpuDriverBugWorkarounds,
1199 base::IntToString(gpu::EXIT_ON_CONTEXT_LOST));
1200 // Workarounds should get parsed without the need for a context.
1201 SetupWithCommandLine(command_line);
1202 EXPECT_TRUE(info_->workarounds().exit_on_context_lost);
1205 TEST_P(FeatureInfoTest, ParseDriverBugWorkaroundsMultiple) {
1206 base::CommandLine command_line(0, NULL);
1207 command_line.AppendSwitchASCII(
1208 switches::kGpuDriverBugWorkarounds,
1209 base::IntToString(gpu::EXIT_ON_CONTEXT_LOST) + "," +
1210 base::IntToString(gpu::MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024) + "," +
1211 base::IntToString(gpu::MAX_TEXTURE_SIZE_LIMIT_4096));
1212 // Workarounds should get parsed without the need for a context.
1213 SetupWithCommandLine(command_line);
1214 EXPECT_TRUE(info_->workarounds().exit_on_context_lost);
1215 EXPECT_EQ(1024, info_->workarounds().max_cube_map_texture_size);
1216 EXPECT_EQ(4096, info_->workarounds().max_texture_size);
1219 TEST_P(FeatureInfoTest, InitializeWithARBSync) {
1220 SetupInitExpectations("GL_ARB_sync");
1221 EXPECT_TRUE(info_->feature_flags().chromium_sync_query);
1222 EXPECT_TRUE(gfx::GLFence::IsSupported());
1225 TEST_P(FeatureInfoTest, InitializeWithNVFence) {
1226 SetupInitExpectations("GL_NV_fence");
1227 EXPECT_TRUE(info_->feature_flags().chromium_sync_query);
1228 EXPECT_TRUE(gfx::GLFence::IsSupported());
1231 TEST_P(FeatureInfoTest, InitializeWithNVDrawBuffers) {
1232 SetupInitExpectationsWithGLVersion("GL_NV_draw_buffers", "", "OpenGL ES 3.0");
1233 EXPECT_TRUE(info_->feature_flags().nv_draw_buffers);
1234 EXPECT_TRUE(info_->feature_flags().ext_draw_buffers);
1237 TEST_P(FeatureInfoTest, InitializeWithPreferredEXTDrawBuffers) {
1238 SetupInitExpectationsWithGLVersion(
1239 "GL_NV_draw_buffers GL_EXT_draw_buffers", "", "OpenGL ES 3.0");
1240 EXPECT_FALSE(info_->feature_flags().nv_draw_buffers);
1241 EXPECT_TRUE(info_->feature_flags().ext_draw_buffers);
1244 TEST_P(FeatureInfoTest, BlendEquationAdvancedDisabled) {
1245 base::CommandLine command_line(0, NULL);
1246 command_line.AppendSwitchASCII(
1247 switches::kGpuDriverBugWorkarounds,
1248 base::IntToString(gpu::DISABLE_BLEND_EQUATION_ADVANCED));
1249 SetupInitExpectationsWithCommandLine(
1250 "GL_KHR_blend_equation_advanced_coherent GL_KHR_blend_equation_advanced",
1251 command_line);
1252 EXPECT_FALSE(info_->feature_flags().blend_equation_advanced);
1253 EXPECT_FALSE(info_->feature_flags().blend_equation_advanced_coherent);
1256 TEST_P(FeatureInfoTest, InitializeCHROMIUM_path_rendering_no_cmdline_switch) {
1257 SetupInitExpectationsWithGLVersion(
1258 "GL_ARB_compatibility GL_NV_path_rendering GL_EXT_direct_state_access",
1259 "", "4.3");
1260 EXPECT_FALSE(info_->feature_flags().chromium_path_rendering);
1261 EXPECT_THAT(info_->extensions(),
1262 Not(HasSubstr("GL_CHROMIUM_path_rendering")));
1265 TEST_P(FeatureInfoTest, InitializeCHROMIUM_path_rendering) {
1266 base::CommandLine command_line(0, NULL);
1267 command_line.AppendSwitch(switches::kEnableGLPathRendering);
1268 SetupInitExpectationsWithGLVersionAndCommandLine(
1269 "GL_ARB_compatibility GL_NV_path_rendering GL_EXT_direct_state_access",
1270 "", "4.3", command_line);
1271 EXPECT_TRUE(info_->feature_flags().chromium_path_rendering);
1272 EXPECT_THAT(info_->extensions(), HasSubstr("GL_CHROMIUM_path_rendering"));
1275 TEST_P(FeatureInfoTest, InitializeCHROMIUM_path_rendering2) {
1276 base::CommandLine command_line(0, NULL);
1277 command_line.AppendSwitch(switches::kEnableGLPathRendering);
1278 SetupInitExpectationsWithGLVersionAndCommandLine(
1279 "GL_NV_path_rendering", "", "OpenGL ES 3.1", command_line);
1280 EXPECT_TRUE(info_->feature_flags().chromium_path_rendering);
1281 EXPECT_THAT(info_->extensions(), HasSubstr("GL_CHROMIUM_path_rendering"));
1284 TEST_P(FeatureInfoTest, InitializeNoCHROMIUM_path_rendering) {
1285 base::CommandLine command_line(0, NULL);
1286 command_line.AppendSwitch(switches::kEnableGLPathRendering);
1287 SetupInitExpectationsWithGLVersionAndCommandLine("GL_ARB_compatibility", "",
1288 "4.3", command_line);
1289 EXPECT_FALSE(info_->feature_flags().chromium_path_rendering);
1290 EXPECT_THAT(info_->extensions(),
1291 Not(HasSubstr("GL_CHROMIUM_path_rendering")));
1294 TEST_P(FeatureInfoTest, InitializeNoCHROMIUM_path_rendering2) {
1295 base::CommandLine command_line(0, NULL);
1296 command_line.AppendSwitch(switches::kEnableGLPathRendering);
1297 SetupInitExpectationsWithGLVersionAndCommandLine(
1298 "GL_ARB_compatibility GL_NV_path_rendering", "", "4.3", command_line);
1299 EXPECT_FALSE(info_->feature_flags().chromium_path_rendering);
1300 EXPECT_THAT(info_->extensions(),
1301 Not(HasSubstr("GL_CHROMIUM_path_rendering")));
1304 TEST_P(FeatureInfoTest, InitializeNoKHR_blend_equation_advanced) {
1305 SetupInitExpectationsWithGLVersion("GL_ARB_compatibility", "", "4.3");
1306 EXPECT_FALSE(info_->feature_flags().blend_equation_advanced);
1307 EXPECT_THAT(info_->extensions(),
1308 Not(HasSubstr("GL_KHR_blend_equation_advanced")));
1311 TEST_P(FeatureInfoTest, InitializeKHR_blend_equations_advanced) {
1312 SetupInitExpectations("GL_KHR_blend_equation_advanced");
1313 EXPECT_THAT(info_->extensions(), HasSubstr("GL_KHR_blend_equation_advanced"));
1314 EXPECT_TRUE(info_->feature_flags().blend_equation_advanced);
1317 TEST_P(FeatureInfoTest, InitializeNV_blend_equations_advanced) {
1318 SetupInitExpectations("GL_NV_blend_equation_advanced");
1319 EXPECT_THAT(info_->extensions(), HasSubstr("GL_KHR_blend_equation_advanced"));
1320 EXPECT_TRUE(info_->feature_flags().blend_equation_advanced);
1323 TEST_P(FeatureInfoTest, InitializeNoKHR_blend_equation_advanced_coherent) {
1324 SetupInitExpectationsWithGLVersion("GL_ARB_compatibility ", "", "4.3");
1325 EXPECT_FALSE(info_->feature_flags().blend_equation_advanced_coherent);
1326 EXPECT_THAT(info_->extensions(),
1327 Not(HasSubstr("GL_KHR_blend_equation_advanced_coherent")));
1330 TEST_P(FeatureInfoTest, InitializeKHR_blend_equations_advanced_coherent) {
1331 SetupInitExpectations("GL_KHR_blend_equation_advanced_coherent");
1332 EXPECT_THAT(info_->extensions(),
1333 HasSubstr("GL_KHR_blend_equation_advanced_coherent"));
1334 EXPECT_TRUE(info_->feature_flags().blend_equation_advanced);
1335 EXPECT_TRUE(info_->feature_flags().blend_equation_advanced_coherent);
1338 TEST_P(FeatureInfoTest, InitializeEXT_texture_rgWithFloat) {
1339 SetupInitExpectations(
1340 "GL_EXT_texture_rg GL_OES_texture_float GL_OES_texture_half_float");
1341 EXPECT_TRUE(info_->feature_flags().ext_texture_rg);
1343 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_RED_EXT));
1344 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_RG_EXT));
1345 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(GL_RED_EXT));
1346 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(GL_RG_EXT));
1347 EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(GL_RED_EXT));
1348 EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(GL_RG_EXT));
1349 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(GL_R8_EXT));
1350 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(GL_RG8_EXT));
1353 TEST_P(FeatureInfoTest, InitializeARB_texture_rgNoFloat) {
1354 SetupInitExpectations("GL_ARB_texture_rg");
1355 EXPECT_TRUE(info_->feature_flags().ext_texture_rg);
1357 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_RED_EXT));
1358 EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_RG_EXT));
1359 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(GL_RED_EXT));
1360 EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(GL_RG_EXT));
1361 EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(GL_RED_EXT));
1362 EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(GL_RG_EXT));
1363 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(GL_R8_EXT));
1364 EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(GL_RG8_EXT));
1367 TEST_P(FeatureInfoTest, InitializeCHROMIUM_ycbcr_422_imageTrue) {
1368 SetupInitExpectations("GL_APPLE_ycbcr_422");
1369 EXPECT_TRUE(info_->feature_flags().chromium_image_ycbcr_422);
1372 } // namespace gles2
1373 } // namespace gpu