Commit 2878379d by Brandon Jones Committed by Commit Bot

Add NPOT validation to copyTextureCHROMIUM

copyTextureCHROMIUM should generate INVALID_VALUE when using a NPOT texture and level not equal to zero, so we should add validation to catch this case. BUG=angleproject:2380 Change-Id: I7ca2e657287c11d560db0ad296f8e87ed0c19798 Reviewed-on: https://chromium-review.googlesource.com/956018 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 19fa1c6f
......@@ -371,13 +371,19 @@ bool IsValidCopyTextureDestinationLevel(Context *context,
TextureType type,
GLint level,
GLsizei width,
GLsizei height)
GLsizei height,
bool isSubImage)
{
if (!ValidMipLevel(context, type, level))
{
return false;
}
if (!ValidImageSizeParameters(context, type, level, width, height, 1, isSubImage))
{
return false;
}
const Caps &caps = context->getCaps();
switch (type)
{
......@@ -3916,7 +3922,7 @@ bool ValidateCopyTextureCHROMIUM(Context *context,
}
if (!IsValidCopyTextureDestinationLevel(context, dest->getType(), destLevel, sourceWidth,
sourceHeight))
sourceHeight, false))
{
ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidMipLevel);
return false;
......@@ -4044,7 +4050,8 @@ bool ValidateCopySubTextureCHROMIUM(Context *context,
return false;
}
if (!IsValidCopyTextureDestinationLevel(context, dest->getType(), destLevel, width, height))
if (!IsValidCopyTextureDestinationLevel(context, dest->getType(), destLevel, width, height,
true))
{
context->handleError(InvalidValue() << "Destination texture level is not valid.");
return false;
......
......@@ -132,6 +132,12 @@ class CopyTextureTestDest : public CopyTextureTest
{
};
class CopyTextureTestWebGL : public CopyTextureTest
{
protected:
CopyTextureTestWebGL() : CopyTextureTest() { setWebGLCompatibilityEnabled(true); }
};
class CopyTextureTestES3 : public CopyTextureTest
{
};
......@@ -1179,6 +1185,35 @@ TEST_P(CopyTextureTestDest, AlphaCopyWithRGB)
EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels);
}
// Test to ensure that CopyTexture will fail with a non-zero level and NPOT texture in WebGL
TEST_P(CopyTextureTestWebGL, NPOT)
{
if (extensionRequestable("GL_CHROMIUM_copy_texture"))
{
glRequestExtensionANGLE("GL_CHROMIUM_copy_texture");
}
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_CHROMIUM_copy_texture"));
std::vector<GLColor> pixelData(10 * 10, GLColor::red);
glBindTexture(GL_TEXTURE_2D, mTextures[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 10, 10, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixelData.data());
// Do a basic copy to make sure things work
glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA,
GL_UNSIGNED_BYTE, false, false, false);
EXPECT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
// Do the same operation with destLevel 1, which should fail
glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 1, GL_RGBA,
GL_UNSIGNED_BYTE, false, false, false);
EXPECT_GL_ERROR(GL_INVALID_VALUE);
}
// Test the newly added ES3 unorm formats
TEST_P(CopyTextureTestES3, ES3UnormFormats)
{
......@@ -1524,6 +1559,7 @@ TEST_P(CopyTextureTestES3, ES3UintFormats)
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against.
ANGLE_INSTANTIATE_TEST(CopyTextureTest, ES2_D3D9(), ES2_D3D11(), ES2_OPENGL(), ES2_OPENGLES());
ANGLE_INSTANTIATE_TEST(CopyTextureTestWebGL, ES2_D3D9(), ES2_D3D11(), ES2_OPENGL(), ES2_OPENGLES());
ANGLE_INSTANTIATE_TEST(CopyTextureTestDest, ES2_D3D11());
ANGLE_INSTANTIATE_TEST(CopyTextureTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
......
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