Commit 9dbaeba8 by Luc Ferron Committed by Commit Bot

Validation layer fixes for compressedtexsubimage* dEQP tests

* Change order of validation in ValidateCompressedTexSubImage3D to get the errors in the same order as the dEQP tests are expecting them. * ES 3.1: Section 8.7, page 169: If the internal format is ETC2/EAC, the target must be a GL_TEXTURE_2D_ARRAY. * ES 3.1: Section 8.7, page 171: For sub textures, ET2/EAC formats also requires exact size to be validated. Bug: angleproject:2327 Change-Id: Ib049c70a52ed5683885a73fb06503898a85786d1 Reviewed-on: https://chromium-review.googlesource.com/897726 Commit-Queue: Luc Ferron <lucferron@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent c0db9add
...@@ -47,6 +47,8 @@ ERRMSG(IndexExceedsMaxVertexAttribute, "Index exceeds MAX_VERTEX_ATTRIBS."); ...@@ -47,6 +47,8 @@ ERRMSG(IndexExceedsMaxVertexAttribute, "Index exceeds MAX_VERTEX_ATTRIBS.");
ERRMSG(InsufficientBufferSize, "Insufficient buffer size."); ERRMSG(InsufficientBufferSize, "Insufficient buffer size.");
ERRMSG(InsufficientVertexBufferSize, "Vertex buffer is not big enough for the draw call"); ERRMSG(InsufficientVertexBufferSize, "Vertex buffer is not big enough for the draw call");
ERRMSG(IntegerOverflow, "Integer overflow."); ERRMSG(IntegerOverflow, "Integer overflow.");
ERRMSG(InternalFormatRequiresTexture2DArray,
"internalformat is an ETC2/EAC format and target is not GL_TEXTURE_2D_ARRAY.");
ERRMSG(InvalidAttachment, "Invalid Attachment Type."); ERRMSG(InvalidAttachment, "Invalid Attachment Type.");
ERRMSG(InvalidBlendEquation, "Invalid blend equation."); ERRMSG(InvalidBlendEquation, "Invalid blend equation.");
ERRMSG(InvalidBlendFunction, "Invalid blend function."); ERRMSG(InvalidBlendFunction, "Invalid blend function.");
......
...@@ -33,7 +33,40 @@ namespace gl ...@@ -33,7 +33,40 @@ namespace gl
{ {
namespace namespace
{ {
bool CompressedTextureFormatRequiresExactSize(GLenum internalFormat)
{
// List of compressed format that require that the texture size is smaller than or a multiple of
// the compressed block size.
switch (internalFormat)
{
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
case GL_ETC1_RGB8_LOSSY_DECODE_ANGLE:
case GL_COMPRESSED_RGB8_LOSSY_DECODE_ETC2_ANGLE:
case GL_COMPRESSED_SRGB8_LOSSY_DECODE_ETC2_ANGLE:
case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE:
case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE:
case GL_COMPRESSED_RGBA8_LOSSY_DECODE_ETC2_EAC_ANGLE:
case GL_COMPRESSED_SRGB8_ALPHA8_LOSSY_DECODE_ETC2_EAC_ANGLE:
return true;
default:
return false;
}
}
bool CompressedSubTextureFormatRequiresExactSize(GLenum internalFormat)
{
// Compressed sub textures have additional formats that requires exact size.
// ES 3.1, Section 8.7, Page 171
return CompressedTextureFormatRequiresExactSize(internalFormat) ||
IsETC2EACFormat(internalFormat);
}
bool ValidateDrawAttribs(ValidationContext *context, bool ValidateDrawAttribs(ValidationContext *context,
GLint primcount, GLint primcount,
GLint maxVertex, GLint maxVertex,
...@@ -462,6 +495,28 @@ bool ValidateVertexShaderAttributeTypeMatch(ValidationContext *context) ...@@ -462,6 +495,28 @@ bool ValidateVertexShaderAttributeTypeMatch(ValidationContext *context)
} // anonymous namespace } // anonymous namespace
bool IsETC2EACFormat(const GLenum format)
{
// ES 3.1, Table 8.19
switch (format)
{
case GL_COMPRESSED_R11_EAC:
case GL_COMPRESSED_SIGNED_R11_EAC:
case GL_COMPRESSED_RG11_EAC:
case GL_COMPRESSED_SIGNED_RG11_EAC:
case GL_COMPRESSED_RGB8_ETC2:
case GL_COMPRESSED_SRGB8_ETC2:
case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
case GL_COMPRESSED_RGBA8_ETC2_EAC:
case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
return true;
default:
return false;
}
}
bool ValidTextureTarget(const ValidationContext *context, GLenum target) bool ValidTextureTarget(const ValidationContext *context, GLenum target)
{ {
switch (target) switch (target)
...@@ -736,34 +791,6 @@ bool ValidImageSizeParameters(ValidationContext *context, ...@@ -736,34 +791,6 @@ bool ValidImageSizeParameters(ValidationContext *context,
return true; return true;
} }
bool CompressedTextureFormatRequiresExactSize(GLenum internalFormat)
{
// List of compressed format that require that the texture size is smaller than or a multiple of
// the compressed block size.
switch (internalFormat)
{
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
case GL_ETC1_RGB8_LOSSY_DECODE_ANGLE:
case GL_COMPRESSED_RGB8_LOSSY_DECODE_ETC2_ANGLE:
case GL_COMPRESSED_SRGB8_LOSSY_DECODE_ETC2_ANGLE:
case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE:
case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE:
case GL_COMPRESSED_RGBA8_LOSSY_DECODE_ETC2_EAC_ANGLE:
case GL_COMPRESSED_SRGB8_ALPHA8_LOSSY_DECODE_ETC2_EAC_ANGLE:
return true;
default:
return false;
}
}
bool ValidCompressedDimension(GLsizei size, GLuint blockSize, bool smallerThanBlockSizeAllowed) bool ValidCompressedDimension(GLsizei size, GLuint blockSize, bool smallerThanBlockSizeAllowed)
{ {
return (smallerThanBlockSizeAllowed && (size > 0) && (blockSize % size == 0)) || return (smallerThanBlockSizeAllowed && (size > 0) && (blockSize % size == 0)) ||
...@@ -826,7 +853,7 @@ bool ValidCompressedSubImageSize(const ValidationContext *context, ...@@ -826,7 +853,7 @@ bool ValidCompressedSubImageSize(const ValidationContext *context,
return false; return false;
} }
if (CompressedTextureFormatRequiresExactSize(internalFormat)) if (CompressedSubTextureFormatRequiresExactSize(internalFormat))
{ {
if (xoffset % formatInfo.compressedBlockWidth != 0 || if (xoffset % formatInfo.compressedBlockWidth != 0 ||
yoffset % formatInfo.compressedBlockHeight != 0) yoffset % formatInfo.compressedBlockHeight != 0)
......
...@@ -31,6 +31,7 @@ class Program; ...@@ -31,6 +31,7 @@ class Program;
class Shader; class Shader;
class ValidationContext; class ValidationContext;
bool IsETC2EACFormat(const GLenum format);
bool ValidTextureTarget(const ValidationContext *context, GLenum target); bool ValidTextureTarget(const ValidationContext *context, GLenum target);
bool ValidTexture2DTarget(const ValidationContext *context, GLenum target); bool ValidTexture2DTarget(const ValidationContext *context, GLenum target);
bool ValidTexture3DTarget(const ValidationContext *context, GLenum target); bool ValidTexture3DTarget(const ValidationContext *context, GLenum target);
......
...@@ -529,6 +529,13 @@ bool ValidateES3TexImage3DParameters(Context *context, ...@@ -529,6 +529,13 @@ bool ValidateES3TexImage3DParameters(Context *context,
return false; return false;
} }
if (IsETC2EACFormat(format) && target != GL_TEXTURE_2D_ARRAY)
{
// ES 3.1, Section 8.7, page 169.
ANGLE_VALIDATION_ERR(context, InvalidOperation(), InternalFormatRequiresTexture2DArray);
return false;
}
return ValidateES3TexImageParametersBase(context, target, level, internalformat, isCompressed, return ValidateES3TexImageParametersBase(context, target, level, internalformat, isCompressed,
isSubImage, xoffset, yoffset, zoffset, width, height, isSubImage, xoffset, yoffset, zoffset, width, height,
depth, border, format, type, bufSize, pixels); depth, border, format, type, bufSize, pixels);
...@@ -2026,16 +2033,22 @@ bool ValidateCompressedTexSubImage3D(Context *context, ...@@ -2026,16 +2033,22 @@ bool ValidateCompressedTexSubImage3D(Context *context,
return false; return false;
} }
if (!ValidateES3TexImage3DParameters(context, target, level, GL_NONE, true, true, xoffset,
yoffset, zoffset, width, height, depth, 0, format, GL_NONE,
-1, data))
{
return false;
}
if (!data) if (!data)
{ {
context->handleError(InvalidValue()); context->handleError(InvalidValue());
return false; return false;
} }
return ValidateES3TexImage3DParameters(context, target, level, GL_NONE, true, true, xoffset, return true;
yoffset, zoffset, width, height, depth, 0, format,
GL_NONE, -1, data);
} }
bool ValidateCompressedTexSubImage3DRobustANGLE(Context *context, bool ValidateCompressedTexSubImage3DRobustANGLE(Context *context,
GLenum target, GLenum target,
GLint level, GLint level,
......
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