Commit b4472275 by Jamie Madill

Add a ValidateAttachmentTarget helper method.

This helper returns the appropriate error with the user specifies an attachment that is invalid or out-of-range (for indexed color attachments). BUG=angle:571 Change-Id: I80ed347e3540579110e40e742fbacb0467cb85fd Reviewed-on: https://chromium-review.googlesource.com/205604Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 570f7c84
...@@ -246,6 +246,40 @@ bool ValidProgram(const Context *context, GLuint id) ...@@ -246,6 +246,40 @@ bool ValidProgram(const Context *context, GLuint id)
} }
} }
bool ValidateAttachmentTarget(const gl::Context *context, GLenum attachment)
{
if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
{
const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
if (colorAttachment >= context->getMaximumRenderTargets())
{
return gl::error(GL_INVALID_VALUE, false);
}
}
else
{
switch (attachment)
{
case GL_DEPTH_ATTACHMENT:
case GL_STENCIL_ATTACHMENT:
break;
case GL_DEPTH_STENCIL_ATTACHMENT:
if (context->getClientVersion() < 3)
{
return gl::error(GL_INVALID_ENUM, false);
}
break;
default:
return gl::error(GL_INVALID_ENUM, false);
}
}
return true;
}
bool ValidateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples, bool ValidateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples,
GLenum internalformat, GLsizei width, GLsizei height, GLenum internalformat, GLsizei width, GLsizei height,
bool angleExtension) bool angleExtension)
...@@ -334,32 +368,9 @@ bool ValidateFramebufferRenderbufferParameters(gl::Context *context, GLenum targ ...@@ -334,32 +368,9 @@ bool ValidateFramebufferRenderbufferParameters(gl::Context *context, GLenum targ
return gl::error(GL_INVALID_OPERATION, false); return gl::error(GL_INVALID_OPERATION, false);
} }
if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) if (!ValidateAttachmentTarget(context, attachment))
{ {
const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); return false;
if (colorAttachment >= context->getMaximumRenderTargets())
{
return gl::error(GL_INVALID_VALUE, false);
}
}
else
{
switch (attachment)
{
case GL_DEPTH_ATTACHMENT:
break;
case GL_STENCIL_ATTACHMENT:
break;
case GL_DEPTH_STENCIL_ATTACHMENT:
if (context->getClientVersion() < 3)
{
return gl::error(GL_INVALID_ENUM, false);
}
break;
default:
return gl::error(GL_INVALID_ENUM, false);
}
} }
// [OpenGL ES 2.0.25] Section 4.4.3 page 112 // [OpenGL ES 2.0.25] Section 4.4.3 page 112
......
...@@ -26,6 +26,7 @@ bool ValidCompressedImageSize(const gl::Context *context, GLenum internalFormat, ...@@ -26,6 +26,7 @@ bool ValidCompressedImageSize(const gl::Context *context, GLenum internalFormat,
bool ValidQueryType(const gl::Context *context, GLenum queryType); bool ValidQueryType(const gl::Context *context, GLenum queryType);
bool ValidProgram(const gl::Context *context, GLuint id); bool ValidProgram(const gl::Context *context, GLuint id);
bool ValidateAttachmentTarget(const gl::Context *context, GLenum attachment);
bool ValidateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples, bool ValidateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples,
GLenum internalformat, GLsizei width, GLsizei height, GLenum internalformat, GLsizei width, GLsizei height,
bool angleExtension); bool angleExtension);
......
...@@ -849,24 +849,9 @@ bool ValidateES2FramebufferTextureParameters(const gl::Context *context, GLenum ...@@ -849,24 +849,9 @@ bool ValidateES2FramebufferTextureParameters(const gl::Context *context, GLenum
return gl::error(GL_INVALID_ENUM, false); return gl::error(GL_INVALID_ENUM, false);
} }
if (attachment >= GL_COLOR_ATTACHMENT0 && attachment <= GL_COLOR_ATTACHMENT15) if (!ValidateAttachmentTarget(context, attachment))
{ {
const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0); return false;
if (colorAttachment >= context->getMaximumRenderTargets())
{
return gl::error(GL_INVALID_VALUE, false);
}
}
else
{
switch (attachment)
{
case GL_DEPTH_ATTACHMENT:
case GL_STENCIL_ATTACHMENT:
break;
default:
return gl::error(GL_INVALID_ENUM, false);
}
} }
if (texture != 0) if (texture != 0)
......
...@@ -458,25 +458,9 @@ bool ValidateES3FramebufferTextureParameters(const gl::Context *context, GLenum ...@@ -458,25 +458,9 @@ bool ValidateES3FramebufferTextureParameters(const gl::Context *context, GLenum
return gl::error(GL_INVALID_ENUM, false); return gl::error(GL_INVALID_ENUM, false);
} }
if (attachment >= GL_COLOR_ATTACHMENT0 && attachment <= GL_COLOR_ATTACHMENT15) if (!ValidateAttachmentTarget(context, attachment))
{ {
const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0); return false;
if (colorAttachment >= context->getMaximumRenderTargets())
{
return gl::error(GL_INVALID_VALUE, false);
}
}
else
{
switch (attachment)
{
case GL_DEPTH_ATTACHMENT:
case GL_STENCIL_ATTACHMENT:
case GL_DEPTH_STENCIL_ATTACHMENT:
break;
default:
return gl::error(GL_INVALID_ENUM, false);
}
} }
if (texture != 0) if (texture != 0)
......
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