Home | History | Annotate | Download | only in service
      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.
      4 
      5 #include "gpu/command_buffer/service/feature_info.h"
      6 
      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_switches.h"
     11 #include "gpu/command_buffer/service/test_helper.h"
     12 #include "gpu/command_buffer/service/texture_manager.h"
     13 #include "gpu/config/gpu_driver_bug_workaround_type.h"
     14 #include "testing/gtest/include/gtest/gtest.h"
     15 #include "ui/gl/gl_implementation.h"
     16 #include "ui/gl/gl_mock.h"
     17 
     18 using ::gfx::MockGLInterface;
     19 using ::testing::_;
     20 using ::testing::DoAll;
     21 using ::testing::HasSubstr;
     22 using ::testing::InSequence;
     23 using ::testing::MatcherCast;
     24 using ::testing::Not;
     25 using ::testing::Pointee;
     26 using ::testing::Return;
     27 using ::testing::SetArrayArgument;
     28 using ::testing::SetArgumentPointee;
     29 using ::testing::StrEq;
     30 using ::testing::StrictMock;
     31 
     32 namespace gpu {
     33 namespace gles2 {
     34 
     35 namespace {
     36 const char kGLRendererStringANGLE[] = "ANGLE (some renderer)";
     37 }  // anonymous namespace
     38 
     39 class FeatureInfoTest : public testing::Test {
     40  public:
     41   FeatureInfoTest() {
     42   }
     43 
     44   void SetupInitExpectations(const char* extensions) {
     45     SetupInitExpectationsWithGLVersion(extensions, "", "");
     46   }
     47 
     48   void SetupInitExpectationsWithGLVersion(
     49       const char* extensions, const char* renderer, const char* version) {
     50     TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
     51         gl_.get(), extensions, renderer, version);
     52     info_ = new FeatureInfo();
     53     info_->Initialize();
     54   }
     55 
     56   void SetupWithCommandLine(const CommandLine& command_line) {
     57     info_ = new FeatureInfo(command_line);
     58   }
     59 
     60   void SetupInitExpectationsWithCommandLine(
     61       const char* extensions, const CommandLine& command_line) {
     62     TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
     63         gl_.get(), extensions, "", "");
     64     info_ = new FeatureInfo(command_line);
     65     info_->Initialize();
     66   }
     67 
     68   void SetupWithoutInit() {
     69     info_ = new FeatureInfo();
     70   }
     71 
     72  protected:
     73   virtual void SetUp() {
     74     gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>());
     75     ::gfx::GLInterface::SetGLInterface(gl_.get());
     76   }
     77 
     78   virtual void TearDown() {
     79     info_ = NULL;
     80     ::gfx::GLInterface::SetGLInterface(NULL);
     81     gl_.reset();
     82   }
     83 
     84   scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_;
     85   scoped_refptr<FeatureInfo> info_;
     86 };
     87 
     88 namespace {
     89 
     90 struct FormatInfo {
     91    GLenum format;
     92    const GLenum* types;
     93    size_t count;
     94 };
     95 
     96 }  // anonymous namespace.
     97 
     98 TEST_F(FeatureInfoTest, Basic) {
     99   SetupWithoutInit();
    100   // Test it starts off uninitialized.
    101   EXPECT_FALSE(info_->feature_flags().chromium_framebuffer_multisample);
    102   EXPECT_FALSE(info_->feature_flags().use_core_framebuffer_multisample);
    103   EXPECT_FALSE(info_->feature_flags().multisampled_render_to_texture);
    104   EXPECT_FALSE(info_->feature_flags(
    105       ).use_img_for_multisampled_render_to_texture);
    106   EXPECT_FALSE(info_->feature_flags().oes_standard_derivatives);
    107   EXPECT_FALSE(info_->feature_flags().npot_ok);
    108   EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
    109   EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
    110   EXPECT_FALSE(info_->feature_flags().oes_egl_image_external);
    111   EXPECT_FALSE(info_->feature_flags().oes_depth24);
    112   EXPECT_FALSE(info_->feature_flags().packed_depth24_stencil8);
    113   EXPECT_FALSE(info_->feature_flags().chromium_stream_texture);
    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);
    129 
    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);
    135 
    136   // Test good types.
    137   {
    138     static const GLenum kAlphaTypes[] = {
    139         GL_UNSIGNED_BYTE,
    140     };
    141     static const GLenum kRGBTypes[] = {
    142         GL_UNSIGNED_BYTE,
    143         GL_UNSIGNED_SHORT_5_6_5,
    144     };
    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,
    149     };
    150     static const GLenum kLuminanceTypes[] = {
    151         GL_UNSIGNED_BYTE,
    152     };
    153     static const GLenum kLuminanceAlphaTypes[] = {
    154         GL_UNSIGNED_BYTE,
    155     };
    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), } ,
    163     };
    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]));
    170       }
    171     }
    172   }
    173 
    174   // Test some bad types
    175   {
    176     static const GLenum kAlphaTypes[] = {
    177         GL_UNSIGNED_SHORT_5_5_5_1,
    178         GL_FLOAT,
    179     };
    180     static const GLenum kRGBTypes[] = {
    181         GL_UNSIGNED_SHORT_4_4_4_4,
    182         GL_FLOAT,
    183     };
    184     static const GLenum kRGBATypes[] = {
    185         GL_UNSIGNED_SHORT_5_6_5,
    186         GL_FLOAT,
    187     };
    188     static const GLenum kLuminanceTypes[] = {
    189         GL_UNSIGNED_SHORT_4_4_4_4,
    190         GL_FLOAT,
    191     };
    192     static const GLenum kLuminanceAlphaTypes[] = {
    193         GL_UNSIGNED_SHORT_5_5_5_1,
    194         GL_FLOAT,
    195     };
    196     static const GLenum kBGRATypes[] = {
    197         GL_UNSIGNED_BYTE,
    198         GL_UNSIGNED_SHORT_5_6_5,
    199         GL_FLOAT,
    200     };
    201     static const GLenum kDepthTypes[] = {
    202         GL_UNSIGNED_BYTE,
    203         GL_UNSIGNED_SHORT,
    204         GL_UNSIGNED_INT,
    205         GL_FLOAT,
    206     };
    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), },
    216     };
    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]));
    223       }
    224     }
    225   }
    226 }
    227 
    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"));
    235 
    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_FALSE(info_->feature_flags().npot_ok);
    251   EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
    252       GL_COMPRESSED_RGB_S3TC_DXT1_EXT));
    253   EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
    254       GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
    255   EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
    256       GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
    257   EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
    258       GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
    259   EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
    260       GL_ETC1_RGB8_OES));
    261   EXPECT_FALSE(info_->validators()->read_pixel_format.IsValid(
    262       GL_BGRA_EXT));
    263   EXPECT_FALSE(info_->validators()->texture_parameter.IsValid(
    264       GL_TEXTURE_MAX_ANISOTROPY_EXT));
    265   EXPECT_FALSE(info_->validators()->g_l_state.IsValid(
    266       GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
    267   EXPECT_FALSE(info_->validators()->frame_buffer_target.IsValid(
    268       GL_READ_FRAMEBUFFER_EXT));
    269   EXPECT_FALSE(info_->validators()->frame_buffer_target.IsValid(
    270       GL_DRAW_FRAMEBUFFER_EXT));
    271   EXPECT_FALSE(info_->validators()->g_l_state.IsValid(
    272       GL_READ_FRAMEBUFFER_BINDING_EXT));
    273   EXPECT_FALSE(info_->validators()->render_buffer_parameter.IsValid(
    274       GL_MAX_SAMPLES_EXT));
    275   EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
    276       GL_DEPTH_COMPONENT));
    277   EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
    278   EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
    279   EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
    280   EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
    281       GL_DEPTH24_STENCIL8));
    282   EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
    283       GL_DEPTH_STENCIL));
    284   EXPECT_FALSE(info_->validators()->texture_format.IsValid(
    285       GL_DEPTH_STENCIL));
    286   EXPECT_FALSE(info_->validators()->pixel_type.IsValid(
    287       GL_UNSIGNED_INT_24_8));
    288   EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
    289       GL_DEPTH_COMPONENT24));
    290   EXPECT_FALSE(info_->validators()->texture_parameter.IsValid(
    291       GL_TEXTURE_USAGE_ANGLE));
    292   EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
    293       GL_DEPTH_COMPONENT16));
    294   EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
    295       GL_DEPTH_COMPONENT32_OES));
    296   EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
    297       GL_DEPTH24_STENCIL8_OES));
    298 }
    299 
    300 TEST_F(FeatureInfoTest, InitializeWithANGLE) {
    301   SetupInitExpectationsWithGLVersion("", kGLRendererStringANGLE, "");
    302   EXPECT_TRUE(info_->feature_flags().is_angle);
    303 }
    304 
    305 TEST_F(FeatureInfoTest, InitializeNPOTExtensionGLES) {
    306   SetupInitExpectations("GL_OES_texture_npot");
    307   EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_npot"));
    308   EXPECT_TRUE(info_->feature_flags().npot_ok);
    309 }
    310 
    311 TEST_F(FeatureInfoTest, InitializeNPOTExtensionGL) {
    312   SetupInitExpectations("GL_ARB_texture_non_power_of_two");
    313   EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_npot"));
    314   EXPECT_TRUE(info_->feature_flags().npot_ok);
    315 }
    316 
    317 TEST_F(FeatureInfoTest, InitializeDXTExtensionGLES2) {
    318   SetupInitExpectations("GL_EXT_texture_compression_dxt1");
    319   EXPECT_THAT(info_->extensions(),
    320               HasSubstr("GL_EXT_texture_compression_dxt1"));
    321   EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
    322       GL_COMPRESSED_RGB_S3TC_DXT1_EXT));
    323   EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
    324       GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
    325   EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
    326       GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
    327   EXPECT_FALSE(info_->validators()->compressed_texture_format.IsValid(
    328       GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
    329 }
    330 
    331 TEST_F(FeatureInfoTest, InitializeDXTExtensionGL) {
    332   SetupInitExpectations("GL_EXT_texture_compression_s3tc");
    333   EXPECT_THAT(info_->extensions(),
    334               HasSubstr("GL_EXT_texture_compression_dxt1"));
    335   EXPECT_THAT(info_->extensions(),
    336               HasSubstr("GL_CHROMIUM_texture_compression_dxt3"));
    337   EXPECT_THAT(info_->extensions(),
    338               HasSubstr("GL_CHROMIUM_texture_compression_dxt5"));
    339   EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
    340       GL_COMPRESSED_RGB_S3TC_DXT1_EXT));
    341   EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
    342       GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
    343   EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
    344       GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
    345   EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
    346       GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
    347 }
    348 
    349 TEST_F(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888GLES2) {
    350   SetupInitExpectations("GL_EXT_texture_format_BGRA8888");
    351   EXPECT_THAT(info_->extensions(),
    352               HasSubstr("GL_EXT_texture_format_BGRA8888"));
    353   EXPECT_TRUE(info_->validators()->texture_format.IsValid(
    354       GL_BGRA_EXT));
    355   EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
    356       GL_BGRA_EXT));
    357   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_BGRA_EXT).IsValid(
    358       GL_UNSIGNED_BYTE));
    359   EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
    360       GL_BGRA8_EXT));
    361 }
    362 
    363 TEST_F(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888GL) {
    364   SetupInitExpectations("GL_EXT_bgra");
    365   EXPECT_THAT(info_->extensions(),
    366               HasSubstr("GL_EXT_texture_format_BGRA8888"));
    367   EXPECT_THAT(info_->extensions(),
    368               HasSubstr("GL_EXT_read_format_bgra"));
    369   EXPECT_THAT(info_->extensions(),
    370               HasSubstr("GL_CHROMIUM_renderbuffer_format_BGRA8888"));
    371   EXPECT_TRUE(info_->validators()->texture_format.IsValid(
    372       GL_BGRA_EXT));
    373   EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
    374       GL_BGRA_EXT));
    375   EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(
    376       GL_BGRA_EXT));
    377   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_BGRA_EXT).IsValid(
    378       GL_UNSIGNED_BYTE));
    379   EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
    380       GL_BGRA8_EXT));
    381 }
    382 
    383 TEST_F(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888Apple) {
    384   SetupInitExpectations("GL_APPLE_texture_format_BGRA8888");
    385   EXPECT_THAT(info_->extensions(),
    386               HasSubstr("GL_EXT_texture_format_BGRA8888"));
    387   EXPECT_TRUE(info_->validators()->texture_format.IsValid(
    388       GL_BGRA_EXT));
    389   EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
    390       GL_BGRA_EXT));
    391   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_BGRA_EXT).IsValid(
    392       GL_UNSIGNED_BYTE));
    393   EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
    394       GL_BGRA8_EXT));
    395 }
    396 
    397 TEST_F(FeatureInfoTest, InitializeEXT_read_format_bgra) {
    398   SetupInitExpectations("GL_EXT_read_format_bgra");
    399   EXPECT_THAT(info_->extensions(),
    400               HasSubstr("GL_EXT_read_format_bgra"));
    401   EXPECT_FALSE(info_->validators()->texture_format.IsValid(
    402       GL_BGRA_EXT));
    403   EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
    404       GL_BGRA_EXT));
    405   EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(
    406       GL_BGRA_EXT));
    407   EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
    408       GL_BGRA8_EXT));
    409 }
    410 
    411 TEST_F(FeatureInfoTest, InitializeOES_texture_floatGLES2) {
    412   SetupInitExpectations("GL_OES_texture_float");
    413   EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
    414   EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
    415   EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_float"));
    416   EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_half_float")));
    417   EXPECT_THAT(info_->extensions(),
    418               Not(HasSubstr("GL_OES_texture_float_linear")));
    419   EXPECT_THAT(info_->extensions(),
    420               Not(HasSubstr("GL_OES_texture_half_float_linear")));
    421   EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
    422   EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
    423   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
    424       GL_FLOAT));
    425   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
    426       GL_FLOAT));
    427   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
    428       GL_FLOAT));
    429   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
    430       GL_FLOAT));
    431   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
    432       GL_FLOAT));
    433   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
    434       GL_HALF_FLOAT_OES));
    435   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
    436       GL_HALF_FLOAT_OES));
    437   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
    438       GL_HALF_FLOAT_OES));
    439   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
    440       GL_HALF_FLOAT_OES));
    441   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
    442       GL_HALF_FLOAT_OES));
    443 }
    444 
    445 TEST_F(FeatureInfoTest, InitializeOES_texture_float_linearGLES2) {
    446   SetupInitExpectations("GL_OES_texture_float GL_OES_texture_float_linear");
    447   EXPECT_TRUE(info_->feature_flags().enable_texture_float_linear);
    448   EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
    449   EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_float"));
    450   EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_half_float")));
    451   EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_float_linear"));
    452   EXPECT_THAT(info_->extensions(),
    453               Not(HasSubstr("GL_OES_texture_half_float_linear")));
    454   EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
    455   EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
    456   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
    457       GL_FLOAT));
    458   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
    459       GL_FLOAT));
    460   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
    461       GL_FLOAT));
    462   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
    463       GL_FLOAT));
    464   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
    465       GL_FLOAT));
    466   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
    467       GL_HALF_FLOAT_OES));
    468   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
    469       GL_HALF_FLOAT_OES));
    470   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
    471       GL_HALF_FLOAT_OES));
    472   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
    473       GL_HALF_FLOAT_OES));
    474   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
    475       GL_HALF_FLOAT_OES));
    476 }
    477 
    478 TEST_F(FeatureInfoTest, InitializeOES_texture_half_floatGLES2) {
    479   SetupInitExpectations("GL_OES_texture_half_float");
    480   EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
    481   EXPECT_FALSE(info_->feature_flags().enable_texture_half_float_linear);
    482   EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_float")));
    483   EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_half_float"));
    484   EXPECT_THAT(info_->extensions(),
    485               Not(HasSubstr("GL_OES_texture_float_linear")));
    486   EXPECT_THAT(info_->extensions(),
    487               Not(HasSubstr("GL_OES_texture_half_float_linear")));
    488   EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
    489   EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
    490   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
    491       GL_FLOAT));
    492   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
    493       GL_FLOAT));
    494   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
    495       GL_FLOAT));
    496   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
    497       GL_FLOAT));
    498   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
    499       GL_FLOAT));
    500   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
    501       GL_HALF_FLOAT_OES));
    502   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
    503       GL_HALF_FLOAT_OES));
    504   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
    505       GL_HALF_FLOAT_OES));
    506   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
    507       GL_HALF_FLOAT_OES));
    508   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
    509       GL_HALF_FLOAT_OES));
    510 }
    511 
    512 TEST_F(FeatureInfoTest, InitializeOES_texture_half_float_linearGLES2) {
    513   SetupInitExpectations(
    514       "GL_OES_texture_half_float GL_OES_texture_half_float_linear");
    515   EXPECT_FALSE(info_->feature_flags().enable_texture_float_linear);
    516   EXPECT_TRUE(info_->feature_flags().enable_texture_half_float_linear);
    517   EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_OES_texture_float")));
    518   EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_half_float"));
    519   EXPECT_THAT(info_->extensions(),
    520               Not(HasSubstr("GL_OES_texture_float_linear")));
    521   EXPECT_THAT(info_->extensions(),
    522               HasSubstr("GL_OES_texture_half_float_linear"));
    523   EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_FLOAT));
    524   EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES));
    525   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
    526       GL_FLOAT));
    527   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
    528       GL_FLOAT));
    529   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
    530       GL_FLOAT));
    531   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
    532       GL_FLOAT));
    533   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
    534       GL_FLOAT));
    535   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_ALPHA).IsValid(
    536       GL_HALF_FLOAT_OES));
    537   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGB).IsValid(
    538       GL_HALF_FLOAT_OES));
    539   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_RGBA).IsValid(
    540       GL_HALF_FLOAT_OES));
    541   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE).IsValid(
    542       GL_HALF_FLOAT_OES));
    543   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_LUMINANCE_ALPHA).IsValid(
    544       GL_HALF_FLOAT_OES));
    545 }
    546 
    547 TEST_F(FeatureInfoTest, InitializeEXT_framebuffer_multisample) {
    548   SetupInitExpectations("GL_EXT_framebuffer_multisample");
    549   EXPECT_TRUE(info_->feature_flags().chromium_framebuffer_multisample);
    550   EXPECT_THAT(info_->extensions(),
    551               HasSubstr("GL_CHROMIUM_framebuffer_multisample"));
    552   EXPECT_TRUE(info_->validators()->frame_buffer_target.IsValid(
    553       GL_READ_FRAMEBUFFER_EXT));
    554   EXPECT_TRUE(info_->validators()->frame_buffer_target.IsValid(
    555       GL_DRAW_FRAMEBUFFER_EXT));
    556   EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
    557       GL_READ_FRAMEBUFFER_BINDING_EXT));
    558   EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
    559       GL_MAX_SAMPLES_EXT));
    560   EXPECT_TRUE(info_->validators()->render_buffer_parameter.IsValid(
    561       GL_RENDERBUFFER_SAMPLES_EXT));
    562 }
    563 
    564 TEST_F(FeatureInfoTest, InitializeANGLE_framebuffer_multisample) {
    565   SetupInitExpectationsWithGLVersion(
    566       "GL_ANGLE_framebuffer_multisample", kGLRendererStringANGLE, "");
    567   EXPECT_TRUE(info_->feature_flags().chromium_framebuffer_multisample);
    568   EXPECT_THAT(info_->extensions(),
    569               HasSubstr("GL_CHROMIUM_framebuffer_multisample"));
    570   EXPECT_TRUE(info_->validators()->frame_buffer_target.IsValid(
    571       GL_READ_FRAMEBUFFER_EXT));
    572   EXPECT_TRUE(info_->validators()->frame_buffer_target.IsValid(
    573       GL_DRAW_FRAMEBUFFER_EXT));
    574   EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
    575       GL_READ_FRAMEBUFFER_BINDING_EXT));
    576   EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
    577       GL_MAX_SAMPLES_EXT));
    578   EXPECT_TRUE(info_->validators()->render_buffer_parameter.IsValid(
    579       GL_RENDERBUFFER_SAMPLES_EXT));
    580 }
    581 
    582 // We don't allow ANGLE_framebuffer_multisample on non-ANGLE implementations,
    583 // because we wouldn't be choosing the right driver entry point and because the
    584 // extension was falsely advertised on some Android devices (crbug.com/165736).
    585 TEST_F(FeatureInfoTest, InitializeANGLE_framebuffer_multisampleWithoutANGLE) {
    586   SetupInitExpectations("GL_ANGLE_framebuffer_multisample");
    587   EXPECT_FALSE(info_->feature_flags().chromium_framebuffer_multisample);
    588   EXPECT_THAT(info_->extensions(),
    589               Not(HasSubstr("GL_CHROMIUM_framebuffer_multisample")));
    590   EXPECT_FALSE(info_->validators()->frame_buffer_target.IsValid(
    591       GL_READ_FRAMEBUFFER_EXT));
    592   EXPECT_FALSE(info_->validators()->frame_buffer_target.IsValid(
    593       GL_DRAW_FRAMEBUFFER_EXT));
    594   EXPECT_FALSE(info_->validators()->g_l_state.IsValid(
    595       GL_READ_FRAMEBUFFER_BINDING_EXT));
    596   EXPECT_FALSE(info_->validators()->g_l_state.IsValid(
    597       GL_MAX_SAMPLES_EXT));
    598   EXPECT_FALSE(info_->validators()->render_buffer_parameter.IsValid(
    599       GL_RENDERBUFFER_SAMPLES_EXT));
    600 }
    601 
    602 TEST_F(FeatureInfoTest, InitializeEXT_multisampled_render_to_texture) {
    603   SetupInitExpectations("GL_EXT_multisampled_render_to_texture");
    604   EXPECT_TRUE(info_->feature_flags(
    605       ).multisampled_render_to_texture);
    606   EXPECT_FALSE(info_->feature_flags(
    607       ).use_img_for_multisampled_render_to_texture);
    608   EXPECT_THAT(info_->extensions(),
    609               HasSubstr("GL_EXT_multisampled_render_to_texture"));
    610   EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
    611       GL_MAX_SAMPLES_EXT));
    612   EXPECT_TRUE(info_->validators()->render_buffer_parameter.IsValid(
    613       GL_RENDERBUFFER_SAMPLES_EXT));
    614   EXPECT_TRUE(info_->validators()->frame_buffer_parameter.IsValid(
    615       GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT));
    616 }
    617 
    618 TEST_F(FeatureInfoTest, InitializeIMG_multisampled_render_to_texture) {
    619   SetupInitExpectations("GL_IMG_multisampled_render_to_texture");
    620   EXPECT_TRUE(info_->feature_flags(
    621       ).use_img_for_multisampled_render_to_texture);
    622   EXPECT_TRUE(info_->feature_flags(
    623       ).use_img_for_multisampled_render_to_texture);
    624   EXPECT_THAT(info_->extensions(),
    625               HasSubstr("GL_EXT_multisampled_render_to_texture"));
    626   EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
    627       GL_MAX_SAMPLES_EXT));
    628   EXPECT_TRUE(info_->validators()->render_buffer_parameter.IsValid(
    629       GL_RENDERBUFFER_SAMPLES_EXT));
    630   EXPECT_TRUE(info_->validators()->frame_buffer_parameter.IsValid(
    631       GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT));
    632 }
    633 
    634 TEST_F(FeatureInfoTest, InitializeEXT_texture_filter_anisotropic) {
    635   SetupInitExpectations("GL_EXT_texture_filter_anisotropic");
    636   EXPECT_THAT(info_->extensions(),
    637               HasSubstr("GL_EXT_texture_filter_anisotropic"));
    638   EXPECT_TRUE(info_->validators()->texture_parameter.IsValid(
    639       GL_TEXTURE_MAX_ANISOTROPY_EXT));
    640   EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
    641       GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
    642 }
    643 
    644 TEST_F(FeatureInfoTest, InitializeEXT_ARB_depth_texture) {
    645   SetupInitExpectations("GL_ARB_depth_texture");
    646   EXPECT_THAT(info_->extensions(),
    647               HasSubstr("GL_GOOGLE_depth_texture"));
    648   EXPECT_THAT(info_->extensions(),
    649               HasSubstr("GL_CHROMIUM_depth_texture"));
    650   EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
    651       GL_DEPTH_COMPONENT));
    652   EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
    653   EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_STENCIL));
    654   EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
    655   EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
    656   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
    657       GL_UNSIGNED_SHORT));
    658   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
    659       GL_UNSIGNED_INT));
    660   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_DEPTH_STENCIL).IsValid(
    661       GL_UNSIGNED_INT_24_8));
    662 }
    663 
    664 TEST_F(FeatureInfoTest, InitializeOES_ARB_depth_texture) {
    665   SetupInitExpectations("GL_OES_depth_texture");
    666   EXPECT_THAT(info_->extensions(),
    667               HasSubstr("GL_GOOGLE_depth_texture"));
    668   EXPECT_THAT(info_->extensions(),
    669               HasSubstr("GL_CHROMIUM_depth_texture"));
    670   EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
    671       GL_DEPTH_COMPONENT));
    672   EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
    673   EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_STENCIL));
    674   EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
    675   EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
    676   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
    677       GL_UNSIGNED_SHORT));
    678   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
    679       GL_UNSIGNED_INT));
    680   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_DEPTH_STENCIL).IsValid(
    681       GL_UNSIGNED_INT_24_8));
    682 }
    683 
    684 TEST_F(FeatureInfoTest, InitializeANGLE_depth_texture) {
    685   SetupInitExpectations("GL_ANGLE_depth_texture");
    686   EXPECT_THAT(info_->extensions(),
    687               HasSubstr("GL_GOOGLE_depth_texture"));
    688   EXPECT_THAT(info_->extensions(),
    689               HasSubstr("GL_CHROMIUM_depth_texture"));
    690   EXPECT_THAT(info_->extensions(),
    691               Not(HasSubstr("GL_ANGLE_depth_texture")));
    692   EXPECT_TRUE(info_->feature_flags().angle_depth_texture);
    693   EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
    694       GL_DEPTH_COMPONENT));
    695   EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
    696   EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_STENCIL));
    697   EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
    698   EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
    699   EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
    700       GL_DEPTH_COMPONENT16));
    701   EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
    702       GL_DEPTH_COMPONENT32_OES));
    703   EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid(
    704       GL_DEPTH24_STENCIL8_OES));
    705   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
    706       GL_UNSIGNED_SHORT));
    707   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
    708       GL_UNSIGNED_INT));
    709   EXPECT_FALSE(info_->GetTextureFormatValidator(GL_DEPTH_STENCIL).IsValid(
    710       GL_UNSIGNED_INT_24_8));
    711 }
    712 
    713 TEST_F(FeatureInfoTest, InitializeEXT_packed_depth_stencil) {
    714   SetupInitExpectations("GL_EXT_packed_depth_stencil");
    715   EXPECT_THAT(info_->extensions(),
    716               HasSubstr("GL_OES_packed_depth_stencil"));
    717   EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
    718       GL_DEPTH24_STENCIL8));
    719   EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
    720       GL_DEPTH_COMPONENT));
    721   EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
    722   EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
    723   EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
    724 }
    725 
    726 TEST_F(FeatureInfoTest, InitializeOES_packed_depth_stencil) {
    727   SetupInitExpectations("GL_OES_packed_depth_stencil");
    728   EXPECT_THAT(info_->extensions(),
    729               HasSubstr("GL_OES_packed_depth_stencil"));
    730   EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
    731       GL_DEPTH24_STENCIL8));
    732   EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
    733       GL_DEPTH_COMPONENT));
    734   EXPECT_FALSE(info_->validators()->texture_format.IsValid(GL_DEPTH_COMPONENT));
    735   EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT));
    736   EXPECT_FALSE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT));
    737 }
    738 
    739 TEST_F(FeatureInfoTest,
    740        InitializeOES_packed_depth_stencil_and_GL_ARB_depth_texture) {
    741   SetupInitExpectations("GL_OES_packed_depth_stencil GL_ARB_depth_texture");
    742   EXPECT_THAT(info_->extensions(),
    743               HasSubstr("GL_OES_packed_depth_stencil"));
    744   EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
    745       GL_DEPTH24_STENCIL8));
    746   EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
    747       GL_DEPTH_STENCIL));
    748   EXPECT_TRUE(info_->validators()->texture_format.IsValid(
    749       GL_DEPTH_STENCIL));
    750   EXPECT_TRUE(info_->validators()->pixel_type.IsValid(
    751       GL_UNSIGNED_INT_24_8));
    752   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
    753       GL_UNSIGNED_SHORT));
    754   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT).IsValid(
    755       GL_UNSIGNED_INT));
    756   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_STENCIL).IsValid(
    757       GL_UNSIGNED_INT_24_8));
    758 }
    759 
    760 TEST_F(FeatureInfoTest, InitializeOES_depth24) {
    761   SetupInitExpectations("GL_OES_depth24");
    762   EXPECT_TRUE(info_->feature_flags().oes_depth24);
    763   EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_depth24"));
    764   EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
    765       GL_DEPTH_COMPONENT24));
    766 }
    767 
    768 TEST_F(FeatureInfoTest, InitializeOES_standard_derivatives) {
    769   SetupInitExpectations("GL_OES_standard_derivatives");
    770   EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_standard_derivatives"));
    771   EXPECT_TRUE(info_->feature_flags().oes_standard_derivatives);
    772   EXPECT_TRUE(info_->validators()->hint_target.IsValid(
    773       GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES));
    774   EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
    775       GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES));
    776 }
    777 
    778 TEST_F(FeatureInfoTest, InitializeOES_rgb8_rgba8) {
    779   SetupInitExpectations("GL_OES_rgb8_rgba8");
    780   EXPECT_THAT(info_->extensions(),
    781               HasSubstr("GL_OES_rgb8_rgba8"));
    782   EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
    783       GL_RGB8_OES));
    784   EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
    785       GL_RGBA8_OES));
    786 }
    787 
    788 TEST_F(FeatureInfoTest, InitializeOES_EGL_image_external) {
    789   SetupInitExpectations("GL_OES_EGL_image_external");
    790   EXPECT_THAT(info_->extensions(),
    791               HasSubstr("GL_OES_EGL_image_external"));
    792   EXPECT_TRUE(info_->feature_flags().oes_egl_image_external);
    793   EXPECT_TRUE(info_->validators()->texture_bind_target.IsValid(
    794       GL_TEXTURE_EXTERNAL_OES));
    795   EXPECT_TRUE(info_->validators()->get_tex_param_target.IsValid(
    796       GL_TEXTURE_EXTERNAL_OES));
    797   EXPECT_TRUE(info_->validators()->texture_parameter.IsValid(
    798       GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES));
    799   EXPECT_TRUE(info_->validators()->g_l_state.IsValid(
    800       GL_TEXTURE_BINDING_EXTERNAL_OES));
    801 }
    802 
    803 TEST_F(FeatureInfoTest, InitializeOES_compressed_ETC1_RGB8_texture) {
    804   SetupInitExpectations("GL_OES_compressed_ETC1_RGB8_texture");
    805   EXPECT_THAT(info_->extensions(),
    806               HasSubstr("GL_OES_compressed_ETC1_RGB8_texture"));
    807   EXPECT_TRUE(info_->validators()->compressed_texture_format.IsValid(
    808       GL_ETC1_RGB8_OES));
    809   EXPECT_FALSE(info_->validators()->texture_internal_format.IsValid(
    810       GL_ETC1_RGB8_OES));
    811 }
    812 
    813 TEST_F(FeatureInfoTest, InitializeCHROMIUM_stream_texture) {
    814   SetupInitExpectations("GL_CHROMIUM_stream_texture");
    815   EXPECT_THAT(info_->extensions(),
    816               HasSubstr("GL_CHROMIUM_stream_texture"));
    817   EXPECT_TRUE(info_->feature_flags().chromium_stream_texture);
    818 }
    819 
    820 TEST_F(FeatureInfoTest, InitializeEXT_occlusion_query_boolean) {
    821   SetupInitExpectations("GL_EXT_occlusion_query_boolean");
    822   EXPECT_THAT(info_->extensions(),
    823               HasSubstr("GL_EXT_occlusion_query_boolean"));
    824   EXPECT_TRUE(info_->feature_flags().occlusion_query_boolean);
    825   EXPECT_FALSE(info_->feature_flags(
    826       ).use_arb_occlusion_query2_for_occlusion_query_boolean);
    827   EXPECT_FALSE(info_->feature_flags(
    828       ).use_arb_occlusion_query_for_occlusion_query_boolean);
    829 }
    830 
    831 TEST_F(FeatureInfoTest, InitializeARB_occlusion_query) {
    832   SetupInitExpectations("GL_ARB_occlusion_query");
    833   EXPECT_THAT(info_->extensions(),
    834               HasSubstr("GL_EXT_occlusion_query_boolean"));
    835   EXPECT_TRUE(info_->feature_flags().occlusion_query_boolean);
    836   EXPECT_FALSE(info_->feature_flags(
    837       ).use_arb_occlusion_query2_for_occlusion_query_boolean);
    838   EXPECT_TRUE(info_->feature_flags(
    839       ).use_arb_occlusion_query_for_occlusion_query_boolean);
    840 }
    841 
    842 TEST_F(FeatureInfoTest, InitializeARB_occlusion_query2) {
    843   SetupInitExpectations("GL_ARB_occlusion_query2 GL_ARB_occlusion_query2");
    844   EXPECT_THAT(info_->extensions(),
    845               HasSubstr("GL_EXT_occlusion_query_boolean"));
    846   EXPECT_TRUE(info_->feature_flags().occlusion_query_boolean);
    847   EXPECT_TRUE(info_->feature_flags(
    848       ).use_arb_occlusion_query2_for_occlusion_query_boolean);
    849   EXPECT_FALSE(info_->feature_flags(
    850       ).use_arb_occlusion_query_for_occlusion_query_boolean);
    851 }
    852 
    853 TEST_F(FeatureInfoTest, InitializeOES_vertex_array_object) {
    854   SetupInitExpectations("GL_OES_vertex_array_object");
    855   EXPECT_THAT(info_->extensions(),
    856       HasSubstr("GL_OES_vertex_array_object"));
    857   EXPECT_TRUE(info_->feature_flags().native_vertex_array_object);
    858 }
    859 
    860 TEST_F(FeatureInfoTest, InitializeARB_vertex_array_object) {
    861   SetupInitExpectations("GL_ARB_vertex_array_object");
    862   EXPECT_THAT(info_->extensions(),
    863       HasSubstr("GL_OES_vertex_array_object"));
    864   EXPECT_TRUE(info_->feature_flags().native_vertex_array_object);
    865 }
    866 
    867 TEST_F(FeatureInfoTest, InitializeAPPLE_vertex_array_object) {
    868   SetupInitExpectations("GL_APPLE_vertex_array_object");
    869   EXPECT_THAT(info_->extensions(),
    870       HasSubstr("GL_OES_vertex_array_object"));
    871   EXPECT_TRUE(info_->feature_flags().native_vertex_array_object);
    872 }
    873 
    874 TEST_F(FeatureInfoTest, InitializeNo_vertex_array_object) {
    875   SetupInitExpectations("");
    876   // Even if the native extensions are not available the implementation
    877   // may still emulate the GL_OES_vertex_array_object functionality. In this
    878   // scenario native_vertex_array_object must be false.
    879   EXPECT_THAT(info_->extensions(),
    880               HasSubstr("GL_OES_vertex_array_object"));
    881   EXPECT_FALSE(info_->feature_flags().native_vertex_array_object);
    882 }
    883 
    884 TEST_F(FeatureInfoTest, InitializeOES_element_index_uint) {
    885   SetupInitExpectations("GL_OES_element_index_uint");
    886   EXPECT_THAT(info_->extensions(),
    887               HasSubstr("GL_OES_element_index_uint"));
    888   EXPECT_TRUE(info_->validators()->index_type.IsValid(GL_UNSIGNED_INT));
    889 }
    890 
    891 TEST_F(FeatureInfoTest, InitializeVAOsWithClientSideArrays) {
    892   CommandLine command_line(0, NULL);
    893   command_line.AppendSwitchASCII(
    894       switches::kGpuDriverBugWorkarounds,
    895       base::IntToString(gpu::USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS));
    896   SetupInitExpectationsWithCommandLine("GL_OES_vertex_array_object",
    897                                        command_line);
    898   EXPECT_TRUE(info_->workarounds().use_client_side_arrays_for_stream_buffers);
    899   EXPECT_FALSE(info_->feature_flags().native_vertex_array_object);
    900 }
    901 
    902 TEST_F(FeatureInfoTest, InitializeEXT_frag_depth) {
    903   SetupInitExpectations("GL_EXT_frag_depth");
    904   EXPECT_TRUE(info_->feature_flags().ext_frag_depth);
    905   EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_frag_depth"));
    906 }
    907 
    908 TEST_F(FeatureInfoTest, InitializeEXT_discard_framebuffer) {
    909   SetupInitExpectations("GL_EXT_discard_framebuffer");
    910   EXPECT_TRUE(info_->feature_flags().ext_discard_framebuffer);
    911   EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_discard_framebuffer"));
    912 }
    913 
    914 TEST_F(FeatureInfoTest, InitializeSamplersWithARBSamplerObjects) {
    915   SetupInitExpectationsWithGLVersion(
    916       "GL_ARB_sampler_objects", "", "OpenGL 3.0");
    917   EXPECT_TRUE(info_->feature_flags().enable_samplers);
    918 }
    919 
    920 TEST_F(FeatureInfoTest, InitializeWithES3) {
    921   SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 3.0");
    922   EXPECT_TRUE(info_->feature_flags().enable_samplers);
    923   EXPECT_TRUE(info_->feature_flags().map_buffer_range);
    924   EXPECT_TRUE(info_->feature_flags().ext_discard_framebuffer);
    925   EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_discard_framebuffer"));
    926   EXPECT_TRUE(info_->feature_flags().chromium_framebuffer_multisample);
    927   EXPECT_TRUE(info_->feature_flags().use_core_framebuffer_multisample);
    928   EXPECT_THAT(info_->extensions(),
    929               HasSubstr("GL_CHROMIUM_framebuffer_multisample"));
    930   EXPECT_FALSE(info_->feature_flags().use_async_readpixels);
    931   EXPECT_TRUE(info_->feature_flags().oes_depth24);
    932   EXPECT_THAT(info_->extensions(), HasSubstr("GL_GOOGLE_depth_texture"));
    933   EXPECT_THAT(info_->extensions(), HasSubstr("GL_CHROMIUM_depth_texture"));
    934   EXPECT_TRUE(info_->validators()->pixel_type.IsValid(GL_UNSIGNED_INT_24_8));
    935   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT)
    936                   .IsValid(GL_UNSIGNED_SHORT));
    937   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_COMPONENT)
    938                   .IsValid(GL_UNSIGNED_INT));
    939   EXPECT_TRUE(info_->GetTextureFormatValidator(GL_DEPTH_STENCIL)
    940                   .IsValid(GL_UNSIGNED_INT_24_8));
    941   EXPECT_TRUE(info_->feature_flags().packed_depth24_stencil8);
    942   EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_depth24"));
    943   EXPECT_TRUE(
    944       info_->validators()->render_buffer_format.IsValid(GL_DEPTH_COMPONENT24));
    945   EXPECT_TRUE(
    946       info_->validators()->render_buffer_format.IsValid(GL_DEPTH24_STENCIL8));
    947   EXPECT_TRUE(
    948       info_->validators()->texture_internal_format.IsValid(GL_DEPTH_STENCIL));
    949   EXPECT_TRUE(info_->validators()->texture_format.IsValid(GL_DEPTH_STENCIL));
    950 }
    951 
    952 TEST_F(FeatureInfoTest, InitializeWithoutSamplers) {
    953   SetupInitExpectationsWithGLVersion("", "", "OpenGL GL 3.0");
    954   EXPECT_FALSE(info_->feature_flags().enable_samplers);
    955 }
    956 
    957 TEST_F(FeatureInfoTest, InitializeWithES3AndFences) {
    958   SetupInitExpectationsWithGLVersion("EGL_KHR_fence_sync", "", "OpenGL ES 3.0");
    959   EXPECT_TRUE(info_->feature_flags().use_async_readpixels);
    960 }
    961 
    962 TEST_F(FeatureInfoTest, ParseDriverBugWorkaroundsSingle) {
    963   CommandLine command_line(0, NULL);
    964   command_line.AppendSwitchASCII(
    965       switches::kGpuDriverBugWorkarounds,
    966       base::IntToString(gpu::EXIT_ON_CONTEXT_LOST));
    967   // Workarounds should get parsed without the need for a context.
    968   SetupWithCommandLine(command_line);
    969   EXPECT_TRUE(info_->workarounds().exit_on_context_lost);
    970 }
    971 
    972 TEST_F(FeatureInfoTest, ParseDriverBugWorkaroundsMultiple) {
    973   CommandLine command_line(0, NULL);
    974   command_line.AppendSwitchASCII(
    975       switches::kGpuDriverBugWorkarounds,
    976       base::IntToString(gpu::EXIT_ON_CONTEXT_LOST) + "," +
    977       base::IntToString(gpu::MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024) + "," +
    978       base::IntToString(gpu::MAX_TEXTURE_SIZE_LIMIT_4096));
    979   // Workarounds should get parsed without the need for a context.
    980   SetupWithCommandLine(command_line);
    981   EXPECT_TRUE(info_->workarounds().exit_on_context_lost);
    982   EXPECT_EQ(1024, info_->workarounds().max_cube_map_texture_size);
    983   EXPECT_EQ(4096, info_->workarounds().max_texture_size);
    984 }
    985 
    986 }  // namespace gles2
    987 }  // namespace gpu
    988