Commit 6d1ccf01 by Geoff Lang Committed by Commit Bot

Re-order the error generation for ES3 TexImage calls.

Explictly check if the internal format enum is ever valid before checking if it is valid in combination with other parameters. Some WebGL tests expect a certain order for generated errors. BUG=angleproject:2009 TEST=conformance2/textures/misc/tex-input-validation Change-Id: I31166a78d00629f8281ef53eced72575497ae448 Reviewed-on: https://chromium-review.googlesource.com/486099 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 66c5e619
...@@ -1892,6 +1892,12 @@ size_t GetVertexFormatTypeSize(VertexFormatType vertexFormatType) ...@@ -1892,6 +1892,12 @@ size_t GetVertexFormatTypeSize(VertexFormatType vertexFormatType)
} }
} }
bool ValidES3InternalFormat(GLenum internalFormat)
{
const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
return internalFormat != GL_NONE && formatMap.find(internalFormat) != formatMap.end();
}
VertexFormat::VertexFormat(GLenum typeIn, GLboolean normalizedIn, GLuint componentsIn, bool pureIntegerIn) VertexFormat::VertexFormat(GLenum typeIn, GLboolean normalizedIn, GLuint componentsIn, bool pureIntegerIn)
: type(typeIn), : type(typeIn),
normalized(normalizedIn), normalized(normalizedIn),
......
...@@ -305,6 +305,10 @@ VertexFormatType GetVertexFormatType(const VertexAttribute &attrib, GLenum curre ...@@ -305,6 +305,10 @@ VertexFormatType GetVertexFormatType(const VertexAttribute &attrib, GLenum curre
const VertexFormat &GetVertexFormatFromType(VertexFormatType vertexFormatType); const VertexFormat &GetVertexFormatFromType(VertexFormatType vertexFormatType);
size_t GetVertexFormatTypeSize(VertexFormatType vertexFormatType); size_t GetVertexFormatTypeSize(VertexFormatType vertexFormatType);
// Check if an internal format is ever valid in ES3. Makes no checks about support for a specific
// context.
bool ValidES3InternalFormat(GLenum internalFormat);
// Implemented in format_map_autogen.cpp // Implemented in format_map_autogen.cpp
bool ValidES3Format(GLenum format); bool ValidES3Format(GLenum format);
bool ValidES3Type(GLenum type); bool ValidES3Type(GLenum type);
......
...@@ -32,9 +32,25 @@ static bool ValidateTexImageFormatCombination(gl::Context *context, ...@@ -32,9 +32,25 @@ static bool ValidateTexImageFormatCombination(gl::Context *context,
{ {
// The type and format are valid if any supported internal format has that type and format // The type and format are valid if any supported internal format has that type and format
if (!ValidES3Format(format) || !ValidES3Type(type)) if (!ValidES3Format(format))
{ {
context->handleError(Error(GL_INVALID_ENUM)); context->handleError(Error(GL_INVALID_ENUM, "Invalid format."));
return false;
}
if (!ValidES3Type(type))
{
context->handleError(Error(GL_INVALID_ENUM, "Invalid type."));
return false;
}
// For historical reasons, glTexImage2D and glTexImage3D pass in their internal format as a
// GLint instead of a GLenum. Therefor an invalid internal format gives a GL_INVALID_VALUE
// error instead of a GL_INVALID_ENUM error. As this validation function is only called in
// the validation codepaths for glTexImage2D/3D, we record a GL_INVALID_VALUE error.
if (!ValidES3InternalFormat(internalFormat))
{
context->handleError(Error(GL_INVALID_VALUE, "Invalid internalFormat."));
return false; return false;
} }
...@@ -51,21 +67,18 @@ static bool ValidateTexImageFormatCombination(gl::Context *context, ...@@ -51,21 +67,18 @@ static bool ValidateTexImageFormatCombination(gl::Context *context,
return false; return false;
} }
// For historical reasons, glTexImage2D and glTexImage3D pass in their internal format as a // Check if this is a valid format combination to load texture data
// GLint instead of a GLenum. Therefor an invalid internal format gives a GL_INVALID_VALUE if (!ValidES3FormatCombination(format, type, internalFormat))
// error instead of a GL_INVALID_ENUM error. As this validation function is only called in
// the validation codepaths for glTexImage2D/3D, we record a GL_INVALID_VALUE error.
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat, type);
if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions()))
{ {
context->handleError(Error(GL_INVALID_VALUE)); context->handleError(
Error(GL_INVALID_OPERATION, "Invalid combination of format, type and internalFormat."));
return false; return false;
} }
// Check if this is a valid format combination to load texture data const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat, type);
if (!ValidES3FormatCombination(format, type, internalFormat)) if (!formatInfo.textureSupport(context->getClientVersion(), context->getExtensions()))
{ {
context->handleError(Error(GL_INVALID_OPERATION)); context->handleError(Error(GL_INVALID_VALUE, "Unsupported internal format."));
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