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 ...@@ -353,7 +353,7 @@ angle::Result BlitGL::copySubImageToLUMAWorkaroundTexture(const gl::Context *con
// Copy the swizzled texture to the destination texture // Copy the swizzled texture to the destination texture
mStateManager->bindTexture(textureType, 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, mFunctions->copyTexSubImage3D(ToGLenum(target), static_cast<GLint>(level), destOffset.x,
destOffset.y, destOffset.z, 0, 0, sourceArea.width, destOffset.y, destOffset.z, 0, 0, sourceArea.width,
...@@ -361,6 +361,7 @@ angle::Result BlitGL::copySubImageToLUMAWorkaroundTexture(const gl::Context *con ...@@ -361,6 +361,7 @@ angle::Result BlitGL::copySubImageToLUMAWorkaroundTexture(const gl::Context *con
} }
else else
{ {
ASSERT(nativegl::UseTexImage2D(textureType));
mFunctions->copyTexSubImage2D(ToGLenum(target), static_cast<GLint>(level), destOffset.x, mFunctions->copyTexSubImage2D(ToGLenum(target), static_cast<GLint>(level), destOffset.x,
destOffset.y, 0, 0, sourceArea.width, sourceArea.height); destOffset.y, 0, 0, sourceArea.width, sourceArea.height);
} }
......
...@@ -83,6 +83,21 @@ gl::Texture::DirtyBits GetLevelWorkaroundDirtyBits() ...@@ -83,6 +83,21 @@ gl::Texture::DirtyBits GetLevelWorkaroundDirtyBits()
return bits; 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 } // anonymous namespace
LUMAWorkaroundGL::LUMAWorkaroundGL() : LUMAWorkaroundGL(false, GL_NONE) {} LUMAWorkaroundGL::LUMAWorkaroundGL() : LUMAWorkaroundGL(false, GL_NONE) {}
...@@ -111,8 +126,7 @@ TextureGL::TextureGL(const gl::TextureState &state, GLuint id) ...@@ -111,8 +126,7 @@ TextureGL::TextureGL(const gl::TextureState &state, GLuint id)
mAppliedMaxLevel(state.getEffectiveMaxLevel()), mAppliedMaxLevel(state.getEffectiveMaxLevel()),
mTextureID(id) mTextureID(id)
{ {
mLevelInfo.resize((gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS + 1) * mLevelInfo.resize(GetMaxLevelInfoCountForTextureType(getType()));
(getType() == gl::TextureType::CubeMap ? gl::kCubeFaceCount : 1));
} }
TextureGL::~TextureGL() TextureGL::~TextureGL()
......
...@@ -1118,10 +1118,9 @@ void GenerateCaps(const FunctionsGL *functions, ...@@ -1118,10 +1118,9 @@ void GenerateCaps(const FunctionsGL *functions,
functions->hasGLESExtension("GL_KHR_debug") || functions->hasGLESExtension("GL_KHR_debug") ||
functions->hasGLESExtension("GL_EXT_debug_marker"); functions->hasGLESExtension("GL_EXT_debug_marker");
extensions->eglImage = functions->hasGLESExtension("GL_OES_EGL_image"); 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->eglImageExternal = functions->hasGLESExtension("GL_OES_EGL_image_external"); extensions->eglImageExternalEssl3 =
// extensions->eglImageExternalEssl3 = functions->hasGLESExtension("GL_OES_EGL_image_external_essl3");
// functions->hasGLESExtension("GL_OES_EGL_image_external_essl3");
if (functions->isAtLeastGL(gl::Version(3, 3)) || if (functions->isAtLeastGL(gl::Version(3, 3)) ||
functions->hasGLExtension("GL_ARB_timer_query") || functions->hasGLExtension("GL_ARB_timer_query") ||
...@@ -1497,7 +1496,8 @@ bool UseTexImage2D(gl::TextureType textureType) ...@@ -1497,7 +1496,8 @@ bool UseTexImage2D(gl::TextureType textureType)
{ {
return textureType == gl::TextureType::_2D || textureType == gl::TextureType::CubeMap || return textureType == gl::TextureType::_2D || textureType == gl::TextureType::CubeMap ||
textureType == gl::TextureType::Rectangle || textureType == gl::TextureType::Rectangle ||
textureType == gl::TextureType::_2DMultisample; textureType == gl::TextureType::_2DMultisample ||
textureType == gl::TextureType::External;
} }
bool UseTexImage3D(gl::TextureType textureType) bool UseTexImage3D(gl::TextureType textureType)
......
...@@ -760,14 +760,19 @@ bool ValidMipLevel(const Context *context, TextureType type, GLint level) ...@@ -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. // level-of-detail" for multisample textures should be. Could maybe make it zero.
maxDimension = caps.max2DTextureSize; maxDimension = caps.max2DTextureSize;
break; break;
case TextureType::CubeMap: case TextureType::CubeMap:
maxDimension = caps.maxCubeMapTextureSize; maxDimension = caps.maxCubeMapTextureSize;
break; break;
case TextureType::External:
case TextureType::Rectangle: case TextureType::Rectangle:
return level == 0; return level == 0;
case TextureType::_3D: case TextureType::_3D:
maxDimension = caps.max3DTextureSize; maxDimension = caps.max3DTextureSize;
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
......
...@@ -346,10 +346,8 @@ bool IsValidCopyTextureSourceTarget(Context *context, TextureType type) ...@@ -346,10 +346,8 @@ bool IsValidCopyTextureSourceTarget(Context *context, TextureType type)
return true; return true;
case TextureType::Rectangle: case TextureType::Rectangle:
return context->getExtensions().textureRectangle; return context->getExtensions().textureRectangle;
case TextureType::External:
// TODO(geofflang): accept GL_TEXTURE_EXTERNAL_OES if the texture_external extension is return context->getExtensions().eglImageExternal;
// supported
default: default:
return false; 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