Commit 4bbb9841 by Chris Forbes

Fix eglCreateImageKHR error logic for level=0

Two issues here: - Logic was inverted - getTopLevel() isn't quite right. The condition in the spec is whether there are any nonzero levels defined; it does not require them to be contiguous with the base level. Test: dEQP-EGL.functional.image.api.create_image_gles2_tex2d_rgba_level0_only Bug: b/141916742 Change-Id: I336d628c9508bfe61d1471431cc6170454a24d1b Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/36888Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent cab045f4
......@@ -4450,7 +4450,7 @@ EGLenum Context::validateSharedImage(EGLenum target, GLuint name, GLuint texture
return EGL_BAD_PARAMETER;
}
if(textureLevel == 0 && !(texture->isSamplerComplete(nullptr) && texture->getTopLevel() == 0))
if(textureLevel == 0 && !texture->isSamplerComplete(nullptr) && texture->hasNonBaseLevels())
{
return EGL_BAD_PARAMETER;
}
......
......@@ -525,6 +525,19 @@ int Texture2D::getTopLevel() const
return level - 1;
}
bool Texture2D::hasNonBaseLevels() const
{
for(int level = 1; level < IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
{
if (image[level])
{
return true;
}
}
return false;
}
bool Texture2D::requiresSync() const
{
for(int level = 0; level < IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
......@@ -1007,6 +1020,19 @@ int TextureCubeMap::getTopLevel() const
return level - 1;
}
bool TextureCubeMap::hasNonBaseLevels() const
{
for(int level = 1; level < IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
{
if (image[0][level])
{
return true;
}
}
return false;
}
bool TextureCubeMap::requiresSync() const
{
for(int level = 0; level < IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
......@@ -1533,6 +1559,19 @@ int Texture3D::getTopLevel() const
return level - 1;
}
bool Texture3D::hasNonBaseLevels() const
{
for(int level = 1; level < IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
{
if (image[level])
{
return true;
}
}
return false;
}
bool Texture3D::requiresSync() const
{
for(int level = 0; level < IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
......
......@@ -146,6 +146,7 @@ public:
virtual GLsizei getDepth(GLenum target, GLint level) const;
virtual GLint getFormat(GLenum target, GLint level) const = 0;
virtual int getTopLevel() const = 0;
virtual bool hasNonBaseLevels() const = 0;
virtual bool requiresSync() const = 0;
virtual bool isBaseLevelDefined() const = 0;
......@@ -210,6 +211,7 @@ public:
GLsizei getHeight(GLenum target, GLint level) const override;
GLint getFormat(GLenum target, GLint level) const override;
int getTopLevel() const override;
bool hasNonBaseLevels() const override;
bool requiresSync() const override;
void setImage(GLint level, GLsizei width, GLsizei height, GLint internalformat, GLenum format, GLenum type, const gl::PixelStorageModes &unpackParameters, const void *pixels);
......@@ -225,6 +227,7 @@ public:
bool isSamplerComplete(Sampler *sampler) const override;
bool isCompressed(GLenum target, GLint level) const override;
bool isDepth(GLenum target, GLint level) const override;
void bindTexImage(gl::Surface *surface);
void releaseTexImage() override;
......@@ -279,6 +282,7 @@ public:
GLsizei getHeight(GLenum target, GLint level) const override;
GLint getFormat(GLenum target, GLint level) const override;
int getTopLevel() const override;
bool hasNonBaseLevels() const override;
bool requiresSync() const override;
void setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLint internalformat, GLenum format, GLenum type, const gl::PixelStorageModes &unpackParameters, const void *pixels);
......@@ -342,6 +346,7 @@ public:
GLsizei getDepth(GLenum target, GLint level) const override;
GLint getFormat(GLenum target, GLint level) const override;
int getTopLevel() const override;
bool hasNonBaseLevels() const override;
bool requiresSync() const override;
void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLint internalformat, GLenum format, GLenum type, const gl::PixelStorageModes &unpackParameters, const void *pixels);
......
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