Hash :
1ea9aaad
Author :
Date :
2015-10-07T11:13:55
Add suppressions for several Intel failures. Also add a new test for UBOs to end2end_tests. BUG=540538 Change-Id: I6ffa6ba061a2c33811c65719deaa4302f1dbd704 Reviewed-on: https://chromium-review.googlesource.com/304521 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tryjob-Request: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@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 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
//
// 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;
namespace
{
class VertexAttributeTest : public ANGLETest
{
protected:
VertexAttributeTest()
{
setWindowWidth(128);
setWindowHeight(128);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
setConfigDepthBits(24);
mProgram = 0;
mTestAttrib = -1;
mExpectedAttrib = -1;
}
struct TestData
{
GLenum type;
GLboolean normalized;
const void *inputData;
const GLfloat *expectedData;
};
void runTest(const TestData& test)
{
// TODO(geofflang): Figure out why this is broken on AMD OpenGL
if (isAMD() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
{
std::cout << "Test skipped on AMD OpenGL." << std::endl;
return;
}
GLint viewportSize[4];
glGetIntegerv(GL_VIEWPORT, viewportSize);
GLint midPixelX = (viewportSize[0] + viewportSize[2]) / 2;
GLint midPixelY = (viewportSize[1] + viewportSize[3]) / 2;
for (GLint i = 0; i < 4; i++)
{
glBindBuffer(GL_ARRAY_BUFFER, 0);
glVertexAttribPointer(mTestAttrib, i + 1, test.type, test.normalized, 0, test.inputData);
glVertexAttribPointer(mExpectedAttrib, i + 1, GL_FLOAT, GL_FALSE, 0, test.expectedData);
glEnableVertexAttribArray(mTestAttrib);
glEnableVertexAttribArray(mExpectedAttrib);
drawQuad(mProgram, "position", 0.5f);
glDisableVertexAttribArray(mTestAttrib);
glDisableVertexAttribArray(mExpectedAttrib);
// We need to offset our checks from triangle edges to ensure we don't fall on a single tri
// Avoid making assumptions of drawQuad with four checks to check the four possible tri regions
EXPECT_PIXEL_EQ((midPixelX + viewportSize[0]) / 2, midPixelY, 255, 255, 255, 255);
EXPECT_PIXEL_EQ((midPixelX + viewportSize[2]) / 2, midPixelY, 255, 255, 255, 255);
EXPECT_PIXEL_EQ(midPixelX, (midPixelY + viewportSize[1]) / 2, 255, 255, 255, 255);
EXPECT_PIXEL_EQ(midPixelX, (midPixelY + viewportSize[3]) / 2, 255, 255, 255, 255);
}
}
void SetUp() override
{
ANGLETest::SetUp();
const std::string testVertexShaderSource = SHADER_SOURCE
(
attribute highp vec4 position;
attribute highp vec4 test;
attribute highp vec4 expected;
varying highp vec4 color;
void main(void)
{
gl_Position = position;
color = vec4(lessThan(abs(test - expected), vec4(1.0 / 64.0)));
}
);
const std::string testFragmentShaderSource = SHADER_SOURCE
(
varying highp vec4 color;
void main(void)
{
gl_FragColor = color;
}
);
mProgram = CompileProgram(testVertexShaderSource, testFragmentShaderSource);
if (mProgram == 0)
{
FAIL() << "shader compilation failed.";
}
mTestAttrib = glGetAttribLocation(mProgram, "test");
mExpectedAttrib = glGetAttribLocation(mProgram, "expected");
glUseProgram(mProgram);
glClearColor(0, 0, 0, 0);
glClearDepthf(0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_DEPTH_TEST);
}
void TearDown() override
{
glDeleteProgram(mProgram);
ANGLETest::TearDown();
}
GLuint compileMultiAttribProgram(GLint attribCount)
{
std::stringstream shaderStream;
shaderStream << "attribute highp vec4 position;" << std::endl;
for (GLint attribIndex = 0; attribIndex < attribCount; ++attribIndex)
{
shaderStream << "attribute float a" << attribIndex << ";" << std::endl;
}
shaderStream << "varying highp float color;" << std::endl
<< "void main() {" << std::endl
<< " gl_Position = position;" << std::endl
<< " color = 0.0;" << std::endl;
for (GLint attribIndex = 0; attribIndex < attribCount; ++attribIndex)
{
shaderStream << " color += a" << attribIndex << ";" << std::endl;
}
shaderStream << "}" << std::endl;
const std::string testFragmentShaderSource = SHADER_SOURCE
(
varying highp float color;
void main(void)
{
gl_FragColor = vec4(color, 0.0, 0.0, 1.0);
}
);
return CompileProgram(shaderStream.str(), testFragmentShaderSource);
}
void setupMultiAttribs(GLuint program, GLint attribCount, GLfloat value)
{
glUseProgram(program);
for (GLint attribIndex = 0; attribIndex < attribCount; ++attribIndex)
{
std::stringstream attribStream;
attribStream << "a" << attribIndex;
GLint location = glGetAttribLocation(program, attribStream.str().c_str());
ASSERT_NE(-1, location);
glVertexAttrib1f(location, value);
glDisableVertexAttribArray(location);
}
}
static const size_t mVertexCount = 24;
GLuint mProgram;
GLint mTestAttrib;
GLint mExpectedAttrib;
};
TEST_P(VertexAttributeTest, UnsignedByteUnnormalized)
{
GLubyte inputData[mVertexCount] = { 0, 1, 2, 3, 4, 5, 6, 7, 125, 126, 127, 128, 129, 250, 251, 252, 253, 254, 255 };
GLfloat expectedData[mVertexCount];
for (size_t i = 0; i < mVertexCount; i++)
{
expectedData[i] = inputData[i];
}
TestData data = { GL_UNSIGNED_BYTE, GL_FALSE, inputData, expectedData };
runTest(data);
}
TEST_P(VertexAttributeTest, UnsignedByteNormalized)
{
GLubyte inputData[mVertexCount] = { 0, 1, 2, 3, 4, 5, 6, 7, 125, 126, 127, 128, 129, 250, 251, 252, 253, 254, 255 };
GLfloat expectedData[mVertexCount];
for (size_t i = 0; i < mVertexCount; i++)
{
expectedData[i] = inputData[i] / 255.0f;
}
TestData data = { GL_UNSIGNED_BYTE, GL_TRUE, inputData, expectedData };
runTest(data);
}
TEST_P(VertexAttributeTest, ByteUnnormalized)
{
GLbyte inputData[mVertexCount] = { 0, 1, 2, 3, 4, -1, -2, -3, -4, 125, 126, 127, -128, -127, -126 };
GLfloat expectedData[mVertexCount];
for (size_t i = 0; i < mVertexCount; i++)
{
expectedData[i] = inputData[i];
}
TestData data = { GL_BYTE, GL_FALSE, inputData, expectedData };
runTest(data);
}
TEST_P(VertexAttributeTest, ByteNormalized)
{
GLbyte inputData[mVertexCount] = { 0, 1, 2, 3, 4, -1, -2, -3, -4, 125, 126, 127, -128, -127, -126 };
GLfloat expectedData[mVertexCount];
for (size_t i = 0; i < mVertexCount; i++)
{
expectedData[i] = ((2.0f * inputData[i]) + 1.0f) / 255.0f;
}
TestData data = { GL_BYTE, GL_TRUE, inputData, expectedData };
runTest(data);
}
TEST_P(VertexAttributeTest, UnsignedShortUnnormalized)
{
GLushort inputData[mVertexCount] = { 0, 1, 2, 3, 254, 255, 256, 32766, 32767, 32768, 65533, 65534, 65535 };
GLfloat expectedData[mVertexCount];
for (size_t i = 0; i < mVertexCount; i++)
{
expectedData[i] = inputData[i];
}
TestData data = { GL_UNSIGNED_SHORT, GL_FALSE, inputData, expectedData };
runTest(data);
}
TEST_P(VertexAttributeTest, UnsignedShortNormalized)
{
GLushort inputData[mVertexCount] = { 0, 1, 2, 3, 254, 255, 256, 32766, 32767, 32768, 65533, 65534, 65535 };
GLfloat expectedData[mVertexCount];
for (size_t i = 0; i < mVertexCount; i++)
{
expectedData[i] = inputData[i] / 65535.0f;
}
TestData data = { GL_UNSIGNED_SHORT, GL_TRUE, inputData, expectedData };
runTest(data);
}
TEST_P(VertexAttributeTest, ShortUnnormalized)
{
GLshort inputData[mVertexCount] = { 0, 1, 2, 3, -1, -2, -3, -4, 32766, 32767, -32768, -32767, -32766 };
GLfloat expectedData[mVertexCount];
for (size_t i = 0; i < mVertexCount; i++)
{
expectedData[i] = inputData[i];
}
TestData data = { GL_SHORT, GL_FALSE, inputData, expectedData };
runTest(data);
}
TEST_P(VertexAttributeTest, ShortNormalized)
{
GLshort inputData[mVertexCount] = { 0, 1, 2, 3, -1, -2, -3, -4, 32766, 32767, -32768, -32767, -32766 };
GLfloat expectedData[mVertexCount];
for (size_t i = 0; i < mVertexCount; i++)
{
expectedData[i] = ((2.0f * inputData[i]) + 1.0f) / 65535.0f;
}
TestData data = { GL_SHORT, GL_TRUE, inputData, expectedData };
runTest(data);
}
// Validate that we can support GL_MAX_ATTRIBS attribs
TEST_P(VertexAttributeTest, MaxAttribs)
{
// TODO(jmadill): Figure out why we get this error on AMD/OpenGL and Intel.
if ((isIntel() || isAMD()) && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
{
std::cout << "Test skipped on Intel and AMD." << std::endl;
return;
}
GLint maxAttribs;
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxAttribs);
ASSERT_GL_NO_ERROR();
// Reserve one attrib for position
GLint drawAttribs = maxAttribs - 1;
GLuint program = compileMultiAttribProgram(drawAttribs);
ASSERT_NE(0u, program);
setupMultiAttribs(program, drawAttribs, 0.5f / static_cast<float>(drawAttribs));
drawQuad(program, "position", 0.5f);
EXPECT_GL_NO_ERROR();
EXPECT_PIXEL_NEAR(0, 0, 128, 0, 0, 255, 1);
}
// Validate that we cannot support GL_MAX_ATTRIBS+1 attribs
TEST_P(VertexAttributeTest, MaxAttribsPlusOne)
{
// TODO(jmadill): Figure out why we get this error on AMD/ES2/OpenGL
if (isAMD() && GetParam() == ES2_OPENGL())
{
std::cout << "Test disabled on AMD/ES2/OpenGL" << std::endl;
return;
}
GLint maxAttribs;
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxAttribs);
ASSERT_GL_NO_ERROR();
// Exceed attrib count by one (counting position)
GLint drawAttribs = maxAttribs;
GLuint program = compileMultiAttribProgram(drawAttribs);
ASSERT_EQ(0u, program);
}
// Simple test for when we use glBindAttribLocation
TEST_P(VertexAttributeTest, SimpleBindAttribLocation)
{
// TODO(jmadill): Figure out why this fails on Intel.
if (isIntel() && GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
{
std::cout << "Test skipped on Intel." << std::endl;
return;
}
// Re-use the multi-attrib program, binding attribute 0
GLuint program = compileMultiAttribProgram(1);
glBindAttribLocation(program, 2, "position");
glBindAttribLocation(program, 3, "a0");
glLinkProgram(program);
// Setup and draw the quad
setupMultiAttribs(program, 1, 0.5f);
drawQuad(program, "position", 0.5f);
EXPECT_GL_NO_ERROR();
EXPECT_PIXEL_NEAR(0, 0, 128, 0, 0, 255, 1);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
// D3D11 Feature Level 9_3 uses different D3D formats for vertex attribs compared to Feature Levels 10_0+, so we should test them separately.
ANGLE_INSTANTIATE_TEST(VertexAttributeTest, ES2_D3D9(), ES2_D3D11(), ES2_D3D11_FL9_3(), ES2_OPENGL(), ES3_OPENGL());
} // namespace