Revert "Validate that attrib offsets don't overflow buffers."

Seems to fail the Windows 8 bots in FL9_3 for some reason.

https://build.chromium.org/p/chromium.gpu.fyi/builders/Win8%20Release%20%28NVIDIA%29/builds/20703

VertexAttributeTest.ShortNormalized_ES2_D3D11_9_3
VertexAttributeTest.ShortUnnormalized_ES2_D3D11_9_3

BUG=angleproject:1339
This reverts commit fb57c04c781df708a432f0e90acf2e431b7983bb.

Change-Id: I4c678ff6b337e9a3e0a1fc809f96f6b89407ea33
Reviewed-on: https://chromium-review.googlesource.com/332442
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index c06eb7a..12c7612 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -68,16 +68,13 @@
                     GLint64 attribSize =
                         static_cast<GLint64>(ComputeVertexAttributeTypeSize(attrib));
                     GLint64 attribDataSize = (maxVertexElement - 1) * attribStride + attribSize;
-                    GLint64 attribOffset   = static_cast<GLint64>(attrib.offset);
 
                     // [OpenGL ES 3.0.2] section 2.9.4 page 40:
                     // We can return INVALID_OPERATION if our vertex attribute does not have
                     // enough backing data.
-                    if (attribDataSize + attribOffset > buffer->getSize())
+                    if (attribDataSize > buffer->getSize())
                     {
-                        context->recordError(
-                            Error(GL_INVALID_OPERATION,
-                                  "Vertex buffer is not big enough for the draw call"));
+                        context->recordError(Error(GL_INVALID_OPERATION));
                         return false;
                     }
                 }
@@ -2020,7 +2017,7 @@
         return false;
     }
 
-    if (!ValidateDrawAttribs(context, primcount, static_cast<GLint>(indexRangeOut->vertexCount())))
+    if (!ValidateDrawAttribs(context, primcount, static_cast<GLsizei>(indexRangeOut->end)))
     {
         return false;
     }
diff --git a/src/tests/gl_tests/VertexAttributeTest.cpp b/src/tests/gl_tests/VertexAttributeTest.cpp
index c9f293b..1f732e7 100644
--- a/src/tests/gl_tests/VertexAttributeTest.cpp
+++ b/src/tests/gl_tests/VertexAttributeTest.cpp
@@ -67,61 +67,16 @@
         IMMEDIATE,
     };
 
-    struct TestData final : angle::NonCopyable
+    struct TestData
     {
-        TestData(GLenum typeIn,
-                 GLboolean normalizedIn,
-                 Source sourceIn,
-                 const void *inputDataIn,
-                 const GLfloat *expectedDataIn)
-            : type(typeIn),
-              normalized(normalizedIn),
-              bufferOffset(0),
-              source(Source::BUFFER),
-              inputData(inputDataIn),
-              expectedData(expectedDataIn)
-        {
-        }
-
         GLenum type;
         GLboolean normalized;
-        size_t bufferOffset;
         Source source;
 
         const void *inputData;
         const GLfloat *expectedData;
     };
 
-    void setupTest(const TestData &test, GLint typeSize)
-    {
-        if (mProgram == 0)
-        {
-            initBasicProgram();
-        }
-
-        if (test.source == Source::BUFFER)
-        {
-            GLsizei dataSize = mVertexCount * TypeStride(test.type) * typeSize;
-            glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
-            glBufferData(GL_ARRAY_BUFFER, dataSize, test.inputData, GL_STATIC_DRAW);
-            glVertexAttribPointer(mTestAttrib, typeSize, test.type, test.normalized, 0,
-                                  reinterpret_cast<GLvoid *>(test.bufferOffset));
-            glBindBuffer(GL_ARRAY_BUFFER, 0);
-        }
-        else
-        {
-            ASSERT_EQ(Source::IMMEDIATE, test.source);
-            glBindBuffer(GL_ARRAY_BUFFER, 0);
-            glVertexAttribPointer(mTestAttrib, typeSize, test.type, test.normalized, 0,
-                                  test.inputData);
-        }
-
-        glVertexAttribPointer(mExpectedAttrib, typeSize, GL_FLOAT, GL_FALSE, 0, test.expectedData);
-
-        glEnableVertexAttribArray(mTestAttrib);
-        glEnableVertexAttribArray(mExpectedAttrib);
-    }
-
     void runTest(const TestData &test)
     {
         // TODO(geofflang): Figure out why this is broken on AMD OpenGL
@@ -145,7 +100,29 @@
         for (GLint i = 0; i < 4; i++)
         {
             GLint typeSize = i + 1;
-            setupTest(test, typeSize);
+
+            if (test.source == Source::BUFFER)
+            {
+                GLsizei dataSize = mVertexCount * TypeStride(test.type) * typeSize;
+                glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
+                glBufferData(GL_ARRAY_BUFFER, dataSize, test.inputData, GL_STATIC_DRAW);
+                glVertexAttribPointer(mTestAttrib, typeSize, test.type, test.normalized, 0,
+                                      nullptr);
+                glBindBuffer(GL_ARRAY_BUFFER, 0);
+            }
+            else
+            {
+                ASSERT_EQ(Source::IMMEDIATE, test.source);
+                glBindBuffer(GL_ARRAY_BUFFER, 0);
+                glVertexAttribPointer(mTestAttrib, typeSize, test.type, test.normalized, 0,
+                                      test.inputData);
+            }
+
+            glVertexAttribPointer(mExpectedAttrib, typeSize, GL_FLOAT, GL_FALSE, 0,
+                                  test.expectedData);
+
+            glEnableVertexAttribArray(mTestAttrib);
+            glEnableVertexAttribArray(mExpectedAttrib);
 
             drawQuad(mProgram, "position", 0.5f);
 
@@ -273,7 +250,7 @@
         expectedData[i] = inputData[i];
     }
 
-    TestData data(GL_UNSIGNED_BYTE, GL_FALSE, Source::IMMEDIATE, inputData, expectedData);
+    TestData data = {GL_UNSIGNED_BYTE, GL_FALSE, Source::IMMEDIATE, inputData, expectedData};
     runTest(data);
 }
 
@@ -286,7 +263,7 @@
         expectedData[i] = Normalize(inputData[i]);
     }
 
-    TestData data(GL_UNSIGNED_BYTE, GL_TRUE, Source::IMMEDIATE, inputData, expectedData);
+    TestData data = {GL_UNSIGNED_BYTE, GL_TRUE, Source::IMMEDIATE, inputData, expectedData};
     runTest(data);
 }
 
@@ -299,7 +276,7 @@
         expectedData[i] = inputData[i];
     }
 
-    TestData data(GL_BYTE, GL_FALSE, Source::IMMEDIATE, inputData, expectedData);
+    TestData data = {GL_BYTE, GL_FALSE, Source::IMMEDIATE, inputData, expectedData};
     runTest(data);
 }
 
@@ -312,7 +289,7 @@
         expectedData[i] = Normalize(inputData[i]);
     }
 
-    TestData data(GL_BYTE, GL_TRUE, Source::IMMEDIATE, inputData, expectedData);
+    TestData data = {GL_BYTE, GL_TRUE, Source::IMMEDIATE, inputData, expectedData};
     runTest(data);
 }
 
@@ -325,7 +302,7 @@
         expectedData[i] = inputData[i];
     }
 
-    TestData data(GL_UNSIGNED_SHORT, GL_FALSE, Source::IMMEDIATE, inputData, expectedData);
+    TestData data = {GL_UNSIGNED_SHORT, GL_FALSE, Source::IMMEDIATE, inputData, expectedData};
     runTest(data);
 }
 
@@ -338,7 +315,7 @@
         expectedData[i] = Normalize(inputData[i]);
     }
 
-    TestData data(GL_UNSIGNED_SHORT, GL_TRUE, Source::IMMEDIATE, inputData, expectedData);
+    TestData data = {GL_UNSIGNED_SHORT, GL_TRUE, Source::IMMEDIATE, inputData, expectedData};
     runTest(data);
 }
 
@@ -351,7 +328,7 @@
         expectedData[i] = inputData[i];
     }
 
-    TestData data(GL_SHORT, GL_FALSE, Source::IMMEDIATE, inputData, expectedData);
+    TestData data = {GL_SHORT, GL_FALSE, Source::IMMEDIATE, inputData, expectedData};
     runTest(data);
 }
 
@@ -364,7 +341,7 @@
         expectedData[i] = Normalize(inputData[i]);
     }
 
-    TestData data(GL_SHORT, GL_TRUE, Source::IMMEDIATE, inputData, expectedData);
+    TestData data = {GL_SHORT, GL_TRUE, Source::IMMEDIATE, inputData, expectedData};
     runTest(data);
 }
 
@@ -385,7 +362,7 @@
         expectedData[i] = static_cast<GLfloat>(inputData[i]);
     }
 
-    TestData data(GL_INT, GL_FALSE, Source::BUFFER, inputData, expectedData);
+    TestData data = {GL_INT, GL_FALSE, Source::BUFFER, inputData, expectedData};
     runTest(data);
 }
 
@@ -400,7 +377,7 @@
         expectedData[i] = Normalize(inputData[i]);
     }
 
-    TestData data(GL_INT, GL_TRUE, Source::BUFFER, inputData, expectedData);
+    TestData data = {GL_INT, GL_TRUE, Source::BUFFER, inputData, expectedData};
     runTest(data);
 }
 
@@ -416,7 +393,7 @@
         expectedData[i] = static_cast<GLfloat>(inputData[i]);
     }
 
-    TestData data(GL_UNSIGNED_INT, GL_FALSE, Source::BUFFER, inputData, expectedData);
+    TestData data = {GL_UNSIGNED_INT, GL_FALSE, Source::BUFFER, inputData, expectedData};
     runTest(data);
 }
 
@@ -432,7 +409,7 @@
         expectedData[i] = Normalize(inputData[i]);
     }
 
-    TestData data(GL_UNSIGNED_INT, GL_TRUE, Source::BUFFER, inputData, expectedData);
+    TestData data = {GL_UNSIGNED_INT, GL_TRUE, Source::BUFFER, inputData, expectedData};
     runTest(data);
 }
 
@@ -507,44 +484,6 @@
     EXPECT_PIXEL_NEAR(0, 0, 128, 0, 0, 255, 1);
 }
 
-// Verify that drawing with a large out-of-range offset generates INVALID_OPERATION.
-TEST_P(VertexAttributeTest, DrawArraysBufferTooSmall)
-{
-    GLfloat inputData[mVertexCount];
-    GLfloat expectedData[mVertexCount];
-    for (size_t count = 0; count < mVertexCount; ++count)
-    {
-        inputData[count]    = static_cast<GLfloat>(count);
-        expectedData[count] = inputData[count];
-    }
-
-    TestData data(GL_FLOAT, GL_FALSE, Source::BUFFER, inputData, expectedData);
-    data.bufferOffset = mVertexCount * TypeStride(GL_FLOAT);
-
-    setupTest(data, 1);
-    drawQuad(mProgram, "position", 0.5f);
-    EXPECT_GL_ERROR(GL_INVALID_OPERATION);
-}
-
-// Verify that index draw with an out-of-range offset generates INVALID_OPERATION.
-TEST_P(VertexAttributeTest, DrawElementsBufferTooSmall)
-{
-    GLfloat inputData[mVertexCount];
-    GLfloat expectedData[mVertexCount];
-    for (size_t count = 0; count < mVertexCount; ++count)
-    {
-        inputData[count]    = static_cast<GLfloat>(count);
-        expectedData[count] = inputData[count];
-    }
-
-    TestData data(GL_FLOAT, GL_FALSE, Source::BUFFER, inputData, expectedData);
-    data.bufferOffset = (mVertexCount - 3) * TypeStride(GL_FLOAT);
-
-    setupTest(data, 1);
-    drawIndexedQuad(mProgram, "position", 0.5f);
-    EXPECT_GL_ERROR(GL_INVALID_OPERATION);
-}
-
 class VertexAttributeCachingTest : public VertexAttributeTest
 {
   protected:
diff --git a/src/tests/test_utils/ANGLETest.cpp b/src/tests/test_utils/ANGLETest.cpp
index b308e11..ee14e6c 100644
--- a/src/tests/test_utils/ANGLETest.cpp
+++ b/src/tests/test_utils/ANGLETest.cpp
@@ -65,11 +65,7 @@
 }  // namespace angle
 
 ANGLETest::ANGLETest()
-    : mEGLWindow(nullptr),
-      mWidth(16),
-      mHeight(16),
-      mIgnoreD3D11SDKLayersWarnings(false),
-      mQuadVertexBuffer(0)
+    : mEGLWindow(nullptr), mWidth(16), mHeight(16), mIgnoreD3D11SDKLayersWarnings(false)
 {
     mEGLWindow =
         new EGLWindow(GetParam().majorVersion, GetParam().minorVersion, GetParam().eglParameters);
@@ -77,10 +73,6 @@
 
 ANGLETest::~ANGLETest()
 {
-    if (mQuadVertexBuffer)
-    {
-        glDeleteBuffers(1, &mQuadVertexBuffer);
-    }
     SafeDelete(mEGLWindow);
 }
 
@@ -191,58 +183,6 @@
     glUseProgram(0);
 }
 
-void ANGLETest::drawIndexedQuad(GLuint program,
-                                const std::string &positionAttribName,
-                                GLfloat positionAttribZ)
-{
-    drawIndexedQuad(program, positionAttribName, positionAttribZ, 1.0f);
-}
-
-void ANGLETest::drawIndexedQuad(GLuint program,
-                                const std::string &positionAttribName,
-                                GLfloat positionAttribZ,
-                                GLfloat positionAttribXYScale)
-{
-    GLint positionLocation = glGetAttribLocation(program, positionAttribName.c_str());
-
-    glUseProgram(program);
-
-    GLuint prevBinding = 0;
-    glGetIntegerv(GL_ARRAY_BUFFER_BINDING, reinterpret_cast<GLint *>(&prevBinding));
-
-    if (mQuadVertexBuffer == 0)
-    {
-        glGenBuffers(1, &mQuadVertexBuffer);
-        const GLfloat vertices[] = {
-            -1.0f * positionAttribXYScale, 1.0f * positionAttribXYScale,  positionAttribZ,
-            -1.0f * positionAttribXYScale, -1.0f * positionAttribXYScale, positionAttribZ,
-            1.0f * positionAttribXYScale,  -1.0f * positionAttribXYScale, positionAttribZ,
-            1.0f * positionAttribXYScale,  1.0f * positionAttribXYScale,  positionAttribZ,
-        };
-        glBindBuffer(GL_ARRAY_BUFFER, mQuadVertexBuffer);
-        glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 3 * 4, vertices, GL_STATIC_DRAW);
-    }
-    else
-    {
-        glBindBuffer(GL_ARRAY_BUFFER, mQuadVertexBuffer);
-    }
-
-    glVertexAttribPointer(positionLocation, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
-    glEnableVertexAttribArray(positionLocation);
-    glBindBuffer(GL_ARRAY_BUFFER, prevBinding);
-
-    const GLushort indices[] = {
-        0, 1, 2, 0, 2, 3,
-    };
-
-    glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
-
-    glDisableVertexAttribArray(positionLocation);
-    glVertexAttribPointer(positionLocation, 4, GL_FLOAT, GL_FALSE, 0, NULL);
-
-    glUseProgram(0);
-}
-
 GLuint ANGLETest::compileShader(GLenum type, const std::string &source)
 {
     GLuint shader = glCreateShader(type);
diff --git a/src/tests/test_utils/ANGLETest.h b/src/tests/test_utils/ANGLETest.h
index b58ee30..3e73712 100644
--- a/src/tests/test_utils/ANGLETest.h
+++ b/src/tests/test_utils/ANGLETest.h
@@ -114,14 +114,6 @@
                          const std::string &positionAttribName,
                          GLfloat positionAttribZ,
                          GLfloat positionAttribXYScale);
-    void drawIndexedQuad(GLuint program,
-                         const std::string &positionAttribName,
-                         GLfloat positionAttribZ);
-    void drawIndexedQuad(GLuint program,
-                         const std::string &positionAttribName,
-                         GLfloat positionAttribZ,
-                         GLfloat positionAttribXYScale);
-
     static GLuint compileShader(GLenum type, const std::string &source);
     static bool extensionEnabled(const std::string &extName);
     static bool eglClientExtensionEnabled(const std::string &extName);
@@ -162,9 +154,6 @@
 
     bool mIgnoreD3D11SDKLayersWarnings;
 
-    // Used for indexed quad rendering
-    GLuint mQuadVertexBuffer;
-
     static OSWindow *mOSWindow;
 };