Commit f67115ce by Jamie Madill

Fix validation in TexSubImage.

We weren't properly checking the x and y offsets against the texture boundary, and were in some cases producing D3D errors with out-of-bounds writes. This was popping up in IncompleteTextureTest. The test itself was also bugged. BUG=angle:610 Change-Id: Id58cac088fed03cae2aabbf00bce234f17208753 Reviewed-on: https://chromium-review.googlesource.com/195410Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 42350abc
...@@ -5166,14 +5166,14 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint ...@@ -5166,14 +5166,14 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
{ {
if (context->getClientVersion() < 3 && if (context->getClientVersion() < 3 &&
!ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true, !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
0, 0, width, height, 0, format, type, pixels)) xoffset, yoffset, width, height, 0, format, type, pixels))
{ {
return; return;
} }
if (context->getClientVersion() >= 3 && if (context->getClientVersion() >= 3 &&
!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true, !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
0, 0, 0, width, height, 1, 0, format, type, pixels)) xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
{ {
return; return;
} }
......
...@@ -126,7 +126,7 @@ TEST_F(IncompleteTextureTest, update_texture) ...@@ -126,7 +126,7 @@ TEST_F(IncompleteTextureTest, update_texture)
fillTextureData(redTextureData, 255, 0, 0, 255); fillTextureData(redTextureData, 255, 0, 0, 255);
for (size_t i = 0; i < 7; i++) for (size_t i = 0; i < 7; i++)
{ {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, redTextureWidth >> i, redTextureHeight >> i, 0, GL_RGBA, GL_UNSIGNED_BYTE, glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA, redTextureWidth >> i, redTextureHeight >> i, 0, GL_RGBA, GL_UNSIGNED_BYTE,
redTextureData.data()); redTextureData.data());
} }
...@@ -143,7 +143,7 @@ TEST_F(IncompleteTextureTest, update_texture) ...@@ -143,7 +143,7 @@ TEST_F(IncompleteTextureTest, update_texture)
for (size_t i = 0; i < 6; i++) for (size_t i = 0; i < 6; i++)
{ {
glTexSubImage2D(GL_TEXTURE_2D, 0, greenTextureWidth >> i, greenTextureHeight >> i, glTexSubImage2D(GL_TEXTURE_2D, i, greenTextureWidth >> i, greenTextureHeight >> i,
greenTextureWidth >> i, greenTextureHeight >> i, GL_RGBA, GL_UNSIGNED_BYTE, greenTextureWidth >> i, greenTextureHeight >> i, GL_RGBA, GL_UNSIGNED_BYTE,
greenTextureData.data()); greenTextureData.data());
} }
......
#include "ANGLETest.h"
class TextureTest : public ANGLETest
{
protected:
TextureTest()
{
setWindowWidth(128);
setWindowHeight(128);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
virtual void SetUp()
{
ANGLETest::SetUp();
glGenTextures(1, &mTexture);
glBindTexture(GL_TEXTURE_2D, mTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
EXPECT_GL_NO_ERROR();
ASSERT_GL_NO_ERROR();
}
virtual void TearDown()
{
glDeleteTextures(1, &mTexture);
ANGLETest::TearDown();
}
GLuint mTexture;
};
TEST_F(TextureTest, negative_api_subimage)
{
glBindTexture(GL_TEXTURE_2D, mTexture);
EXPECT_GL_ERROR(GL_NO_ERROR);
const GLubyte *pixels[20] = { 0 };
glTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
EXPECT_GL_ERROR(GL_INVALID_VALUE);
}
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