Commit be607ad6 by Geoff Lang Committed by Commit Bot

GL: Implement GL_OES_EGL_image_external and GL_OES_EGL_image_external_essl3

Chrome uses external textures as part of its hardware video decode paths on Android. BUG=angleproject:2507 Change-Id: I2af608f84a99843c99a16dcfb9fb2fa28cc8fbb6 Reviewed-on: https://chromium-review.googlesource.com/c/1361480Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent f5c88e7e
......@@ -353,7 +353,7 @@ angle::Result BlitGL::copySubImageToLUMAWorkaroundTexture(const gl::Context *con
// Copy the swizzled texture to the destination texture
mStateManager->bindTexture(textureType, texture);
if (target == gl::TextureTarget::_3D || target == gl::TextureTarget::_2DArray)
if (nativegl::UseTexImage3D(textureType))
{
mFunctions->copyTexSubImage3D(ToGLenum(target), static_cast<GLint>(level), destOffset.x,
destOffset.y, destOffset.z, 0, 0, sourceArea.width,
......@@ -361,6 +361,7 @@ angle::Result BlitGL::copySubImageToLUMAWorkaroundTexture(const gl::Context *con
}
else
{
ASSERT(nativegl::UseTexImage2D(textureType));
mFunctions->copyTexSubImage2D(ToGLenum(target), static_cast<GLint>(level), destOffset.x,
destOffset.y, 0, 0, sourceArea.width, sourceArea.height);
}
......
......@@ -83,6 +83,21 @@ gl::Texture::DirtyBits GetLevelWorkaroundDirtyBits()
return bits;
}
size_t GetMaxLevelInfoCountForTextureType(gl::TextureType type)
{
switch (type)
{
case gl::TextureType::CubeMap:
return (gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS + 1) * gl::kCubeFaceCount;
case gl::TextureType::External:
return 1;
default:
return gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS + 1;
}
}
} // anonymous namespace
LUMAWorkaroundGL::LUMAWorkaroundGL() : LUMAWorkaroundGL(false, GL_NONE) {}
......@@ -111,8 +126,7 @@ TextureGL::TextureGL(const gl::TextureState &state, GLuint id)
mAppliedMaxLevel(state.getEffectiveMaxLevel()),
mTextureID(id)
{
mLevelInfo.resize((gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS + 1) *
(getType() == gl::TextureType::CubeMap ? gl::kCubeFaceCount : 1));
mLevelInfo.resize(GetMaxLevelInfoCountForTextureType(getType()));
}
TextureGL::~TextureGL()
......
......@@ -1118,10 +1118,9 @@ void GenerateCaps(const FunctionsGL *functions,
functions->hasGLESExtension("GL_KHR_debug") ||
functions->hasGLESExtension("GL_EXT_debug_marker");
extensions->eglImage = functions->hasGLESExtension("GL_OES_EGL_image");
// TODO(geofflang): Support external texture targets in TextureGL. http://anglebug.com/2507
// extensions->eglImageExternal = functions->hasGLESExtension("GL_OES_EGL_image_external");
// extensions->eglImageExternalEssl3 =
// functions->hasGLESExtension("GL_OES_EGL_image_external_essl3");
extensions->eglImageExternal = functions->hasGLESExtension("GL_OES_EGL_image_external");
extensions->eglImageExternalEssl3 =
functions->hasGLESExtension("GL_OES_EGL_image_external_essl3");
if (functions->isAtLeastGL(gl::Version(3, 3)) ||
functions->hasGLExtension("GL_ARB_timer_query") ||
......@@ -1497,7 +1496,8 @@ bool UseTexImage2D(gl::TextureType textureType)
{
return textureType == gl::TextureType::_2D || textureType == gl::TextureType::CubeMap ||
textureType == gl::TextureType::Rectangle ||
textureType == gl::TextureType::_2DMultisample;
textureType == gl::TextureType::_2DMultisample ||
textureType == gl::TextureType::External;
}
bool UseTexImage3D(gl::TextureType textureType)
......
......@@ -760,14 +760,19 @@ bool ValidMipLevel(const Context *context, TextureType type, GLint level)
// level-of-detail" for multisample textures should be. Could maybe make it zero.
maxDimension = caps.max2DTextureSize;
break;
case TextureType::CubeMap:
maxDimension = caps.maxCubeMapTextureSize;
break;
case TextureType::External:
case TextureType::Rectangle:
return level == 0;
case TextureType::_3D:
maxDimension = caps.max3DTextureSize;
break;
default:
UNREACHABLE();
}
......
......@@ -346,10 +346,8 @@ bool IsValidCopyTextureSourceTarget(Context *context, TextureType type)
return true;
case TextureType::Rectangle:
return context->getExtensions().textureRectangle;
// TODO(geofflang): accept GL_TEXTURE_EXTERNAL_OES if the texture_external extension is
// supported
case TextureType::External:
return context->getExtensions().eglImageExternal;
default:
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment