Add texture rectangle extension.
This is needed to support binding IOSurfaces to textures on OSX. This
commit adds support in the API and tests, but didn't need to implement
compiler changes as it already supported ARB_texture_rectangle.
Implementation of CHROMIUM_opy_texture for rectangle texture and the
spec are left for follow-up commits.
Change-Id: I45c66be763a9d3f6f619640f9f95f39b05c70867
Reviewed-on: https://chromium-review.googlesource.com/559106
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/renderer/gl/FramebufferGL.cpp b/src/libANGLE/renderer/gl/FramebufferGL.cpp
index 4a9a413..eccb9b6 100644
--- a/src/libANGLE/renderer/gl/FramebufferGL.cpp
+++ b/src/libANGLE/renderer/gl/FramebufferGL.cpp
@@ -48,7 +48,8 @@
const TextureGL *textureGL = GetImplAs<TextureGL>(texture);
if (texture->getTarget() == GL_TEXTURE_2D ||
- texture->getTarget() == GL_TEXTURE_2D_MULTISAMPLE)
+ texture->getTarget() == GL_TEXTURE_2D_MULTISAMPLE ||
+ texture->getTarget() == GL_TEXTURE_RECTANGLE_ANGLE)
{
functions->framebufferTexture2D(GL_FRAMEBUFFER, attachmentPoint,
texture->getTarget(), textureGL->getTextureID(),
diff --git a/src/libANGLE/renderer/gl/StateManagerGL.cpp b/src/libANGLE/renderer/gl/StateManagerGL.cpp
index dbaad8b..51117bd 100644
--- a/src/libANGLE/renderer/gl/StateManagerGL.cpp
+++ b/src/libANGLE/renderer/gl/StateManagerGL.cpp
@@ -171,6 +171,7 @@
ASSERT(extensions.maxViews >= 1u);
mTextures[GL_TEXTURE_2D].resize(rendererCaps.maxCombinedTextureImageUnits);
+ mTextures[GL_TEXTURE_RECTANGLE_ANGLE].resize(rendererCaps.maxCombinedTextureImageUnits);
mTextures[GL_TEXTURE_CUBE_MAP].resize(rendererCaps.maxCombinedTextureImageUnits);
mTextures[GL_TEXTURE_2D_ARRAY].resize(rendererCaps.maxCombinedTextureImageUnits);
mTextures[GL_TEXTURE_3D].resize(rendererCaps.maxCombinedTextureImageUnits);
diff --git a/src/libANGLE/renderer/gl/TextureGL.cpp b/src/libANGLE/renderer/gl/TextureGL.cpp
index 352cc69..e45a462 100644
--- a/src/libANGLE/renderer/gl/TextureGL.cpp
+++ b/src/libANGLE/renderer/gl/TextureGL.cpp
@@ -41,7 +41,8 @@
bool UseTexImage2D(GLenum textureType)
{
- return textureType == GL_TEXTURE_2D || textureType == GL_TEXTURE_CUBE_MAP;
+ return textureType == GL_TEXTURE_2D || textureType == GL_TEXTURE_CUBE_MAP ||
+ textureType == GL_TEXTURE_RECTANGLE_ANGLE;
}
bool UseTexImage3D(GLenum textureType)
@@ -811,7 +812,7 @@
std::max(size.height >> level, 1),
1);
- if (getTarget() == GL_TEXTURE_2D)
+ if (getTarget() == GL_TEXTURE_2D || getTarget() == GL_TEXTURE_RECTANGLE_ANGLE)
{
if (internalFormatInfo.compressed)
{
@@ -989,7 +990,7 @@
gl::Error TextureGL::bindTexImage(const gl::Context *context, egl::Surface *surface)
{
- ASSERT(getTarget() == GL_TEXTURE_2D);
+ ASSERT(getTarget() == GL_TEXTURE_2D || getTarget() == GL_TEXTURE_RECTANGLE_ANGLE);
// Make sure this texture is bound
mStateManager->bindTexture(getTarget(), mTextureID);
@@ -1001,7 +1002,7 @@
gl::Error TextureGL::releaseTexImage(const gl::Context *context)
{
// Not all Surface implementations reset the size of mip 0 when releasing, do it manually
- ASSERT(getTarget() == GL_TEXTURE_2D);
+ ASSERT(getTarget() == GL_TEXTURE_2D || getTarget() == GL_TEXTURE_RECTANGLE_ANGLE);
mStateManager->bindTexture(getTarget(), mTextureID);
if (UseTexImage2D(getTarget()))
diff --git a/src/libANGLE/renderer/gl/renderergl_utils.cpp b/src/libANGLE/renderer/gl/renderergl_utils.cpp
index 92c7f3b..fb911b9 100644
--- a/src/libANGLE/renderer/gl/renderergl_utils.cpp
+++ b/src/libANGLE/renderer/gl/renderergl_utils.cpp
@@ -1002,6 +1002,14 @@
functions->hasGLESExtension("GL_ARB_invalidate_subdata");
extensions->translatedShaderSource = true;
+
+ if (functions->isAtLeastGL(gl::Version(3, 1)) ||
+ functions->hasGLExtension("GL_ARB_texture_rectangle"))
+ {
+ extensions->textureRectangle = true;
+ caps->maxRectangleTextureSize =
+ QuerySingleGLInt(functions, GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE);
+ }
}
void GenerateWorkarounds(const FunctionsGL *functions, WorkaroundsGL *workarounds)