Bug 1591436 - Avoid using glTexImage3D on android emulator. r=gw
authorJamie Nicol <jnicol@mozilla.com>
Thu, 31 Oct 2019 19:08:37 +0000
changeset 500134 f39fa8f0265d5a86d452c589ac88455ce7295fcc
parent 500133 9c304ce34a04364bf6e8a57f3a41a14c1ae1d574
child 500135 17366ca83b0c964f0b413ddd76229a768660d9e5
push id114164
push useraiakab@mozilla.com
push dateTue, 05 Nov 2019 10:06:15 +0000
treeherdermozilla-inbound@4d585c7edc76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgw
bugs1591436
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1591436 - Avoid using glTexImage3D on android emulator. r=gw A bug in the android emulator means that glTexImage3D thinks the maximum texture size is the value of GL_MAX_TEXTURE_SIZE, rather than the value returned by glGetIntegerv(GL_MAX_TEXTURE_SIZE). This means that calls to glTexImage3D fail when width, height, or depth > 3379. This forces us to use glTexStorage3D instead of glTexImage3D, avoiding this bug. This relies upon swizzling, which is indeed supported on the android emulator. Differential Revision: https://phabricator.services.mozilla.com/D51293
gfx/wr/webrender/src/device/gl.rs
--- a/gfx/wr/webrender/src/device/gl.rs
+++ b/gfx/wr/webrender/src/device/gl.rs
@@ -1320,16 +1320,21 @@ impl Device {
         // [2] https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_format_BGRA8888.txt
         // [3] https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_storage.txt
         // [4] http://http.download.nvidia.com/developer/Papers/2005/Fast_Texture_Transfers/Fast_Texture_Transfers.pdf
 
         // To support BGRA8 with glTexStorage* we specifically need
         // GL_EXT_texture_storage and GL_EXT_texture_format_BGRA8888.
         let supports_gles_bgra = supports_extension(&extensions, "GL_EXT_texture_format_BGRA8888");
 
+        // On the android emulator glTexImage fails to create textures larger than 3379.
+        // So we must use glTexStorage instead. See bug 1591436.
+        let is_emulator = renderer_name.starts_with("Android Emulator");
+        let avoid_tex_image = is_emulator;
+
         let (color_formats, bgra_formats, bgra8_sampling_swizzle, texture_storage_usage) = match gl.get_type() {
             // There is `glTexStorage`, use it and expect RGBA on the input.
             gl::GlType::Gl if
                 allow_texture_storage_support &&
                 allow_texture_swizzling &&
                 supports_extension(&extensions, "GL_ARB_texture_storage")
             => (
                 TextureFormatPair::from(ImageFormat::RGBA8),
@@ -1350,17 +1355,17 @@ impl Device {
                 TextureFormatPair { internal: gl::BGRA8_EXT, external: gl::BGRA_EXT },
                 Swizzle::Rgba, // no conversion needed
                 TexStorageUsage::Always,
             ),
             // For BGRA8 textures we must use the unsized BGRA internal
             // format and glTexImage. If texture storage is supported we can
             // use it for other formats.
             // We can't use glTexStorage with BGRA8 as the internal format.
-            gl::GlType::Gles if supports_gles_bgra => (
+            gl::GlType::Gles if supports_gles_bgra && !avoid_tex_image => (
                 TextureFormatPair::from(ImageFormat::RGBA8),
                 TextureFormatPair::from(gl::BGRA_EXT),
                 Swizzle::Rgba, // no conversion needed
                 TexStorageUsage::NonBGRA8,
             ),
             // BGRA is not supported as an internal format, therefore we will
             // use RGBA. The swizzling will happen at the texture unit.
             gl::GlType::Gles if allow_texture_swizzling => (