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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jamie Nicol 2019-10-31 19:08:37 +00:00
Родитель 469002ab6c
Коммит 0fa5e56eb1
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -1325,6 +1325,11 @@ impl Device {
// 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
@ -1355,7 +1360,7 @@ impl Device {
// 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