Commit 606c86ee by Nicolas Capens Committed by Nicolas Capens

Support GL_TEXTURE_2D targets in glEGLImageTargetTexture2DOES.

BUG=18316605 Change-Id: I46cf8b97fcb2d7606a94570ef1d742ce0f973dfb Reviewed-on: https://swiftshader-review.googlesource.com/1356Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 857758fd
...@@ -536,6 +536,18 @@ void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo ...@@ -536,6 +536,18 @@ void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo
renderTarget->release(); renderTarget->release();
} }
void Texture2D::setImage(egl::Image *sharedImage)
{
sharedImage->addRef();
if(image[0])
{
image[0]->unbind();
}
image[0] = sharedImage;
}
// Tests for 2D texture sampling completeness. [OpenGL ES 2.0.24] section 3.8.2 page 85. // Tests for 2D texture sampling completeness. [OpenGL ES 2.0.24] section 3.8.2 page 85.
bool Texture2D::isSamplerComplete() const bool Texture2D::isSamplerComplete() const
{ {
...@@ -707,23 +719,12 @@ GLenum TextureExternal::getTarget() const ...@@ -707,23 +719,12 @@ GLenum TextureExternal::getTarget() const
return GL_TEXTURE_EXTERNAL_OES; return GL_TEXTURE_EXTERNAL_OES;
} }
void TextureExternal::setImage(Image *sharedImage)
{
if(image[0])
{
image[0]->release();
}
sharedImage->addRef();
image[0] = sharedImage;
}
} }
// Exported functions for use by EGL // Exported functions for use by EGL
extern "C" extern "C"
{ {
es1::Image *createBackBuffer(int width, int height, const egl::Config *config) egl::Image *createBackBuffer(int width, int height, const egl::Config *config)
{ {
if(config) if(config)
{ {
...@@ -733,7 +734,7 @@ extern "C" ...@@ -733,7 +734,7 @@ extern "C"
return 0; return 0;
} }
es1::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard) egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard)
{ {
if(width == 0 || height == 0 || height > OUTLINE_RESOLUTION) if(width == 0 || height == 0 || height > OUTLINE_RESOLUTION)
{ {
......
...@@ -136,6 +136,8 @@ public: ...@@ -136,6 +136,8 @@ public:
void copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); void copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
void setImage(egl::Image *image);
virtual bool isSamplerComplete() const; virtual bool isSamplerComplete() const;
virtual bool isCompressed(GLenum target, GLint level) const; virtual bool isCompressed(GLenum target, GLint level) const;
virtual bool isDepth(GLenum target, GLint level) const; virtual bool isDepth(GLenum target, GLint level) const;
...@@ -174,8 +176,6 @@ public: ...@@ -174,8 +176,6 @@ public:
virtual ~TextureExternal(); virtual ~TextureExternal();
virtual GLenum getTarget() const; virtual GLenum getTarget() const;
void setImage(Image *image);
}; };
} }
......
...@@ -4196,6 +4196,7 @@ void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image ...@@ -4196,6 +4196,7 @@ void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image
{ {
switch(target) switch(target)
{ {
case GL_TEXTURE_2D:
case GL_TEXTURE_EXTERNAL_OES: case GL_TEXTURE_EXTERNAL_OES:
break; break;
default: default:
...@@ -4211,14 +4212,21 @@ void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image ...@@ -4211,14 +4212,21 @@ void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image
if(context) if(context)
{ {
es1::TextureExternal *texture = context->getTextureExternal(); es1::Texture2D *texture = 0;
switch(target)
{
case GL_TEXTURE_2D: texture = context->getTexture2D(); break;
case GL_TEXTURE_EXTERNAL_OES: texture = context->getTextureExternal(); break;
default: UNREACHABLE();
}
if(!texture) if(!texture)
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
es1::Image *glImage = static_cast<es1::Image*>(image); egl::Image *glImage = static_cast<egl::Image*>(image);
texture->setImage(glImage); texture->setImage(glImage);
} }
......
...@@ -536,6 +536,18 @@ void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo ...@@ -536,6 +536,18 @@ void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo
renderTarget->release(); renderTarget->release();
} }
void Texture2D::setImage(egl::Image *sharedImage)
{
sharedImage->addRef();
if(image[0])
{
image[0]->unbind();
}
image[0] = sharedImage;
}
// Tests for 2D texture sampling completeness. [OpenGL ES 2.0.24] section 3.8.2 page 85. // Tests for 2D texture sampling completeness. [OpenGL ES 2.0.24] section 3.8.2 page 85.
bool Texture2D::isSamplerComplete() const bool Texture2D::isSamplerComplete() const
{ {
...@@ -1140,23 +1152,12 @@ GLenum TextureExternal::getTarget() const ...@@ -1140,23 +1152,12 @@ GLenum TextureExternal::getTarget() const
return GL_TEXTURE_EXTERNAL_OES; return GL_TEXTURE_EXTERNAL_OES;
} }
void TextureExternal::setImage(Image *sharedImage)
{
if(image[0])
{
image[0]->release();
}
sharedImage->addRef();
image[0] = sharedImage;
}
} }
// Exported functions for use by EGL // Exported functions for use by EGL
extern "C" extern "C"
{ {
es2::Image *createBackBuffer(int width, int height, const egl::Config *config) egl::Image *createBackBuffer(int width, int height, const egl::Config *config)
{ {
if(config) if(config)
{ {
...@@ -1166,7 +1167,7 @@ extern "C" ...@@ -1166,7 +1167,7 @@ extern "C"
return 0; return 0;
} }
es2::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard) egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard)
{ {
if(width == 0 || height == 0 || height > OUTLINE_RESOLUTION) if(width == 0 || height == 0 || height > OUTLINE_RESOLUTION)
{ {
......
...@@ -136,6 +136,8 @@ public: ...@@ -136,6 +136,8 @@ public:
void copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); void copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
void setImage(egl::Image *image);
virtual bool isSamplerComplete() const; virtual bool isSamplerComplete() const;
virtual bool isCompressed(GLenum target, GLint level) const; virtual bool isCompressed(GLenum target, GLint level) const;
virtual bool isDepth(GLenum target, GLint level) const; virtual bool isDepth(GLenum target, GLint level) const;
...@@ -231,8 +233,6 @@ public: ...@@ -231,8 +233,6 @@ public:
virtual ~TextureExternal(); virtual ~TextureExternal();
virtual GLenum getTarget() const; virtual GLenum getTarget() const;
void setImage(Image *image);
}; };
} }
......
...@@ -6110,6 +6110,7 @@ void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image ...@@ -6110,6 +6110,7 @@ void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image
{ {
switch(target) switch(target)
{ {
case GL_TEXTURE_2D:
case GL_TEXTURE_EXTERNAL_OES: case GL_TEXTURE_EXTERNAL_OES:
break; break;
default: default:
...@@ -6125,14 +6126,21 @@ void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image ...@@ -6125,14 +6126,21 @@ void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image
if(context) if(context)
{ {
es2::TextureExternal *texture = context->getTextureExternal(); es2::Texture2D *texture = 0;
switch(target)
{
case GL_TEXTURE_2D: texture = context->getTexture2D(); break;
case GL_TEXTURE_EXTERNAL_OES: texture = context->getTextureExternal(); break;
default: UNREACHABLE();
}
if(!texture) if(!texture)
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
es2::Image *glImage = static_cast<es2::Image*>(image); egl::Image *glImage = static_cast<egl::Image*>(image);
texture->setImage(glImage); texture->setImage(glImage);
} }
......
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