Hash :
c422207e
Author :
Date :
2015-05-25T13:19:48
Disable some tests due to failures on Intel OpenGL. BUG=angleproject:884 Change-Id: Iceb571807a2232dae22703953e12e1af4bba5a87 Reviewed-on: https://chromium-review.googlesource.com/273029 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
//
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "test_utils/ANGLETest.h"
using namespace angle;
template <typename IndexType, GLenum IndexTypeName>
class IndexedPointsTest : public ANGLETest
{
protected:
IndexedPointsTest()
{
setWindowWidth(128);
setWindowHeight(128);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
setConfigDepthBits(24);
}
float getIndexPositionX(size_t idx)
{
return (idx == 0 || idx == 3) ? -0.5f : 0.5f;
}
float getIndexPositionY(size_t idx)
{
return (idx == 2 || idx == 3) ? -0.5f : 0.5f;
}
virtual void SetUp()
{
ANGLETest::SetUp();
const std::string vertexShaderSource = SHADER_SOURCE
(
precision highp float;
attribute vec2 position;
void main()
{
gl_PointSize = 5.0;
gl_Position = vec4(position, 0.0, 1.0);
}
);
const std::string fragmentShaderSource = SHADER_SOURCE
(
precision highp float;
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
);
mProgram = CompileProgram(vertexShaderSource, fragmentShaderSource);
if (mProgram == 0)
{
FAIL() << "shader compilation failed.";
}
const GLfloat vertices[] =
{
getIndexPositionX(0), getIndexPositionY(0),
getIndexPositionX(1), getIndexPositionY(1),
getIndexPositionX(2), getIndexPositionY(2),
getIndexPositionX(3), getIndexPositionY(3),
};
glGenBuffers(1, &mVertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), &vertices[0], GL_STATIC_DRAW);
const IndexType indices[] = { 0, 1, 2, 3 };
glGenBuffers(1, &mIndexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), &indices[0], GL_STATIC_DRAW);
}
virtual void TearDown()
{
glDeleteProgram(mProgram);
ANGLETest::TearDown();
}
void runTest(GLuint firstIndex)
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
GLint viewportSize[4];
glGetIntegerv(GL_VIEWPORT, viewportSize);
glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer);
GLint vertexLocation = glGetAttribLocation(mProgram, "position");
glVertexAttribPointer(vertexLocation, 2, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(vertexLocation);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer);
glUseProgram(mProgram);
glDrawElements(GL_POINTS, mPointCount - firstIndex, IndexTypeName, reinterpret_cast<void*>(firstIndex * sizeof(IndexType)));
for (size_t i = 0; i < mPointCount; i++)
{
GLuint x = static_cast<GLuint>(viewportSize[0] + (getIndexPositionX(i) * 0.5f + 0.5f) * (viewportSize[2] - viewportSize[0]));
GLuint y = static_cast<GLuint>(viewportSize[1] + (getIndexPositionY(i) * 0.5f + 0.5f) * (viewportSize[3] - viewportSize[1]));
if (i < firstIndex)
{
EXPECT_PIXEL_EQ(x, y, 0, 0, 0, 255);
}
else
{
EXPECT_PIXEL_EQ(x, y, 255, 0, 0, 255);
}
}
}
GLuint mProgram;
GLuint mVertexBuffer;
GLuint mIndexBuffer;
static const GLuint mPointCount = 4;
};
typedef IndexedPointsTest<GLubyte, GL_UNSIGNED_BYTE> IndexedPointsTestUByte;
TEST_P(IndexedPointsTestUByte, UnsignedByteOffset0)
{
runTest(0);
}
TEST_P(IndexedPointsTestUByte, UnsignedByteOffset1)
{
runTest(1);
}
TEST_P(IndexedPointsTestUByte, UnsignedByteOffset2)
{
runTest(2);
}
TEST_P(IndexedPointsTestUByte, UnsignedByteOffset3)
{
runTest(3);
}
typedef IndexedPointsTest<GLushort, GL_UNSIGNED_SHORT> IndexedPointsTestUShort;
TEST_P(IndexedPointsTestUShort, UnsignedShortOffset0)
{
runTest(0);
}
TEST_P(IndexedPointsTestUShort, UnsignedShortOffset1)
{
runTest(1);
}
TEST_P(IndexedPointsTestUShort, UnsignedShortOffset2)
{
runTest(2);
}
TEST_P(IndexedPointsTestUShort, UnsignedShortOffset3)
{
runTest(3);
}
typedef IndexedPointsTest<GLuint, GL_UNSIGNED_INT> IndexedPointsTestUInt;
TEST_P(IndexedPointsTestUInt, UnsignedIntOffset0)
{
if (getClientVersion() < 3 && !extensionEnabled("GL_OES_element_index_uint"))
{
return;
}
runTest(0);
}
TEST_P(IndexedPointsTestUInt, UnsignedIntOffset1)
{
if (getClientVersion() < 3 && !extensionEnabled("GL_OES_element_index_uint"))
{
return;
}
runTest(1);
}
TEST_P(IndexedPointsTestUInt, UnsignedIntOffset2)
{
if (getClientVersion() < 3 && !extensionEnabled("GL_OES_element_index_uint"))
{
return;
}
runTest(2);
}
TEST_P(IndexedPointsTestUInt, UnsignedIntOffset3)
{
if (getClientVersion() < 3 && !extensionEnabled("GL_OES_element_index_uint"))
{
return;
}
runTest(3);
}
// TODO(geofflang): Figure out why this test fails on Intel OpenGL
ANGLE_INSTANTIATE_TEST(IndexedPointsTestUByte, ES2_D3D11());
ANGLE_INSTANTIATE_TEST(IndexedPointsTestUShort, ES2_D3D11());
ANGLE_INSTANTIATE_TEST(IndexedPointsTestUInt, ES2_D3D11());