diff options
author | dongseong.hwang <dongseong.hwang@intel.com> | 2014-08-27 10:18:18 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-27 17:25:44 +0000 |
commit | 42485ac75b825f1eb30132fa5341985ade5b1eb5 (patch) | |
tree | ccf0b95f23776995367e7d10d99e546249e2e262 /gpu | |
parent | 82fd6e6f80b2e35a1ace01dd25d4a8dcc40b4d75 (diff) | |
download | chromium_src-42485ac75b825f1eb30132fa5341985ade5b1eb5.zip chromium_src-42485ac75b825f1eb30132fa5341985ade5b1eb5.tar.gz chromium_src-42485ac75b825f1eb30132fa5341985ade5b1eb5.tar.bz2 |
gpu: support immutable texture on Linux Mesa driver and GLES3.
Mesa GL driver supports GL_ARB_texture_storage extensions, not
GL_EXT_texture_storage. GLES3 supports glTexStroage2D by default.
GLES3 doesn't support BGRA format for immutable texture without
GL_APPLE_texture_format_bgra8888 extension. We prefer BGRA support
to immutable texture support, so GLES3 enables immutable texture
only if it supports GL_APPLE_texture_format_bgra8888.
In addition, currently the compositor blindly uses BGRA on glTexStorage2D.
It can cause a potential bug so this CL checks BGRA format support
to use BGRA on glTexStorage2D.
This CL makes Intel GPU (e.g. Intel Chromebook) and GLES3 devices with
GL_APPLE_texture_format_bgra8888 extension take advantage of immutable
texture.
BUG=407034
Review URL: https://codereview.chromium.org/499283002
Cr-Commit-Position: refs/heads/master@{#292175}
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/service/feature_info.cc | 17 | ||||
-rw-r--r-- | gpu/command_buffer/service/feature_info_unittest.cc | 181 |
2 files changed, 196 insertions, 2 deletions
diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc index de3eb56..968f2e4 100644 --- a/gpu/command_buffer/service/feature_info.cc +++ b/gpu/command_buffer/service/feature_info.cc @@ -396,10 +396,12 @@ void FeatureInfo::InitializeFeatures() { bool enable_texture_format_bgra8888 = false; bool enable_read_format_bgra = false; bool enable_render_buffer_bgra = false; + bool enable_immutable_texture_format_bgra_on_es3 = + extensions.Contains("GL_APPLE_texture_format_BGRA8888"); // Check if we should allow GL_EXT_texture_format_BGRA8888 if (extensions.Contains("GL_EXT_texture_format_BGRA8888") || - extensions.Contains("GL_APPLE_texture_format_BGRA8888") || + enable_immutable_texture_format_bgra_on_es3 || extensions.Contains("GL_EXT_bgra")) { enable_texture_format_bgra8888 = true; } @@ -692,7 +694,18 @@ void FeatureInfo::InitializeFeatures() { validators_.texture_parameter.AddValue(GL_TEXTURE_USAGE_ANGLE); } - if (extensions.Contains("GL_EXT_texture_storage")) { + // Note: Only APPLE_texture_format_BGRA8888 extension allows BGRA8_EXT in + // ES3's glTexStorage2D. We prefer support BGRA to texture storage. + // So we don't expose GL_EXT_texture_storage when ES3 + + // GL_EXT_texture_format_BGRA8888 because we fail the GL_BGRA8 requirement. + // However we expose GL_EXT_texture_storage when just ES3 because we don't + // claim to handle GL_BGRA8. + bool support_texture_storage_on_es3 = + (is_es3 && enable_immutable_texture_format_bgra_on_es3) || + (is_es3 && !enable_texture_format_bgra8888); + if (extensions.Contains("GL_EXT_texture_storage") || + extensions.Contains("GL_ARB_texture_storage") || + support_texture_storage_on_es3) { feature_flags_.ext_texture_storage = true; AddExtensionString("GL_EXT_texture_storage"); validators_.texture_parameter.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT); diff --git a/gpu/command_buffer/service/feature_info_unittest.cc b/gpu/command_buffer/service/feature_info_unittest.cc index 1010f99..6e2cb46 100644 --- a/gpu/command_buffer/service/feature_info_unittest.cc +++ b/gpu/command_buffer/service/feature_info_unittest.cc @@ -433,6 +433,187 @@ TEST_F(FeatureInfoTest, InitializeEXT_read_format_bgra) { GL_BGRA8_EXT)); } +TEST_F(FeatureInfoTest, InitializeEXT_texture_storage) { + SetupInitExpectations("GL_EXT_texture_storage"); + EXPECT_TRUE(info_->feature_flags().ext_texture_storage); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); + EXPECT_TRUE(info_->validators()->texture_parameter.IsValid( + GL_TEXTURE_IMMUTABLE_FORMAT_EXT)); + EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( + GL_BGRA8_EXT)); + EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( + GL_RGBA32F_EXT)); + EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( + GL_RGB32F_EXT)); + EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( + GL_ALPHA32F_EXT)); + EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( + GL_LUMINANCE32F_EXT)); + EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( + GL_LUMINANCE_ALPHA32F_EXT)); + EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( + GL_RGBA16F_EXT)); + EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( + GL_RGB16F_EXT)); + EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( + GL_ALPHA16F_EXT)); + EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( + GL_LUMINANCE16F_EXT)); + EXPECT_FALSE(info_->validators()->texture_internal_format_storage.IsValid( + GL_LUMINANCE_ALPHA16F_EXT)); +} + +TEST_F(FeatureInfoTest, InitializeARB_texture_storage) { + SetupInitExpectations("GL_ARB_texture_storage"); + EXPECT_TRUE(info_->feature_flags().ext_texture_storage); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); + EXPECT_TRUE(info_->validators()->texture_parameter.IsValid( + GL_TEXTURE_IMMUTABLE_FORMAT_EXT)); +} + +TEST_F(FeatureInfoTest, InitializeEXT_texture_storage_BGRA) { + SetupInitExpectations("GL_EXT_texture_storage GL_EXT_bgra"); + EXPECT_TRUE(info_->feature_flags().ext_texture_storage); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); + EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid( + GL_BGRA8_EXT)); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888")); +} + +TEST_F(FeatureInfoTest, InitializeARB_texture_storage_BGRA) { + SetupInitExpectations("GL_ARB_texture_storage GL_EXT_bgra"); + EXPECT_TRUE(info_->feature_flags().ext_texture_storage); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); + EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid( + GL_BGRA8_EXT)); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888")); +} + +TEST_F(FeatureInfoTest, InitializeEXT_texture_storage_BGRA8888) { + SetupInitExpectations( + "GL_EXT_texture_storage GL_EXT_texture_format_BGRA8888"); + EXPECT_TRUE(info_->feature_flags().ext_texture_storage); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888")); + EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid( + GL_BGRA8_EXT)); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888")); +} + +TEST_F(FeatureInfoTest, InitializeEXT_texture_storage_float) { + SetupInitExpectations("GL_EXT_texture_storage GL_OES_texture_float"); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_float")); + EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid( + GL_RGBA32F_EXT)); + EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid( + GL_RGB32F_EXT)); + EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid( + GL_ALPHA32F_EXT)); + EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid( + GL_LUMINANCE32F_EXT)); + EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid( + GL_LUMINANCE_ALPHA32F_EXT)); +} + +TEST_F(FeatureInfoTest, InitializeEXT_texture_storage_half_float) { + SetupInitExpectations("GL_EXT_texture_storage GL_OES_texture_half_float"); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_OES_texture_half_float")); + EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid( + GL_RGBA16F_EXT)); + EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid( + GL_RGB16F_EXT)); + EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid( + GL_ALPHA16F_EXT)); + EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid( + GL_LUMINANCE16F_EXT)); + EXPECT_TRUE(info_->validators()->texture_internal_format_storage.IsValid( + GL_LUMINANCE_ALPHA16F_EXT)); +} + +// Check how to handle ES, texture_storage and BGRA combination; 8 tests. + +// 1- ES2 + GL_EXT_texture_storage -> GL_EXT_texture_storage (and no +// GL_EXT_texture_format_BGRA8888 - we don't claim to handle GL_BGRA8 in +// glTexStorage2DEXT) +TEST_F(FeatureInfoTest, InitializeGLES2_texture_storage) { + SetupInitExpectationsWithGLVersion( + "GL_EXT_texture_storage", "", "OpenGL ES 2.0"); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); + EXPECT_THAT(info_->extensions(), + Not(HasSubstr("GL_EXT_texture_format_BGRA8888"))); +} + +// 2- ES2 + GL_EXT_texture_storage + (GL_EXT_texture_format_BGRA8888 or +// GL_APPLE_texture_format_bgra8888) +TEST_F(FeatureInfoTest, InitializeGLES2_texture_storage_BGRA) { + SetupInitExpectationsWithGLVersion( + "GL_EXT_texture_storage GL_EXT_texture_format_BGRA8888", + "", + "OpenGL ES 2.0"); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888")); +} + +// 3- ES2 + GL_EXT_texture_format_BGRA8888 or GL_APPLE_texture_format_bgra8888 +TEST_F(FeatureInfoTest, InitializeGLES2_texture_format_BGRA) { + SetupInitExpectationsWithGLVersion( + "GL_EXT_texture_format_BGRA8888", "", "OpenGL ES 2.0"); + EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_texture_storage"))); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888")); +} + +// 4- ES2 (neither GL_EXT_texture_storage nor GL_EXT_texture_format_BGRA8888) -> +// nothing +TEST_F(FeatureInfoTest, InitializeGLES2_neither_texture_storage_nor_BGRA) { + SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 2.0"); + EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_texture_storage"))); + EXPECT_THAT(info_->extensions(), + Not(HasSubstr("GL_EXT_texture_format_BGRA8888"))); +} + +// 5- ES3 + GL_EXT_texture_format_BGRA8888 -> GL_EXT_texture_format_BGRA8888 +// (we can't expose GL_EXT_texture_storage because we fail the GL_BGRA8 +// requirement) +TEST_F(FeatureInfoTest, InitializeGLES3_texture_storage_EXT_BGRA) { + SetupInitExpectationsWithGLVersion( + "GL_EXT_texture_format_BGRA8888", "", "OpenGL ES 3.0"); + EXPECT_THAT(info_->extensions(), Not(HasSubstr("GL_EXT_texture_storage"))); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888")); +} + +// 6- ES3 + GL_APPLE_texture_format_bgra8888 -> GL_EXT_texture_storage + +// GL_EXT_texture_format_BGRA8888 (driver promises to handle GL_BGRA8 by +// exposing GL_APPLE_texture_format_bgra8888) +TEST_F(FeatureInfoTest, InitializeGLES3_texture_storage_APPLE_BGRA) { + SetupInitExpectationsWithGLVersion( + "GL_APPLE_texture_format_BGRA8888", "", "OpenGL ES 3.0"); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888")); +} + +// 7- ES3 + GL_EXT_texture_storage + GL_EXT_texture_format_BGRA8888 -> +// GL_EXT_texture_storage + GL_EXT_texture_format_BGRA8888 (driver promises to +// handle GL_BGRA8 by exposing GL_EXT_texture_storage) +TEST_F(FeatureInfoTest, InitializeGLES3_EXT_texture_storage_EXT_BGRA) { + SetupInitExpectationsWithGLVersion( + "GL_EXT_texture_storage GL_EXT_texture_format_BGRA8888", + "", + "OpenGL ES 3.0"); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_format_BGRA8888")); +} + +// 8- ES3 + none of the above -> GL_EXT_texture_storage (and no +// GL_EXT_texture_format_BGRA8888 - we don't claim to handle GL_BGRA8) +TEST_F(FeatureInfoTest, InitializeGLES3_texture_storage) { + SetupInitExpectationsWithGLVersion("", "", "OpenGL ES 3.0"); + EXPECT_THAT(info_->extensions(), HasSubstr("GL_EXT_texture_storage")); + EXPECT_THAT(info_->extensions(), + Not(HasSubstr("GL_EXT_texture_format_BGRA8888"))); +} + TEST_F(FeatureInfoTest, InitializeARB_texture_float) { SetupInitExpectations("GL_ARB_texture_float"); EXPECT_TRUE(info_->feature_flags().chromium_color_buffer_float_rgba); |