src/third_party/angle/src/tests/gl_tests/IndexBufferOffsetTest.cpp
// Uses index buffer offset and 2 drawElement calls one of the other, one has aligned
// offset and one doesn't
Uses index buffer offset and 2 drawElement calls one of the other, one has aligned
offset and one doesn't
Uses index buffer offset and 2 drawElement calls one of the other one has aligned offset and one doesn ' t
TEST_P(IndexBufferOffsetTest, DrawAtDifferentOffsetAlignments)
{
    GLubyte indexData8[]   = {0, 1, 0, 1, 2, 3};
    GLushort indexData16[] = {0, 1, 2, 1, 2, 3};
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    size_t indexDataWidth16 = 6 * sizeof(GLushort);
    GLuint buffer[2];
    glGenBuffers(2, buffer);
    glUseProgram(mProgram);
    glUniform4f(mColorUniformLocation, 1.0f, 0.0f, 0.0f, 1.0f);
    glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer);
    glVertexAttribPointer(mPositionAttributeLocation, 2, GL_FLOAT, GL_FALSE, 0, 0);
    glEnableVertexAttribArray(mPositionAttributeLocation);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer[0]);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indexData8), indexData8, GL_DYNAMIC_DRAW);
    glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, reinterpret_cast<void *>(2));
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer[1]);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexDataWidth16, indexData16, GL_DYNAMIC_DRAW);
    glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT,
                   reinterpret_cast<void *>(indexDataWidth16 / 2));
    EXPECT_PIXEL_COLOR_EQ(0, getWindowHeight() / 4, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(getWindowWidth() - 1, getWindowHeight() - 1, GLColor::red);
    EXPECT_GL_NO_ERROR();
}
TEST_P ( IndexBufferOffsetTest , DrawAtDifferentOffsetAlignments ) { GLubyte indexData8 [ ] = { 0 , 1 , 0 , 1 , 2 , 3 } ; GLushort indexData16 [ ] = { 0 , 1 , 2 , 1 , 2 , 3 } ; glClearColor ( 0.0f , 0.0f , 0.0f , 1.0f ) ; glClear ( GL_COLOR_BUFFER_BIT ) ; size_t indexDataWidth16 = 6 * sizeof ( GLushort ) ; GLuint buffer [ 2 ] ; glGenBuffers ( 2 , buffer ) ; glUseProgram ( mProgram ) ; glUniform4f ( mColorUniformLocation , 1.0f , 0.0f , 0.0f , 1.0f ) ; glBindBuffer ( GL_ARRAY_BUFFER , mVertexBuffer ) ; glVertexAttribPointer ( mPositionAttributeLocation , 2 , GL_FLOAT , GL_FALSE , 0 , 0 ) ; glEnableVertexAttribArray ( mPositionAttributeLocation ) ; glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , buffer [ 0 ] ) ; glBufferData ( GL_ELEMENT_ARRAY_BUFFER , sizeof ( indexData8 ) , indexData8 , GL_DYNAMIC_DRAW ) ; glDrawElements ( GL_TRIANGLES , 3 , GL_UNSIGNED_BYTE , reinterpret_cast < void * > ( 2 ) ) ; glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , buffer [ 1 ] ) ; glBufferData ( GL_ELEMENT_ARRAY_BUFFER , indexDataWidth16 , indexData16 , GL_DYNAMIC_DRAW ) ; glDrawElements ( GL_TRIANGLES , 3 , GL_UNSIGNED_SHORT , reinterpret_cast < void * > ( indexDataWidth16 / 2 ) ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , getWindowHeight ( ) / 4 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( getWindowWidth ( ) - 1 , getWindowHeight ( ) - 1 , GLColor :: red ) ; EXPECT_GL_NO_ERROR ( ) ; }
Uses index buffer offset and 2 drawElement calls one of the other, one has aligned
offset and one doesn't
Uses index buffer offset and 2 drawElement calls one of the other one has aligned offset and one doesn ' t
// 8 bit index with aligned offset // 16 bits index buffer, which unaligned offset // Check the upper left triangle // Check the down right triangle