Validate that unpack skip is in bounds
Unpack skip needs to be taken into account when determining which part
of the unpack buffer is read. This is now done in the out-of-bounds
check when validating texture upload calls.
Unpack skip code is removed from D3D9 backend, since skip is not
supported in GLES2.
BUG=angleproject:1411
TEST=angle_end2end_tests
Change-Id: I0db4db0877a352613c57e2820e5b650edb5a73ab
Reviewed-on: https://chromium-review.googlesource.com/352450
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/tests/gl_tests/TextureTest.cpp b/src/tests/gl_tests/TextureTest.cpp
index facdcf9..c86bdfb 100644
--- a/src/tests/gl_tests/TextureTest.cpp
+++ b/src/tests/gl_tests/TextureTest.cpp
@@ -5,6 +5,7 @@
//
#include "test_utils/ANGLETest.h"
+#include "test_utils/gl_raii.h"
using namespace angle;
@@ -3354,6 +3355,39 @@
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
}
+// Test that skip defined in unpack parameters is taken into account when determining whether
+// unpacking source extends outside unpack buffer bounds.
+TEST_P(Texture2DTestES3, UnpackSkipPixelsOutOfBounds)
+{
+ glBindTexture(GL_TEXTURE_2D, mTexture2D);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ ASSERT_GL_NO_ERROR();
+
+ GLBuffer buf;
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buf.get());
+ std::vector<GLColor> pixelsGreen(128u * 128u, GLColor::green);
+ glBufferData(GL_PIXEL_UNPACK_BUFFER, pixelsGreen.size() * 4u, pixelsGreen.data(),
+ GL_DYNAMIC_COPY);
+ ASSERT_GL_NO_ERROR();
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
+ ASSERT_GL_NO_ERROR();
+
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, 1);
+ ASSERT_GL_NO_ERROR();
+
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 128, 128, GL_RGBA, GL_UNSIGNED_BYTE, 0);
+ EXPECT_GL_ERROR(GL_INVALID_OPERATION);
+
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, 1);
+ ASSERT_GL_NO_ERROR();
+
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 128, 128, GL_RGBA, GL_UNSIGNED_BYTE, 0);
+ EXPECT_GL_ERROR(GL_INVALID_OPERATION);
+}
+
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
// TODO(oetuaho): Enable all below tests on OpenGL. Requires a fix for ANGLE bug 1278.
ANGLE_INSTANTIATE_TEST(Texture2DTest,