1 #ifndef _GL4CSHADINGLANGUAGE420PACKTESTS_HPP 2 #define _GL4CSHADINGLANGUAGE420PACKTESTS_HPP 3 /*------------------------------------------------------------------------- 4 * OpenGL Conformance Test Suite 5 * ----------------------------- 6 * 7 * Copyright (c) 2014-2016 The Khronos Group Inc. 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 */ /*! 22 * \file 23 * \brief 24 */ /*-------------------------------------------------------------------*/ 25 26 /** 27 * \file gl4cShadingLanguage420PackTests.hpp 28 * \brief Declares test classes for "Shading Language 420Pack" functionality. 29 */ /*-------------------------------------------------------------------*/ 30 31 #include "glcTestCase.hpp" 32 #include "glwDefs.hpp" 33 34 namespace tcu 35 { 36 class MessageBuilder; 37 } /* namespace tcu */ 38 39 namespace gl4cts 40 { 41 42 namespace GLSL420Pack 43 { 44 class Utils 45 { 46 public: 47 /* Public enums */ 48 enum TEXTURE_TYPES 49 { 50 TEX_BUFFER, 51 TEX_2D, 52 TEX_2D_RECT, 53 TEX_2D_ARRAY, 54 TEX_3D, 55 TEX_CUBE, 56 TEX_1D, 57 TEX_1D_ARRAY, 58 59 /* */ 60 TEXTURE_TYPES_MAX 61 }; 62 63 enum SHADER_STAGES 64 { 65 COMPUTE_SHADER = 0, 66 VERTEX_SHADER, 67 TESS_CTRL_SHADER, 68 TESS_EVAL_SHADER, 69 GEOMETRY_SHADER, 70 FRAGMENT_SHADER, 71 72 /* */ 73 SHADER_STAGES_MAX 74 }; 75 76 enum UTF8_CHARACTERS 77 { 78 TWO_BYTES, 79 THREE_BYTES, 80 FOUR_BYTES, 81 FIVE_BYTES, 82 SIX_BYTES, 83 REDUNDANT_ASCII, 84 85 /* */ 86 EMPTY 87 }; 88 89 enum TYPES 90 { 91 FLOAT, 92 DOUBLE, 93 INT, 94 UINT, 95 96 /* */ 97 TYPES_MAX 98 }; 99 100 enum QUALIFIER_CLASSES 101 { 102 QUAL_CLS_INVARIANCE = 0, 103 QUAL_CLS_INTERPOLATION, 104 QUAL_CLS_LAYOUT, 105 QUAL_CLS_AUXILARY_STORAGE, 106 QUAL_CLS_STORAGE, 107 QUAL_CLS_PRECISION, 108 109 /* */ 110 QUAL_CLS_MAX 111 }; 112 113 enum QUALIFIERS 114 { 115 QUAL_NONE, 116 117 /* CONSTNESS */ 118 QUAL_CONST, 119 120 /* STORAGE */ 121 QUAL_IN, 122 QUAL_OUT, 123 QUAL_INOUT, 124 QUAL_UNIFORM, 125 126 /* AUXILARY */ 127 QUAL_PATCH, 128 QUAL_CENTROID, 129 QUAL_SAMPLE, 130 131 /* INTERPOLATION */ 132 QUAL_FLAT, 133 QUAL_NOPERSPECTIVE, 134 QUAL_SMOOTH, 135 136 /* LAYOUT */ 137 QUAL_LOCATION, 138 139 /* PRECISION */ 140 QUAL_LOWP, 141 QUAL_MEDIUMP, 142 QUAL_HIGHP, 143 QUAL_PRECISE, 144 145 /* INVARIANCE */ 146 QUAL_INVARIANT, 147 148 /* */ 149 QUAL_MAX 150 }; 151 152 enum VARIABLE_STORAGE 153 { 154 INPUT, 155 OUTPUT, 156 UNIFORM, 157 158 /* */ 159 STORAGE_MAX 160 }; 161 162 enum VARIABLE_FLAVOUR 163 { 164 BASIC, 165 ARRAY, 166 INDEXED_BY_INVOCATION_ID 167 }; 168 169 /* Public types */ 170 struct buffer 171 { 172 buffer(deqp::Context &context); 173 ~buffer(); 174 175 void bind() const; 176 177 void bindRange(glw::GLuint index, glw::GLintptr offset, glw::GLsizeiptr size); 178 179 void generate(glw::GLenum target); 180 void *map(glw::GLenum access) const; 181 void unmap() const; 182 183 void update(glw::GLsizeiptr size, glw::GLvoid *data, glw::GLenum usage); 184 185 void release(); 186 glw::GLuint m_id; 187 188 private: 189 deqp::Context &m_context; 190 glw::GLenum m_target; 191 }; 192 193 struct framebuffer 194 { 195 framebuffer(deqp::Context &context); 196 ~framebuffer(); 197 198 void attachTexture(glw::GLenum attachment, glw::GLuint texture_id, glw::GLuint width, glw::GLuint height); 199 200 void bind(); 201 void clear(glw::GLenum mask); 202 203 void clearColor(glw::GLfloat red, glw::GLfloat green, glw::GLfloat blue, glw::GLfloat alpha); 204 205 void generate(); 206 207 glw::GLuint m_id; 208 209 private: 210 deqp::Context &m_context; 211 }; 212 213 struct shaderSource 214 { 215 shaderSource(); 216 shaderSource(const shaderSource &source); 217 shaderSource(const glw::GLchar *source_code); 218 219 struct shaderPart 220 { 221 std::string m_code; 222 glw::GLint m_length; 223 }; 224 225 std::vector<shaderPart> m_parts; 226 bool m_use_lengths; 227 }; 228 229 class shaderCompilationException : public std::exception 230 { 231 public: 232 shaderCompilationException(const shaderSource &source, const glw::GLchar *message); 233 ~shaderCompilationException()234 virtual ~shaderCompilationException() throw() 235 { 236 } 237 238 virtual const char *what() const throw(); 239 240 shaderSource m_shader_source; 241 std::string m_error_message; 242 }; 243 244 class programLinkageException : public std::exception 245 { 246 public: 247 programLinkageException(const glw::GLchar *error_message); 248 ~programLinkageException()249 virtual ~programLinkageException() throw() 250 { 251 } 252 253 virtual const char *what() const throw(); 254 255 std::string m_error_message; 256 }; 257 258 /** Store information about program object 259 * 260 **/ 261 struct program 262 { 263 program(deqp::Context &context); 264 ~program(); 265 266 void build(const glw::GLchar *compute_shader_code, const glw::GLchar *fragment_shader_code, 267 const glw::GLchar *geometry_shader_code, const glw::GLchar *tesselation_control_shader_code, 268 const glw::GLchar *tesselation_evaluation_shader_code, const glw::GLchar *vertex_shader_code, 269 const glw::GLchar *const *varying_names, glw::GLuint n_varying_names, bool is_separable = false); 270 271 void build(const shaderSource &compute_shader, const shaderSource &fragment_shader, 272 const shaderSource &geometry_shader, const shaderSource &tesselation_control_shader, 273 const shaderSource &tesselation_evaluation_shader, const shaderSource &vertex_shader, 274 const glw::GLchar *const *varying_names, glw::GLuint n_varying_names, bool is_separable = false); 275 276 void compile(glw::GLuint shader_id, const shaderSource &source) const; 277 278 void createFromBinary(const std::vector<glw::GLubyte> &binary, glw::GLenum binary_format); 279 280 glw::GLint getAttribLocation(const glw::GLchar *name) const; 281 282 void getBinary(std::vector<glw::GLubyte> &binary, glw::GLenum &binary_format) const; 283 284 glw::GLuint getSubroutineIndex(const glw::GLchar *subroutine_name, glw::GLenum shader_stage) const; 285 286 glw::GLint getSubroutineUniformLocation(const glw::GLchar *uniform_name, glw::GLenum shader_stage) const; 287 288 glw::GLint getUniform1i(glw::GLuint location) const; 289 glw::GLint getUniformLocation(const glw::GLchar *uniform_name) const; 290 291 void link() const; 292 void remove(); 293 294 void uniform(const glw::GLchar *uniform_name, TYPES type, glw::GLuint n_columns, glw::GLuint n_rows, 295 const void *data) const; 296 297 void use() const; 298 299 /* */ 300 static void printShaderSource(const shaderSource &source, tcu::MessageBuilder &log); 301 302 static const glw::GLenum ARB_COMPUTE_SHADER; 303 304 glw::GLuint m_compute_shader_id; 305 glw::GLuint m_fragment_shader_id; 306 glw::GLuint m_geometry_shader_id; 307 glw::GLuint m_program_object_id; 308 glw::GLuint m_tesselation_control_shader_id; 309 glw::GLuint m_tesselation_evaluation_shader_id; 310 glw::GLuint m_vertex_shader_id; 311 312 private: 313 deqp::Context &m_context; 314 }; 315 316 struct texture 317 { 318 texture(deqp::Context &context); 319 ~texture(); 320 321 void bind() const; 322 323 void create(glw::GLuint width, glw::GLuint height, glw::GLenum internal_format); 324 325 void create(glw::GLuint width, glw::GLuint height, glw::GLuint depth, glw::GLenum internal_format, 326 TEXTURE_TYPES texture_type); 327 328 void createBuffer(glw::GLenum internal_format, glw::GLuint buffer_id); 329 330 void get(glw::GLenum format, glw::GLenum type, glw::GLvoid *out_data) const; 331 332 void release(); 333 334 void update(glw::GLuint width, glw::GLuint height, glw::GLuint depth, glw::GLenum format, glw::GLenum type, 335 glw::GLvoid *data); 336 337 glw::GLuint m_id; 338 339 private: 340 glw::GLuint m_buffer_id; 341 deqp::Context &m_context; 342 TEXTURE_TYPES m_texture_type; 343 }; 344 345 struct vertexArray 346 { 347 vertexArray(deqp::Context &Context); 348 ~vertexArray(); 349 350 void generate(); 351 void bind(); 352 353 glw::GLuint m_id; 354 355 private: 356 deqp::Context &m_context; 357 }; 358 359 /* Public typedefs */ 360 typedef std::vector<Utils::QUALIFIERS> qualifierSet; 361 362 /* UniformN*v prototypes */ 363 typedef GLW_APICALL void(GLW_APIENTRY *uniformNdv)(glw::GLint, glw::GLsizei, const glw::GLdouble *); 364 typedef GLW_APICALL void(GLW_APIENTRY *uniformNfv)(glw::GLint, glw::GLsizei, const glw::GLfloat *); 365 typedef GLW_APICALL void(GLW_APIENTRY *uniformNiv)(glw::GLint, glw::GLsizei, const glw::GLint *); 366 typedef GLW_APICALL void(GLW_APIENTRY *uniformNuiv)(glw::GLint, glw::GLsizei, const glw::GLuint *); 367 typedef GLW_APICALL void(GLW_APIENTRY *uniformMatrixNdv)(glw::GLint, glw::GLsizei, glw::GLboolean, 368 const glw::GLdouble *); 369 typedef GLW_APICALL void(GLW_APIENTRY *uniformMatrixNfv)(glw::GLint, glw::GLsizei, glw::GLboolean, 370 const glw::GLfloat *); 371 372 /* Public static methods */ 373 /* UniformN*v routine getters */ 374 static uniformNdv getUniformNdv(const glw::Functions &gl, glw::GLuint n_rows); 375 376 static uniformNfv getUniformNfv(const glw::Functions &gl, glw::GLuint n_rows); 377 378 static uniformNiv getUniformNiv(const glw::Functions &gl, glw::GLuint n_rows); 379 380 static uniformNuiv getUniformNuiv(const glw::Functions &gl, glw::GLuint n_rows); 381 382 static uniformMatrixNdv getUniformMatrixNdv(const glw::Functions &gl, glw::GLuint n_columns, glw::GLuint n_rows); 383 384 static uniformMatrixNfv getUniformMatrixNfv(const glw::Functions &gl, glw::GLuint n_columns, glw::GLuint n_rows); 385 386 /* GLSL qualifiers */ 387 static bool doesContainQualifier(QUALIFIERS qualifier, const qualifierSet &qualifiers); 388 389 static bool doesStageSupportQualifier(SHADER_STAGES stage, VARIABLE_STORAGE storage, QUALIFIERS qualifier); 390 391 static const glw::GLchar *getQualifierString(QUALIFIERS qualifier); 392 static std::string getQualifiersListString(const qualifierSet &qualifiers); 393 394 static qualifierSet prepareQualifiersSet(const qualifierSet &in_qualifiers, SHADER_STAGES stage, 395 VARIABLE_STORAGE storage); 396 397 /* Variable name */ 398 static std::string getBlockVariableDefinition(const Utils::qualifierSet &qualifiers, const glw::GLchar *type_name, 399 const glw::GLchar *variable_name); 400 401 static std::string getBlockVariableReference(VARIABLE_FLAVOUR flavour, const glw::GLchar *variable_name, 402 const glw::GLchar *block_name); 403 404 static std::string getVariableDefinition(VARIABLE_FLAVOUR flavour, const Utils::qualifierSet &qualifiers, 405 const glw::GLchar *type_name, const glw::GLchar *variable_name); 406 407 static VARIABLE_FLAVOUR getVariableFlavour(Utils::SHADER_STAGES stage, Utils::VARIABLE_STORAGE storage, 408 const Utils::qualifierSet &qualifiers); 409 410 static std::string getVariableName(Utils::SHADER_STAGES stage, Utils::VARIABLE_STORAGE storage, 411 const glw::GLchar *variable_name); 412 413 static std::string getVariableReference(VARIABLE_FLAVOUR flavour, const glw::GLchar *variable_name); 414 415 static void prepareBlockVariableStrings(Utils::SHADER_STAGES in_stage, Utils::VARIABLE_STORAGE in_storage, 416 const Utils::qualifierSet &in_qualifiers, const glw::GLchar *in_type_name, 417 const glw::GLchar *in_variable_name, const glw::GLchar *in_block_name, 418 std::string &out_definition, std::string &out_reference); 419 420 static void prepareVariableStrings(Utils::SHADER_STAGES in_stage, Utils::VARIABLE_STORAGE in_storage, 421 const Utils::qualifierSet &in_qualifiers, const glw::GLchar *in_type_name, 422 const glw::GLchar *in_variable_name, std::string &out_definition, 423 std::string &out_reference); 424 425 /* Textures */ 426 static const glw::GLchar *getImageType(TEXTURE_TYPES type); 427 static glw::GLuint getNumberOfCoordinates(TEXTURE_TYPES type); 428 static const glw::GLchar *getSamplerType(TEXTURE_TYPES type); 429 static glw::GLenum getTextureTartet(TEXTURE_TYPES type); 430 static const glw::GLchar *getTextureTypeName(TEXTURE_TYPES type); 431 432 /* Stuff */ 433 static bool checkUniformBinding(Utils::program &program, const glw::GLchar *name, glw::GLint expected_binding); 434 static bool checkUniformArrayBinding(Utils::program &program, const glw::GLchar *name, glw::GLuint index, 435 glw::GLint expected_binding); 436 static bool doesTypeSupportMatrix(TYPES type); 437 static const glw::GLchar *getShaderStageName(SHADER_STAGES stage); 438 static const glw::GLchar *getTypeName(TYPES type, glw::GLuint n_columns, glw::GLuint n_rows); 439 static const glw::GLchar *getUtf8Character(UTF8_CHARACTERS character); 440 static bool isExtensionSupported(deqp::Context &context, const glw::GLchar *extension_name); 441 static bool isGLVersionAtLeast(const glw::Functions &gl, glw::GLint required_major, glw::GLint required_minor); 442 static void replaceToken(const glw::GLchar *token, size_t &search_position, const glw::GLchar *text, 443 std::string &string); 444 static void replaceAllTokens(const glw::GLchar *token, const glw::GLchar *text, std::string &string); 445 }; 446 447 /** Base class for tests **/ 448 class TestBase : public deqp::TestCase 449 { 450 public: 451 /* Public methods */ 452 TestBase(deqp::Context &context, const glw::GLchar *test_name, const glw::GLchar *test_description); ~TestBase()453 virtual ~TestBase() 454 { 455 } 456 457 /* Public methods inherited from TestCase */ 458 virtual tcu::TestNode::IterateResult iterate(void); 459 460 protected: 461 /* Methods to be implemented by child class */ 462 virtual void getShaderSourceConfig(glw::GLuint &out_n_parts, bool &out_use_lengths); 463 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 464 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 465 Utils::shaderSource &out_source) = 0; 466 virtual void prepareUniforms(Utils::program &program); 467 virtual bool testInit(); 468 virtual bool testCompute() = 0; 469 virtual bool testDrawArray(bool use_version_400) = 0; 470 471 /* Methods available to child classes */ 472 const glw::GLchar *getStageSpecificLayout(Utils::SHADER_STAGES stage) const; 473 const glw::GLchar *getVersionString(Utils::SHADER_STAGES stage, bool use_version_400) const; 474 void initShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, Utils::shaderSource &out_source); 475 int maxImageUniforms(Utils::SHADER_STAGES stage) const; 476 477 /* Protected variables */ 478 bool m_is_compute_shader_supported; 479 bool m_is_explicit_uniform_location; 480 bool m_is_shader_language_420pack; 481 482 private: 483 /* Private methods */ 484 bool test(); 485 }; 486 487 /** Base class for API tests */ 488 class APITestBase : public TestBase 489 { 490 public: 491 /* Public methods */ 492 APITestBase(deqp::Context &context, const glw::GLchar *test_name, const glw::GLchar *test_description); 493 ~APITestBase()494 virtual ~APITestBase() 495 { 496 } 497 498 protected: 499 /* Protected methods inherited from TestBase */ 500 virtual bool testCompute(); 501 virtual bool testDrawArray(bool use_version_400); 502 503 /* Protected methods to be implemented by child class */ 504 virtual bool checkResults(Utils::program &program) = 0; 505 506 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 507 Utils::shaderSource &out_source) = 0; 508 }; 509 510 /** Base class for GLSL tests **/ 511 class GLSLTestBase : public TestBase 512 { 513 public: 514 /* Public methods */ 515 GLSLTestBase(deqp::Context &context, const glw::GLchar *test_name, const glw::GLchar *test_description); 516 ~GLSLTestBase()517 virtual ~GLSLTestBase() 518 { 519 } 520 521 protected: 522 /* Protected methods inherited from TestBase */ 523 virtual bool testCompute(); 524 virtual bool testDrawArray(bool use_version_400); 525 526 /* Protected methods to be implemented by child class */ 527 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 528 Utils::shaderSource &out_source) = 0; 529 530 virtual const glw::GLchar *prepareSourceTexture(Utils::texture &texture); 531 532 virtual void prepareVertexBuffer(const Utils::program &program, Utils::buffer &buffer, Utils::vertexArray &vao); 533 534 virtual bool verifyAdditionalResults() const; 535 virtual void releaseResource(); 536 537 private: 538 /* Private methods */ 539 void bindTextureToimage(Utils::program &program, Utils::texture &texture, const glw::GLchar *uniform_name) const; 540 541 void bindTextureToSampler(Utils::program &program, Utils::texture &texture, const glw::GLchar *uniform_name) const; 542 543 bool checkResults(Utils::texture &color_texture) const; 544 545 void prepareFramebuffer(Utils::framebuffer &framebuffer, Utils::texture &color_texture) const; 546 547 void prepareImage(Utils::program &program, Utils::texture &color_texture) const; 548 549 /* Private constants */ 550 static const glw::GLenum m_color_texture_internal_format; 551 static const glw::GLenum m_color_texture_format; 552 static const glw::GLenum m_color_texture_type; 553 static const glw::GLuint m_color_texture_width; 554 static const glw::GLuint m_color_texture_height; 555 }; 556 557 /** Base class for negative tests **/ 558 class NegativeTestBase : public TestBase 559 { 560 public: 561 /* Public methods */ 562 NegativeTestBase(deqp::Context &context, const glw::GLchar *test_name, const glw::GLchar *test_description); 563 ~NegativeTestBase()564 virtual ~NegativeTestBase() 565 { 566 } 567 568 protected: 569 /* Protected methods inherited from TestBase */ 570 virtual bool testCompute(); 571 virtual bool testDrawArray(bool use_version_400); 572 573 /* Protected methods to be implemented by child class */ 574 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 575 Utils::shaderSource &out_source) = 0; 576 }; 577 578 /** Base class for "binding image" tests **/ 579 class BindingImageTest : public GLSLTestBase 580 { 581 public: 582 /* Public methods */ 583 BindingImageTest(deqp::Context &context, const glw::GLchar *test_name, const glw::GLchar *test_description); 584 ~BindingImageTest()585 virtual ~BindingImageTest() 586 { 587 } 588 589 protected: 590 /* Protected methods */ 591 void prepareBuffer(Utils::buffer &buffer, glw::GLuint color); 592 593 void prepareTexture(Utils::texture &texture, const Utils::buffer &buffer, Utils::TEXTURE_TYPES texture_type, 594 glw::GLuint color, glw::GLuint unit); 595 596 bool verifyBuffer(const Utils::buffer &buffer) const; 597 bool verifyTexture(const Utils::texture &texture) const; 598 599 /* Protected constants */ 600 static const glw::GLuint m_width; 601 static const glw::GLuint m_green_color; 602 static const glw::GLuint m_height; 603 static const glw::GLuint m_depth; 604 }; 605 606 /** Test implementation, description follows: 607 * 608 * GLSL Tests: 609 * 610 * * Unix-style new line continuation: 611 * 612 * Run test with shader that contains line continuation and Unix-style (LF) 613 * new line characters inside: 614 * 615 * - assignment expression (after and before '=' operator) 616 * 617 * - vector variable initializer (after ',' in contructor) 618 * 619 * - tokens (inside function name, inside type name, inside variable name). 620 * These tokens are later used to generate some color value, that 621 * is later verifed. 622 * 623 * - preprocessor (#define) syntax - inside and in between preprocessor 624 * tokens. These tokens are later used to generate some color value, 625 * that is later verifed. 626 * 627 * - comments 628 * 629 * For example test for line continuation inside preprocessor tokens may use 630 * following GLSL code: 631 * 632 * #define ADD_ONE(XX) (X\\ 633 * X + 1.0) 634 * vec4 getColor(float f) { 635 * return vec4(0.0, ADD_ONE(0.0), 0.0, 1.0); 636 * } 637 * 638 * Where returned color is verified agains some reference value. 639 * 640 * 641 * * DOS-style line continuation: 642 * 643 * Run same test with line continuation sign before DOS-style (CR+LF) new 644 * line character. 645 * 646 * 647 * * Multiple line continuations in same GLSL token: 648 * 649 * Run test with shader that contains multiple (3 or more) line 650 * continuation and newlines inside same GLSL tokens (function or variable 651 * names). 652 * 653 * 654 * * Line continuation near GLSL shader source null-termination: 655 * 656 * Run test with shader that contains line continuation character as the 657 * last character in null terminated shader string. 658 * 659 * 660 * * Line continuation near GLSL shader source end: 661 * 662 * Run test with shader that contains line continuation character as the 663 * last character in not null terminated shader string (shader source length 664 * parameter is specified in glShaderSource call). 665 * 666 * 667 * * Line continuation near end of GLSL shader source string: 668 * 669 * Run test with shader constructed by multple strings passed to 670 * glShaderSource. New line continuation characters placed as: 671 * 672 * - last character of passed null terminated string 673 * - next-to-last character of passed null terminated string, 674 * followed by newline 675 * - last character of passed not null terminated string 676 * - next-to-last character of passed not null terminated string, 677 * followed by newline 678 * 679 * Each string with line continuation should be followed by a next, 680 * non-empty string. 681 **/ 682 class LineContinuationTest : public GLSLTestBase 683 { 684 public: 685 enum CASES 686 { 687 ASSIGNMENT_BEFORE_OPERATOR = 0, 688 ASSIGNMENT_AFTER_OPERATOR, 689 VECTOR_VARIABLE_INITIALIZER, 690 TOKEN_INSIDE_FUNCTION_NAME, 691 TOKEN_INSIDE_TYPE_NAME, 692 TOKEN_INSIDE_VARIABLE_NAME, 693 PREPROCESSOR_TOKEN_INSIDE, 694 PREPROCESSOR_TOKEN_BETWEEN, 695 COMMENT, 696 SOURCE_TERMINATION_NULL, 697 SOURCE_TERMINATION_NON_NULL, 698 PART_TERMINATION_NULL, 699 PART_NEXT_TO_TERMINATION_NULL, 700 PART_TERMINATION_NON_NULL, 701 PART_NEXT_TO_TERMINATION_NON_NULL, 702 703 /* DEBUG: there will be no line continuations at all */ 704 DEBUG_CASE 705 }; 706 707 enum REPETITIONS 708 { 709 ONCE = 0, 710 MULTIPLE_TIMES, 711 }; 712 713 enum LINE_ENDINGS 714 { 715 UNIX = 0, 716 DOS, 717 }; 718 719 /** Declare test case 720 * 721 **/ 722 struct testCase 723 { 724 glw::GLuint m_case; 725 glw::GLuint m_repetitions; 726 glw::GLuint m_line_endings; 727 }; 728 729 /* Public methods */ 730 LineContinuationTest(deqp::Context &context, testCase test_case); 731 ~LineContinuationTest()732 virtual ~LineContinuationTest() 733 { 734 } 735 736 protected: 737 /* Protected methods inherited from GLSLTestBase */ 738 virtual void getShaderSourceConfig(glw::GLuint &out_n_parts, bool &out_use_lengths); 739 740 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 741 742 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 743 Utils::shaderSource &out_source); 744 745 virtual const glw::GLchar *prepareSourceTexture(Utils::texture &texture); 746 747 virtual void prepareVertexBuffer(const Utils::program &program, Utils::buffer &buffer, Utils::vertexArray &vao); 748 749 private: 750 /* Private methods */ 751 const glw::GLchar *casesToStr(CASES cases) const; 752 const glw::GLchar *getExpectedValueString() const; 753 std::string getLineContinuationString() const; 754 bool isShaderMultipart() const; 755 const glw::GLchar *lineEndingsToStr(LINE_ENDINGS line_ending) const; 756 void prepareComputShaderSource(Utils::shaderSource &shaderSource); 757 758 void prepareShaderSourceForDraw(Utils::SHADER_STAGES stage, bool use_version_400, Utils::shaderSource &source); 759 760 const glw::GLchar *repetitionsToStr(REPETITIONS repetitions) const; 761 void replaceAllCaseTokens(std::string &source) const; 762 bool useSourceLengths() const; 763 764 /* Private constants */ 765 static const glw::GLuint m_n_repetitions; 766 static const glw::GLchar *m_texture_coordinates_name; 767 768 /* Private variables */ 769 testCase m_test_case; 770 }; 771 772 /** Test implementation, description follows: 773 * 774 * Correct numbering of lines with line continuations: 775 * 776 * Try to compile shader with line continuation schemes, followed 777 * by __LINE__ macro capturing the current line number. 778 * The value of __LINE__ is than validated against expected 779 * constant. Expected value must account for continued lines, 780 * for example in code below, they are two line continuations, 781 * so the expected value is N - 2 (where N is the "raw" line number). 782 * 783 * ivec4 glsl\\ 784 * Test\\ 785 * Func(float f) { 786 * obvious = error; 787 * return vec4(__LINE__, 0, 0, 1); 788 * } 789 **/ 790 class LineNumberingTest : public GLSLTestBase 791 { 792 public: 793 /* Public methods */ 794 LineNumberingTest(deqp::Context &); 795 ~LineNumberingTest()796 virtual ~LineNumberingTest() 797 { 798 } 799 800 protected: 801 /* Protected methods inherited from GLSLTestBase */ 802 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 803 Utils::shaderSource &out_source); 804 }; 805 806 /** Test implementation, description follows: 807 * 808 * * UTF-8 characters in comments: 809 * 810 * Run test with shader that contains non-ASCII UTF-8 characters in comments. 811 * Use 2-byte UTF-8 characters (Latin-1 supplements, Greek, Hebrew, Cyril), 812 * 3-byte (Chinese/Japanese/Korean), 4-byte (less common CJK). 813 * Also test 5 and 6 byte codes. 814 * Also test base plane ASCII characters encoded with redundant bytes, 815 * such as 'a' or <whitespace> encoded by 4 bytes. 816 * 817 * Encode UTF-8 strings manually in test, either by c-array or '\0xNN' escape 818 * sequences. 819 * 820 * 821 * * UTF-8 characters in preprocessor: 822 * 823 * Run test with shader that contains non-ASCII UTF-8 characters (arbitrary 824 * from above) in preprocessor tokens. Use preprocessor to strip these UTF-8 825 * characters, so they does not occur in preprocessed GLSL shader source. 826 * 827 * 828 * * Incomplete UTF-8 near GLSL shader source null-termination: 829 * 830 * Run test with shader that contains comment with incomplete UTF-8 831 * character as the last character in null terminated shader string. 832 * 833 * 834 * * Incomplete UTF-8 near GLSL shader source end: 835 * 836 * Run test with shader that contains comment with incomplete UTF-8 837 * character as the last character in not-null terminated shader string. 838 * Shader source length parameter is specified in glShaderSource call. 839 **/ 840 class UTF8CharactersTest : public GLSLTestBase 841 { 842 public: 843 enum CASES 844 { 845 IN_COMMENT = 0, 846 IN_PREPROCESSOR, 847 AS_LAST_CHARACTER_NULL_TERMINATED, 848 AS_LAST_CHARACTER_NON_NULL_TERMINATED, 849 850 DEBUG_CASE 851 }; 852 853 struct testCase 854 { 855 CASES m_case; 856 Utils::UTF8_CHARACTERS m_character; 857 }; 858 859 /* Public methods */ 860 UTF8CharactersTest(deqp::Context &context, testCase test_case); 861 ~UTF8CharactersTest()862 virtual ~UTF8CharactersTest() 863 { 864 } 865 866 /* Protected methods inherited from GLSLTestBase */ 867 virtual void getShaderSourceConfig(glw::GLuint &out_n_parts, bool &out_use_lengths); 868 869 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 870 871 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 872 Utils::shaderSource &out_source); 873 874 virtual const glw::GLchar *prepareSourceTexture(Utils::texture &texture); 875 876 private: 877 /* Private methods */ 878 const glw::GLchar *casesToStr() const; 879 const glw::GLchar *characterToStr() const; 880 881 /* Private variables */ 882 testCase m_test_case; 883 }; 884 885 /** Test implementation, description follows: 886 * 887 * * UTF-8 in after preprocessor, in GLSL syntax: 888 * 889 * Try to compile shader that contains non-ASCII UTF-8 character after 890 * preprocessing. Expect compilation error. 891 **/ 892 class UTF8InSourceTest : public NegativeTestBase 893 { 894 public: 895 /* Public methods */ 896 UTF8InSourceTest(deqp::Context &context, Utils::UTF8_CHARACTERS character); 897 ~UTF8InSourceTest()898 virtual ~UTF8InSourceTest() 899 { 900 } 901 902 /* Protected methods inherited from GLSLTestBase */ 903 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 904 905 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 906 Utils::shaderSource &out_source); 907 908 private: 909 const glw::GLchar *characterToStr() const; 910 911 /* Private variables */ 912 Utils::UTF8_CHARACTERS m_character; 913 }; 914 915 /** Test implementation, description follows: 916 * 917 * * Check all implicit conversions on function return: 918 * 919 * Run test with shader that verifies value being return by following 920 * function: 921 * 922 * T1 f(T2 x, T2 y) { return x + y; }' 923 * 924 * By substituting T1 and T2 typenames check following conversions: 925 * - int to uint 926 * - int to float 927 * - uint to float 928 * - int to double 929 * - uint to double 930 * - float to double 931 * Use scalars and vector types (all vector sizes). For conversions not 932 * involving ints or uints test also matrix types (all matrix sizes) 933 * 934 * Call this function on literals, constant expressions and variables 935 * (variables should contain values that cannot be constant folded during 936 * compilation). 937 **/ 938 class ImplicitConversionsValidTest : public GLSLTestBase 939 { 940 public: 941 struct typesPair 942 { 943 Utils::TYPES m_t1; 944 Utils::TYPES m_t2; 945 }; 946 947 struct testCase 948 { 949 typesPair m_types; 950 glw::GLuint m_n_cols; 951 glw::GLuint m_n_rows; 952 }; 953 954 /* Public methods */ 955 ImplicitConversionsValidTest(deqp::Context &context, testCase test_case); 956 ~ImplicitConversionsValidTest()957 virtual ~ImplicitConversionsValidTest() 958 { 959 } 960 961 protected: 962 /* Methods to be implemented by child class */ 963 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 964 965 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 966 Utils::shaderSource &out_source); 967 968 virtual void prepareUniforms(Utils::program &program); 969 970 private: 971 /* Private methods */ 972 const testCase &getCurrentTestCase(); 973 974 std::string getValueList(glw::GLuint n_columns, glw::GLuint n_rows); 975 976 /* Private variables */ 977 testCase m_debug_test_case; 978 std::vector<testCase> m_test_cases; 979 glw::GLuint m_current_test_case_index; 980 }; 981 982 /** Test implementation, description follows: 983 * 984 * * Check if uint to int conversion is forbidden: 985 * 986 * Try to compile shader that returns uint value from function returning int. 987 * Expect shader compilation error. Use scalars and vector types. 988 **/ 989 class ImplicitConversionsInvalidTest : public NegativeTestBase 990 { 991 public: 992 /* Public methods */ 993 ImplicitConversionsInvalidTest(deqp::Context &); 994 ~ImplicitConversionsInvalidTest()995 virtual ~ImplicitConversionsInvalidTest() 996 { 997 } 998 999 protected: 1000 /* Methods to be implemented by child class */ 1001 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 1002 1003 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1004 Utils::shaderSource &out_source); 1005 1006 private: 1007 /* Private methods */ 1008 std::string getValueList(glw::GLuint n_rows); 1009 1010 /* Private variables */ 1011 glw::GLuint m_current_test_case_index; 1012 }; 1013 1014 /** Test implementation, description follows: 1015 * 1016 * * Read-only variables: 1017 * 1018 * Run shader which contains and uses following read-only variables: 1019 * const float c1 = X1; 1020 * const vec4 c2 = X2; 1021 * const mat2 c3 = X3; 1022 * const S c4 = X4; 1023 * const vec4 c5[15] = X5; 1024 * 1025 * Where X1..X5 are non-constant initializer expressions (expressions which 1026 * cannot be constant folded). S is a struct of scalar, vector and matrix 1027 * transparent types. Verify value of each read-only variable. 1028 **/ 1029 class ConstDynamicValueTest : public GLSLTestBase 1030 { 1031 public: 1032 /* Public methods */ 1033 ConstDynamicValueTest(deqp::Context &); 1034 ~ConstDynamicValueTest()1035 virtual ~ConstDynamicValueTest() 1036 { 1037 } 1038 1039 protected: 1040 /* Methods to be implemented by child class */ 1041 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1042 Utils::shaderSource &out_source); 1043 1044 virtual void prepareUniforms(Utils::program &program); 1045 }; 1046 1047 /** Test implementation, description follows: 1048 * 1049 * * Override value of read-only variable: 1050 * 1051 * Try to compile shaders, that override value of constant variable. 1052 * Use constant variable defined as: 1053 * const float c1 = X1; 1054 * 1055 * Where X1 is once a literal initializer and in another shader is a 1056 * non-const-foldable non-constant variable. 1057 * 1058 * Variable is non-const-foldable when it's value cannot be deduced during 1059 * shader compilation. (As an example uniforms and varyings are non const 1060 * foldable). 1061 * 1062 * Expect compilation errors on any assignment to such variable. 1063 **/ 1064 class ConstAssignmentTest : public NegativeTestBase 1065 { 1066 public: 1067 /* Public methods */ 1068 ConstAssignmentTest(deqp::Context &); 1069 ~ConstAssignmentTest()1070 virtual ~ConstAssignmentTest() 1071 { 1072 } 1073 1074 protected: 1075 /* Methods to be implemented by child class */ 1076 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 1077 1078 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1079 Utils::shaderSource &out_source); 1080 1081 private: 1082 /* Private variables */ 1083 glw::GLuint m_current_test_case_index; 1084 }; 1085 1086 /** Test implementation, description follows: 1087 * 1088 * * Read-only variable use in place of constant expression: 1089 * 1090 * Try to compile shader, that tries to force constant folding on const 1091 * variable, when constant variable was initialized with non-constant, 1092 * non const foldable expression. For example: 1093 * 1094 * vec4 glslTestFunc(float f) { 1095 * const float fConst1 = f; 1096 * float a[f]; //force constant folding of f. 1097 * return vec4(a[0]); 1098 * } 1099 * ... 1100 * glslTestFunc(gl_FragCoord.x); 1101 **/ 1102 class ConstDynamicValueAsConstExprTest : public NegativeTestBase 1103 { 1104 public: 1105 /* Public methods */ 1106 ConstDynamicValueAsConstExprTest(deqp::Context &); 1107 ~ConstDynamicValueAsConstExprTest()1108 virtual ~ConstDynamicValueAsConstExprTest() 1109 { 1110 } 1111 1112 protected: 1113 /* Methods to be implemented by child class */ 1114 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1115 Utils::shaderSource &out_source); 1116 }; 1117 1118 /** Test implementation, description follows: 1119 * 1120 * * Input variable qualifier order: 1121 * 1122 * Run shader which uses input variable, that is declared with all 1123 * permutations of following qualifiers: 1124 * 1125 * storage qualifiers: in 1126 * interpolation qualifiers: (none), flat, noperespective, smooth 1127 * auxaliary qualifiers: (none), patch, sample, centroid 1128 * precision qualifiers: (none), precise 1129 * invariance qualifiers: (none), invariant 1130 * layout qualifiers: (none), layout(location = 0) 1131 * 1132 * Test fragment, tessellation evaluation, tessellation control and geometry 1133 * shader inputs. Skip illegal permutations: flat interpolation qualifier 1134 * used with non empty auxaliary qualifier, patch qualifier outside 1135 * tessellation shaders. Also skip non-flat interpolation qualifiers for 1136 * vertex, tessellation and geometry shaders. 1137 * 1138 * * Input variable qualifers used multiple times: 1139 * 1140 * Same as above, but use some qualifiers multiple times. 1141 * 1142 * * Output variable qualifier order: 1143 * Run shader which uses output variable, that is declared with all 1144 * permutations of following qualifiers: 1145 * 1146 * storage qualifiers: out 1147 * interpolation qualifiers: (none), flat, noperespective, smooth 1148 * auxaliary qualifiers: (none), patch, sample, centroid 1149 * precision qualifiers: (none), precise 1150 * invariance qualifiers: (none), invariant 1151 * layout qualifiers: (none), layout(location = 0) 1152 * 1153 * All permutations above following sets should be used (so all combinations 1154 * of qualifiers are tested and all orderings of such combinations are tested). 1155 * Used shader input must match output from earlier shader stage. 1156 * 1157 * Test tessellation evaluation, tessellation control, geometry and vertex 1158 * shader inputs. Skip illegal permutations: flat interpolation qualifier used 1159 * with non empty auxaliary qualifier, patch qualifier outside tessellation 1160 * shaders. 1161 * 1162 * 1163 * * Output variable qualifers used multiple times: 1164 * 1165 * Same as above, but use some qualifiers multiple times. 1166 **/ 1167 class QualifierOrderTest : public GLSLTestBase 1168 { 1169 public: 1170 /* Public methods */ 1171 QualifierOrderTest(deqp::Context &context, Utils::qualifierSet &test_case, glw::GLuint test_id); 1172 ~QualifierOrderTest()1173 virtual ~QualifierOrderTest() 1174 { 1175 } 1176 1177 protected: 1178 /* Methods to be implemented by child class */ 1179 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 1180 1181 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1182 Utils::shaderSource &out_source); 1183 1184 virtual void prepareVertexBuffer(const Utils::program &program, Utils::buffer &buffer, Utils::vertexArray &vao); 1185 1186 private: 1187 /* Private methods */ 1188 const Utils::qualifierSet &getCurrentTestCase(); 1189 1190 /* Private varaibles */ 1191 std::vector<Utils::qualifierSet> m_test_cases; 1192 glw::GLuint m_current_test_case_index; 1193 }; 1194 1195 /** Test implementation, description follows: 1196 * 1197 * * Input block interface qualifier order: 1198 * 1199 * Run shaders with same variable qualifications as above used for input 1200 * interface block member. 1201 * 1202 * Use following block declaration: 1203 * in BLOCK { 1204 * vec4 color; 1205 * }; 1206 * 1207 * Test fragment shader, tessellation evaluation, tessellation control and 1208 * geometry shader inputs. Skip illegal permutations, same as in previous 1209 * test cases. 1210 * 1211 * 1212 * * Input block interface qualifers used multiple times: 1213 * 1214 * Same as above, but use some qualifiers multiple times. 1215 * 1216 * * Output block interface qualifier order: 1217 * Run shaders with same variable qualifications as above used for output 1218 * interface block member. 1219 * 1220 * Use following block declaration: 1221 * out BLOCK { 1222 * vec4 color; 1223 * }; 1224 * 1225 * Test tessellation evaluation, tessellation control, geometry and vertex 1226 * shader outputs. Skip illegal permutations, same as in previous test case. 1227 * 1228 * 1229 * * Output block interface qualifers used multiple times: 1230 * 1231 * Same as above, but use some qualifiers multiple times. 1232 **/ 1233 class QualifierOrderBlockTest : public GLSLTestBase 1234 { 1235 public: 1236 /* Public methods */ 1237 QualifierOrderBlockTest(deqp::Context &context, Utils::qualifierSet &test_case, glw::GLuint test_id); 1238 ~QualifierOrderBlockTest()1239 virtual ~QualifierOrderBlockTest() 1240 { 1241 } 1242 1243 protected: 1244 /* Methods to be implemented by child class */ 1245 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 1246 1247 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1248 Utils::shaderSource &out_source); 1249 1250 virtual void prepareVertexBuffer(const Utils::program &program, Utils::buffer &buffer, Utils::vertexArray &vao); 1251 1252 private: 1253 /* Private methods */ 1254 const Utils::qualifierSet &getCurrentTestCase(); 1255 1256 /* Private varaibles */ 1257 std::vector<Utils::qualifierSet> m_test_cases; 1258 glw::GLuint m_current_test_case_index; 1259 }; 1260 1261 /** Test implementation, description follows: 1262 * 1263 * * Uniform variable qualifier order: 1264 * 1265 * Run shaders which use uniform, that is declared with all permutations of 1266 * 'precise', 'uniform', and 'layout(...)' qualifiers. 1267 * 1268 * 1269 * * Uniform qualifers used multiple times: 1270 * 1271 * Same as above, but use some qualifiers multiple times. 1272 **/ 1273 class QualifierOrderUniformTest : public GLSLTestBase 1274 { 1275 public: 1276 /* Public methods */ 1277 QualifierOrderUniformTest(deqp::Context &context, Utils::qualifierSet test_case, glw::GLuint test_id); 1278 ~QualifierOrderUniformTest()1279 virtual ~QualifierOrderUniformTest() 1280 { 1281 } 1282 1283 protected: 1284 /* Methods to be implemented by child class */ 1285 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 1286 1287 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1288 Utils::shaderSource &out_source); 1289 1290 virtual void prepareUniforms(Utils::program &program); 1291 1292 virtual bool testInit(); 1293 1294 private: 1295 /* Private methods */ 1296 const Utils::qualifierSet &getCurrentTestCase(); 1297 1298 /* Private varaibles */ 1299 std::vector<Utils::qualifierSet> m_test_cases; 1300 glw::GLuint m_current_test_case_index; 1301 }; 1302 1303 /** Test implementation, description follows: 1304 * 1305 * * Function inout parameter qualifier order: 1306 * 1307 * Run shaders which use function, that has inout parameter declared with all 1308 * permutations of 'lowp' or 'mediump' or 'highp', 'precise' qualifiers. 1309 * 1310 * Also run with some qualifiers used multiple times. 1311 **/ 1312 class QualifierOrderFunctionInoutTest : public GLSLTestBase 1313 { 1314 public: 1315 /* Public methods */ 1316 QualifierOrderFunctionInoutTest(deqp::Context &context, Utils::qualifierSet test_case, glw::GLuint test_id); 1317 ~QualifierOrderFunctionInoutTest()1318 virtual ~QualifierOrderFunctionInoutTest() 1319 { 1320 } 1321 1322 protected: 1323 /* Methods to be implemented by child class */ 1324 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 1325 1326 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1327 Utils::shaderSource &out_source); 1328 1329 virtual void prepareUniforms(Utils::program &program); 1330 1331 private: 1332 /* Private methods */ 1333 const Utils::qualifierSet &getCurrentTestCase(); 1334 1335 /* Private varaibles */ 1336 std::vector<Utils::qualifierSet> m_test_cases; 1337 glw::GLuint m_current_test_case_index; 1338 }; 1339 1340 /** Test implementation, description follows: 1341 * 1342 * * Function input parameter qualifier order: 1343 * 1344 * Run shaders which use function, that has 'in' parameter declared with all 1345 * permutations of 'in', 'lowp' or 'mediump' or 'highp', 'precise', 'const' 1346 * qualifiers. 1347 * 1348 * Also run with some qualifiers used multiple times. 1349 **/ 1350 class QualifierOrderFunctionInputTest : public GLSLTestBase 1351 { 1352 public: 1353 /* Public methods */ 1354 QualifierOrderFunctionInputTest(deqp::Context &context, Utils::qualifierSet test_case, glw::GLuint test_id); 1355 ~QualifierOrderFunctionInputTest()1356 virtual ~QualifierOrderFunctionInputTest() 1357 { 1358 } 1359 1360 protected: 1361 /* Methods to be implemented by child class */ 1362 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 1363 1364 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1365 Utils::shaderSource &out_source); 1366 1367 virtual void prepareUniforms(Utils::program &program); 1368 1369 private: 1370 /* Private methods */ 1371 const Utils::qualifierSet &getCurrentTestCase(); 1372 1373 /* Private varaibles */ 1374 std::vector<Utils::qualifierSet> m_test_cases; 1375 glw::GLuint m_current_test_case_index; 1376 }; 1377 1378 /** Test implementation, description follows: 1379 * 1380 * * Function output parameter qualifier order: 1381 * 1382 * Run shaders which use function, that has out parameter declared with all 1383 * permutations of 'lowp' or 'mediump' or 'highp', 'precise' qualifiers. 1384 * 1385 * Also run with some qualifiers used multiple times. 1386 **/ 1387 class QualifierOrderFunctionOutputTest : public GLSLTestBase 1388 { 1389 public: 1390 /* Public methods */ 1391 QualifierOrderFunctionOutputTest(deqp::Context &context, Utils::qualifierSet test_case, glw::GLuint test_id); 1392 ~QualifierOrderFunctionOutputTest()1393 virtual ~QualifierOrderFunctionOutputTest() 1394 { 1395 } 1396 1397 protected: 1398 /* Methods to be implemented by child class */ 1399 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 1400 1401 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1402 Utils::shaderSource &out_source); 1403 1404 virtual void prepareUniforms(Utils::program &program); 1405 1406 private: 1407 /* Private methods */ 1408 const Utils::qualifierSet &getCurrentTestCase(); 1409 1410 /* Private varaibles */ 1411 std::vector<Utils::qualifierSet> m_test_cases; 1412 glw::GLuint m_current_test_case_index; 1413 }; 1414 1415 /** Test implementation, description follows: 1416 * 1417 * * Input variable layout qualifiers override: 1418 * 1419 * Run shaders which use input variable, qualified with multiple layout 1420 * qualifiers. For example: 1421 * 1422 * layout(location = 3) layout(location = 2) out vec4 gColor 1423 * 1424 * 1425 * * Geometry shader layout qualifiers override: 1426 * 1427 * Run shader which use multiple global geometry shader qualifiers. 1428 * For example: 1429 * 1430 * layout( triangle_strip, max_vertices = 2 ) layout( max_vertices = 3) out;' 1431 * 1432 * 1433 * * Tesselation shader layout qualifiers override: 1434 * 1435 * Run shader which use multiple tesselation shader qualifiers, for example: 1436 * 1437 * layout(vertices = 2) layout(vertices = 4) out; 1438 **/ 1439 class QualifierOverrideLayoutTest : public GLSLTestBase 1440 { 1441 public: 1442 /* Public methods */ 1443 QualifierOverrideLayoutTest(deqp::Context &); 1444 ~QualifierOverrideLayoutTest()1445 virtual ~QualifierOverrideLayoutTest() 1446 { 1447 } 1448 1449 protected: 1450 /* Methods to be implemented by child class */ 1451 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1452 Utils::shaderSource &out_source); 1453 1454 virtual void prepareVertexBuffer(const Utils::program &program, Utils::buffer &buffer, Utils::vertexArray &vao); 1455 }; 1456 1457 /** Test implementation, description follows: 1458 * 1459 * * 'binding' qualified used for uniform block: 1460 * 1461 * Create shader program which uses uniform block declaration 1462 * with 'binding' layout qualifier specified. For example: 1463 * 1464 * layout(std140, binding = 2) uniform BLOCK { 1465 * vec4 color; 1466 * } block; 1467 * 1468 * Bind filled uniform buffer object to binding point 2. 1469 * 1470 * Run shader program, validate uniform buffer contents in shader. 1471 * 1472 * 1473 * * 'binding' layout qualifier used for multiple uniform blocks in same shader: 1474 * 1475 * Same as above, but use multiple uniform block declarations, each with 1476 * different 'layout(binding = X)' qualifier. Validate contents of all 1477 * uniform buffers in shader. 1478 * 1479 * 1480 * * 'binding' layout qualifier used for uniform block in different shader 1481 * stages: 1482 * 1483 * Link multiple shaders of different stage that use same uniform block. 1484 * All uniform block declarations use same 'binding' layout qualifier. 1485 * 1486 * Validate contents of uniform buffer in all shader stages. 1487 **/ 1488 class BindingUniformBlocksTest : public GLSLTestBase 1489 { 1490 public: 1491 /* Public methods */ 1492 BindingUniformBlocksTest(deqp::Context &); 1493 ~BindingUniformBlocksTest()1494 virtual ~BindingUniformBlocksTest() 1495 { 1496 } 1497 1498 protected: 1499 /* Methods to be implemented by child class */ 1500 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1501 Utils::shaderSource &out_source); 1502 1503 virtual void prepareUniforms(Utils::program &program); 1504 virtual void releaseResource(); 1505 1506 private: 1507 /* Private variables */ 1508 Utils::buffer m_goku_buffer; 1509 Utils::buffer m_vegeta_buffer; 1510 Utils::buffer m_children_buffer; 1511 }; 1512 1513 /** Test implementation, description follows: 1514 * 1515 * * 'binding' layout qualifier used only once for same uniform block in 1516 * different shader stages: 1517 1518 * Link multiple shaders of different stage that use same uniform block. 1519 * 'binding' layout qualifier is used only in one shader stage, other shader 1520 * stages does not specify layout qualifier. 1521 * 1522 * Validate contents of uniform buffer in all shader stages. 1523 **/ 1524 class BindingUniformSingleBlockTest : public GLSLTestBase 1525 { 1526 public: 1527 /* Public methods */ 1528 BindingUniformSingleBlockTest(deqp::Context &context, Utils::SHADER_STAGES test_stage); 1529 ~BindingUniformSingleBlockTest()1530 virtual ~BindingUniformSingleBlockTest() 1531 { 1532 } 1533 1534 protected: 1535 /* Methods to be implemented by child class */ 1536 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 1537 1538 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1539 Utils::shaderSource &out_source); 1540 1541 virtual void prepareUniforms(Utils::program &program); 1542 virtual void releaseResource(); 1543 1544 private: 1545 /* Private variables */ 1546 Utils::buffer m_goku_buffer; 1547 Utils::SHADER_STAGES m_test_stage; 1548 }; 1549 1550 /** Test implementation, description follows: 1551 * 1552 * * 'binding' layout qualifier used with uniform block array. 1553 * 1554 * Create shader program which uses uniform block array, with 'binding' 1555 * layout qualifier specified, example: 1556 * 1557 * layout(std140, binding = 2) uniform BLOCK { 1558 * vec4 color; 1559 * } block[14]; 1560 * 1561 * Bind filled uniform buffer objects to binding points 2..16. Validate 1562 * contents of all uniform buffers in shader. 1563 * 1564 * * bindings of array of uniform blocks: 1565 * 1566 * Check if uniform buffer array elements automatically get subsequent 1567 * binding values, when their interface is specified using 'binding' 1568 * layout qualifier. Use glGetActiveUniformBlockiv. 1569 **/ 1570 class BindingUniformBlockArrayTest : public GLSLTestBase 1571 { 1572 public: 1573 /* Public methods */ 1574 BindingUniformBlockArrayTest(deqp::Context &); 1575 ~BindingUniformBlockArrayTest()1576 virtual ~BindingUniformBlockArrayTest() 1577 { 1578 } 1579 1580 protected: 1581 /* Methods to be implemented by child class */ 1582 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1583 Utils::shaderSource &out_source); 1584 1585 virtual void prepareUniforms(Utils::program &program); 1586 virtual void releaseResource(); 1587 1588 private: 1589 /* Private methods */ 1590 void checkBinding(Utils::program &program, glw::GLuint index, glw::GLint expected_binding); 1591 1592 /* Private variables */ 1593 Utils::buffer m_goku_00_buffer; 1594 Utils::buffer m_goku_01_buffer; 1595 Utils::buffer m_goku_02_buffer; 1596 Utils::buffer m_goku_03_buffer; 1597 Utils::buffer m_goku_04_buffer; 1598 Utils::buffer m_goku_05_buffer; 1599 Utils::buffer m_goku_06_buffer; 1600 Utils::buffer m_goku_07_buffer; 1601 Utils::buffer m_goku_08_buffer; 1602 Utils::buffer m_goku_09_buffer; 1603 Utils::buffer m_goku_10_buffer; 1604 Utils::buffer m_goku_11_buffer; 1605 Utils::buffer m_goku_12_buffer; 1606 Utils::buffer m_goku_13_buffer; 1607 }; 1608 1609 /** Test implementation, description follows: 1610 * 1611 * * Default binding value: 1612 * 1613 * Create shader program, with uniform buffer interface declared without 1614 * 'binding' layout qualifier. Use glGetActiveUniformBlockiv to test if 1615 * default 'binding' value is 0. 1616 **/ 1617 class BindingUniformDefaultTest : public APITestBase 1618 { 1619 public: 1620 /* Public methods */ 1621 BindingUniformDefaultTest(deqp::Context &); 1622 ~BindingUniformDefaultTest()1623 virtual ~BindingUniformDefaultTest() 1624 { 1625 } 1626 1627 protected: 1628 /* Methods to be implemented by child class */ 1629 virtual bool checkResults(Utils::program &program); 1630 1631 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1632 Utils::shaderSource &out_source); 1633 }; 1634 1635 /** Test implementation, description follows: 1636 * 1637 * * Override binding value from API: 1638 * 1639 * Create a shader program with uniform buffer interface declared with 1640 * 'layout(..., binding = 3)'. Use glUniformBlockBinding to change binding 1641 * value to 11. Test if binding point 11 is now used during rendering. 1642 * Test if binding point 11 is returned when enumerating interface with 1643 * glGetActiveUniformBlockiv. 1644 **/ 1645 class BindingUniformAPIOverirdeTest : public GLSLTestBase 1646 { 1647 public: 1648 /* Public methods */ 1649 BindingUniformAPIOverirdeTest(deqp::Context &); 1650 ~BindingUniformAPIOverirdeTest()1651 virtual ~BindingUniformAPIOverirdeTest() 1652 { 1653 } 1654 1655 protected: 1656 /* Methods to be implemented by child class */ 1657 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1658 Utils::shaderSource &out_source); 1659 1660 virtual void prepareUniforms(Utils::program &program); 1661 virtual void releaseResource(); 1662 1663 private: 1664 /* Private variables */ 1665 Utils::buffer m_goku_buffer; 1666 }; 1667 1668 /** Test implementation, description follows: 1669 * 1670 * * 'binding' layout qualifier used with global uniform 1671 * 1672 * Use 'binding' layout qualifier on global (default block) uniform. 1673 * Expect shader compilation error. 1674 **/ 1675 class BindingUniformGlobalBlockTest : public NegativeTestBase 1676 { 1677 public: 1678 /* Public methods */ 1679 BindingUniformGlobalBlockTest(deqp::Context &); 1680 ~BindingUniformGlobalBlockTest()1681 virtual ~BindingUniformGlobalBlockTest() 1682 { 1683 } 1684 1685 protected: 1686 /* Methods to be implemented by child class */ 1687 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1688 Utils::shaderSource &out_source); 1689 }; 1690 1691 /** Test implementation, description follows: 1692 * 1693 * * Wrong value for 'binding' layout qualifier. 1694 * 1695 * Use -1, variable name, 'std140' as binding value. 1696 * Expect shader compilation error in each case. 1697 * 1698 * * Missing value for 'binding' layout qualifier. 1699 * 1700 * Expect shader compilation error in following declaration: 1701 * 1702 * layout(std140, binding) uniform BLOCK { 1703 * vec4 color; 1704 * } block[14]; 1705 **/ 1706 class BindingUniformInvalidTest : public NegativeTestBase 1707 { 1708 public: 1709 enum TESTCASES 1710 { 1711 NEGATIVE_VALUE, 1712 VARIABLE_NAME, 1713 STD140, 1714 MISSING, 1715 1716 /* */ 1717 TEST_CASES_MAX 1718 }; 1719 1720 /* Public methods */ 1721 BindingUniformInvalidTest(deqp::Context &context, TESTCASES case_index); 1722 ~BindingUniformInvalidTest()1723 virtual ~BindingUniformInvalidTest() 1724 { 1725 } 1726 1727 protected: 1728 /* Methods to be implemented by child class */ 1729 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 1730 1731 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1732 Utils::shaderSource &out_source); 1733 1734 private: 1735 /* Private methods */ 1736 const glw::GLchar *getCaseString(TESTCASES test_case); 1737 const glw::GLchar *getTestCaseString(TESTCASES test_case); 1738 1739 /* Provate variables */ 1740 TESTCASES m_case; 1741 TESTCASES m_test_case_idx; 1742 }; 1743 1744 /** Test implementation, description follows: 1745 * 1746 * * 'binding' qualified used for sampler uniform: 1747 * 1748 * Create shader program which uses sampler uniform declaration with 1749 * 'binding' layout qualifier specified. For example: 1750 * 1751 * layout(binding = 2) uniform sampler2D s; 1752 * 1753 * Bind 2D texture to texture unit GL_TEXTURE2. 1754 * 1755 * Run shader program, validate binding by sampling from texture in shader. 1756 * 1757 * 1758 * * 'binding' layout qualifier used for multiple sampler uniforms in same 1759 * shader: 1760 * 1761 * Same as above, but use multiple sampler uniform declarations, each with 1762 * different 'layout(binding = X)' qualifier. Validate bindings of all 1763 * samplers by sampling textures in shader. 1764 * 1765 * 1766 * * 'binding' layout qualifier used for sampler uniform in different shader 1767 * stages: 1768 * 1769 * 1770 * Link multiple shaders of different stages that use same sampler uniform. 1771 * All sampler uniform declarations use same 'binding' layout qualifier. 1772 * 1773 * Validate binding of sampler by sampling texture in shader. 1774 * 1775 * * 'binding layout qualifier used with sampler uniforms of various types. 1776 * 1777 * Create shader program which uses samplers of type: samplerBuffer, 1778 * sampler2D, sampler2DRect, sampler2DArray, sampler3D, samplerCubeMap, 1779 * sampler1D, sampler1DArray. 1780 * 1781 * Each sampler declaration uses 'binding' qualifier with different value. 1782 * 1783 * Validate bindings of all samplers by sampling bound textures in shader. 1784 **/ 1785 class BindingSamplersTest : public GLSLTestBase 1786 { 1787 public: 1788 /* Public methods */ 1789 BindingSamplersTest(deqp::Context &context, Utils::TEXTURE_TYPES test_case); 1790 ~BindingSamplersTest()1791 virtual ~BindingSamplersTest() 1792 { 1793 } 1794 1795 protected: 1796 /* Methods to be implemented by child class */ 1797 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 1798 1799 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1800 Utils::shaderSource &out_source); 1801 1802 virtual void prepareUniforms(Utils::program &program); 1803 virtual void releaseResource(); 1804 1805 private: 1806 /* Private methods */ 1807 void prepareTexture(Utils::texture &texture, Utils::TEXTURE_TYPES texture_type, glw::GLuint color); 1808 1809 /* Private variables */ 1810 Utils::texture m_goku_texture; 1811 Utils::texture m_vegeta_texture; 1812 Utils::texture m_trunks_texture; 1813 Utils::buffer m_buffer; 1814 Utils::TEXTURE_TYPES m_test_case; 1815 }; 1816 1817 /** Test implementation, description follows: 1818 * 1819 * * 'binding' layout qualifier used only once for same sampler uniform in 1820 * different shader stages: 1821 * 1822 * Link multiple shaders of different stages that use same sampler uniform. 1823 * 'binding' layout qualifier is used only in one shader stage, other shader 1824 * stages does not specify layout qualifier. 1825 * 1826 * Validate binding of sampler by sampling texture in all shader stages. 1827 **/ 1828 class BindingSamplerSingleTest : public GLSLTestBase 1829 { 1830 public: 1831 /* Public methods */ 1832 BindingSamplerSingleTest(deqp::Context &context, Utils::SHADER_STAGES test_stage); 1833 ~BindingSamplerSingleTest()1834 virtual ~BindingSamplerSingleTest() 1835 { 1836 } 1837 1838 protected: 1839 /* Methods to be implemented by child class */ 1840 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 1841 1842 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1843 Utils::shaderSource &out_source); 1844 1845 virtual void prepareUniforms(Utils::program &program); 1846 virtual void releaseResource(); 1847 1848 private: 1849 /* Private variables */ 1850 Utils::texture m_goku_texture; 1851 Utils::SHADER_STAGES m_test_stage; 1852 }; 1853 1854 /** Test implementation, description follows: 1855 * 1856 * * 'binding' layout qualifier used with sampler uniform array. 1857 * 1858 * Create shader program which uses sampler uniform array, with 'binding' 1859 * layout qualifier specified, example: 1860 * 1861 * layout(binding = 2) uniform sampler2D s[7]; 1862 * 1863 * Bind textures to texture units 2..9. Validate bindings of all samplers 1864 * by sampling bound textures in shader. 1865 * 1866 * * bindings of array of sampler uniforms 1867 * 1868 * Check if sampler uniform array elements automatically get subsequent 1869 * binding values, when their interface is specified using 'binding' 1870 * layout qualifier. Use glGetUniformiv. 1871 **/ 1872 class BindingSamplerArrayTest : public GLSLTestBase 1873 { 1874 public: 1875 /* Public methods */ 1876 BindingSamplerArrayTest(deqp::Context &); 1877 ~BindingSamplerArrayTest()1878 virtual ~BindingSamplerArrayTest() 1879 { 1880 } 1881 1882 protected: 1883 /* Methods to be implemented by child class */ 1884 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1885 Utils::shaderSource &out_source); 1886 1887 virtual void prepareUniforms(Utils::program &program); 1888 virtual void releaseResource(); 1889 1890 private: 1891 /* Private methods */ 1892 void checkBinding(Utils::program &program, glw::GLuint index, glw::GLint expected_binding); 1893 1894 /* Private variables */ 1895 Utils::texture m_goku_00_texture; 1896 Utils::texture m_goku_01_texture; 1897 Utils::texture m_goku_02_texture; 1898 Utils::texture m_goku_03_texture; 1899 Utils::texture m_goku_04_texture; 1900 Utils::texture m_goku_05_texture; 1901 Utils::texture m_goku_06_texture; 1902 }; 1903 1904 /** Test implementation, description follows: 1905 * 1906 * * Default binding value: 1907 * 1908 * Create shader program, with sampler uniform declared without 'binding' 1909 * layout qualifier. Use glGetUniformiv to test, if default 'binding' value 1910 * is 0. 1911 **/ 1912 class BindingSamplerDefaultTest : public APITestBase 1913 { 1914 public: 1915 /* Public methods */ 1916 BindingSamplerDefaultTest(deqp::Context &); 1917 ~BindingSamplerDefaultTest()1918 virtual ~BindingSamplerDefaultTest() 1919 { 1920 } 1921 1922 protected: 1923 /* Methods to be implemented by child class */ 1924 virtual bool checkResults(Utils::program &program); 1925 1926 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1927 Utils::shaderSource &out_source); 1928 }; 1929 1930 /** Test implementation, description follows: 1931 * 1932 * * Override binding value from API: 1933 * 1934 * Create a shader program with sampler uniform buffer declared with 1935 * 'layout(binding = 3)'. Use glUniform1i to change binding value to 11. 1936 * Test if binding point 11 is now used during rendering. 1937 * Test if binding point 11 is returned querying interface with 1938 * glGetUniformiv. 1939 **/ 1940 class BindingSamplerAPIOverrideTest : public GLSLTestBase 1941 { 1942 public: 1943 /* Public methods */ 1944 BindingSamplerAPIOverrideTest(deqp::Context &); 1945 ~BindingSamplerAPIOverrideTest()1946 virtual ~BindingSamplerAPIOverrideTest() 1947 { 1948 } 1949 1950 protected: 1951 /* Methods to be implemented by child class */ 1952 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 1953 Utils::shaderSource &out_source); 1954 1955 virtual void prepareUniforms(Utils::program &program); 1956 virtual void releaseResource(); 1957 1958 private: 1959 /* Private variables */ 1960 Utils::texture m_goku_texture; 1961 }; 1962 1963 /** Test implementation, description follows: 1964 * 1965 * * Wrong value for 'binding' layout qualifier. 1966 * 1967 * Use -1 or variable name as binding value. Expect shader compilation 1968 * error in each case. 1969 * 1970 * 1971 * * Missing value for 'binding' layout qualifier. 1972 * 1973 * Expect shader compilation error in following declaration: 1974 * 1975 * layout(binding) uniform sampler2D s; 1976 **/ 1977 class BindingSamplerInvalidTest : public NegativeTestBase 1978 { 1979 public: 1980 enum TESTCASES 1981 { 1982 NEGATIVE_VALUE, 1983 VARIABLE_NAME, 1984 STD140, 1985 MISSING, 1986 1987 /* */ 1988 TEST_CASES_MAX 1989 }; 1990 1991 /* Public methods */ 1992 BindingSamplerInvalidTest(deqp::Context &context, TESTCASES case_index); ~BindingSamplerInvalidTest()1993 virtual ~BindingSamplerInvalidTest() 1994 { 1995 } 1996 1997 protected: 1998 /* Methods to be implemented by child class */ 1999 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 2000 2001 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2002 Utils::shaderSource &out_source); 2003 2004 private: 2005 /* Private methods */ 2006 const glw::GLchar *getCaseString(TESTCASES test_case); 2007 const glw::GLchar *getTestCaseString(TESTCASES test_case); 2008 2009 /* Provate variables */ 2010 TESTCASES m_case; 2011 TESTCASES m_test_case_idx; 2012 }; 2013 2014 /** Test implementation, description follows: 2015 * 2016 * * 'binding' qualified used for image uniform: 2017 * 2018 * Create shader program which uses image uniform declaration with 2019 * 'binding' layout qualifier specified. For example: 2020 * 2021 * layout(rgba32f, binding = 2) image2D i; 2022 * 2023 * Bind 2D texture to image unit 2. 2024 * 2025 * Run shader program, validate binding by storing values to image in shader. 2026 * 2027 * 2028 * * 'binding' layout qualifier used for multiple image uniforms in same 2029 * shader: 2030 * 2031 * Same as above, but use multiple image uniform declarations, each with 2032 * different 'layout(binding = X)' qualifier. Validate bindings of all 2033 * samplers by storing values to textures in shader. 2034 * 2035 * 2036 * * 'binding' layout qualifier used for image uniform in different shader 2037 * stages: 2038 * 2039 * Link multiple shaders of different stages that use same image uniform. 2040 * All uniform uniform declarations use same 'binding' layout qualifier. 2041 * 2042 * Validate binding of image uniform by storing values to image in shader. 2043 * 2044 * 2045 * * 'binding' layout qualifier used with image uniforms of various types. 2046 * 2047 * Create shader program which uses samplers of type: imageBuffer, 2048 * image2D, image2DRect, image2DArray, image3D, imageCubeMap, 2049 * image1D, image1DArray. 2050 * 2051 * Each image declaration uses 'binding' qualifier with different value. 2052 * 2053 * Validate bindings of all image uniforms by storing values to textures 2054 * in shader. 2055 **/ 2056 class BindingImagesTest : public BindingImageTest 2057 { 2058 public: 2059 /* Public methods */ 2060 BindingImagesTest(deqp::Context &context, Utils::TEXTURE_TYPES test_case); 2061 ~BindingImagesTest()2062 virtual ~BindingImagesTest() 2063 { 2064 } 2065 2066 protected: 2067 /* Methods to be implemented by child class */ 2068 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 2069 2070 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2071 Utils::shaderSource &out_source); 2072 2073 virtual void prepareUniforms(Utils::program &program); 2074 virtual bool verifyAdditionalResults() const; 2075 virtual void releaseResource(); 2076 2077 private: 2078 /* Private variables */ 2079 Utils::texture m_goku_texture; 2080 Utils::texture m_vegeta_texture; 2081 Utils::texture m_trunks_texture; 2082 Utils::buffer m_goku_buffer; 2083 Utils::buffer m_vegeta_buffer; 2084 Utils::buffer m_trunks_buffer; 2085 Utils::TEXTURE_TYPES m_test_case; 2086 2087 /* Private constant */ 2088 static const glw::GLuint m_goku_data; 2089 static const glw::GLuint m_vegeta_data; 2090 static const glw::GLuint m_trunks_data; 2091 }; 2092 2093 /** Test implementation, description follows: 2094 * 2095 * * 'binding' layout qualifier used only once for same image uniform in 2096 different shader stages: 2097 * 2098 * Link multiple shaders of different stages that use same image uniform. 2099 * 'binding' layout qualifier is used only in one shader stage, other shader 2100 * stages does not specify layout qualifier. 2101 * 2102 * Validate binding of image uniform by storing values to image in shader. 2103 **/ 2104 class BindingImageSingleTest : public BindingImageTest 2105 { 2106 public: 2107 /* Public methods */ 2108 BindingImageSingleTest(deqp::Context &context, Utils::SHADER_STAGES test_stage); 2109 ~BindingImageSingleTest()2110 virtual ~BindingImageSingleTest() 2111 { 2112 } 2113 2114 protected: 2115 /* Methods to be implemented by child class */ 2116 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 2117 2118 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2119 Utils::shaderSource &out_source); 2120 2121 virtual void prepareUniforms(Utils::program &program); 2122 virtual bool verifyAdditionalResults() const; 2123 virtual void releaseResource(); 2124 2125 private: 2126 /* Private variables */ 2127 Utils::texture m_goku_texture; 2128 Utils::SHADER_STAGES m_test_stage; 2129 }; 2130 2131 /** Test implementation, description follows: 2132 * 2133 * * 'binding' layout qualifier used with image uniform array. 2134 * 2135 * Create shader program which uses image uniform array, with 'binding' 2136 * layout qualifier specified, example: 2137 * 2138 * layout(rgba32f, binding = 2) uniform image2D i[7]; 2139 * 2140 * Bind textures to image units 2..9. Validate bindings of all 2141 * image uniforms by storing values to textures in shader. 2142 * 2143 * 2144 * * Bindings of array of image uniforms 2145 * 2146 * Check if image uniform array elements automatically get subsequent 2147 * binding values, when their interface is specified using 'binding' 2148 * layout qualifier. Use glGetUniformiv. 2149 **/ 2150 class BindingImageArrayTest : public BindingImageTest 2151 { 2152 public: 2153 /* Public methods */ 2154 BindingImageArrayTest(deqp::Context &); 2155 ~BindingImageArrayTest()2156 virtual ~BindingImageArrayTest() 2157 { 2158 } 2159 2160 protected: 2161 /* Methods to be implemented by child class */ 2162 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2163 Utils::shaderSource &out_source); 2164 2165 virtual void prepareUniforms(Utils::program &program); 2166 virtual void releaseResource(); 2167 2168 private: 2169 /* Private methods */ 2170 void checkBinding(Utils::program &program, glw::GLuint index, glw::GLint expected_binding); 2171 2172 /* Private variables */ 2173 Utils::texture m_goku_00_texture; 2174 Utils::texture m_goku_01_texture; 2175 Utils::texture m_goku_02_texture; 2176 Utils::texture m_goku_03_texture; 2177 Utils::texture m_goku_04_texture; 2178 Utils::texture m_goku_05_texture; 2179 Utils::texture m_goku_06_texture; 2180 }; 2181 2182 /** Test implementation, description follows: 2183 * 2184 * * Default binding value: 2185 * 2186 * Create shader program, with image uniform declared without 'binding' 2187 * layout qualifier. Use glGetUniformiv to test if default 'binding' value 2188 * is 0. 2189 **/ 2190 class BindingImageDefaultTest : public APITestBase 2191 { 2192 public: 2193 /* Public methods */ 2194 BindingImageDefaultTest(deqp::Context &); 2195 ~BindingImageDefaultTest()2196 virtual ~BindingImageDefaultTest() 2197 { 2198 } 2199 2200 protected: 2201 /* Methods to be implemented by child class */ 2202 virtual bool checkResults(Utils::program &program); 2203 2204 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2205 Utils::shaderSource &out_source); 2206 }; 2207 2208 /** Test implementation, description follows: 2209 * 2210 * * Override binding value from API: 2211 * 2212 * Create a shader program with image uniform buffer declared with 2213 * 'layout(binding = 3)'. Use glUniform1i to change binding value to 11. 2214 * Test if binding point 11 is now used during rendering. 2215 * Test if binding point 11 is returned querying interface with 2216 * glGetUniformiv. 2217 **/ 2218 class BindingImageAPIOverrideTest : public BindingImageTest 2219 { 2220 public: 2221 /* Public methods */ 2222 BindingImageAPIOverrideTest(deqp::Context &); 2223 ~BindingImageAPIOverrideTest()2224 virtual ~BindingImageAPIOverrideTest() 2225 { 2226 } 2227 2228 protected: 2229 /* Methods to be implemented by child class */ 2230 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2231 Utils::shaderSource &out_source); 2232 2233 virtual void prepareUniforms(Utils::program &program); 2234 virtual void releaseResource(); 2235 2236 private: 2237 /* Private variables */ 2238 Utils::texture m_goku_texture; 2239 }; 2240 2241 /** Test implementation, description follows: 2242 * 2243 * * Wrong value for 'binding' layout qualifier. 2244 * 2245 * Use -1, 'rgba32f' or variable name as binding value. Expect shader 2246 * compilation error in each case. 2247 * 2248 * 2249 * * Missing value for 'binding' layout qualifier. 2250 * 2251 * Expect shader compilation error in following declaration: 2252 * 2253 * layout(rgba32f, binding) uniform image2D s; 2254 **/ 2255 class BindingImageInvalidTest : public NegativeTestBase 2256 { 2257 public: 2258 /* Private enums */ 2259 enum TESTCASES 2260 { 2261 NEGATIVE_VALUE, 2262 VARIABLE_NAME, 2263 STD140, 2264 MISSING, 2265 2266 /* */ 2267 TEST_CASES_MAX 2268 }; 2269 2270 /* Public methods */ 2271 BindingImageInvalidTest(deqp::Context &context, TESTCASES test_case_idx); 2272 ~BindingImageInvalidTest()2273 virtual ~BindingImageInvalidTest() 2274 { 2275 } 2276 2277 protected: 2278 /* Methods to be implemented by child class */ 2279 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 2280 2281 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2282 Utils::shaderSource &out_source); 2283 2284 private: 2285 /* Private methods */ 2286 const glw::GLchar *getCaseString(TESTCASES test_case); 2287 const glw::GLchar *getTestCaseString(TESTCASES test_case); 2288 2289 /* Provate variables */ 2290 TESTCASES m_case; 2291 TESTCASES m_test_case_idx; 2292 }; 2293 2294 /** Test implementation, description follows: 2295 * 2296 * * Vectors initialized using curly brace initializer lists: 2297 * 2298 * Test expressions like: 2299 * vec4 a = { 0.0, 1.0, 2.0, 3.0 }; 2300 * 2301 * Test all vector sizes. 2302 * Verify if all components were set correctly. 2303 * 2304 * 2305 * * Matrices initialized using curly brace initializer lists: 2306 * 2307 * Test expressions like: 2308 * mat2 a = {{ 0.0, 1.0 }, { 2.0, 3.0 }}; 2309 * mat2x3 b = {{ 0.0, 1.0, 2.0 }, { 3.0, 4.0, 5.0 }}; 2310 * 2311 * Test all square matrix sizes. Check all non-square matrix sizes. 2312 * 2313 * Verify if all components were set correctly. 2314 * 2315 * 2316 * * Matrix rows initialized using curly brace initializer lists: 2317 * 2318 * Test expressions like: 2319 * mat2 a = { vec2( 0.0, 1.0 ), vec2( 2.0, 3.0 ) }; 2320 * mat2x3 b = {vec3( 0.0, 1.0, 2.0), vec3( 3.0, 4.0, 5.0 )}; 2321 * 2322 * Test all square matrix sizes. Check all non-square matrix sizes. 2323 * 2324 * Verify if all components were set correctly. 2325 * 2326 * 2327 * * Arrays initialized using curly brace initializer lists: 2328 * 2329 * - Check arrays of scalars. 2330 * 2331 * - Check arrays of vectors. Vectors initialized using *vec*(...) constructor. 2332 * 2333 * - Check arrays of vectors. Vectors initialized initializer lists. 2334 * 2335 * - Check arrays of matrices. Matrices initialized using *mat*(...) contructor. 2336 * 2337 * - Check arrays of matrices. Matrices initialized initializer lists. 2338 * 2339 * Verify if all components were set correctly. 2340 * 2341 * 2342 * * Structures of transparent types initialized using initializer lists: 2343 * 2344 * Check arrays of structures also. 2345 * 2346 * Test expressions like: 2347 * struct S { float f; int i; uint u; } 2348 * S a = {1.0, 2, -3}; 2349 * S b[3] = { S(1.0, 2, -3 ), { 3.0, 5, -6 }, { 7.0, 8, -9 } }; 2350 * S c[3] = { { 1.0, 2, -3 }, { 3.0, 5, -6 }, { 7.0, 8, -9 } }; 2351 * 2352 * Verify if all components were set correctly. 2353 * 2354 * 2355 * * Nested structures and arrays initialized using initializer lists: 2356 * 2357 * - Check nested structures. Members initialized using <struct-type>(...) 2358 * constructor. 2359 * 2360 * - Check nested structures. Members initialized using initializer lists.\ 2361 * 2362 * - Check nested structures with multiple nesting levels. 2363 * 2364 * - Check structures of arrays of structures. Initialize all members using 2365 * initializer lists. 2366 * 2367 * - Check structures of arrays of structures. Use mix of constructors and 2368 * initializer lists to initialize members. 2369 * 2370 * - Check arrays of structures, containing structures. Initialize all 2371 * members using initializer lists. 2372 * 2373 * - Check arrays of structures containing structures. Use mix of 2374 * constructors and initializer lists to initialize members. 2375 * 2376 * - Check structures containing structures, that contain arrays. 2377 * Initialize all members using initializer lists. 2378 * 2379 * - Check structures containing structures, that contain arrays. Use mix of 2380 * constructors and initializer lists to initialize members. 2381 * 2382 * Verify if all components were set correctly. 2383 * 2384 * 2385 * * Unsized arrays initialized with initialer lists: 2386 * 2387 * Test expressions like: 2388 * int i[] = { 1, 2, 3 }; 2389 * S b[] = { S(1.0, 2, -3 ), { 3.0, 5, -6 }, { 7.0, 8, -9 } }; 2390 * S c[] = { { 1.0, 2, -3 }, { 3.0, 5, -6 }, { 7.0, 8, -9 } }; 2391 * 2392 * Verify if all components were set correctly. 2393 **/ 2394 class InitializerListTest : public GLSLTestBase 2395 { 2396 public: 2397 enum TESTED_INITIALIZERS 2398 { 2399 VECTOR, 2400 MATRIX, 2401 MATRIX_ROWS, 2402 STRUCT, 2403 ARRAY_SCALAR, 2404 ARRAY_VECTOR_CTR, 2405 ARRAY_VECTOR_LIST, 2406 ARRAY_MATRIX_CTR, 2407 ARRAY_MATRIX_LIST, 2408 ARRAY_STRUCT, 2409 NESTED_STRUCT_CTR, 2410 NESTED_STRUCT_LIST, 2411 NESTED_STURCT_ARRAYS_STRUCT_LIST, 2412 NESTED_STURCT_ARRAYS_STRUCT_MIX, 2413 NESTED_ARRAY_STRUCT_STRUCT_LIST, 2414 NESTED_ARRAY_STRUCT_STRUCT_MIX, 2415 NESTED_STRUCT_STRUCT_ARRAY_LIST, 2416 NESTED_STRUCT_STRUCT_ARRAY_MIX, 2417 UNSIZED_ARRAY_SCALAR, 2418 UNSIZED_ARRAY_VECTOR, 2419 UNSIZED_ARRAY_MATRIX, 2420 UNSIZED_ARRAY_STRUCT, 2421 2422 /* */ 2423 TESTED_INITIALIZERS_MAX 2424 }; 2425 2426 struct testCase 2427 { 2428 TESTED_INITIALIZERS m_initializer; 2429 2430 glw::GLuint m_n_cols; 2431 glw::GLuint m_n_rows; 2432 }; 2433 2434 /* Public methods */ 2435 InitializerListTest(deqp::Context &context, testCase test_case); 2436 ~InitializerListTest()2437 virtual ~InitializerListTest() 2438 { 2439 } 2440 2441 protected: 2442 /* Methods to be implemented by child class */ 2443 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 2444 2445 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2446 Utils::shaderSource &out_source); 2447 2448 virtual void prepareUniforms(Utils::program &program); 2449 2450 private: 2451 /* Private methods */ 2452 std::string getArrayDefinition(); 2453 std::string getExpectedValue(); 2454 std::string getInitialization(); 2455 void logTestCaseName(); 2456 std::string getSum(); 2457 std::string getTypeDefinition(); 2458 std::string getTypeName(); 2459 2460 std::string getVectorArrayCtr(glw::GLuint columns, glw::GLuint size); 2461 2462 std::string getVectorArrayList(glw::GLuint columns, glw::GLuint size); 2463 2464 std::string getVectorConstructor(glw::GLuint column, glw::GLuint size); 2465 2466 std::string getVectorInitializer(glw::GLuint column, glw::GLuint size); 2467 2468 std::string getVectorArraySum(const glw::GLchar *array_name, glw::GLuint columns, glw::GLuint size); 2469 2470 std::string getVectorSum(const glw::GLchar *vector_name, glw::GLuint size); 2471 2472 std::string getVectorValues(glw::GLuint column, glw::GLuint size); 2473 std::string getInitializerName(TESTED_INITIALIZERS initializer); 2474 2475 /* Private variables */ 2476 std::vector<testCase> m_test_cases; 2477 glw::GLint m_current_test_case_index; 2478 2479 /* Private constants */ 2480 static const glw::GLfloat m_value; 2481 }; 2482 2483 /** Test implementation, description follows: 2484 * 2485 * * Wrong type of component in initializer list. 2486 * 2487 * Try to use wrong type of component. Expect compilation error. For example: 2488 * 2489 * int a = { true }; 2490 * 2491 * 2492 * * Wrong number of components in initializer list. 2493 * 2494 * Try to wrong number of components. Expect compilation error. For example: 2495 * 2496 * vec4 a = { 0.0, 0.0, 0.0 }; 2497 * vec3 a = { 0.0, 0.0, 0.0, 0.0 }; 2498 * 2499 * 2500 * * Wrong matrix sizes in initializer lists: 2501 * 2502 * Try to use wrong matrix row size or column count. Expect compilation error. 2503 * For example: 2504 * 2505 * mat2x3 b = {{ 0.0, 1.0, 2.0 }, { 3.0, 4.0}}; 2506 * mat2x3 b = {{ 0.0, 1.0}, { 2.0, 3.0}, { 4.0, 5.0 }}; 2507 * mat2x3 b = {{ 0.0, 1.0, 2.0 }, { 3.0, 4.0, 5.0 }}; 2508 * mat2x3 b = {{ 0.0, 1.0, 2.0 }, { 3.0, 4.0, 5.0 }}; 2509 * 2510 * 2511 * * Initializer list inside constructor: 2512 * Try to use initializer list inside constructor. Expect compilation error. 2513 * For example: 2514 * 2515 * struct S { vec2 v; }; 2516 * S s = S( {1.0, 2.0 } ); 2517 * 2518 * 2519 * * Wrong struct layout in initializer list: 2520 * Try to initialize struct with bad initializer list layout. 2521 * Expect compilation error. 2522 * 2523 * Check wrong member type, wrong member count and wrong member ordering. 2524 **/ 2525 class InitializerListNegativeTest : public NegativeTestBase 2526 { 2527 public: 2528 /* Private enums */ 2529 enum TESTED_ERRORS 2530 { 2531 TYPE_UIVEC_BOOL, 2532 TYPE_IVEC_BOOL, 2533 TYPE_VEC_BOOL, 2534 TYPE_MAT_BOOL, 2535 COMPONENTS_VEC_LESS, 2536 COMPONENTS_VEC_MORE, 2537 COMPONENTS_MAT_LESS_ROWS, 2538 COMPONENTS_MAT_LESS_COLUMNS, 2539 COMPONENTS_MAT_MORE_ROWS, 2540 COMPONENTS_MAT_MORE_COLUMNS, 2541 LIST_IN_CONSTRUCTOR, 2542 STRUCT_LAYOUT_MEMBER_TYPE, 2543 STRUCT_LAYOUT_MEMBER_COUNT_MORE, 2544 STRUCT_LAYOUT_MEMBER_COUNT_LESS, 2545 STRUCT_LAYOUT_MEMBER_ORDER, 2546 2547 /* */ 2548 TESTED_ERRORS_MAX 2549 }; 2550 2551 /* Public methods */ 2552 InitializerListNegativeTest(deqp::Context &context, TESTED_ERRORS test_case); 2553 ~InitializerListNegativeTest()2554 virtual ~InitializerListNegativeTest() 2555 { 2556 } 2557 2558 protected: 2559 /* Methods to be implemented by child class */ 2560 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 2561 2562 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2563 Utils::shaderSource &out_source); 2564 2565 private: 2566 /* Private methods */ 2567 std::string getInitialization(); 2568 void logTestCaseName(); 2569 std::string getSum(); 2570 std::string getTypeDefinition(); 2571 std::string getTypeName(); 2572 std::string getTestedErrorName(TESTED_ERRORS error); 2573 2574 /* Private variables */ 2575 std::vector<TESTED_ERRORS> m_test_cases; 2576 glw::GLint m_current_test_case_index; 2577 }; 2578 2579 /** Test implementation, description follows: 2580 * 2581 * * Apply .length() to various types: 2582 * 2583 * Check value returned by .length(), when applied to vectors of all types. 2584 * Check value returned by .length(), when applied to matrices of all types. 2585 * 2586 * Check float, int and uint base types of vectors and matrices. 2587 * Check all vector sizes, check all matrix dimensions. 2588 * 2589 * Also check value returned by .length() when applied to vector or matrix 2590 * members of a structures or interface blocks. 2591 * 2592 * 2593 * * Constant folding of .length() expressions: 2594 * 2595 * Use value of .length() to set array size. For example: 2596 * 2597 * vec4 a; 2598 * float b[a.length()]; 2599 **/ 2600 class LengthOfVectorAndMatrixTest : public GLSLTestBase 2601 { 2602 public: 2603 /* Private types */ 2604 struct testCase 2605 { 2606 Utils::TYPES m_type; 2607 glw::GLuint m_n_cols; 2608 glw::GLuint m_n_rows; 2609 }; 2610 2611 /* Public methods */ 2612 LengthOfVectorAndMatrixTest(deqp::Context &context, testCase test_case); 2613 ~LengthOfVectorAndMatrixTest()2614 virtual ~LengthOfVectorAndMatrixTest() 2615 { 2616 } 2617 2618 protected: 2619 /* Methods to be implemented by child class */ 2620 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 2621 2622 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2623 Utils::shaderSource &out_source); 2624 2625 virtual void prepareUniforms(Utils::program &program); 2626 2627 virtual void prepareVertexBuffer(const Utils::program &program, Utils::buffer &buffer, Utils::vertexArray &vao); 2628 2629 private: 2630 /* Private methods */ 2631 std::string getExpectedValue(Utils::SHADER_STAGES in_stage); 2632 std::string getInitialization(); 2633 2634 std::string getMatrixInitializer(glw::GLuint n_cols, glw::GLuint n_rows); 2635 2636 std::string getVectorInitializer(Utils::TYPES type, glw::GLuint n_rows); 2637 2638 void prepareComputeShaderSource(Utils::shaderSource &out_source); 2639 2640 void prepareDrawShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2641 Utils::shaderSource &out_source); 2642 std::string getTypeName(Utils::TYPES type); 2643 2644 glw::GLuint m_current_test_case_index; 2645 bool m_is_compute_program; 2646 std::vector<testCase> m_test_cases; 2647 }; 2648 2649 /** Test implementation, description follows: 2650 * 2651 * * .length() called on compute type: 2652 * 2653 * Check value returned by .length(), when applied to computed types: 2654 * 2655 * - rows of matrices 2656 * mat4x3 a; 2657 * a[<variable>].length() 2658 * 2659 * - computed types: matrix multiplication 2660 * mat4x2 a; 2661 * mat3x4 b; 2662 * (a * b).length() 2663 * (a * b)[<variable>].length() 2664 * 2665 * - computed types: vector multiplication 2666 * vec3 a; 2667 * vec3 b; 2668 * (a * b).length() 2669 * 2670 * 2671 * * Constant folding of .length() expressions using computed type. 2672 * 2673 * Use value of .length() to set array size, when called on computed type. 2674 * For example: 2675 * mat4x2 a; 2676 * mat3x4 b; 2677 * float c[a(a * b).length()]; 2678 * float d[(a * b)[<variable>].length()]; 2679 * 2680 * 2681 * * .length() called on build-in values. 2682 * 2683 * Check value returned by .length when called on gl_Position, 2684 * gl_PointCoord, gl_SamplePosition 2685 * 2686 * 2687 * * .length() called on build-in functions 2688 * 2689 * Check value returned by .length() when called on values returned from 2690 * build in functions. For example: 2691 * outerProduct(vec4(0.0), vec3(0.0)).length() 2692 **/ 2693 class LengthOfComputeResultTest : public GLSLTestBase 2694 { 2695 public: 2696 /* Public methods */ 2697 LengthOfComputeResultTest(deqp::Context &); 2698 ~LengthOfComputeResultTest()2699 virtual ~LengthOfComputeResultTest() 2700 { 2701 } 2702 2703 protected: 2704 /* Methods to be implemented by child class */ 2705 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2706 Utils::shaderSource &out_source); 2707 2708 virtual void prepareUniforms(Utils::program &program); 2709 }; 2710 2711 /** Test implementation, description follows: 2712 * 2713 * * All sizes of scalar swizzle 2714 * 2715 * Test value returned by all sizes of scalar swizzlers: .x, .xx, .xxx and 2716 * .xxx, when called on a float variable. 2717 * 2718 * * Scalar swizzling of literals 2719 * 2720 * Call scalar swizzler .xxx on literal, for example (0.0).xxx. 2721 * 2722 * * Scalar swizzling of constant expressions 2723 * 2724 * Call scalar swizzler .xxx on constant, for example: 2725 * 2726 * const float x = 0.0; 2727 * x.xxx 2728 * 2729 * * Mixed scalar swizzling 2730 * 2731 * Check combinations of 'x', 'r', 's' swizzlers: .xx, .rr, .ss, .xrs 2732 * 2733 * * Nested swizzlers 2734 * 2735 * Check nested swizzlers. For example: 2736 * const float x = 0.0; 2737 * x.r.s.x.ss 2738 **/ 2739 class ScalarSwizzlersTest : public GLSLTestBase 2740 { 2741 public: 2742 /* Public methods */ 2743 ScalarSwizzlersTest(deqp::Context &); 2744 ~ScalarSwizzlersTest()2745 virtual ~ScalarSwizzlersTest() 2746 { 2747 } 2748 2749 protected: 2750 /* Methods to be implemented by child class */ 2751 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2752 Utils::shaderSource &out_source); 2753 2754 virtual void prepareUniforms(Utils::program &program); 2755 }; 2756 2757 /** Test implementation, description follows: 2758 * 2759 * * Wrong swizzlers for scalars: 2760 * 2761 * Swizzlers not applicable for scalars like .z, .xz, .q should fail 2762 * shader compilation. 2763 * 2764 * * Wrong swizzlers: 2765 * 2766 * Wrong swizzlers, like .u should fail shader compilation. 2767 * 2768 * * Wrong syntax: 2769 * 2770 * Literal swizzlers without parenthesis, like 1.x, should fail shader 2771 * compilation. 2772 **/ 2773 class ScalarSwizzlersInvalidTest : public NegativeTestBase 2774 { 2775 public: 2776 /* Private enums */ 2777 enum TESTED_CASES 2778 { 2779 INVALID_Y, 2780 INVALID_B, 2781 INVALID_Q, 2782 INVALID_XY, 2783 INVALID_XRS, 2784 WRONG, 2785 MISSING_PARENTHESIS, 2786 }; 2787 2788 /* Public methods */ 2789 ScalarSwizzlersInvalidTest(deqp::Context &context, TESTED_CASES test_case); 2790 ~ScalarSwizzlersInvalidTest()2791 virtual ~ScalarSwizzlersInvalidTest() 2792 { 2793 } 2794 2795 protected: 2796 /* Methods to be implemented by child class */ 2797 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 2798 2799 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2800 Utils::shaderSource &out_source); 2801 2802 private: 2803 const glw::GLchar *getTestCaseString(TESTED_CASES test_case); 2804 2805 TESTED_CASES m_case; 2806 TESTED_CASES m_test_case_idx; 2807 }; 2808 2809 /** Test implementation, description follows: 2810 * 2811 * * Value of gl_MinProgramTexelOffset: 2812 * 2813 * Check that gl_MinProgramTexelOffset matches the value of 2814 * GL_MIN_PROGRAM_TEXEL_OFFSET from API. 2815 * 2816 * Check that both values satisfy minimal requirement from OpenGL 2817 * specification. 2818 * 2819 * * Value of gl_MinProgramTexelOffset: 2820 * 2821 * Check that gl_MinProgramTexelOffset matches the value of 2822 * GL_MAX_PROGRAM_TEXEL_OFFSET from API. 2823 * 2824 * Check that both values satisfy minimal requirement from OpenGL 2825 * specification. 2826 **/ 2827 class BuiltInValuesTest : public GLSLTestBase 2828 { 2829 public: 2830 /* Public methods */ 2831 BuiltInValuesTest(deqp::Context &); 2832 ~BuiltInValuesTest()2833 virtual ~BuiltInValuesTest() 2834 { 2835 } 2836 2837 protected: 2838 /* Methods to be implemented by child class */ 2839 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2840 Utils::shaderSource &out_source); 2841 2842 virtual void prepareUniforms(Utils::program &program); 2843 virtual bool testInit(); 2844 2845 private: 2846 /* Private constants */ 2847 static const glw::GLint m_min_program_texel_offset_limit; 2848 static const glw::GLint m_max_program_texel_offset_limit; 2849 2850 /* Private variables */ 2851 glw::GLint m_min_program_texel_offset; 2852 glw::GLint m_max_program_texel_offset; 2853 }; 2854 2855 /** Test implementation, description follows: 2856 * 2857 **/ 2858 class BuiltInAssignmentTest : public NegativeTestBase 2859 { 2860 public: 2861 /* Public methods */ 2862 BuiltInAssignmentTest(deqp::Context &context, glw::GLuint test_case); 2863 ~BuiltInAssignmentTest()2864 virtual ~BuiltInAssignmentTest() 2865 { 2866 } 2867 2868 protected: 2869 /* Methods to be implemented by child class */ 2870 virtual bool prepareNextTestCase(glw::GLuint test_case_index); 2871 2872 virtual void prepareShaderSource(Utils::SHADER_STAGES in_stage, bool in_use_version_400, 2873 Utils::shaderSource &out_source); 2874 2875 private: 2876 /* Private variables */ 2877 glw::GLuint m_case; 2878 }; 2879 } // namespace GLSL420Pack 2880 2881 /** Group class for Shader Language 420Pack conformance tests */ 2882 class ShadingLanguage420PackTests : public deqp::TestCaseGroup 2883 { 2884 public: 2885 /* Public methods */ 2886 ShadingLanguage420PackTests(deqp::Context &context); 2887 ~ShadingLanguage420PackTests(void)2888 virtual ~ShadingLanguage420PackTests(void) 2889 { 2890 } 2891 2892 virtual void init(void); 2893 2894 private: 2895 /* Private methods */ 2896 ShadingLanguage420PackTests(const ShadingLanguage420PackTests &other); 2897 ShadingLanguage420PackTests &operator=(const ShadingLanguage420PackTests &other); 2898 2899 void addBindingSamplerSingleTest(); 2900 void addBindingImageSingleTest(); 2901 void addUTF8CharactersTest(); 2902 void addUTF8InSourceTest(); 2903 void addQualifierOrderTest(); 2904 void addQualifierOrderBlockTest(); 2905 void addLineContinuationTest(); 2906 void addImplicitConversionsValidTest(); 2907 void addQualifierOrderUniformTest(); 2908 void addQualifierOrderFunctionInoutTest(); 2909 void addQualifierOrderFunctionInputTest(); 2910 void addQualifierOrderFunctionOutputTest(); 2911 void addBindingUniformSingleBlockTest(); 2912 void addBindingUniformInvalidTest(); 2913 void addBindingSamplersTest(); 2914 void addBindingSamplerInvalidTest(); 2915 void addBindingImagesTest(); 2916 void addBindingImageInvalidTest(); 2917 void addInitializerListTest(); 2918 void addInitializerListNegativeTest(); 2919 void addLengthOfVectorAndMatrixTest(); 2920 void addScalarSwizzlersInvalidTest(); 2921 void addBuiltInAssignmentTest(); 2922 }; 2923 2924 } // namespace gl4cts 2925 2926 #endif // _GL4CSHADINGLANGUAGE420PACKTESTS_HPP 2927