Hash :
1be913cf
Author :
Date :
2016-07-11T17:59:16
Add support for ES31 context creation The dEQP test for context creation passes. SH_WEBGL3_SPEC has been added, but it should be considered whether we should keep it, remove it or rename it. It was added so that there is a webgl mapping to es 310 shaders. Check Compiler.cpp. The bison file has been modified so that some tokens from es3 can be also used in es31 as well. A separate macro ES3_1_ONLY is added so that some tokens are limited only for es 310 shaders. BUG=angleproject:1442 TEST=angle_unittests Change-Id: I2e5ca227c96046c30dc796ab934f3fda9c533eba Reviewed-on: https://chromium-review.googlesource.com/360300 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: 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 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
//
// 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);
ASSERT_NE(0u, mProgram);
const std::string vertexShaderSource2 = SHADER_SOURCE
(
precision highp float;
attribute vec2 position;
attribute vec4 color;
varying vec4 vcolor;
void main()
{
gl_PointSize = 5.0;
gl_Position = vec4(position, 0.0, 1.0);
vcolor = color;
}
);
const std::string fragmentShaderSource2 = SHADER_SOURCE
(
precision highp float;
varying vec4 vcolor;
void main()
{
gl_FragColor = vec4(vcolor.xyz, 1.0);
}
);
mVertexWithColorBufferProgram = CompileProgram(vertexShaderSource2, fragmentShaderSource2);
ASSERT_NE(0u, mVertexWithColorBufferProgram);
// Construct a vertex buffer of position values and color values
// contained in a single structure
const float verticesWithColor[] =
{
getIndexPositionX(0), getIndexPositionY(0), 0.0f, 1.0f, 0.0f,
getIndexPositionX(2), getIndexPositionY(2), 0.0f, 1.0f, 0.0f,
getIndexPositionX(1), getIndexPositionY(1), 0.0f, 1.0f, 0.0f,
getIndexPositionX(3), getIndexPositionY(3), 0.0f, 1.0f, 0.0f,
};
glGenBuffers(1, &mVertexWithColorBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mVertexWithColorBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(verticesWithColor), &verticesWithColor[0], GL_STATIC_DRAW);
// Construct a vertex buffer of position values only
const GLfloat vertices[] =
{
getIndexPositionX(0), getIndexPositionY(0),
getIndexPositionX(2), getIndexPositionY(2),
getIndexPositionX(1), getIndexPositionY(1),
getIndexPositionX(3), getIndexPositionY(3),
};
glGenBuffers(1, &mVertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), &vertices[0], GL_STATIC_DRAW);
// The indices buffer is shared between both variations of tests
const IndexType indices[] = { 0, 2, 1, 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()
{
glDeleteBuffers(1, &mVertexBuffer);
glDeleteBuffers(1, &mIndexBuffer);
glDeleteProgram(mProgram);
glDeleteBuffers(1, &mVertexWithColorBuffer);
glDeleteProgram(mVertexWithColorBufferProgram);
ANGLETest::TearDown();
}
void runTest(GLuint firstIndex, bool useVertexBufferWithColor = false)
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
GLint viewportSize[4];
glGetIntegerv(GL_VIEWPORT, viewportSize);
// Choose appropriate program to apply for the test
GLuint program = useVertexBufferWithColor ? mVertexWithColorBufferProgram : mProgram;
if (useVertexBufferWithColor)
{
glBindBuffer(GL_ARRAY_BUFFER, mVertexWithColorBuffer);
GLint vertexLocation = glGetAttribLocation(program, "position");
glVertexAttribPointer(vertexLocation, 2, GL_FLOAT, GL_FALSE,
static_cast<const GLsizei>(VertexWithColorSize), 0);
glEnableVertexAttribArray(vertexLocation);
GLint vertexColorLocation = glGetAttribLocation(program, "color");
glVertexAttribPointer(vertexColorLocation, 3, GL_FLOAT, GL_FALSE,
static_cast<const GLsizei>(VertexWithColorSize),
(GLvoid *)((sizeof(float) * 2)));
glEnableVertexAttribArray(vertexColorLocation);
}
else
{
glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer);
GLint vertexLocation = glGetAttribLocation(program, "position");
glVertexAttribPointer(vertexLocation, 2, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(vertexLocation);
}
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer);
glUseProgram(program);
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
{
if (useVertexBufferWithColor)
{
// Pixel data is assumed to be GREEN
EXPECT_PIXEL_EQ(x, y, 0, 255, 0, 255);
}
else
{
// Pixel data is assumed to be RED
EXPECT_PIXEL_EQ(x, y, 255, 0, 0, 255);
}
}
}
swapBuffers();
}
GLuint mProgram;
GLuint mVertexBuffer;
GLuint mIndexBuffer;
GLuint mVertexWithColorBufferProgram;
GLuint mVertexWithColorBuffer;
static const GLuint mPointCount = 4;
private:
const size_t VertexWithColorSize = sizeof(float) * 5;
};
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);
}
TEST_P(IndexedPointsTestUByte, VertexWithColorUnsignedByteOffset0)
{
runTest(0, true);
}
TEST_P(IndexedPointsTestUByte, VertexWithColorUnsignedByteOffset1)
{
runTest(1, true);
}
TEST_P(IndexedPointsTestUByte, VertexWithColorUnsignedByteOffset2)
{
runTest(2, true);
}
TEST_P(IndexedPointsTestUByte, VertexWithColorUnsignedByteOffset3)
{
runTest(3, true);
}
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);
}
TEST_P(IndexedPointsTestUShort, VertexWithColorUnsignedShortOffset0)
{
runTest(0, true);
}
TEST_P(IndexedPointsTestUShort, VertexWithColorUnsignedShortOffset1)
{
runTest(1, true);
}
TEST_P(IndexedPointsTestUShort, VertexWithColorUnsignedShortOffset2)
{
runTest(2, true);
}
TEST_P(IndexedPointsTestUShort, VertexWithColorUnsignedShortOffset3)
{
runTest(3, true);
}
TEST_P(IndexedPointsTestUShort, VertexWithColorUnsignedShortOffsetChangingIndices)
{
runTest(3, true);
runTest(1, true);
runTest(0, true);
runTest(2, true);
}
typedef IndexedPointsTest<GLuint, GL_UNSIGNED_INT> IndexedPointsTestUInt;
TEST_P(IndexedPointsTestUInt, UnsignedIntOffset0)
{
if (getClientMajorVersion() < 3 && !extensionEnabled("GL_OES_element_index_uint"))
{
return;
}
runTest(0);
}
TEST_P(IndexedPointsTestUInt, UnsignedIntOffset1)
{
if (getClientMajorVersion() < 3 && !extensionEnabled("GL_OES_element_index_uint"))
{
return;
}
runTest(1);
}
TEST_P(IndexedPointsTestUInt, UnsignedIntOffset2)
{
if (getClientMajorVersion() < 3 && !extensionEnabled("GL_OES_element_index_uint"))
{
return;
}
runTest(2);
}
TEST_P(IndexedPointsTestUInt, UnsignedIntOffset3)
{
if (getClientMajorVersion() < 3 && !extensionEnabled("GL_OES_element_index_uint"))
{
return;
}
runTest(3);
}
TEST_P(IndexedPointsTestUInt, VertexWithColorUnsignedIntOffset0)
{
if (getClientMajorVersion() < 3 && !extensionEnabled("GL_OES_element_index_uint"))
{
return;
}
runTest(0, false);
}
TEST_P(IndexedPointsTestUInt, VertexWithColorUnsignedIntOffset1)
{
if (getClientMajorVersion() < 3 && !extensionEnabled("GL_OES_element_index_uint"))
{
return;
}
runTest(1, false);
}
TEST_P(IndexedPointsTestUInt, VertexWithColorUnsignedIntOffset2)
{
if (getClientMajorVersion() < 3 && !extensionEnabled("GL_OES_element_index_uint"))
{
return;
}
runTest(2, false);
}
TEST_P(IndexedPointsTestUInt, VertexWithColorUnsignedIntOffset3)
{
if (getClientMajorVersion() < 3 && !extensionEnabled("GL_OES_element_index_uint"))
{
return;
}
runTest(3, false);
}
// TODO(geofflang): Figure out why this test fails on Intel OpenGL
ANGLE_INSTANTIATE_TEST(IndexedPointsTestUByte,
ES2_D3D11(),
ES2_D3D11_FL9_3(),
ES2_OPENGL(),
ES2_OPENGLES());
ANGLE_INSTANTIATE_TEST(IndexedPointsTestUShort,
ES2_D3D11(),
ES2_D3D11_FL9_3(),
ES2_OPENGL(),
ES2_OPENGLES());
ANGLE_INSTANTIATE_TEST(IndexedPointsTestUInt,
ES2_D3D11(),
ES2_D3D11_FL9_3(),
ES2_OPENGL(),
ES2_OPENGLES());