Hash :
d6053daa
Author :
Date :
2019-12-05T17:46:23
Remove tabs from source files. WebKit's Subversion repo refuses to commit source files that contain tabs. Bug: angleproject:3439 Change-Id: I0a804bcfa0375a98e19945e20297c90d31106827 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1954410 Commit-Queue: James Darpinian <jdarpinian@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@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 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562
//
// Copyright 2016 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.
//
// QualificationOrder_test.cpp:
// OpenGL ES 3.1 removes the strict order of qualifiers imposed by the grammar.
// This file contains tests for invalid order and usage of qualifiers.
#include "tests/test_utils/ShaderCompileTreeTest.h"
using namespace sh;
class QualificationOrderFragmentShaderTest : public ShaderCompileTreeTest
{
public:
QualificationOrderFragmentShaderTest() {}
protected:
void initResources(ShBuiltInResources *resources) override
{
resources->MaxDrawBuffers = (getShaderSpec() == SH_GLES2_SPEC) ? 1 : 8;
}
::GLenum getShaderType() const override { return GL_FRAGMENT_SHADER; }
ShShaderSpec getShaderSpec() const override { return SH_GLES3_1_SPEC; }
};
class QualificationOrderVertexShaderTest : public QualificationOrderFragmentShaderTest
{
public:
QualificationOrderVertexShaderTest() {}
protected:
::GLenum getShaderType() const override { return GL_VERTEX_SHADER; }
};
// Repeating centroid qualifier is invalid.
TEST_F(QualificationOrderFragmentShaderTest, RepeatingCentroid)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"flat centroid centroid in float myValue;\n"
"void main() {\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Repeating uniform storage qualifiers is invalid.
TEST_F(QualificationOrderFragmentShaderTest, RepeatingUniforms)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"uniform uniform float myValue;\n"
"void main() {\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Repeating varying storage qualifiers is invalid.
TEST_F(QualificationOrderFragmentShaderTest, RepeatingVaryings)
{
const std::string &shaderString =
"precision mediump float;\n"
"varying varying vec4 myColor;\n"
"void main() {\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Layout qualifier should be before the storage qualifiers.
TEST_F(QualificationOrderFragmentShaderTest, WrongOrderQualifiers)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"out layout(location=1) vec4 myColor;\n"
"void main() {\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Centroid out is the correct order. Out centroid is incorrect.
TEST_F(QualificationOrderVertexShaderTest, WrongOrderCentroidOut)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"in vec4 uv;\n"
"out centroid vec4 position;\n"
"void main() {\n"
"position = uv;\n"
"gl_Position = uv;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Centroid in is the correct order. In centroid is incorrect.
TEST_F(QualificationOrderFragmentShaderTest, WrongOrderCentroidIn)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"in centroid vec4 colorIN;\n"
"out vec4 colorOUT;\n"
"void main() {\n"
"colorOUT = colorIN;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Type cannot be before the storage qualifier.
TEST_F(QualificationOrderFragmentShaderTest, WrongOrderTypeStorage)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"centroid in vec4 colorIN;\n"
"vec4 out colorOUT;\n"
"void main() {\n"
"colorOUT = colorIN;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// A variable cannot have two conflicting storage qualifiers.
TEST_F(QualificationOrderFragmentShaderTest, RepeatingDifferentStorageQualifiers)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"centroid in vec4 colorIN;\n"
"uniform out vec4 colorOUT;\n"
"void main() {\n"
"colorOUT = colorIN;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// A variable cannot have two different layout qualifiers.
TEST_F(QualificationOrderFragmentShaderTest, RepeatingLayoutQualifiers)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"in vec4 colorIN;\n"
"layout(location=0) layout(location=0) out vec4 colorOUT;\n"
"void main() {\n"
"colorOUT = colorIN;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// A variable cannot have repeating invariant qualifiers.
TEST_F(QualificationOrderFragmentShaderTest, RepeatingInvariantQualifiers)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"in vec4 colorIN;\n"
"invariant invariant out vec4 colorOUT;\n"
"void main() {\n"
"colorOUT = colorIN;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// A variable cannot have repeating storage qualifiers.
TEST_F(QualificationOrderVertexShaderTest, RepeatingAttributes)
{
const std::string &shaderString =
"precision mediump float;\n"
"attribute attribute vec4 positionIN;\n"
"void main() {\n"
"gl_Position = positionIN;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Wrong order for invariant varying. It should be 'invariant varying', not 'varying invariant'.
TEST_F(QualificationOrderVertexShaderTest, VaryingInvariantWrongOrder)
{
const std::string &shaderString =
"precision mediump float;\n"
"attribute vec4 positionIN;\n"
"varying invariant vec4 dataOUT;\n"
"void main() {\n"
"gl_Position = positionIN;\n"
"dataOUT = 0.5 * dataOUT + vec4(0.5);\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// A variable cannot have repeating storage qualifiers.
TEST_F(QualificationOrderVertexShaderTest, AttributeVaryingMix)
{
const std::string &shaderString =
"precision mediump float;\n"
"attribute varying vec4 positionIN;\n"
"void main() {\n"
"gl_Position = positionIN;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// A variable cannot have repeating storage qualifiers.
TEST_F(QualificationOrderVertexShaderTest, VaryingAttributeMix)
{
const std::string &shaderString =
"precision mediump float;\n"
"varying attribute vec4 positionIN;\n"
"void main() {\n"
"gl_Position = positionIN;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// A variable cannot have repeating interpolation qualifiers.
TEST_F(QualificationOrderVertexShaderTest, RepeatingInterpolationQualifiers)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"in vec4 positionIN;\n"
"flat flat out vec4 dataOUT;\n"
"void main() {\n"
"gl_Position = positionIN;\n"
"dataOUT = 0.5 * dataOUT + vec4(0.5);\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Wrong order for the interpolation and storage qualifier. The correct order is interpolation
// qualifier and then storage qualifier.
TEST_F(QualificationOrderVertexShaderTest, WrongOrderInterpolationStorageQualifiers)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"in vec4 positionIN;\n"
"out flat vec4 dataOUT;\n"
"void main() {\n"
"gl_Position = positionIN;\n"
"dataOUT = 0.5 * dataOUT + vec4(0.5);\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// The correct order is invariant, interpolation, storage.
TEST_F(QualificationOrderVertexShaderTest, WrongOrderInvariantInterpolationStorageQualifiers)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"in vec4 positionIN;\n"
"flat invariant out vec4 dataOUT;\n"
"void main() {\n"
"gl_Position = positionIN;\n"
"dataOUT = 0.5 * dataOUT + vec4(0.5);\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// The invariant qualifer has to be before the storage qualifiers.
TEST_F(QualificationOrderVertexShaderTest, WrongOrderInvariantNotFirst)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"in vec4 positionIN;\n"
"centroid out invariant vec4 dataOUT;\n"
"void main() {\n"
"gl_Position = positionIN;\n"
"dataOUT = 0.5 * dataOUT + vec4(0.5);\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// The precision qualifier is after the storage qualifiers.
TEST_F(QualificationOrderVertexShaderTest, WrongOrderPrecision)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"in vec4 positionIN;\n"
"highp centroid out vec4 dataOUT;\n"
"void main() {\n"
"gl_Position = positionIN;\n"
"dataOUT = 0.5 * dataOUT + vec4(0.5);\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// A variable cannot have multiple declarations of the 'in' storage qualifier.
TEST_F(QualificationOrderVertexShaderTest, RepeatingInQualifier)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"in in vec4 positionIN;\n"
"void main() {\n"
"gl_Position = positionIN;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// A variable cannot have multiple declarations of the 'attribute' storage qualifier.
TEST_F(QualificationOrderVertexShaderTest, RepeatingAttributeQualifier)
{
const std::string &shaderString =
"precision mediump float;\n"
"attribute attribute vec4 positionIN;\n"
"void main() {\n"
"gl_Position = positionIN;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Vertex input cannot be qualified with invariant.
TEST_F(QualificationOrderVertexShaderTest, InvariantVertexInput)
{
const std::string &shaderString =
"precision mediump float;\n"
"invariant attribute vec4 positionIN;\n"
"void main() {\n"
"gl_Position = positionIN;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Cannot have a function parameter with the invariant qualifier.
TEST_F(QualificationOrderFragmentShaderTest, InvalidFunctionParametersInvariant)
{
const std::string &shaderString =
"precision lowp float;\n"
"varying float value;\n"
"float foo0 (invariant in float x) {\n"
" return 2.0*x;\n"
"}\n"
"void main()\n"
"{\n"
" gl_FragColor = vec4(foo0(value));\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure" << mInfoLog;
}
}
// Cannot have a function parameter with the attribute qualifier.
TEST_F(QualificationOrderFragmentShaderTest, InvalidFunctionParametersAttribute)
{
const std::string &shaderString =
"precision lowp float;\n"
"varying float value;\n"
"float foo0 (attribute float x) {\n"
" return 2.0*x;\n"
"}\n"
"void main()\n"
"{\n"
" gl_FragColor = vec4(foo0(value));\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure" << mInfoLog;
}
}
// Cannot have a function parameter with the varying qualifier.
TEST_F(QualificationOrderFragmentShaderTest, InvalidFunctionParametersVarying)
{
const std::string &shaderString =
"precision lowp float;\n"
"varying float value;\n"
"float foo0 (varying float x) {\n"
" return 2.0*x;\n"
"}\n"
"void main()\n"
"{\n"
" gl_FragColor = vec4(foo0(value));\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure" << mInfoLog;
}
}
// Cannot have a function parameter with the layout qualifier
TEST_F(QualificationOrderFragmentShaderTest, InvalidFunctionParametersLayout)
{
const std::string &shaderString =
"#version 300 es\n"
"precision lowp float;\n"
"in float value;\n"
"float foo0 (layout(location = 3) in float x) {\n"
" return 2.0*x;\n"
"}\n"
"out vec4 colorOUT;\n"
"void main()\n"
"{\n"
" colorOUT = vec4(foo0(value));\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure" << mInfoLog;
}
}
// Cannot have a function parameter with the centroid qualifier
TEST_F(QualificationOrderFragmentShaderTest, InvalidFunctionParametersCentroidIn)
{
const std::string &shaderString =
"#version 300 es\n"
"precision lowp float;\n"
"in float value;\n"
"float foo0 (centroid in float x) {\n"
" return 2.0*x;\n"
"}\n"
"out vec4 colorOUT;\n"
"void main()\n"
"{\n"
" colorOUT = vec4(foo0(value));\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure" << mInfoLog;
}
}
// Cannot have a function parameter with the flat qualifier
TEST_F(QualificationOrderFragmentShaderTest, InvalidFunctionParametersFlatIn)
{
const std::string &shaderString =
"#version 300 es\n"
"precision lowp float;\n"
"in float value;\n"
"float foo0 (flat in float x) {\n"
" return 2.0*x;\n"
"}\n"
"out vec4 colorOUT;\n"
"void main()\n"
"{\n"
" colorOUT = vec4(foo0(value));\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure" << mInfoLog;
}
}
// Output layout location qualifier can't appear more than once within a declaration.
// GLSL ES 3.00.6 section 4.3.8.2 Output Layout Qualifiers.
TEST_F(QualificationOrderFragmentShaderTest, TwoOutputLocations)
{
const std::string &shaderString =
"#version 300 es\n"
"precision mediump float;\n"
"layout(location=1, location=2) out vec4 myColor;\n"
"void main() {\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}