1 #ifndef _GL4CENHANCEDLAYOUTSTESTS_HPP 2 #define _GL4CENHANCEDLAYOUTSTESTS_HPP 3 /*------------------------------------------------------------------------- 4 * OpenGL Conformance Test Suite 5 * ----------------------------- 6 * 7 * Copyright (c) 2015-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 gl4cEnhancedLayoutsTests.hpp 28 * \brief Declares test classes for "Enhanced Layouts" 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 EnhancedLayouts 43 { 44 namespace Utils 45 { 46 /** Represents data type 47 * 48 **/ 49 struct Type 50 { 51 public: 52 enum TYPES 53 { 54 Float, 55 Double, 56 Int, 57 Uint, 58 }; 59 60 /* Public methods */ 61 /* Functionality */ 62 std::vector<glw::GLubyte> GenerateData() const; 63 std::vector<glw::GLubyte> GenerateDataPacked() const; 64 glw::GLuint GetActualAlignment(glw::GLuint align, bool is_array) const; 65 glw::GLuint GetBaseAlignment(bool is_array) const; 66 std::string GetGLSLConstructor(const glw::GLvoid *data) const; 67 const glw::GLchar *GetGLSLTypeName() const; 68 glw::GLuint GetLocations(bool is_vs_input = false) const; 69 glw::GLuint GetSize(const bool is_std140 = false) const; 70 glw::GLenum GetTypeGLenum() const; 71 glw::GLuint GetNumComponents() const; 72 std::vector<glw::GLuint> GetValidComponents() const; 73 74 /* Public static routines */ 75 /* Functionality */ 76 static glw::GLuint CalculateStd140Stride(glw::GLuint alignment, glw::GLuint n_columns, 77 glw::GLuint n_array_elements); 78 79 static bool DoesTypeSupportMatrix(TYPES type); 80 81 static glw::GLuint GetActualOffset(glw::GLuint start_offset, glw::GLuint actual_alignment); 82 83 static Type GetType(TYPES basic_type, glw::GLuint n_columns, glw::GLuint n_rows); 84 85 static glw::GLuint GetTypeSize(TYPES type); 86 87 /* GL gets */ 88 static glw::GLenum GetTypeGLenum(TYPES type); 89 90 static bool CanTypesShareLocation(TYPES first, TYPES second); 91 92 /* Public fields */ 93 TYPES m_basic_type; 94 glw::GLuint m_n_columns; 95 glw::GLuint m_n_rows; 96 97 /* Public constants */ 98 static const Type _double; 99 static const Type dmat2; 100 static const Type dmat2x3; 101 static const Type dmat2x4; 102 static const Type dmat3x2; 103 static const Type dmat3; 104 static const Type dmat3x4; 105 static const Type dmat4x2; 106 static const Type dmat4x3; 107 static const Type dmat4; 108 static const Type dvec2; 109 static const Type dvec3; 110 static const Type dvec4; 111 static const Type _float; 112 static const Type _int; 113 static const Type ivec2; 114 static const Type ivec3; 115 static const Type ivec4; 116 static const Type mat2; 117 static const Type mat2x3; 118 static const Type mat2x4; 119 static const Type mat3x2; 120 static const Type mat3; 121 static const Type mat3x4; 122 static const Type mat4x2; 123 static const Type mat4x3; 124 static const Type mat4; 125 static const Type vec2; 126 static const Type vec3; 127 static const Type vec4; 128 static const Type uint; 129 static const Type uvec2; 130 static const Type uvec3; 131 static const Type uvec4; 132 }; 133 134 /** Represents buffer instance 135 * Provides basic buffer functionality 136 **/ 137 class Buffer 138 { 139 public: 140 /* Public enums */ 141 enum BUFFERS 142 { 143 Array, 144 Element, 145 Shader_Storage, 146 Texture, 147 Transform_feedback, 148 Uniform, 149 }; 150 151 enum USAGE 152 { 153 DynamicCopy, 154 DynamicDraw, 155 DynamicRead, 156 StaticCopy, 157 StaticDraw, 158 StaticRead, 159 StreamCopy, 160 StreamDraw, 161 StreamRead, 162 }; 163 164 enum ACCESS 165 { 166 ReadOnly, 167 WriteOnly, 168 ReadWrite, 169 }; 170 171 /* Public methods */ 172 /* Ctr & Dtr */ 173 Buffer(deqp::Context &context); 174 ~Buffer(); 175 176 /* Init & Release */ 177 void Init(BUFFERS buffer, USAGE usage, glw::GLsizeiptr size, glw::GLvoid *data); 178 void Release(); 179 180 /* Functionality */ 181 void Bind() const; 182 void BindBase(glw::GLuint index) const; 183 184 void BindRange(glw::GLuint index, glw::GLintptr offset, glw::GLsizeiptr size) const; 185 186 void Data(USAGE usage, glw::GLsizeiptr size, glw::GLvoid *data); 187 188 glw::GLvoid *Map(ACCESS access); 189 190 void SubData(glw::GLintptr offset, glw::GLsizeiptr size, glw::GLvoid *data); 191 192 void UnMap(); 193 194 /* Public static routines */ 195 /* Functionality */ 196 static void Bind(const glw::Functions &gl, glw::GLuint id, BUFFERS buffer); 197 198 static void BindBase(const glw::Functions &gl, glw::GLuint id, BUFFERS buffer, glw::GLuint index); 199 200 static void BindRange(const glw::Functions &gl, glw::GLuint id, BUFFERS buffer, glw::GLuint index, 201 glw::GLintptr offset, glw::GLsizeiptr size); 202 203 static void Data(const glw::Functions &gl, BUFFERS buffer, USAGE usage, glw::GLsizeiptr size, glw::GLvoid *data); 204 205 static void Generate(const glw::Functions &gl, glw::GLuint &out_id); 206 207 static void *Map(const glw::Functions &gl, BUFFERS buffer, ACCESS access); 208 209 static void SubData(const glw::Functions &gl, BUFFERS buffer, glw::GLintptr offset, glw::GLsizeiptr size, 210 glw::GLvoid *data); 211 212 static void UnMap(const glw::Functions &gl, BUFFERS buffer); 213 214 /* GL gets */ 215 static glw::GLenum GetAccessGLenum(ACCESS access); 216 static glw::GLenum GetBufferGLenum(BUFFERS buffer); 217 static glw::GLenum GetUsageGLenum(USAGE usage); 218 219 /* Gets */ 220 static const glw::GLchar *GetBufferName(BUFFERS buffer); 221 222 /* Public fields */ 223 glw::GLuint m_id; 224 225 /* Public constants */ 226 static const glw::GLuint m_invalid_id; 227 228 /* Buffer type maybe changed for different cases*/ 229 BUFFERS m_buffer; 230 231 private: 232 /* Private fields */ 233 deqp::Context &m_context; 234 }; 235 236 /** Represents framebuffer 237 * Provides basic functionality 238 **/ 239 class Framebuffer 240 { 241 public: 242 /* Public methods */ 243 /* Ctr & Dtr */ 244 Framebuffer(deqp::Context &context); 245 ~Framebuffer(); 246 247 /* Init & Release */ 248 void Init(); 249 void Release(); 250 251 /* Functionality */ 252 void AttachTexture(glw::GLenum attachment, glw::GLuint texture_id, glw::GLuint width, glw::GLuint height); 253 254 void Bind(); 255 void Clear(glw::GLenum mask); 256 257 void ClearColor(glw::GLfloat red, glw::GLfloat green, glw::GLfloat blue, glw::GLfloat alpha); 258 259 /* Public static routines */ 260 static void AttachTexture(const glw::Functions &gl, glw::GLenum attachment, glw::GLuint texture_id, 261 glw::GLuint width, glw::GLuint height); 262 263 static void Bind(const glw::Functions &gl, glw::GLuint id); 264 265 static void Clear(const glw::Functions &gl, glw::GLenum mask); 266 267 static void ClearColor(const glw::Functions &gl, glw::GLfloat red, glw::GLfloat green, glw::GLfloat blue, 268 glw::GLfloat alpha); 269 270 static void Generate(const glw::Functions &gl, glw::GLuint &out_id); 271 272 /* Public fields */ 273 glw::GLuint m_id; 274 275 /* Public constants */ 276 static const glw::GLuint m_invalid_id; 277 278 private: 279 /* Private fields */ 280 deqp::Context &m_context; 281 }; 282 283 /** Represents shader instance. 284 * Provides basic functionality for shaders. 285 **/ 286 class Shader 287 { 288 public: 289 /* Public enums */ 290 enum STAGES 291 { 292 COMPUTE = 0, 293 VERTEX, 294 TESS_CTRL, 295 TESS_EVAL, 296 GEOMETRY, 297 FRAGMENT, 298 299 /* */ 300 STAGE_MAX 301 }; 302 303 /* Public types */ 304 305 class InvalidSourceException : public std::exception 306 { 307 public: 308 InvalidSourceException(const glw::GLchar *error_message, const std::string &source, STAGES stage); 309 ~InvalidSourceException()310 virtual ~InvalidSourceException() throw() 311 { 312 } 313 314 virtual const char *what() const throw(); 315 316 void log(deqp::Context &context) const; 317 318 std::string m_message; 319 std::string m_source; 320 STAGES m_stage; 321 }; 322 323 /* Public methods */ 324 /* Ctr & Dtr */ 325 Shader(deqp::Context &context); 326 ~Shader(); 327 328 /* Init & Realese */ 329 void Init(STAGES stage, const std::string &source); 330 void Release(); 331 332 /* Public static routines */ 333 /* Functionality */ 334 static void Compile(const glw::Functions &gl, glw::GLuint id); 335 336 static void Create(const glw::Functions &gl, STAGES stage, glw::GLuint &out_id); 337 338 static void Source(const glw::Functions &gl, glw::GLuint id, const std::string &source); 339 340 /* GL gets */ 341 static glw::GLenum GetShaderStageGLenum(STAGES stage); 342 343 /* Get stage name */ 344 static const glw::GLchar *GetStageName(STAGES stage); 345 346 /* Logs sources */ 347 static void LogSource(deqp::Context &context, const std::string &source, STAGES stage); 348 349 /* Public fields */ 350 glw::GLuint m_id; 351 352 /* Public constants */ 353 static const glw::GLuint m_invalid_id; 354 355 private: 356 /* Private types */ 357 class CompilationException : public std::exception 358 { 359 public: 360 CompilationException(const glw::GLchar *message); 361 ~CompilationException()362 virtual ~CompilationException() throw() 363 { 364 } 365 366 virtual const char *what() const throw(); 367 368 std::string m_message; 369 }; 370 371 /* Private fields */ 372 deqp::Context &m_context; 373 }; 374 375 /* Forward declaration */ 376 struct Interface; 377 378 /** Represents GLSL variable 379 * 380 **/ 381 struct Variable 382 { 383 public: 384 /* Typedefs */ 385 typedef std::vector<Variable> Vector; 386 typedef std::vector<Variable *> PtrVector; 387 388 /* Enums */ 389 enum STORAGE 390 { 391 VARYING_INPUT, 392 VARYING_OUTPUT, 393 UNIFORM, 394 SSB, 395 MEMBER, 396 397 /* */ 398 STORAGE_MAX 399 }; 400 401 enum VARYING_DIRECTION 402 { 403 INPUT, 404 OUTPUT, 405 }; 406 407 enum FLAVOUR 408 { 409 BASIC, 410 ARRAY, 411 INDEXED_BY_INVOCATION_ID, 412 }; 413 414 /**/ 415 enum TYPE 416 { 417 BUILTIN, 418 INTERFACE, 419 }; 420 421 /* Types */ 422 struct Descriptor 423 { 424 /* */ 425 typedef std::vector<Descriptor> Vector; 426 427 /* */ 428 Descriptor(const glw::GLchar *name, const glw::GLchar *qualifiers, glw::GLint expected_component, 429 glw::GLint expected_location, const Type &type, glw::GLboolean normalized, 430 glw::GLuint n_array_elements, glw::GLint expected_stride_of_element, glw::GLuint offset); 431 432 Descriptor(const glw::GLchar *name, const glw::GLchar *qualifiers, glw::GLint expected_componenet, 433 glw::GLint expected_location, Interface *interface, glw::GLuint n_array_elements, 434 glw::GLint expected_stride_of_element, glw::GLuint offset); 435 436 /* */ 437 std::string GetDefinition(FLAVOUR flavour, STORAGE storage) const; 438 439 /* */ 440 glw::GLint m_expected_component; 441 glw::GLint m_expected_location; 442 glw::GLint m_expected_stride_of_element; 443 glw::GLuint m_n_array_elements; 444 std::string m_name; 445 glw::GLboolean m_normalized; 446 glw::GLuint m_offset; 447 std::string m_qualifiers; 448 449 TYPE m_type; 450 union 451 { 452 Type m_builtin; 453 Interface *m_interface; 454 }; 455 }; 456 457 /* Constructors */ 458 template <typename T> Variablegl4cts::EnhancedLayouts::Utils::Variable459 Variable(const glw::GLchar *name, const glw::GLchar *qualifiers, glw::GLint expected_component, 460 glw::GLint expected_location, const Type &type, glw::GLboolean normalized, glw::GLuint n_array_elements, 461 glw::GLint expected_stride_of_element, glw::GLuint offset, const T *data, size_t data_size, 462 STORAGE storage) 463 : m_data((glw::GLvoid *)data) 464 , m_data_size(data_size) 465 , m_descriptor(name, qualifiers, expected_component, expected_location, type, normalized, n_array_elements, 466 expected_stride_of_element, offset) 467 , m_storage(storage) 468 { 469 } 470 471 template <typename T> Variablegl4cts::EnhancedLayouts::Utils::Variable472 Variable(const glw::GLchar *name, const glw::GLchar *qualifiers, glw::GLint expected_component, 473 glw::GLint expected_location, Interface *interface, glw::GLuint n_array_elements, 474 glw::GLint expected_stride_of_element, glw::GLuint offset, const T *data, size_t data_size, 475 STORAGE storage) 476 : m_data((glw::GLvoid *)data) 477 , m_data_size(data_size) 478 , m_descriptor(name, qualifiers, expected_component, expected_location, interface, n_array_elements, 479 expected_stride_of_element, offset) 480 , m_storage(storage) 481 { 482 } 483 484 Variable(const Variable &var); 485 486 /* Functionality */ 487 std::string GetDefinition(FLAVOUR flavour) const; 488 glw::GLuint GetSize() const; 489 glw::GLuint GetStride() const; 490 bool IsBlock() const; 491 bool IsStruct() const; 492 /* Static routines */ 493 static FLAVOUR GetFlavour(Shader::STAGES stage, VARYING_DIRECTION direction); 494 static std::string GetReference(const std::string &parent_name, const Descriptor &variable, FLAVOUR flavour, 495 glw::GLuint array_index); 496 497 /* Fields */ 498 glw::GLvoid *m_data; 499 size_t m_data_size; 500 Descriptor m_descriptor; 501 STORAGE m_storage; 502 503 /* Constants */ 504 static const glw::GLint m_automatic_location; 505 }; 506 507 /* Define the methods NAME, that will add new variable to VECTOR with STORAGE set */ 508 #define DEFINE_VARIABLE_CLASS(NAME, STORAGE, VECTOR) \ 509 template <typename T> \ 510 Variable *NAME(const glw::GLchar *name, const glw::GLchar *qualifiers, glw::GLint expected_component, \ 511 glw::GLint expected_location, const Type &type, glw::GLboolean normalized, \ 512 glw::GLuint n_array_elements, glw::GLint expected_stride_of_element, glw::GLuint offset, \ 513 const T *data, size_t data_size) \ 514 { \ 515 Variable *var = new Variable(name, qualifiers, expected_component, expected_location, type, normalized, \ 516 n_array_elements, expected_stride_of_element, offset, data, data_size, STORAGE); \ 517 if (0 == var) \ 518 { \ 519 TCU_FAIL("Memory allocation"); \ 520 } \ 521 VECTOR.push_back(var); \ 522 return VECTOR.back(); \ 523 } \ 524 \ 525 template <typename T> \ 526 Variable *NAME(const glw::GLchar *name, const glw::GLchar *qualifiers, glw::GLint expected_component, \ 527 glw::GLint expected_location, Interface *interface, glw::GLuint n_array_elements, \ 528 glw::GLint expected_stride_of_element, glw::GLuint offset, const T *data, size_t data_size) \ 529 { \ 530 Variable *var = new Variable(name, qualifiers, expected_component, expected_location, interface, \ 531 n_array_elements, expected_stride_of_element, offset, data, data_size, STORAGE); \ 532 if (0 == var) \ 533 { \ 534 TCU_FAIL("Memory allocation"); \ 535 } \ 536 VECTOR.push_back(var); \ 537 return VECTOR.back(); \ 538 } 539 540 /** Represents structures and block 541 * 542 **/ 543 struct Interface 544 { 545 public: 546 /* Typedefs */ 547 typedef std::vector<Interface> Vector; 548 typedef std::vector<Interface *> PtrVector; 549 550 /**/ 551 enum TYPE 552 { 553 STRUCT, 554 BLOCK 555 }; 556 557 /* Constructor */ 558 Interface(const glw::GLchar *name, TYPE type); 559 560 /* */ 561 Variable::Descriptor *Member(const glw::GLchar *name, const glw::GLchar *qualifiers, glw::GLint expected_component, 562 glw::GLint expected_location, const Type &type, glw::GLboolean normalized, 563 glw::GLuint n_array_elements, glw::GLint expected_stride_of_element, 564 glw::GLuint offset); 565 Variable::Descriptor *Member(const glw::GLchar *name, const glw::GLchar *qualifiers, glw::GLint expected_component, 566 glw::GLint expected_location, Interface *interface, glw::GLuint n_array_elements, 567 glw::GLint expected_stride_of_element, glw::GLuint offset); 568 569 /**/ 570 Variable::Descriptor *AddMember(const Variable::Descriptor &member); 571 572 std::string GetDefinition() const; 573 574 /**/ 575 Variable::Descriptor::Vector m_members; 576 std::string m_name; 577 TYPE m_type; 578 }; 579 580 struct ShaderInterface 581 { 582 ShaderInterface(Shader::STAGES stage); 583 584 DEFINE_VARIABLE_CLASS(Input, Variable::VARYING_INPUT, m_inputs) 585 DEFINE_VARIABLE_CLASS(Output, Variable::VARYING_OUTPUT, m_outputs) 586 DEFINE_VARIABLE_CLASS(Uniform, Variable::UNIFORM, m_uniforms) 587 DEFINE_VARIABLE_CLASS(SSB, Variable::SSB, m_ssb_blocks) 588 589 /**/ 590 std::string GetDefinitionsGlobals() const; 591 std::string GetDefinitionsInputs() const; 592 std::string GetDefinitionsOutputs() const; 593 std::string GetDefinitionsSSBs() const; 594 std::string GetDefinitionsUniforms() const; 595 596 std::string m_globals; 597 Variable::PtrVector m_inputs; 598 Variable::PtrVector m_outputs; 599 Variable::PtrVector m_uniforms; 600 Variable::PtrVector m_ssb_blocks; 601 602 Shader::STAGES m_stage; 603 }; 604 605 struct VaryingConnection 606 { 607 /* */ 608 typedef std::vector<VaryingConnection> Vector; 609 610 /* */ 611 VaryingConnection(Variable *in, Variable *out); 612 613 /* */ 614 Variable *m_in; 615 Variable *m_out; 616 }; 617 618 struct VaryingPassthrough 619 { 620 /* */ 621 void Add(Shader::STAGES stage, Variable *in, Variable *out); 622 623 VaryingConnection::Vector &Get(Shader::STAGES stage); 624 625 /**/ 626 VaryingConnection::Vector m_fragment; 627 VaryingConnection::Vector m_geometry; 628 VaryingConnection::Vector m_tess_ctrl; 629 VaryingConnection::Vector m_tess_eval; 630 VaryingConnection::Vector m_vertex; 631 }; 632 633 struct ProgramInterface 634 { 635 636 /* */ 637 ProgramInterface(); 638 ~ProgramInterface(); 639 640 /* */ 641 Interface *AddInterface(const glw::GLchar *name, Interface::TYPE type); 642 Interface *Block(const glw::GLchar *name); 643 Interface *GetBlock(const glw::GLchar *name); 644 ShaderInterface &GetShaderInterface(Shader::STAGES stage); 645 const ShaderInterface &GetShaderInterface(Shader::STAGES stage) const; 646 Interface *GetStructure(const glw::GLchar *name); 647 Interface *Structure(const glw::GLchar *name); 648 649 /**/ 650 std::string GetDefinitionsStructures() const; 651 std::string GetInterfaceForStage(Shader::STAGES stage) const; 652 653 /* */ 654 Interface *CloneBlockForStage(const Interface &block, Shader::STAGES stage, Variable::STORAGE storage, 655 const glw::GLchar *prefix); 656 void CloneVertexInterface(VaryingPassthrough &variable_pass); 657 658 /* */ 659 static const glw::GLchar *GetStagePrefix(Shader::STAGES stage, Variable::STORAGE storage); 660 661 /* */ 662 Interface::PtrVector m_structures; 663 Interface::PtrVector m_blocks; 664 665 ShaderInterface m_compute; 666 ShaderInterface m_vertex; 667 ShaderInterface m_tess_ctrl; 668 ShaderInterface m_tess_eval; 669 ShaderInterface m_geometry; 670 ShaderInterface m_fragment; 671 672 //Variable::Vector m_fragment_outputs; 673 //Variable::PtrVector m_captured_varyings; 674 675 private: 676 /* */ 677 void cloneVariableForStage(const Variable &variable, Shader::STAGES stage, const glw::GLchar *prefix, 678 VaryingPassthrough &varying_passthrough); 679 Variable *cloneVariableForStage(const Variable &variable, Shader::STAGES stage, Variable::STORAGE storage, 680 const glw::GLchar *prefix); 681 void replaceBinding(Variable &variable, Shader::STAGES stage); 682 }; 683 684 /** Represents program pipeline 685 * 686 **/ 687 class Pipeline 688 { 689 public: 690 /* Public methods */ 691 /* Ctr & Dtr */ 692 Pipeline(deqp::Context &context); 693 ~Pipeline(); 694 695 /* Init & Release */ 696 void Init(); 697 void Release(); 698 699 /* Functionality */ 700 void Bind(); 701 void UseProgramStages(glw::GLuint program_id, glw::GLenum stages); 702 703 /* Public static routines */ 704 /* Functionality */ 705 void Bind(const glw::Functions &gl, glw::GLuint id); 706 void UseProgramStages(const glw::Functions &gl, glw::GLuint id, glw::GLuint program_id, glw::GLenum stages); 707 708 /* Public fields */ 709 glw::GLuint m_id; 710 711 /* Public constants */ 712 static const glw::GLuint m_invalid_id; 713 714 private: 715 /* Private fields */ 716 deqp::Context &m_context; 717 }; 718 719 /** Represents program instance. 720 * Provides basic functionality 721 **/ 722 class Program 723 { 724 public: 725 /* Public types */ 726 class BuildException : public std::exception 727 { 728 public: 729 BuildException(const glw::GLchar *error_message, const std::string compute_shader, 730 const std::string fragment_shader, const std::string geometry_shader, 731 const std::string tess_ctrl_shader, const std::string tess_eval_shader, 732 const std::string vertex_shader); ~BuildException()733 virtual ~BuildException() throw() 734 { 735 } 736 737 virtual const char *what() const throw(); 738 739 void log(deqp::Context &context) const; 740 741 std::string m_error_message; 742 std::string m_compute_shader; 743 std::string m_fragment_shader; 744 std::string m_geometry_shader; 745 std::string m_tess_ctrl_shader; 746 std::string m_tess_eval_shader; 747 std::string m_vertex_shader; 748 }; 749 750 typedef std::vector<std::string> NameVector; 751 752 /* Public methods */ 753 /* Ctr & Dtr */ 754 Program(deqp::Context &context); 755 ~Program(); 756 757 /* Init & Release */ 758 void Init(const std::string &compute_shader, const std::string &fragment_shader, const std::string &geometry_shader, 759 const std::string &tessellation_control_shader, const std::string &tessellation_evaluation_shader, 760 const std::string &vertex_shader, const NameVector &captured_varyings, bool capture_interleaved, 761 bool is_separable); 762 763 void Init(const std::string &compute_shader, const std::string &fragment_shader, const std::string &geometry_shader, 764 const std::string &tessellation_control_shader, const std::string &tessellation_evaluation_shader, 765 const std::string &vertex_shader, bool is_separable); 766 767 void Release(); 768 769 /* Functionality */ 770 void GetActiveUniformsiv(glw::GLsizei count, const glw::GLuint *indices, glw::GLenum pname, 771 glw::GLint *params) const; 772 773 glw::GLint GetAttribLocation(const std::string &name) const; 774 775 void GetResource(glw::GLenum interface, glw::GLuint index, glw::GLenum property, glw::GLsizei buf_size, 776 glw::GLint *params) const; 777 778 glw::GLuint GetResourceIndex(const std::string &name, glw::GLenum interface) const; 779 780 void GetUniformIndices(glw::GLsizei count, const glw::GLchar **names, glw::GLuint *indices) const; 781 782 glw::GLint GetUniformLocation(const std::string &name) const; 783 void Use() const; 784 785 /* Public static routines */ 786 /* Functionality */ 787 static void Attach(const glw::Functions &gl, glw::GLuint program_id, glw::GLuint shader_id); 788 789 static void Capture(const glw::Functions &gl, glw::GLuint id, const NameVector &captured_varyings, 790 bool capture_interleaved); 791 792 static void Create(const glw::Functions &gl, glw::GLuint &out_id); 793 794 static void GetActiveUniformsiv(const glw::Functions &gl, glw::GLuint program_id, glw::GLsizei count, 795 const glw::GLuint *indices, glw::GLenum pname, glw::GLint *params); 796 797 static void GetUniformIndices(const glw::Functions &gl, glw::GLuint program_id, glw::GLsizei count, 798 const glw::GLchar **names, glw::GLuint *indices); 799 800 static void Link(const glw::Functions &gl, glw::GLuint id); 801 802 static void Uniform(const glw::Functions &gl, const Type &type, glw::GLsizei count, glw::GLint location, 803 const glw::GLvoid *data); 804 805 static void Use(const glw::Functions &gl, glw::GLuint id); 806 807 /* Get locations */ 808 static glw::GLint GetAttribLocation(const glw::Functions &gl, glw::GLuint id, const std::string &name); 809 810 static void GetResource(const glw::Functions &gl, glw::GLuint id, glw::GLenum interface, glw::GLuint index, 811 glw::GLenum property, glw::GLsizei buf_size, glw::GLint *params); 812 813 static glw::GLuint GetResourceIndex(const glw::Functions &gl, glw::GLuint id, const std::string &name, 814 glw::GLenum interface); 815 816 static glw::GLint GetUniformLocation(const glw::Functions &gl, glw::GLuint id, const std::string &name); 817 818 /* Public fields */ 819 glw::GLuint m_id; 820 821 Shader m_compute; 822 Shader m_fragment; 823 Shader m_geometry; 824 Shader m_tess_ctrl; 825 Shader m_tess_eval; 826 Shader m_vertex; 827 828 /* Public constants */ 829 static const glw::GLuint m_invalid_id; 830 831 private: 832 /* Private types */ 833 class LinkageException : public std::exception 834 { 835 public: 836 LinkageException(const glw::GLchar *error_message); 837 ~LinkageException()838 virtual ~LinkageException() throw() 839 { 840 } 841 842 virtual const char *what() const throw(); 843 844 std::string m_error_message; 845 }; 846 847 /* Private fields */ 848 deqp::Context &m_context; 849 }; 850 851 class Texture 852 { 853 public: 854 /* Public enums */ 855 enum TYPES 856 { 857 TEX_BUFFER, 858 TEX_2D, 859 TEX_2D_RECT, 860 TEX_2D_ARRAY, 861 TEX_3D, 862 TEX_CUBE, 863 TEX_1D, 864 TEX_1D_ARRAY, 865 }; 866 867 /* Public methods */ 868 /* Ctr & Dtr */ 869 Texture(deqp::Context &context); 870 ~Texture(); 871 872 /* Init & Release */ 873 void Init(TYPES tex_type, glw::GLuint width, glw::GLuint height, glw::GLuint depth, glw::GLenum internal_format, 874 glw::GLenum format, glw::GLenum type, glw::GLvoid *data); 875 876 void Init(glw::GLenum internal_format, glw::GLuint buffer_id); 877 878 void Release(); 879 880 /* Functionality */ 881 void Bind() const; 882 void Get(glw::GLenum format, glw::GLenum type, glw::GLvoid *out_data) const; 883 884 /* Public static routines */ 885 /* Functionality */ 886 static void Bind(const glw::Functions &gl, glw::GLuint id, TYPES tex_type); 887 888 static void Generate(const glw::Functions &gl, glw::GLuint &out_id); 889 890 static void Get(const glw::Functions &gl, TYPES tex_type, glw::GLenum format, glw::GLenum type, 891 glw::GLvoid *out_data); 892 893 static void Storage(const glw::Functions &gl, TYPES tex_type, glw::GLuint width, glw::GLuint height, 894 glw::GLuint depth, glw::GLenum internal_format); 895 896 static void TexBuffer(const glw::Functions &gl, glw::GLenum internal_format, glw::GLuint &buffer_id); 897 898 static void Update(const glw::Functions &gl, TYPES tex_type, glw::GLuint width, glw::GLuint height, 899 glw::GLuint depth, glw::GLenum format, glw::GLenum type, glw::GLvoid *data); 900 901 /* GL gets */ 902 static glw::GLenum GetTargetGLenum(TYPES tex_type); 903 904 /* Public fields */ 905 glw::GLuint m_id; 906 907 /* Public constants */ 908 static const glw::GLuint m_invalid_id; 909 910 private: 911 deqp::Context &m_context; 912 TYPES m_type; 913 }; 914 915 /** Represents Vertex array object 916 * Provides basic functionality 917 **/ 918 class VertexArray 919 { 920 public: 921 /* Public methods */ 922 /* Ctr & Dtr */ 923 VertexArray(deqp::Context &Context); 924 ~VertexArray(); 925 926 /* Init & Release */ 927 void Init(); 928 //void Init(const ProgramInterface& program_interface, 929 // glw::GLuint vertex_buffer, 930 // glw::GLuint index_buffer); 931 void Release(); 932 933 void Attribute(glw::GLuint index, const Type &type, glw::GLuint n_array_elements, glw::GLboolean normalized, 934 glw::GLsizei stride, const glw::GLvoid *pointer); 935 936 void Bind(); 937 938 /* Public static methods */ 939 static void AttribPointer(const glw::Functions &gl, glw::GLuint index, const Type &type, 940 glw::GLuint n_array_elements, glw::GLboolean normalized, glw::GLsizei stride, 941 const glw::GLvoid *pointer); 942 943 static void Bind(const glw::Functions &gl, glw::GLuint id); 944 945 static void Disable(const glw::Functions &gl, glw::GLuint index, const Type &type, glw::GLuint n_array_elements); 946 947 static void Divisor(const glw::Functions &gl, glw::GLuint index, glw::GLuint divisor); 948 949 static void Enable(const glw::Functions &gl, glw::GLuint index, const Type &type, glw::GLuint n_array_elements); 950 951 static void Generate(const glw::Functions &gl, glw::GLuint &out_id); 952 953 /* Public fields */ 954 glw::GLuint m_id; 955 956 /* Public constants */ 957 static const glw::GLuint m_invalid_id; 958 959 private: 960 deqp::Context &m_context; 961 }; 962 963 /* UniformN*v prototypes */ 964 typedef GLW_APICALL void(GLW_APIENTRY *uniformNdv)(glw::GLint, glw::GLsizei, const glw::GLdouble *); 965 typedef GLW_APICALL void(GLW_APIENTRY *uniformNfv)(glw::GLint, glw::GLsizei, const glw::GLfloat *); 966 typedef GLW_APICALL void(GLW_APIENTRY *uniformNiv)(glw::GLint, glw::GLsizei, const glw::GLint *); 967 typedef GLW_APICALL void(GLW_APIENTRY *uniformNuiv)(glw::GLint, glw::GLsizei, const glw::GLuint *); 968 typedef GLW_APICALL void(GLW_APIENTRY *uniformMatrixNdv)(glw::GLint, glw::GLsizei, glw::GLboolean, 969 const glw::GLdouble *); 970 typedef GLW_APICALL void(GLW_APIENTRY *uniformMatrixNfv)(glw::GLint, glw::GLsizei, glw::GLboolean, 971 const glw::GLfloat *); 972 973 /* Public static methods */ 974 /* UniformN*v routine getters */ 975 uniformNdv getUniformNdv(const glw::Functions &gl, glw::GLuint n_rows); 976 uniformNfv getUniformNfv(const glw::Functions &gl, glw::GLuint n_rows); 977 uniformNiv getUniformNiv(const glw::Functions &gl, glw::GLuint n_rows); 978 uniformNuiv getUniformNuiv(const glw::Functions &gl, glw::GLuint n_rows); 979 uniformMatrixNdv getUniformMatrixNdv(const glw::Functions &gl, glw::GLuint n_columns, glw::GLuint n_rows); 980 uniformMatrixNfv getUniformMatrixNfv(const glw::Functions &gl, glw::GLuint n_columns, glw::GLuint n_rows); 981 982 /* Stuff */ 983 bool checkProgramInterface(const ProgramInterface &program_interface, Program &program, std::stringstream &stream); 984 985 bool isExtensionSupported(deqp::Context &context, const glw::GLchar *extension_name); 986 987 bool isGLVersionAtLeast(const glw::Functions &gl, glw::GLint required_major, glw::GLint required_minor); 988 989 void replaceToken(const glw::GLchar *token, size_t &search_position, const glw::GLchar *text, std::string &string); 990 991 void replaceAllTokens(const glw::GLchar *token, const glw::GLchar *text, std::string &string); 992 993 glw::GLuint roundUpToPowerOf2(glw::GLuint value); 994 995 void insertElementOfList(const glw::GLchar *element, const glw::GLchar *separator, size_t &search_position, 996 std::string &string); 997 998 void endList(const glw::GLchar *separator, size_t &search_position, std::string &string); 999 } // namespace Utils 1000 1001 /** Base class for tests **/ 1002 class TestBase : public deqp::TestCase 1003 { 1004 public: 1005 /* Public methods */ 1006 TestBase(deqp::Context &context, const glw::GLchar *test_name, const glw::GLchar *test_description); 1007 ~TestBase()1008 virtual ~TestBase() 1009 { 1010 } 1011 1012 /* Public methods inherited from TestCase */ 1013 virtual tcu::TestNode::IterateResult iterate(void); 1014 1015 protected: 1016 /* Methods to be implemented by child class */ 1017 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1018 virtual glw::GLuint getTestCaseNumber(); 1019 virtual bool testCase(glw::GLuint test_case_index) = 0; 1020 virtual void testInit(); 1021 1022 /* Routines avaiable for children */ 1023 glw::GLuint calculateStride(const Utils::Interface &interface) const; 1024 void generateData(const Utils::Interface &interface, glw::GLuint offset, std::vector<glw::GLubyte> &out_data) const; 1025 1026 glw::GLint getLastInputLocation(Utils::Shader::STAGES stage, const Utils::Type &type, glw::GLuint array_lenth, 1027 bool ignore_prev_stage); 1028 1029 glw::GLint getLastOutputLocation(Utils::Shader::STAGES stage, const Utils::Type &type, glw::GLuint array_lenth, 1030 bool ignore_next_stage); 1031 1032 Utils::Type getType(glw::GLuint index) const; 1033 std::string getTypeName(glw::GLuint index) const; 1034 glw::GLuint getTypesNumber() const; 1035 1036 bool isFlatRequired(Utils::Shader::STAGES stage, const Utils::Type &type, Utils::Variable::STORAGE storage, 1037 const bool coherent = false) const; 1038 1039 private: 1040 /* Private methods */ 1041 bool test(); 1042 }; 1043 1044 /** Base class for test doing Buffer alghorithm **/ 1045 class BufferTestBase : public TestBase 1046 { 1047 public: 1048 /* Public methods */ 1049 BufferTestBase(deqp::Context &context, const glw::GLchar *test_name, const glw::GLchar *test_description); 1050 ~BufferTestBase()1051 virtual ~BufferTestBase() 1052 { 1053 } 1054 1055 protected: 1056 /* */ 1057 struct bufferDescriptor 1058 { 1059 /* Typedefs */ 1060 typedef std::vector<bufferDescriptor> Vector; 1061 1062 /* Fileds */ 1063 std::vector<glw::GLubyte> m_expected_data; 1064 std::vector<glw::GLubyte> m_initial_data; 1065 glw::GLuint m_index; 1066 Utils::Buffer::BUFFERS m_target; 1067 1068 /* Constants */ 1069 static const glw::GLuint m_non_indexed; 1070 }; 1071 1072 class bufferCollection 1073 { 1074 public: 1075 struct pair 1076 { 1077 Utils::Buffer *m_buffer; 1078 bufferDescriptor *m_descriptor; 1079 }; 1080 1081 ~bufferCollection(); 1082 1083 typedef std::vector<pair> Vector; 1084 1085 Vector m_vector; 1086 }; 1087 1088 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 1089 1090 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 1091 1092 virtual void getCapturedVaryings(glw::GLuint test_case_index, Utils::Program::NameVector &captured_varyings, 1093 glw::GLint *xfb_components); 1094 1095 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 1096 std::string &out_calculations); 1097 1098 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 1099 std::string &out_interface); 1100 1101 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1102 1103 virtual bool inspectProgram(glw::GLuint test_case_index, Utils::Program &program, std::stringstream &out_stream); 1104 1105 virtual bool testCase(glw::GLuint test_case_index); 1106 virtual bool verifyBuffers(bufferCollection &buffers); 1107 1108 private: 1109 void cleanBuffers(); 1110 std::string getShaderTemplate(Utils::Shader::STAGES stage); 1111 void prepareBuffer(Utils::Buffer &buffer, bufferDescriptor &descriptor); 1112 void prepareBuffers(bufferDescriptor::Vector &descriptors, bufferCollection &out_buffers); 1113 1114 /* */ 1115 }; 1116 1117 class NegativeTestBase : public TestBase 1118 { 1119 public: 1120 /* Public methods */ 1121 NegativeTestBase(deqp::Context &context, const glw::GLchar *test_name, const glw::GLchar *test_description); 1122 ~NegativeTestBase()1123 virtual ~NegativeTestBase() 1124 { 1125 } 1126 1127 protected: 1128 /* Methods to be implemented by child class */ 1129 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage) = 0; 1130 virtual bool isComputeRelevant(glw::GLuint test_case_index); 1131 virtual bool isFailureExpected(glw::GLuint test_case_index); 1132 virtual bool isSeparable(const glw::GLuint test_case_index); 1133 virtual bool testCase(glw::GLuint test_case_index); 1134 }; 1135 1136 /** Base class for test doing Texture algorithm **/ 1137 class TextureTestBase : public TestBase 1138 { 1139 public: 1140 /* Public methods */ 1141 TextureTestBase(deqp::Context &context, const glw::GLchar *test_name, const glw::GLchar *test_description); 1142 ~TextureTestBase()1143 virtual ~TextureTestBase() 1144 { 1145 } 1146 1147 protected: 1148 /* Methods to be implemented by child class */ 1149 virtual bool checkResults(glw::GLuint test_case_index, Utils::Texture &color_0); 1150 1151 virtual void executeDispatchCall(glw::GLuint test_case_index); 1152 virtual void executeDrawCall(glw::GLuint test_case_index); 1153 1154 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1155 Utils::VaryingPassthrough &varying_passthrough); 1156 1157 virtual std::string getPassSnippet(glw::GLuint test_case_index, Utils::VaryingPassthrough &varying_passthrough, 1158 Utils::Shader::STAGES stage); 1159 1160 virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1161 Utils::Shader::STAGES stage); 1162 1163 virtual bool isComputeRelevant(glw::GLuint test_case_index); 1164 virtual bool isDrawRelevant(glw::GLuint test_case_index); 1165 1166 virtual void prepareAttributes(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1167 Utils::Buffer &buffer, Utils::VertexArray &vao); 1168 1169 virtual void prepareAttribLocation(Utils::Program &program, Utils::ProgramInterface &program_interface); 1170 1171 virtual void prepareFragmentDataLoc(Utils::Program &program, Utils::ProgramInterface &program_interface); 1172 1173 virtual void prepareFramebuffer(Utils::Framebuffer &framebuffer, Utils::Texture &color_0_texture); 1174 1175 virtual void prepareImage(glw::GLint location, Utils::Texture &image_texture) const; 1176 1177 virtual void prepareSSBs(glw::GLuint test_case_index, Utils::ShaderInterface &si, Utils::Program &program, 1178 Utils::Buffer &buffer); 1179 1180 virtual void prepareSSBs(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1181 Utils::Program &program, Utils::Buffer &cs_buffer); 1182 1183 virtual void prepareSSBs(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1184 Utils::Program &program, Utils::Buffer &fs_buffer, Utils::Buffer &gs_buffer, 1185 Utils::Buffer &tcs_buffer, Utils::Buffer &tes_buffer, Utils::Buffer &vs_buffer); 1186 1187 virtual void prepareUniforms(glw::GLuint test_case_index, Utils::ShaderInterface &si, Utils::Program &program, 1188 Utils::Buffer &buffer); 1189 1190 virtual void prepareUniforms(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1191 Utils::Program &program, Utils::Buffer &cs_buffer); 1192 1193 virtual void prepareUniforms(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1194 Utils::Program &program, Utils::Buffer &fs_buffer, Utils::Buffer &gs_buffer, 1195 Utils::Buffer &tcs_buffer, Utils::Buffer &tes_buffer, Utils::Buffer &vs_buffer); 1196 1197 virtual void prepareUniforms(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1198 Utils::Program &fs_program, Utils::Program &gs_program, Utils::Program &tcs_program, 1199 Utils::Program &tes_program, Utils::Program &vs_program, Utils::Buffer &fs_buffer, 1200 Utils::Buffer &gs_buffer, Utils::Buffer &tcs_buffer, Utils::Buffer &tes_buffer, 1201 Utils::Buffer &vs_buffer); 1202 //virtual void prepareDrawPrograms (glw::GLuint test_case_index, 1203 // Utils::Program& fragment, 1204 // Utils::Program& geometry, 1205 // Utils::Program& tess_ctrl, 1206 // Utils::Program& tess_eval, 1207 // Utils::Program& vertex); 1208 virtual bool testCase(glw::GLuint test_case_index); 1209 virtual bool testMonolithic(glw::GLuint test_case_index); 1210 virtual bool testSeparable(glw::GLuint test_case_index); 1211 virtual bool useComponentQualifier(glw::GLuint test_case_index); 1212 virtual bool useMonolithicProgram(glw::GLuint test_case_index); 1213 1214 /* Protected constants */ 1215 static const glw::GLuint m_width; 1216 static const glw::GLuint m_height; 1217 1218 private: 1219 std::string getShaderSource(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1220 Utils::VaryingPassthrough &varying_passthrough, Utils::Shader::STAGES stage); 1221 1222 const glw::GLchar *getShaderTemplate(Utils::Shader::STAGES stage); 1223 1224 std::string getVariablePassthrough(const std::string &in_parent_name, 1225 const Utils::Variable::Descriptor &in_variable, 1226 Utils::Variable::FLAVOUR in_flavour, const std::string &out_parent_name, 1227 const Utils::Variable::Descriptor &out_variable, 1228 Utils::Variable::FLAVOUR out_flavour); 1229 1230 std::string getVariableVerification(const std::string &parent_name, const glw::GLvoid *data, 1231 const Utils::Variable::Descriptor &variable, Utils::Variable::FLAVOUR flavour); 1232 1233 void prepareSSB(Utils::Program &program, Utils::Variable &variable, Utils::Buffer &buffer); 1234 1235 void prepareUniform(Utils::Program &program, Utils::Variable &variable, Utils::Buffer &buffer); 1236 }; 1237 1238 /** Implementation of test APIConstantValues. Description follows: 1239 * 1240 * Test verifies values of the following constants are at least as specified: 1241 * - MAX_TRANSFORM_FEEDBACK_BUFFERS - 4, 1242 * - MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS - 64. 1243 **/ 1244 class APIConstantValuesTest : public deqp::TestCase 1245 { 1246 public: 1247 /* Public methods */ 1248 APIConstantValuesTest(deqp::Context &context); ~APIConstantValuesTest()1249 virtual ~APIConstantValuesTest() 1250 { 1251 } 1252 1253 /* Public methods inherited from TestCase */ 1254 virtual tcu::TestNode::IterateResult iterate(void); 1255 }; 1256 1257 /** Implementation of test APIErrors. Description follows: 1258 * 1259 * Test verifies that errors are generated as specified: 1260 * - GetProgramInterfaceiv should generate INVALID_OPERATION when 1261 * <programInterface> is TRANSFORM_FEEDBACK_BUFFER and <pname> is 1262 * MAX_NAME_LENGTH; 1263 * - GetProgramResourceIndex should generate INVALID_ENUM when 1264 * <programInterface> is TRANSFORM_FEEDBACK_BUFFER; 1265 * - GetProgramResourceName should generate INVALID_ENUM when 1266 * <programInterface> is TRANSFORM_FEEDBACK_BUFFER; 1267 **/ 1268 class APIErrorsTest : public deqp::TestCase 1269 { 1270 public: 1271 /* Public methods */ 1272 APIErrorsTest(deqp::Context &context); ~APIErrorsTest()1273 virtual ~APIErrorsTest() 1274 { 1275 } 1276 1277 /* Public methods inherited from TestCase */ 1278 virtual tcu::TestNode::IterateResult iterate(void); 1279 1280 private: 1281 void checkError(glw::GLenum expected_error, const glw::GLchar *message, bool &test_result); 1282 }; 1283 1284 /** Implementation of test GLSLContantValues. Description follows: 1285 * 1286 * Test verifies values of the following symbols: 1287 * 1288 * GL_ARB_enhanced_layouts, 1289 * gl_MaxTransformFeedbackBuffers, 1290 * gl_MaxTransformFeedbackInterleavedComponents. 1291 * 1292 * This test implements Texture algorithm. Test following code snippet: 1293 * 1294 * if (1 != GL_ARB_enhanced_layouts) 1295 * { 1296 * result = 0; 1297 * } 1298 * else if (MAX_TRANSFORM_FEEDBACK_BUFFERS 1299 * != gl_MaxTransformFeedbackBuffers) 1300 * { 1301 * result = 0; 1302 * } 1303 * else if (MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 1304 * != gl_MaxTransformFeedbackInterleavedComponents) 1305 * { 1306 * result = 0; 1307 * } 1308 **/ 1309 class GLSLContantValuesTest : public TextureTestBase 1310 { 1311 public: 1312 GLSLContantValuesTest(deqp::Context &context); ~GLSLContantValuesTest()1313 ~GLSLContantValuesTest() 1314 { 1315 } 1316 1317 protected: 1318 virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1319 Utils::Shader::STAGES stage); 1320 1321 virtual bool isComputeRelevant(glw::GLuint test_case_index); 1322 }; 1323 1324 /** Implementation of test GLSLContantImmutablity. Description follows: 1325 * 1326 * Test verifies that values of the following symbols cannot be changed in 1327 * shader: 1328 * 1329 * GL_ARB_enhanced_layouts, 1330 * gl_MaxTransformFeedbackBuffers, 1331 * gl_MaxTransformFeedbackInterleavedComponents. 1332 * 1333 * Compile following code snippet: 1334 * 1335 * CONSTANT = 3; 1336 * 1337 * It is expected that compilation will fail. Test each shader stage 1338 * separately. Test each constant separately. 1339 **/ 1340 class GLSLContantImmutablityTest : public NegativeTestBase 1341 { 1342 public: 1343 /* Private enums */ 1344 enum CONSTANTS 1345 { 1346 GL_ARB_ENHANCED_LAYOUTS, 1347 GL_MAX_XFB, 1348 GL_MAX_XFB_INT_COMP, 1349 1350 /* */ 1351 CONSTANTS_MAX, 1352 }; 1353 1354 /* Public methods */ 1355 GLSLContantImmutablityTest(deqp::Context &context, glw::GLuint constant, glw::GLuint stage); 1356 ~GLSLContantImmutablityTest()1357 virtual ~GLSLContantImmutablityTest() 1358 { 1359 } 1360 1361 protected: 1362 /* Methods to be implemented by child class */ 1363 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1364 1365 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1366 virtual glw::GLuint getTestCaseNumber(); 1367 virtual bool isComputeRelevant(glw::GLuint test_case_index); 1368 virtual void testInit(); 1369 1370 private: 1371 /* Private types */ 1372 struct testCase 1373 { 1374 CONSTANTS m_constant; 1375 Utils::Shader::STAGES m_stage; 1376 }; 1377 1378 /* Private methods */ 1379 const glw::GLchar *getConstantName(CONSTANTS constant); 1380 1381 /* Private fields */ 1382 std::vector<testCase> m_test_cases; 1383 glw::GLuint m_constant; 1384 glw::GLuint m_stage; 1385 }; 1386 1387 /** Implementation of test GLSLConstantIntegralExpression. Description follows: 1388 * 1389 * Check that following symbols can be used as integral constant expressions: 1390 * 1391 * GL_ARB_enhanced_layouts, 1392 * gl_MaxTransformFeedbackBuffers, 1393 * gl_MaxTransformFeedbackInterleavedComponents. 1394 * 1395 * Test implement Texture algorithm. Test following code snippet: 1396 * 1397 * uniform uint goku [GL_ARB_enhanced_layouts / GOKU_DIV]; 1398 * uniform uint gohan[gl_MaxTransformFeedbackBuffers / GOHAN_DIV]; 1399 * uniform uint goten[gl_MaxTransformFeedbackInterleavedComponents / 1400 * GOTEN_DIV]; 1401 * 1402 * for (i = 0; i < goku.length; ++i) 1403 * goku_sum += goku[i]; 1404 * 1405 * for (i = 0; i < gohan.length; ++i) 1406 * gohan_sum += gohan[i]; 1407 * 1408 * for (i = 0; i < goten.length; ++i) 1409 * goten_sum += goten[i]; 1410 * 1411 * if ( (expected_goku_sum == goku_sum) && 1412 * (expected_gohan_sum == gohan_sum) && 1413 * (expected_goten_sum == goten_sum) ) 1414 * result = 1; 1415 * else 1416 * result = 0; 1417 * 1418 * Select DIV values so as array lengths are below 16. 1419 **/ 1420 class GLSLConstantIntegralExpressionTest : public TextureTestBase 1421 { 1422 public: 1423 /* Public methods */ 1424 GLSLConstantIntegralExpressionTest(deqp::Context &context); 1425 ~GLSLConstantIntegralExpressionTest()1426 virtual ~GLSLConstantIntegralExpressionTest() 1427 { 1428 } 1429 1430 protected: 1431 /* Protected methods */ 1432 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1433 Utils::VaryingPassthrough &varying_passthrough); 1434 1435 virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1436 Utils::Shader::STAGES stage); 1437 1438 virtual void prepareUniforms(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1439 Utils::Program &program, Utils::Buffer &cs_buffer); 1440 1441 virtual void prepareUniforms(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1442 Utils::Program &program, Utils::Buffer &fs_buffer, Utils::Buffer &gs_buffer, 1443 Utils::Buffer &tcs_buffer, Utils::Buffer &tes_buffer, Utils::Buffer &vs_buffer); 1444 1445 private: 1446 glw::GLint m_gohan_length; 1447 glw::GLint m_goten_length; 1448 }; 1449 1450 /** Implementation of test UniformBlockMemberOffsetAndAlign. Description follows: 1451 * 1452 * Test verifies that: 1453 * - offset and align qualifiers are respected for uniform block members, 1454 * - align qualifier is ignored if value is too small, 1455 * - align qualifier accepts values bigger than size of base type, 1456 * - manual and automatic offsets and alignments can be mixed. 1457 * 1458 * This test implement Texture algorithm. Test following code snippet: 1459 * 1460 * const int basic_size = sizeof(basic_type_of(type)); 1461 * const int type_size = sizeof(type); 1462 * const int type_align = roundUpToPowerOf2(type_size); 1463 * 1464 * layout (std140, offset = 0) uniform Block { 1465 * layout(align = 8 * basic_size) type at_first_offset; 1466 * layout(offset = type_size, align = basic_size / 2) 1467 * type at_second_offset; 1468 * layout(align = 2 * type_align) type at_third_offset; 1469 * layout(offset = 3 * type_align + type_size) 1470 * type at_fourth_offset; 1471 * type at_fifth_offset; 1472 * type at_sixth_offset[2]; 1473 * layout(align = 8 * basic_size) type at_eight_offset; 1474 * }; 1475 * 1476 * if ( (at_first_offset == at_eight_offset ) && 1477 * (at_second_offset == at_sixth_offset[1]) && 1478 * (at_third_offset == at_sixth_offset[0]) && 1479 * (at_fourth_offset == at_fifth_offset ) ) 1480 * result = 1; 1481 * else 1482 * result = 0; 1483 * 1484 * Additionally inspect program to verify that all block members: 1485 * - are reported, 1486 * - have correct offsets. 1487 * 1488 * Test should be executed for all types. 1489 **/ 1490 class UniformBlockMemberOffsetAndAlignTest : public TextureTestBase 1491 { 1492 public: 1493 /* Public methods */ 1494 UniformBlockMemberOffsetAndAlignTest(deqp::Context &context); 1495 ~UniformBlockMemberOffsetAndAlignTest()1496 virtual ~UniformBlockMemberOffsetAndAlignTest() 1497 { 1498 } 1499 1500 protected: 1501 /* Protected methods */ 1502 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1503 Utils::VaryingPassthrough &varying_passthrough); 1504 1505 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1506 virtual glw::GLuint getTestCaseNumber(); 1507 1508 virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1509 Utils::Shader::STAGES stage); 1510 1511 private: 1512 std::vector<glw::GLubyte> m_data; 1513 }; 1514 1515 /** Implementation of test UniformBlockLayoutQualifierConflict. Description follows: 1516 * 1517 * Test verifies that offset and align can only be used on members of blocks 1518 * declared as std140. 1519 * 1520 * Test following code snippet with all shader stages: 1521 * 1522 * layout(QUALIFIER) uniform Block { 1523 * layout(offset = 16) vec4 b; 1524 * layout(align = 48) vec4 a; 1525 * }; 1526 * 1527 * Test following block qualifiers and all types: 1528 * 1529 * default - meaning not declared by shader 1530 * std140, 1531 * shared, 1532 * packed. 1533 * 1534 * Qualifier std430 is not allowed for uniform blocks. 1535 * 1536 * Test expect that only case using std140 will compile and link successfully, 1537 * while the rest will fail to compile or link. 1538 **/ 1539 class UniformBlockLayoutQualifierConflictTest : public NegativeTestBase 1540 { 1541 public: 1542 /* Private enums */ 1543 enum QUALIFIERS 1544 { 1545 DEFAULT, 1546 STD140, 1547 SHARED, 1548 PACKED, 1549 1550 /* */ 1551 QUALIFIERS_MAX, 1552 }; 1553 1554 /* Public methods */ 1555 UniformBlockLayoutQualifierConflictTest(deqp::Context &context, glw::GLuint qualifier, glw::GLuint stage); 1556 ~UniformBlockLayoutQualifierConflictTest()1557 virtual ~UniformBlockLayoutQualifierConflictTest() 1558 { 1559 } 1560 1561 protected: 1562 /* Methods to be implemented by child class */ 1563 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1564 1565 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1566 virtual glw::GLuint getTestCaseNumber(); 1567 1568 virtual bool isComputeRelevant(glw::GLuint test_case_index); 1569 virtual bool isFailureExpected(glw::GLuint test_case_index); 1570 virtual void testInit(); 1571 1572 private: 1573 /* Private types */ 1574 struct testCase 1575 { 1576 QUALIFIERS m_qualifier; 1577 Utils::Shader::STAGES m_stage; 1578 }; 1579 1580 /* Private methods */ 1581 const glw::GLchar *getQualifierName(QUALIFIERS qualifier); 1582 1583 /* Private fields */ 1584 std::vector<testCase> m_test_cases; 1585 glw::GLuint m_qualifier; 1586 glw::GLuint m_stage; 1587 }; 1588 1589 /** Implementation of test UniformBlockMemberInvalidOffsetAlignment. Description follows: 1590 * 1591 * Test verifies that offset alignment rules are enforced. 1592 * 1593 * Declare uniform block, which contains following member declaration: 1594 * 1595 * layout(offset = X) type block_member 1596 * 1597 * Shader compilation is expected to fail for any X that is not a multiple of 1598 * the base alignment of type. 1599 * Test all offsets covering locations first and one before last: 1600 * 1601 * <0, sizeof(type)> 1602 * <MAX_UNIFORM_BLOCK_SIZE - 2 * sizeof(type), 1603 * MAX_UNIFORM_BLOCK_SIZE - sizeof(type)> 1604 * 1605 * Test all shader stages. Test all types. Each case should be tested 1606 * separately. 1607 **/ 1608 class UniformBlockMemberInvalidOffsetAlignmentTest : public NegativeTestBase 1609 { 1610 public: 1611 /* Public methods */ 1612 UniformBlockMemberInvalidOffsetAlignmentTest(deqp::Context &context, glw::GLuint type, glw::GLuint stage); 1613 1614 UniformBlockMemberInvalidOffsetAlignmentTest(deqp::Context &context, const glw::GLchar *name, 1615 const glw::GLchar *description, glw::GLuint type, glw::GLuint stage); 1616 ~UniformBlockMemberInvalidOffsetAlignmentTest()1617 virtual ~UniformBlockMemberInvalidOffsetAlignmentTest() 1618 { 1619 } 1620 stageAllowed(glw::GLuint stage)1621 inline bool stageAllowed(glw::GLuint stage) 1622 { 1623 return isStageSupported(static_cast<Utils::Shader::STAGES>(stage)); 1624 } 1625 1626 protected: 1627 /* Methods to be implemented by child class */ 1628 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1629 1630 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1631 virtual glw::GLuint getTestCaseNumber(); 1632 virtual glw::GLint getMaxBlockSize(); 1633 virtual bool isComputeRelevant(glw::GLuint test_case_index); 1634 virtual bool isFailureExpected(glw::GLuint test_case_index); 1635 virtual bool isStageSupported(Utils::Shader::STAGES stage); 1636 virtual void testInit(); 1637 1638 protected: 1639 /* Protected types */ 1640 struct testCase 1641 { 1642 glw::GLuint m_offset; 1643 bool m_should_fail; 1644 Utils::Shader::STAGES m_stage; 1645 Utils::Type m_type; 1646 }; 1647 1648 glw::GLuint m_type; 1649 glw::GLuint m_stage; 1650 1651 /* Protected fields */ 1652 std::vector<testCase> m_test_cases; 1653 }; 1654 1655 /** Implementation of test UniformBlockMemberOverlappingOffsets. Description follows: 1656 * 1657 * Test verifies that block members cannot overlap. 1658 * 1659 * Use following code snippet: 1660 * 1661 * layout (std140) uniform Block { 1662 * layout (offset = b_offset) b_type b; 1663 * layout (offset = a_offset) a_type a; 1664 * }; 1665 * 1666 * It is expected that overlapping members will cause compilation failure. 1667 * 1668 * There are three cases to test: 1669 * 1670 * - when member is declared with the same offset as already declared 1671 * member, 1672 * - when member is declared with offset that lay in the middle of already 1673 * declared member, 1674 * - when member is declared with offset just before already declared 1675 * member and there is not enough space. 1676 * 1677 * Test all shader stages. Test all types. Test cases separately. 1678 * 1679 * Note that not all type combinations let to test all three cases, e.g. 1680 * vec4 and float. 1681 **/ 1682 class UniformBlockMemberOverlappingOffsetsTest : public NegativeTestBase 1683 { 1684 public: 1685 /* Public methods */ 1686 UniformBlockMemberOverlappingOffsetsTest(deqp::Context &context, glw::GLuint type_i, glw::GLuint type_j); 1687 1688 UniformBlockMemberOverlappingOffsetsTest(deqp::Context &context, const glw::GLchar *name, 1689 const glw::GLchar *description, glw::GLuint type_i, glw::GLuint type_j); 1690 ~UniformBlockMemberOverlappingOffsetsTest()1691 virtual ~UniformBlockMemberOverlappingOffsetsTest() 1692 { 1693 } 1694 1695 protected: 1696 /* Methods to be implemented by child class */ 1697 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1698 1699 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1700 virtual glw::GLuint getTestCaseNumber(); 1701 virtual bool isComputeRelevant(glw::GLuint test_case_index); 1702 virtual bool isStageSupported(Utils::Shader::STAGES stage); 1703 virtual void testInit(); 1704 1705 protected: 1706 /* Protected types */ 1707 struct testCase 1708 { 1709 glw::GLuint m_b_offset; 1710 Utils::Type m_b_type; 1711 glw::GLuint m_a_offset; 1712 Utils::Type m_a_type; 1713 Utils::Shader::STAGES m_stage; 1714 }; 1715 1716 /* Protected methods */ 1717 glw::GLuint gcd(glw::GLuint a, glw::GLuint b); 1718 glw::GLuint lcm(glw::GLuint a, glw::GLuint b); 1719 1720 /* Protected fields */ 1721 std::vector<testCase> m_test_cases; 1722 1723 glw::GLuint m_type_i; 1724 glw::GLuint m_type_j; 1725 }; 1726 1727 /** Implementation of test UniformBlockMemberAlignNonPowerOf2. Description follows: 1728 * 1729 * Test verifies that align qualifier must use power of 2. 1730 * 1731 * Test following code snippet: 1732 * 1733 * layout (std140, offset = 8) uniform Block { 1734 * vec4 b; 1735 * layout (align = a_alignment) type a; 1736 * }; 1737 * 1738 * It is expected that compilation will fail whenever a_alignment is not 1739 * a power of 2. 1740 * 1741 * Test all alignment in range <0, sizeof(dmat4)>. Test all shader stages. 1742 * Test all types. 1743 **/ 1744 class UniformBlockMemberAlignNonPowerOf2Test : public NegativeTestBase 1745 { 1746 public: 1747 /* Public methods */ 1748 UniformBlockMemberAlignNonPowerOf2Test(deqp::Context &context, glw::GLuint type); 1749 1750 UniformBlockMemberAlignNonPowerOf2Test(deqp::Context &context, const glw::GLchar *name, 1751 const glw::GLchar *description, glw::GLuint type); 1752 ~UniformBlockMemberAlignNonPowerOf2Test()1753 virtual ~UniformBlockMemberAlignNonPowerOf2Test() 1754 { 1755 } 1756 1757 protected: 1758 /* Methods to be implemented by child class */ 1759 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1760 1761 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1762 virtual glw::GLuint getTestCaseNumber(); 1763 virtual bool isComputeRelevant(glw::GLuint test_case_index); 1764 virtual bool isFailureExpected(glw::GLuint test_case_index); 1765 virtual bool isStageSupported(Utils::Shader::STAGES stage); 1766 virtual void testInit(); 1767 1768 protected: 1769 /* Protected types */ 1770 struct testCase 1771 { 1772 glw::GLuint m_alignment; 1773 Utils::Type m_type; 1774 bool m_should_fail; 1775 Utils::Shader::STAGES m_stage; 1776 }; 1777 1778 /* Protected methods */ 1779 bool isPowerOf2(glw::GLuint val); 1780 1781 /* Protected fields */ 1782 std::vector<testCase> m_test_cases; 1783 glw::GLuint m_type; 1784 }; 1785 1786 /** Implementation of test UniformBlockAlignment. Description follows: 1787 * 1788 * UniformBlockAlignment 1789 * 1790 * Test verifies that align qualifier is applied to block members as specified. 1791 * 1792 * This test implements Texture algorithm. Test following code snippet: 1793 * 1794 * struct Data { 1795 * vec4 vector; 1796 * float scalar; 1797 * }; 1798 * 1799 * layout (std140, offset = 8, align = 64) uniform Block { 1800 * vec4 first; 1801 * Data second; 1802 * Data third[2]; 1803 * vec4 fourth[3]; 1804 * layout (align = 16) vec4 fifth[2]; 1805 * Data sixth; 1806 * }; 1807 * 1808 * Verify that all uniforms have correct values. Additionally inspect program 1809 * to check that all offsets are as expected. 1810 **/ 1811 class UniformBlockAlignmentTest : public TextureTestBase 1812 { 1813 public: 1814 /* Public methods */ 1815 UniformBlockAlignmentTest(deqp::Context &context); 1816 ~UniformBlockAlignmentTest()1817 virtual ~UniformBlockAlignmentTest() 1818 { 1819 } 1820 1821 protected: 1822 /* Protected methods */ 1823 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1824 Utils::VaryingPassthrough &varying_passthrough); 1825 1826 private: 1827 std::vector<glw::GLubyte> m_data; 1828 }; 1829 1830 /** Implementation of test SSBMemberOffsetAndAlign. Description follows: 1831 * 1832 * Test verifies that: 1833 * - offset and align qualifiers are respected for shader storage block 1834 * members, 1835 * - align qualifier is ignored if value is too small, 1836 * - align qualifier accepts values bigger than size of base type, 1837 * - manual and automatic offsets and alignments can be mixed. 1838 * 1839 * Modify UniformBlockMemberOffsetAndAlign to test shader storage block instead 1840 * of uniform block. 1841 **/ 1842 class SSBMemberOffsetAndAlignTest : public TextureTestBase 1843 { 1844 public: 1845 /* Public methods */ 1846 SSBMemberOffsetAndAlignTest(deqp::Context &context); ~SSBMemberOffsetAndAlignTest()1847 virtual ~SSBMemberOffsetAndAlignTest() 1848 { 1849 } 1850 1851 protected: 1852 /* Protected methods */ 1853 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1854 Utils::VaryingPassthrough &varying_passthrough); 1855 1856 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1857 virtual glw::GLuint getTestCaseNumber(); 1858 1859 virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 1860 Utils::Shader::STAGES stage); 1861 1862 virtual bool isDrawRelevant(glw::GLuint test_case_index); 1863 1864 private: 1865 std::vector<glw::GLubyte> m_data; 1866 }; 1867 1868 /** Implementation of test SSBLayoutQualifierConflict. Description follows: 1869 * 1870 * Test verifies that offset and align can only be used on members of blocks 1871 * declared as std140 or std430. 1872 * 1873 * Modify UniformBlockMemberOffsetAndAlign to test shader storage block instead 1874 * of uniform block. 1875 * 1876 * Qualifier std430 is allowed for shader storage blocks, it should be included 1877 * in test. It is expected that std430 case will build successfully. 1878 **/ 1879 class SSBLayoutQualifierConflictTest : public NegativeTestBase 1880 { 1881 public: 1882 enum QUALIFIERS 1883 { 1884 DEFAULT, 1885 STD140, 1886 STD430, 1887 SHARED, 1888 PACKED, 1889 1890 /* */ 1891 QUALIFIERS_MAX, 1892 }; 1893 1894 /* Public methods */ 1895 SSBLayoutQualifierConflictTest(deqp::Context &context, glw::GLuint qualifier, glw::GLuint stage); 1896 ~SSBLayoutQualifierConflictTest()1897 virtual ~SSBLayoutQualifierConflictTest() 1898 { 1899 } 1900 stageAllowed(glw::GLuint stage)1901 inline bool stageAllowed(glw::GLuint stage) 1902 { 1903 return isStageSupported(static_cast<Utils::Shader::STAGES>(stage)); 1904 } 1905 1906 protected: 1907 /* Methods to be implemented by child class */ 1908 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1909 1910 virtual std::string getTestCaseName(glw::GLuint test_case_index); 1911 virtual glw::GLuint getTestCaseNumber(); 1912 virtual bool isComputeRelevant(glw::GLuint test_case_index); 1913 virtual bool isFailureExpected(glw::GLuint test_case_index); 1914 virtual void testInit(); 1915 1916 private: 1917 /* Private types */ 1918 struct testCase 1919 { 1920 QUALIFIERS m_qualifier; 1921 Utils::Shader::STAGES m_stage; 1922 }; 1923 1924 /* Private methods */ 1925 const glw::GLchar *getQualifierName(QUALIFIERS qualifier); 1926 bool isStageSupported(Utils::Shader::STAGES stage); 1927 1928 /* Private fields */ 1929 std::vector<testCase> m_test_cases; 1930 glw::GLuint m_qualifier; 1931 glw::GLuint m_stage; 1932 }; 1933 1934 /** Implementation of test SSBMemberInvalidOffsetAlignment. Description follows: 1935 * 1936 * Test verifies that offset alignment rules are enforced. 1937 * 1938 * Modify UniformBlockMemberInvalidOffsetAlignment to test shader 1939 * storage block against MAX_SHADER_STORAGE_BLOCK_SIZE instead of 1940 * uniform block 1941 **/ 1942 class SSBMemberInvalidOffsetAlignmentTest : public UniformBlockMemberInvalidOffsetAlignmentTest 1943 { 1944 public: 1945 /* Public methods */ 1946 SSBMemberInvalidOffsetAlignmentTest(deqp::Context &context, glw::GLuint type, glw::GLuint stage); 1947 ~SSBMemberInvalidOffsetAlignmentTest()1948 virtual ~SSBMemberInvalidOffsetAlignmentTest() 1949 { 1950 } 1951 stageAllowed(glw::GLuint stage)1952 inline bool stageAllowed(glw::GLuint stage) 1953 { 1954 return isStageSupported(static_cast<Utils::Shader::STAGES>(stage)); 1955 } 1956 1957 protected: 1958 /* Methods to be implemented by child class */ 1959 virtual glw::GLint getMaxBlockSize(); 1960 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1961 1962 virtual bool isStageSupported(Utils::Shader::STAGES stage); 1963 }; 1964 1965 /** Implementation of test SSBMemberOverlappingOffsets. Description follows: 1966 * 1967 * Test verifies that block members cannot overlap. 1968 * 1969 * Modify UniformBlockMemberOverlappingOffsets to test shader storage block 1970 * instead of uniform block. 1971 **/ 1972 class SSBMemberOverlappingOffsetsTest : public UniformBlockMemberOverlappingOffsetsTest 1973 { 1974 public: 1975 /* Public methods */ 1976 SSBMemberOverlappingOffsetsTest(deqp::Context &context, glw::GLuint type_i, glw::GLuint type_j); ~SSBMemberOverlappingOffsetsTest()1977 virtual ~SSBMemberOverlappingOffsetsTest() 1978 { 1979 } 1980 1981 protected: 1982 /* Methods to be implemented by child class */ 1983 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 1984 1985 virtual bool isStageSupported(Utils::Shader::STAGES stage); 1986 }; 1987 1988 /** Implementation of test SSBMemberAlignNonPowerOf2. Description follows: 1989 * 1990 * Test verifies that align qualifier must use power of 2. 1991 * 1992 * Modify UniformBlockMemberAlignNonPowerOf2 to test shader storage block 1993 * instead of uniform block. 1994 **/ 1995 class SSBMemberAlignNonPowerOf2Test : public UniformBlockMemberAlignNonPowerOf2Test 1996 { 1997 public: 1998 /* Public methods */ 1999 SSBMemberAlignNonPowerOf2Test(deqp::Context &context, glw::GLuint type); 2000 ~SSBMemberAlignNonPowerOf2Test()2001 virtual ~SSBMemberAlignNonPowerOf2Test() 2002 { 2003 } 2004 2005 protected: 2006 /* Methods to be implemented by child class */ 2007 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2008 2009 virtual bool isStageSupported(Utils::Shader::STAGES stage); 2010 }; 2011 2012 /** Implementation of test SSBAlignment. Description follows: 2013 * 2014 * Test verifies that align qualifier is applied to block members as specified. 2015 * 2016 * Modify UniformBlockAlignment to test shader storage block instead 2017 * of uniform block. 2018 **/ 2019 class SSBAlignmentTest : public TextureTestBase 2020 { 2021 public: 2022 /* Public methods */ 2023 SSBAlignmentTest(deqp::Context &context); 2024 ~SSBAlignmentTest()2025 virtual ~SSBAlignmentTest() 2026 { 2027 } 2028 2029 protected: 2030 /* Protected methods */ 2031 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2032 Utils::VaryingPassthrough &varying_passthrough); 2033 2034 virtual bool isDrawRelevant(glw::GLuint test_case_index); 2035 2036 private: 2037 std::vector<glw::GLubyte> m_data; 2038 }; 2039 2040 /** Implementation of test VaryingLocations. Description follows: 2041 * 2042 * Test verifies that "varying" locations are assigned as declared in shader. 2043 * 2044 * This test implements Texture algorithm. Use separate shader objects instead 2045 * of monolithic program. Test following code snippet: 2046 * 2047 * layout(location = 0) in type input_at_first_location; 2048 * layout(location = last_input) in type input_at_last_location; 2049 * layout(location = 1) out type output_at_first_location; 2050 * layout(location = last_output) out type output_at_last_location; 2051 * 2052 * output_at_first_location = input_at_first_location; 2053 * output_at_last_location = input_at_last_location; 2054 * 2055 * if ( (EXPECTED_VALUE == input_at_first_location) && 2056 * (EXPECTED_VALUE == input_at_last_location) ) 2057 * { 2058 * result = 1; 2059 * } 2060 * 2061 * Additionally inspect program to check that all locations are as expected. 2062 * 2063 * Test all types. Test all shader stages. 2064 **/ 2065 class VaryingLocationsTest : public TextureTestBase 2066 { 2067 public: 2068 VaryingLocationsTest(deqp::Context &context); 2069 2070 VaryingLocationsTest(deqp::Context &context, const glw::GLchar *test_name, const glw::GLchar *test_description); 2071 ~VaryingLocationsTest()2072 ~VaryingLocationsTest() 2073 { 2074 } 2075 2076 protected: 2077 /* Protected methods */ 2078 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2079 Utils::VaryingPassthrough &varying_passthrough); 2080 2081 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2082 virtual glw::GLuint getTestCaseNumber(); 2083 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2084 virtual bool useMonolithicProgram(glw::GLuint test_case_index); 2085 2086 /* To be implemented by children */ 2087 virtual void prepareShaderStage(Utils::Shader::STAGES stage, const Utils::Type &type, 2088 Utils::ProgramInterface &program_interface, 2089 Utils::VaryingPassthrough &varying_passthrough); 2090 2091 /* Protected methods */ 2092 std::string prepareGlobals(glw::GLint last_in_loc, glw::GLint last_out_loc); 2093 2094 /* Protected fields */ 2095 std::vector<glw::GLubyte> m_first_data; 2096 std::vector<glw::GLubyte> m_last_data; 2097 glw::GLint m_gl_max_geometry_input_components; 2098 }; 2099 2100 /** Implementation of test VertexAttribLocations. Description follows: 2101 * 2102 * Test verifies that drawing operations provide vertex attributes at expected 2103 * locations. 2104 * 2105 * This test implements Texture algorithm. Use separate shader objects instead 2106 * of monolithic program. Tessellation stages are not necessary and can be 2107 * omitted. Test following code snippet: 2108 * 2109 * layout (location = 2) in uint vertex_index; 2110 * layout (location = 5) in uint instance_index; 2111 * 2112 * if ( (gl_VertexID == vertex_index) && 2113 * (gl_InstanceID == instance_index) ) 2114 * { 2115 * result = 1; 2116 * } 2117 * 2118 * Test following Draw* operations: 2119 * - DrawArrays, 2120 * - DrawArraysInstanced, 2121 * - DrawElements, 2122 * - DrawElementsBaseVertex, 2123 * - DrawElementsInstanced, 2124 * - DrawElementsInstancedBaseInstance, 2125 * - DrawElementsInstancedBaseVertex, 2126 * - DrawElementsInstancedBaseVertexBaseInstance. 2127 * 2128 * Number of drawn instances should be equal 4. base_vertex parameter should be 2129 * set to 4. base_instance should be set to 2. 2130 * 2131 * Values provided for "vertex_index" should match index of vertex. Values 2132 * provided for "instance_index" should match index of instance 2133 * (use VertexAttribDivisor). 2134 **/ 2135 class VertexAttribLocationsTest : public TextureTestBase 2136 { 2137 public: 2138 VertexAttribLocationsTest(deqp::Context &context); 2139 ~VertexAttribLocationsTest()2140 ~VertexAttribLocationsTest() 2141 { 2142 } 2143 2144 protected: 2145 /* Protected methods */ 2146 virtual void executeDrawCall(glw::GLuint test_case_index); 2147 2148 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2149 Utils::VaryingPassthrough &varying_passthrough); 2150 2151 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2152 virtual glw::GLuint getTestCaseNumber(); 2153 2154 virtual std::string getVerificationSnippet(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2155 Utils::Shader::STAGES stage); 2156 2157 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2158 2159 virtual void prepareAttributes(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2160 Utils::Buffer &buffer, Utils::VertexArray &vao); 2161 2162 virtual bool useMonolithicProgram(glw::GLuint test_case_index); 2163 2164 private: 2165 /* Private enums */ 2166 enum TESTCASES 2167 { 2168 DRAWARRAYS, 2169 DRAWARRAYSINSTANCED, 2170 DRAWELEMENTS, 2171 DRAWELEMENTSBASEVERTEX, 2172 DRAWELEMENTSINSTANCED, 2173 DRAWELEMENTSINSTANCEDBASEINSTANCE, 2174 DRAWELEMENTSINSTANCEDBASEVERTEX, 2175 DRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCE, 2176 2177 /* */ 2178 TESTCASES_MAX 2179 }; 2180 2181 /* Private constants */ 2182 static const glw::GLuint m_base_vertex; 2183 static const glw::GLuint m_base_instance; 2184 static const glw::GLuint m_loc_vertex; 2185 static const glw::GLuint m_loc_instance; 2186 static const glw::GLuint m_n_instances; 2187 }; 2188 2189 /** Implementation of test VaryingArrayLocations. Description follows: 2190 * 2191 * VaryingArrayLocations 2192 * 2193 * Test verifies that locations of arrays of "varying" are assigned as declared 2194 * in shader. 2195 * 2196 * This test implements Texture algorithm. Use separate shader objects instead 2197 * of monolithic program. Test following code snippet: 2198 * 2199 * layout(location = 0) in type in_at_first_loc[FIRST_LENGTH]; 2200 * layout(location = last_input) in type in_at_last_loc[LAST_LENGTH]; 2201 * layout(location = 1) out type out_at_first_loc[FIRST_LENGTH]; 2202 * layout(location = last_output) out type out_at_last_loc[LAST_LENGTH]; 2203 * 2204 * for (uint i = 0u; i < in_at_first_loc.length(); ++i) 2205 * { 2206 * out_at_first_loc[i] = in_at_first_loc[i]; 2207 * 2208 * if (EXPECTED_VALUE[i] != in_at_first_loc[i]) 2209 * { 2210 * result = 0; 2211 * } 2212 * } 2213 * 2214 * for (uint i = 0u; i < in_at_last_loc.length(); ++i) 2215 * { 2216 * out_at_last_loc[i] = in_at_last_loc[i]; 2217 * 2218 * if (EXPECTED_VALUE[i] != in_at_last_loc[i]) 2219 * { 2220 * result = 0; 2221 * } 2222 * } 2223 * 2224 * FIRST_LENGTH and LAST_LENGTH values should be selected so as not to exceed 2225 * limits. 2226 * 2227 * Additionally inspect program to check that all locations are as expected. 2228 * 2229 * Test all types. Test all shader stages. 2230 **/ 2231 class VaryingArrayLocationsTest : public VaryingLocationsTest 2232 { 2233 public: 2234 VaryingArrayLocationsTest(deqp::Context &context); 2235 ~VaryingArrayLocationsTest()2236 ~VaryingArrayLocationsTest() 2237 { 2238 } 2239 2240 protected: 2241 /* Protected methods */ 2242 virtual void prepareShaderStage(Utils::Shader::STAGES stage, const Utils::Type &type, 2243 Utils::ProgramInterface &program_interface, 2244 Utils::VaryingPassthrough &varying_passthrough); 2245 }; 2246 2247 /** Implementation of test VaryingStructureLocations. Description follows: 2248 * 2249 * Test verifies that structures locations are as expected. 2250 * 2251 * This test implements Texture algorithm. Use separate shader objects instead 2252 * of monolithic program. Test following code snippet: 2253 * 2254 * struct Data 2255 * { 2256 * type single; 2257 * type array[ARRAY_LENGTH]; 2258 * }; 2259 * 2260 * layout (location = INPUT_LOCATION) in Data input[VARYING_LENGTH]; 2261 * layout (location = OUTPUT_LOCATION) out Data output[VARYING_LENGTH]; 2262 * 2263 * if ( (EXPECTED_VALUE == input[0].single) && 2264 * (EXPECTED_VALUE == input[0].array[0]) && 2265 * (EXPECTED_VALUE == input[0].array[last]) && 2266 * (EXPECTED_VALUE == input[last].single) && 2267 * (EXPECTED_VALUE == input[last].array[0]) && 2268 * (EXPECTED_VALUE == input[last].array[last]) ) 2269 * { 2270 * result = 1; 2271 * } 2272 * 2273 * output[0].single = input[0].single; 2274 * output[0].array[0] = input[0].array[0]; 2275 * output[0].array[last] = input[0].array[last]; 2276 * output[last].single = input[last].single; 2277 * output[last].array[0] = input[last].array[0]; 2278 * output[last].array[last] = input[last].array[last]; 2279 * 2280 * Select array lengths and locations so as no limits are exceeded. 2281 **/ 2282 2283 class VaryingStructureLocationsTest : public TextureTestBase 2284 { 2285 public: 2286 VaryingStructureLocationsTest(deqp::Context &context); 2287 ~VaryingStructureLocationsTest()2288 ~VaryingStructureLocationsTest() 2289 { 2290 } 2291 2292 protected: 2293 /* Protected methods */ 2294 virtual std::string getPassSnippet(glw::GLuint test_case_index, Utils::VaryingPassthrough &varying_passthrough, 2295 Utils::Shader::STAGES stage); 2296 2297 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2298 Utils::VaryingPassthrough &varying_passthrough); 2299 2300 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2301 virtual glw::GLuint getTestCaseNumber(); 2302 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2303 virtual bool useMonolithicProgram(glw::GLuint test_case_index); 2304 2305 /* Protected fields */ 2306 std::vector<glw::GLubyte> m_single_data; 2307 std::vector<glw::GLubyte> m_array_data; 2308 std::vector<glw::GLubyte> m_data; 2309 }; 2310 2311 /** Implementation of test VaryingStructureMemberLocation. Description follows: 2312 * 2313 * Test verifies that it is not allowed to declare structure member at specific 2314 * location. 2315 * 2316 * Test following code snippet: 2317 * 2318 * struct Data 2319 * { 2320 * vec4 gohan; 2321 * layout (location = LOCATION) vec4 goten; 2322 * } 2323 * 2324 * in Data goku; 2325 * 2326 * Select LOCATION so as not to exceed limits. Test all shader stages. Test 2327 * both in and out varyings. 2328 * 2329 * It is expected that compilation will fail. 2330 **/ 2331 class VaryingStructureMemberLocationTest : public NegativeTestBase 2332 { 2333 public: 2334 VaryingStructureMemberLocationTest(deqp::Context &context, glw::GLuint m_stage); 2335 ~VaryingStructureMemberLocationTest()2336 ~VaryingStructureMemberLocationTest() 2337 { 2338 } 2339 2340 protected: 2341 /* Methods to be implemented by child class */ 2342 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2343 2344 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2345 virtual glw::GLuint getTestCaseNumber(); 2346 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2347 virtual void testInit(); 2348 2349 private: 2350 /* Private types */ 2351 struct testCase 2352 { 2353 bool m_is_input; 2354 Utils::Shader::STAGES m_stage; 2355 }; 2356 2357 /* Private fields */ 2358 std::vector<testCase> m_test_cases; 2359 glw::GLuint m_stage; 2360 }; 2361 2362 /** Implementation of test VaryingBlockLocations. Description follows: 2363 * 2364 * Test verifies that "block varyings" locations are as expected. 2365 * 2366 * This test implements Texture algorithm. Use separate shader objects instead 2367 * of monolithic program. Test following code snippet: 2368 * 2369 * layout (location = GOKU_LOCATION) in Goku 2370 * { 2371 * vec4 gohan; 2372 * layout (location = GOTEN_LOCATION) vec4 goten; 2373 * vec4 chichi; 2374 * }; 2375 * 2376 * layout (location = VEGETA_LOCATION) out Vegeta 2377 * { 2378 * vec4 trunks; 2379 * layout (location = BRA_LOCATION) vec4 bra; 2380 * vec4 bulma; 2381 * }; 2382 * 2383 * if ( (EXPECTED_VALUE == gohan) && 2384 * (EXPECTED_VALUE == goten) && 2385 * (EXPECTED_VALUE == chichi) ) 2386 * { 2387 * result = 1; 2388 * } 2389 * 2390 * trunks = gohan; 2391 * bra = goten; 2392 * bulma = chichi; 2393 * 2394 * Select all locations so as not to cause any conflicts or exceed limits. 2395 **/ 2396 class VaryingBlockLocationsTest : public TextureTestBase 2397 { 2398 public: 2399 VaryingBlockLocationsTest(deqp::Context &context); ~VaryingBlockLocationsTest()2400 ~VaryingBlockLocationsTest() 2401 { 2402 } 2403 2404 protected: 2405 /* Protected methods */ 2406 virtual std::string getPassSnippet(glw::GLuint test_case_index, Utils::VaryingPassthrough &varying_passthrough, 2407 Utils::Shader::STAGES stage); 2408 2409 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2410 Utils::VaryingPassthrough &varying_passthrough); 2411 2412 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2413 virtual bool useMonolithicProgram(glw::GLuint test_case_index); 2414 2415 /* Protected fields */ 2416 std::vector<glw::GLubyte> m_third_data; 2417 std::vector<glw::GLubyte> m_fourth_data; 2418 std::vector<glw::GLubyte> m_fifth_data; 2419 std::vector<glw::GLubyte> m_data; 2420 }; 2421 2422 /** Implementation of test VaryingBlockMemberLocations. Description follows: 2423 * 2424 * Test verifies that it is a compilation error to declare some of block 2425 * members with location qualifier, but not all, when there is no "block level" 2426 * location qualifier. 2427 * 2428 * Test following code snippets: 2429 * 2430 * in Goku 2431 * { 2432 * vec4 gohan; 2433 * layout (location = GOTEN_LOCATION) vec4 goten; 2434 * vec4 chichi; 2435 * }; 2436 * 2437 * , 2438 * 2439 * in Goku 2440 * { 2441 * layout (location = GOHAN_LOCATION) vec4 gohan; 2442 * layout (location = GOTEN_LOCATION) vec4 goten; 2443 * layout (location = CHICHI_LOCATION) vec4 chichi; 2444 * }; 2445 * 2446 * Select all locations so as not to exceed any limits. 2447 * 2448 * It is expected that compilation of first snippet will fail. Compilation of 2449 * second snippet should be successful. 2450 * 2451 * Test all shader stages. Test both in and out blocks. 2452 **/ 2453 class VaryingBlockMemberLocationsTest : public NegativeTestBase 2454 { 2455 public: 2456 /* Public methods */ 2457 VaryingBlockMemberLocationsTest(deqp::Context &context, glw::GLuint stage); 2458 ~VaryingBlockMemberLocationsTest()2459 virtual ~VaryingBlockMemberLocationsTest() 2460 { 2461 } 2462 2463 protected: 2464 /* Methods to be implemented by child class */ 2465 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2466 2467 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2468 virtual glw::GLuint getTestCaseNumber(); 2469 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2470 virtual bool isFailureExpected(glw::GLuint test_case_index); 2471 virtual void testInit(); 2472 2473 private: 2474 /* Private types */ 2475 struct testCase 2476 { 2477 bool m_is_input; 2478 bool m_qualify_all; 2479 Utils::Shader::STAGES m_stage; 2480 }; 2481 2482 /* Private fields */ 2483 std::vector<testCase> m_test_cases; 2484 glw::GLuint m_stage; 2485 }; 2486 2487 /** Implementation of test VaryingBlockAutomaticMemberLocations. Description follows: 2488 * 2489 * Test verifies that compiler will assign subsequent locations to block 2490 * members. 2491 * 2492 * Test following code snippet: 2493 * 2494 * layout (location = 2) in DBZ 2495 * { 2496 * vec4 goku; // 2 2497 * vec4 gohan[GOHAN_LENGTH]; // 3 2498 * vec4 goten; // 3 + GOHAN_LENGTH 2499 * layout (location = 1) vec4 chichi; // 1 2500 * vec4 pan; // 2; ERROR location 2 used twice 2501 * }; 2502 * 2503 * Test all shader stages. Test both in and out blocks. 2504 * 2505 * It is expected that build process will fail. 2506 **/ 2507 class VaryingBlockAutomaticMemberLocationsTest : public NegativeTestBase 2508 { 2509 public: 2510 /* Public methods */ 2511 VaryingBlockAutomaticMemberLocationsTest(deqp::Context &context, glw::GLuint stage); 2512 ~VaryingBlockAutomaticMemberLocationsTest()2513 virtual ~VaryingBlockAutomaticMemberLocationsTest() 2514 { 2515 } 2516 2517 protected: 2518 /* Methods to be implemented by child class */ 2519 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2520 2521 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2522 virtual glw::GLuint getTestCaseNumber(); 2523 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2524 virtual void testInit(); 2525 2526 private: 2527 /* Private types */ 2528 struct testCase 2529 { 2530 bool m_is_input; 2531 Utils::Shader::STAGES m_stage; 2532 }; 2533 2534 /* Private fields */ 2535 std::vector<testCase> m_test_cases; 2536 glw::GLuint m_stage; 2537 }; 2538 2539 /** Implementation of test VaryingLocationLimit. Description follows: 2540 * 2541 * Test verifies that "location" qualifier cannot exceed limits. 2542 * 2543 * Test following code snippet: 2544 * 2545 * layout (location = LAST + 1) in type goku; 2546 * 2547 * LAST should be set to index of last available location. 2548 * 2549 * Test all types. Test all shader stages. Test both in and out varyings. 2550 * 2551 * It is expected that shader compilation will fail. 2552 **/ 2553 class VaryingLocationLimitTest : public NegativeTestBase 2554 { 2555 public: 2556 /* Public methods */ 2557 VaryingLocationLimitTest(deqp::Context &context, glw::GLuint type, glw::GLuint stage); 2558 ~VaryingLocationLimitTest()2559 virtual ~VaryingLocationLimitTest() 2560 { 2561 } 2562 2563 protected: 2564 /* Methods to be implemented by child class */ 2565 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2566 2567 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2568 virtual glw::GLuint getTestCaseNumber(); 2569 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2570 virtual bool isSeparable(const glw::GLuint test_case_index); 2571 virtual void testInit(); 2572 2573 private: 2574 /* Private types */ 2575 struct testCase 2576 { 2577 bool m_is_input; 2578 Utils::Type m_type; 2579 Utils::Shader::STAGES m_stage; 2580 }; 2581 2582 /* Private fields */ 2583 std::vector<testCase> m_test_cases; 2584 glw::GLuint m_type; 2585 glw::GLuint m_stage; 2586 }; 2587 2588 /** Implementation of test VaryingComponents. Description follows: 2589 * 2590 * VaryingComponents 2591 * 2592 * Test verifies that "varying" can be assigned to specific components. 2593 * 2594 * Modify VaryingLocations to test all possible combinations of components 2595 * layout: 2596 * - g64vec2 2597 * - g64scalar, g64scalar 2598 * - gvec4 2599 * - scalar, gvec3 2600 * - gvec3, scalar 2601 * - gvec2, gvec2 2602 * - gvec2, scalar, scalar 2603 * - scalar, gvec2, scalar 2604 * - scalar, scalar, gvec2 2605 * - scalar, scalar, scalar, scalar. 2606 * 2607 * Additionally inspect program to check that all locations and components are 2608 * as expected. 2609 **/ 2610 class VaryingComponentsTest : public VaryingLocationsTest 2611 { 2612 public: 2613 enum COMPONENTS_LAYOUT 2614 { 2615 G64VEC2, 2616 G64SCALAR_G64SCALAR, 2617 GVEC4, 2618 SCALAR_GVEC3, 2619 GVEC3_SCALAR, 2620 GVEC2_GVEC2, 2621 GVEC2_SCALAR_SCALAR, 2622 SCALAR_GVEC2_SCALAR, 2623 SCALAR_SCALAR_GVEC2, 2624 SCALAR_SCALAR_SCALAR_SCALAR, 2625 }; 2626 2627 VaryingComponentsTest(deqp::Context &context, COMPONENTS_LAYOUT layout, Utils::Type::TYPES type); 2628 2629 VaryingComponentsTest(deqp::Context &context, const glw::GLchar *test_name, const glw::GLchar *test_description, 2630 COMPONENTS_LAYOUT layout, Utils::Type::TYPES type); 2631 ~VaryingComponentsTest()2632 ~VaryingComponentsTest() 2633 { 2634 } 2635 2636 std::string getComponentsLayoutName(COMPONENTS_LAYOUT layout); 2637 std::string getTypesName(Utils::Type::TYPES type); 2638 2639 protected: 2640 /* Protected methods */ 2641 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 2642 Utils::VaryingPassthrough &varying_passthrough); 2643 2644 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2645 virtual glw::GLuint getTestCaseNumber(); 2646 virtual void testInit(); 2647 virtual bool useComponentQualifier(glw::GLuint test_case_index); 2648 2649 /* To be implemented by children */ 2650 virtual glw::GLuint getArrayLength(); 2651 COMPONENTS_LAYOUT m_layout; 2652 Utils::Type::TYPES m_type; 2653 2654 private: 2655 /* Private struct */ 2656 struct descriptor 2657 { 2658 void assign(glw::GLint component, const glw::GLchar *component_str, glw::GLint location, 2659 const glw::GLchar *location_str, glw::GLuint n_rows, const glw::GLchar *name); 2660 2661 glw::GLint m_component; 2662 const glw::GLchar *m_component_str; 2663 glw::GLint m_location; 2664 const glw::GLchar *m_location_str; 2665 glw::GLuint m_n_rows; 2666 const glw::GLchar *m_name; 2667 }; 2668 2669 struct testCase 2670 { 2671 testCase(COMPONENTS_LAYOUT layout, Utils::Type::TYPES type); 2672 2673 COMPONENTS_LAYOUT m_layout; 2674 Utils::Type::TYPES m_type; 2675 }; 2676 2677 /* Private routines */ 2678 std::string prepareGlobals(glw::GLuint last_in_location, glw::GLuint last_out_location); 2679 2680 std::string prepareName(const glw::GLchar *name, glw::GLint location, glw::GLint component, 2681 Utils::Shader::STAGES stage, Utils::Variable::STORAGE storage); 2682 2683 std::string prepareQualifiers(const glw::GLchar *location, const glw::GLchar *component, 2684 const glw::GLchar *interpolation); 2685 2686 using VaryingLocationsTest::prepareShaderStage; 2687 2688 void prepareShaderStage(Utils::Shader::STAGES stage, const Utils::Type &vector_type, 2689 Utils::ProgramInterface &program_interface, const testCase &test_case, 2690 Utils::VaryingPassthrough &varying_passthrough); 2691 2692 Utils::Variable *prepareVarying(const Utils::Type &basic_type, const descriptor &desc, 2693 const glw::GLchar *interpolation, Utils::ShaderInterface &si, 2694 Utils::Shader::STAGES stage, Utils::Variable::STORAGE storage); 2695 2696 /* Private fields */ 2697 std::vector<testCase> m_test_cases; 2698 std::vector<glw::GLubyte> m_data; 2699 }; 2700 2701 /** Implementation of test VaryingArrayComponents. Description follows: 2702 * 2703 * Test verifies that arrays of "varyings" can be assigned to specific 2704 * components. 2705 * 2706 * Modify VaryingComponents similarly to VaryingArrayLocations. 2707 **/ 2708 class VaryingArrayComponentsTest : public VaryingComponentsTest 2709 { 2710 public: 2711 VaryingArrayComponentsTest(deqp::Context &context, COMPONENTS_LAYOUT layout, Utils::Type::TYPES type); 2712 ~VaryingArrayComponentsTest()2713 ~VaryingArrayComponentsTest() 2714 { 2715 } 2716 2717 protected: 2718 /* Protected methods */ 2719 virtual glw::GLuint getArrayLength(); 2720 }; 2721 2722 /** Implementation of test VaryingInvalidValueComponent. Description follows: 2723 * 2724 * Test verifies that it is not allowed to use some component values 2725 * with specific types. 2726 * 2727 * Test following code snippets: 2728 * 2729 * layout (location = 1, component = COMPONENT) in type gohan; 2730 * 2731 * and 2732 * 2733 * layout (location = 1, component = COMPONENT) in type gohan[LENGTH]; 2734 * 2735 * Select COMPONENT so it is an invalid value either due the specific 2736 * restrictions of each type, eg. 2 for vec4, which overflows the 2737 * amount of components in a location. Select array length so as to 2738 * not exceed limits of available locations. 2739 * 2740 * Test all types. Test all shader stages. Test both in and out varyings. 2741 * 2742 * It is expected that build process will fail. 2743 **/ 2744 class VaryingInvalidValueComponentTest : public NegativeTestBase 2745 { 2746 public: 2747 /* Public methods */ 2748 VaryingInvalidValueComponentTest(deqp::Context &context, glw::GLuint type); 2749 ~VaryingInvalidValueComponentTest()2750 virtual ~VaryingInvalidValueComponentTest() 2751 { 2752 } 2753 getTypeHelper(glw::GLuint index) const2754 inline Utils::Type getTypeHelper(glw::GLuint index) const 2755 { 2756 return getType(index); 2757 } 2758 2759 protected: 2760 /* Methods to be implemented by child class */ 2761 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2762 2763 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2764 virtual glw::GLuint getTestCaseNumber(); 2765 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2766 virtual void testInit(); 2767 2768 private: 2769 /* Private types */ 2770 struct testCase 2771 { 2772 glw::GLuint m_component; 2773 bool m_is_input; 2774 bool m_is_array; 2775 Utils::Shader::STAGES m_stage; 2776 Utils::Type m_type; 2777 }; 2778 2779 /* Private fields */ 2780 std::vector<testCase> m_test_cases; 2781 glw::GLuint m_type; 2782 }; 2783 2784 /** Implementation of test VaryingExceedingComponents. Description follows: 2785 * 2786 * Test verifies that it is not allowed to use a value that exceeds 2787 * the amount of possible components in a location. 2788 * 2789 * Test following code snippets: 2790 * 2791 * layout (location = 1, component = 4) in type gohan; 2792 * 2793 * and 2794 * 2795 * layout (location = 1, component = 4) in type gohan[LENGTH]; 2796 * 2797 * Select array length so as to not exceed limits of available locations. 2798 * 2799 * Test all types. Test all shader stages. Test both in and out varyings. 2800 * 2801 * It is expected that build process will fail. 2802 **/ 2803 class VaryingExceedingComponentsTest : public NegativeTestBase 2804 { 2805 public: 2806 /* Public methods */ 2807 VaryingExceedingComponentsTest(deqp::Context &context, glw::GLuint type); 2808 ~VaryingExceedingComponentsTest()2809 virtual ~VaryingExceedingComponentsTest() 2810 { 2811 } 2812 getTypeHelper(glw::GLuint index) const2813 inline Utils::Type getTypeHelper(glw::GLuint index) const 2814 { 2815 return getType(index); 2816 } 2817 2818 protected: 2819 /* Methods to be implemented by child class */ 2820 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2821 2822 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2823 virtual glw::GLuint getTestCaseNumber(); 2824 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2825 virtual void testInit(); 2826 2827 private: 2828 /* Private types */ 2829 struct testCase 2830 { 2831 bool m_is_input; 2832 bool m_is_array; 2833 Utils::Shader::STAGES m_stage; 2834 Utils::Type m_type; 2835 }; 2836 2837 /* Private fields */ 2838 std::vector<testCase> m_test_cases; 2839 glw::GLuint m_type; 2840 }; 2841 2842 /** Implementation of test VaryingComponentWithoutLocation. Description follows: 2843 * 2844 * Test verifies that "component" qualifier cannot be used without "location" 2845 * qualifier. 2846 * 2847 * Test following code snippet: 2848 * 2849 * layout (component = COMPONENT) in type goku; 2850 * 2851 * Test all types. Test all valid COMPONENT values. Test all shader stages. 2852 * Test both in and out varyings. 2853 * 2854 * It is expected that shader compilation will fail. 2855 **/ 2856 class VaryingComponentWithoutLocationTest : public NegativeTestBase 2857 { 2858 public: 2859 /* Public methods */ 2860 VaryingComponentWithoutLocationTest(deqp::Context &context, glw::GLuint type); 2861 ~VaryingComponentWithoutLocationTest()2862 virtual ~VaryingComponentWithoutLocationTest() 2863 { 2864 } 2865 getTypeHelper(glw::GLuint index) const2866 inline Utils::Type getTypeHelper(glw::GLuint index) const 2867 { 2868 return getType(index); 2869 } 2870 2871 protected: 2872 /* Methods to be implemented by child class */ 2873 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2874 2875 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2876 virtual glw::GLuint getTestCaseNumber(); 2877 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2878 virtual void testInit(); 2879 2880 private: 2881 /* Private types */ 2882 struct testCase 2883 { 2884 glw::GLuint m_component; 2885 bool m_is_input; 2886 Utils::Shader::STAGES m_stage; 2887 Utils::Type m_type; 2888 }; 2889 2890 /* Private fields */ 2891 std::vector<testCase> m_test_cases; 2892 glw::GLuint m_type; 2893 }; 2894 2895 /** Implementation of test VaryingComponentOfInvalidType. Description follows: 2896 * 2897 * Test verifies that it is not allowed to declare matrix, struct, block and 2898 * array of those at specific component. 2899 * 2900 * Test following code snippets: 2901 * 2902 * layout (location = 0, component = COMPONENT) in matrix_type varying; 2903 * 2904 * , 2905 * 2906 * layout (location = 0, component = COMPONENT) 2907 * in matrix_type varying[LENGTH]; 2908 * 2909 * , 2910 * 2911 * layout (location = 0, component = COMPONENT) in Block 2912 * { 2913 * type member; 2914 * }; 2915 * 2916 * , 2917 * 2918 * layout (location = 0, component = COMPONENT) in Block 2919 * { 2920 * type member; 2921 * } block[LENGTH]; 2922 * 2923 * , 2924 * 2925 * struct Data 2926 * { 2927 * type member; 2928 * }; 2929 * 2930 * layout (location = 0, component = COMPONENT) in Data varying; 2931 * 2932 * and 2933 * 2934 * struct Data 2935 * { 2936 * type member; 2937 * }; 2938 * 2939 * layout (location = 0, component = COMPONENT) in Data varying[LENGTH]; 2940 * 2941 * Test all types. Test all shader stages. Test both in and out varyings. 2942 * 2943 * It is expected that build process will fail. 2944 **/ 2945 class VaryingComponentOfInvalidTypeTest : public NegativeTestBase 2946 { 2947 public: 2948 /* Public methods */ 2949 VaryingComponentOfInvalidTypeTest(deqp::Context &context, glw::GLuint type, glw::GLuint stage); 2950 ~VaryingComponentOfInvalidTypeTest()2951 virtual ~VaryingComponentOfInvalidTypeTest() 2952 { 2953 } 2954 2955 protected: 2956 /* Methods to be implemented by child class */ 2957 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 2958 2959 virtual std::string getTestCaseName(glw::GLuint test_case_index); 2960 virtual glw::GLuint getTestCaseNumber(); 2961 2962 virtual bool isComputeRelevant(glw::GLuint test_case_index); 2963 virtual void testInit(); 2964 2965 private: 2966 /* Private enums */ 2967 enum CASES 2968 { 2969 MATRIX = 0, 2970 DVEC3_DVEC4, 2971 BLOCK, 2972 STRUCT, 2973 2974 /* */ 2975 MAX_CASES 2976 }; 2977 2978 /* Private types */ 2979 struct testCase 2980 { 2981 CASES m_case; 2982 glw::GLuint m_component; 2983 bool m_is_array; 2984 bool m_is_input; 2985 Utils::Shader::STAGES m_stage; 2986 Utils::Type m_type; 2987 }; 2988 2989 /* Private fields */ 2990 std::vector<testCase> m_test_cases; 2991 glw::GLuint m_type; 2992 glw::GLuint m_stage; 2993 }; 2994 2995 /** Implementation of test InputComponentAliasing. Description follows: 2996 * 2997 * Test verifies that component aliasing cause compilation or linking error. 2998 * 2999 * Test following code snippet: 3000 * 3001 * layout (location = 1, component = GOHAN_COMPONENT) in type gohan; 3002 * layout (location = 1, component = GOTEN_COMPONENT) in type goten; 3003 * 3004 * if (EXPECTED_VALUE == gohan) 3005 * { 3006 * result = 1; 3007 * } 3008 * 3009 * Test all components combinations that cause aliasing. Test all types. Test 3010 * all shader stages. It is expected that build process will fail. 3011 * 3012 * Vertex shader allows component aliasing on input as long as only one of the 3013 * attributes is used in each execution path. Test vertex shader stage with two 3014 * variants: 3015 * - first as presented above, 3016 * - second, where "result = 1;" is replaced with "result = goten;". 3017 * In first case build process should succeed, in the second case build process 3018 * should fail. 3019 **/ 3020 class InputComponentAliasingTest : public NegativeTestBase 3021 { 3022 public: 3023 /* Public methods */ 3024 InputComponentAliasingTest(deqp::Context &context, glw::GLuint type); 3025 ~InputComponentAliasingTest()3026 virtual ~InputComponentAliasingTest() 3027 { 3028 } 3029 getTypeHelper(glw::GLuint index) const3030 inline Utils::Type getTypeHelper(glw::GLuint index) const 3031 { 3032 return getType(index); 3033 } 3034 3035 protected: 3036 /* Methods to be implemented by child class */ 3037 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3038 3039 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3040 virtual glw::GLuint getTestCaseNumber(); 3041 3042 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3043 virtual bool isFailureExpected(glw::GLuint test_case_index); 3044 virtual void testInit(); 3045 3046 private: 3047 /* Private types */ 3048 struct testCase 3049 { 3050 glw::GLuint m_component_gohan; 3051 glw::GLuint m_component_goten; 3052 Utils::Shader::STAGES m_stage; 3053 Utils::Type m_type; 3054 }; 3055 3056 /* Private fields */ 3057 std::vector<testCase> m_test_cases; 3058 glw::GLuint m_type; 3059 }; 3060 3061 /** Implementation of test OutputComponentAliasing. Description follows: 3062 * 3063 * Test verifies that component aliasing cause compilation or linking error. 3064 * 3065 * Test following code snippet: 3066 * 3067 * layout (location = 1, component = GOHAN_COMPONENT) out type gohan; 3068 * layout (location = 1, component = GOTEN_COMPONENT) out type goten; 3069 * 3070 * gohan = GOHAN_VALUE; 3071 * goten = GOTEN_VALUE; 3072 * 3073 * Test all components combinations that cause aliasing. Test all types. Test 3074 * all shader stages. It is expected that build process will fail. 3075 **/ 3076 class OutputComponentAliasingTest : public NegativeTestBase 3077 { 3078 public: 3079 /* Public methods */ 3080 OutputComponentAliasingTest(deqp::Context &context, glw::GLuint type); 3081 ~OutputComponentAliasingTest()3082 virtual ~OutputComponentAliasingTest() 3083 { 3084 } 3085 getTypeHelper(glw::GLuint index) const3086 inline Utils::Type getTypeHelper(glw::GLuint index) const 3087 { 3088 return getType(index); 3089 } 3090 3091 protected: 3092 /* Methods to be implemented by child class */ 3093 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3094 3095 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3096 virtual glw::GLuint getTestCaseNumber(); 3097 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3098 virtual void testInit(); 3099 3100 private: 3101 /* Private types */ 3102 struct testCase 3103 { 3104 glw::GLuint m_component_gohan; 3105 glw::GLuint m_component_goten; 3106 Utils::Shader::STAGES m_stage; 3107 Utils::Type m_type; 3108 }; 3109 3110 /* Private fields */ 3111 std::vector<testCase> m_test_cases; 3112 glw::GLuint m_type; 3113 }; 3114 3115 /** Implementation of test VaryingLocationAliasingWithMixedTypes. Description follows: 3116 * 3117 * Test verifies that it is not allowed to mix integer and float base types at 3118 * aliased location. 3119 * 3120 * Test following code snippet: 3121 * 3122 * layout (location = 1, component = GOHAN_COMPONENT) in gohan_type gohan; 3123 * layout (location = 1, component = GOTEN_COMPONENT) in goten_type goten; 3124 * 3125 * Test all components combinations that do not cause component aliasing. Test 3126 * all types combinations that cause float/integer conflict. Test all shader 3127 * stages. Test both in and out varyings. 3128 * 3129 * It is expected that build process will fail. 3130 **/ 3131 class VaryingLocationAliasingWithMixedTypesTest : public NegativeTestBase 3132 { 3133 public: 3134 /* Public methods */ 3135 VaryingLocationAliasingWithMixedTypesTest(deqp::Context &context, glw::GLuint type_gohan, glw::GLuint type_goten); 3136 ~VaryingLocationAliasingWithMixedTypesTest()3137 virtual ~VaryingLocationAliasingWithMixedTypesTest() 3138 { 3139 } 3140 getTypeHelper(glw::GLuint index) const3141 inline Utils::Type getTypeHelper(glw::GLuint index) const 3142 { 3143 return getType(index); 3144 } 3145 3146 protected: 3147 /* Methods to be implemented by child class */ 3148 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3149 3150 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3151 virtual glw::GLuint getTestCaseNumber(); 3152 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3153 virtual void testInit(); 3154 3155 private: 3156 /* Private types */ 3157 struct testCase 3158 { 3159 glw::GLuint m_component_gohan; 3160 glw::GLuint m_component_goten; 3161 bool m_is_input; 3162 Utils::Shader::STAGES m_stage; 3163 Utils::Type m_type_gohan; 3164 Utils::Type m_type_goten; 3165 }; 3166 3167 /* Private fields */ 3168 std::vector<testCase> m_test_cases; 3169 glw::GLuint m_type_gohan; 3170 glw::GLuint m_type_goten; 3171 }; 3172 3173 /** Implementation of test VaryingLocationAliasingWithMixedInterpolation. Description follows: 3174 * 3175 * Test verifies that it is not allowed to mix interpolation methods at aliased 3176 * location. 3177 * 3178 * Test following code snippet: 3179 * 3180 * layout (location = 1, component = GOHAN_COMPONENT) 3181 * GOHAN_INTERPOLATION in type gohan; 3182 * layout (location = 1, component = GOTEN_COMPONENT) 3183 * GOTEN_INTERPOLATION in type goten; 3184 * 3185 * Test all interpolation combinations that cause conflict. Select components 3186 * so as not to cause component aliasing. Test all types. Test all shader 3187 * stages. Test both in and out varyings. 3188 * 3189 * Note, that vertex shader's input and fragment shader's output cannot be 3190 * qualified with interpolation method. 3191 * 3192 * It is expected that build process will fail. 3193 **/ 3194 class VaryingLocationAliasingWithMixedInterpolationTest : public NegativeTestBase 3195 { 3196 public: 3197 /* Public methods */ 3198 VaryingLocationAliasingWithMixedInterpolationTest(deqp::Context &context, glw::GLuint type_gohan, 3199 glw::GLuint type_goten); 3200 ~VaryingLocationAliasingWithMixedInterpolationTest()3201 virtual ~VaryingLocationAliasingWithMixedInterpolationTest() 3202 { 3203 } 3204 getTypeHelper(glw::GLuint index) const3205 inline Utils::Type getTypeHelper(glw::GLuint index) const 3206 { 3207 return getType(index); 3208 } 3209 3210 protected: 3211 /* Methods to be implemented by child class */ 3212 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3213 3214 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3215 virtual glw::GLuint getTestCaseNumber(); 3216 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3217 virtual void testInit(); 3218 3219 private: 3220 enum INTERPOLATIONS 3221 { 3222 SMOOTH = 0, 3223 FLAT, 3224 NO_PERSPECTIVE, 3225 3226 /* */ 3227 INTERPOLATION_MAX 3228 }; 3229 3230 /* Private types */ 3231 struct testCase 3232 { 3233 glw::GLuint m_component_gohan; 3234 glw::GLuint m_component_goten; 3235 INTERPOLATIONS m_interpolation_gohan; 3236 INTERPOLATIONS m_interpolation_goten; 3237 bool m_is_input; 3238 Utils::Shader::STAGES m_stage; 3239 Utils::Type m_type_gohan; 3240 Utils::Type m_type_goten; 3241 }; 3242 3243 /* Private routines */ 3244 const glw::GLchar *getInterpolationQualifier(INTERPOLATIONS interpolation); 3245 3246 /* Private fields */ 3247 std::vector<testCase> m_test_cases; 3248 glw::GLuint m_type_gohan; 3249 glw::GLuint m_type_goten; 3250 }; 3251 3252 /** Implementation of test VaryingLocationAliasingWithMixedAuxiliaryStorage. Description follows: 3253 * 3254 * Test verifies that it is not allowed to mix auxiliary storage at aliased 3255 * location. 3256 * 3257 * Test following code snippet: 3258 * 3259 * layout (location = 1, component = GOHAN_COMPONENT) 3260 * GOHAN_AUXILIARY in type gohan; 3261 * layout (location = 1, component = GOTEN_COMPONENT) 3262 * GOTEN_AUXILIARY in type goten; 3263 * 3264 * Test all auxiliary storage combinations that cause conflict. Select 3265 * components so as not to cause component aliasing. Test all types. Test all 3266 * shader stages. Test both in and out varyings. 3267 * 3268 * It is expected that build process will fail. 3269 **/ 3270 class VaryingLocationAliasingWithMixedAuxiliaryStorageTest : public NegativeTestBase 3271 { 3272 public: 3273 /* Public methods */ 3274 VaryingLocationAliasingWithMixedAuxiliaryStorageTest(deqp::Context &context, glw::GLuint type_gohan, 3275 glw::GLuint type_goten); 3276 ~VaryingLocationAliasingWithMixedAuxiliaryStorageTest()3277 virtual ~VaryingLocationAliasingWithMixedAuxiliaryStorageTest() 3278 { 3279 } 3280 getTypeHelper(glw::GLuint index) const3281 inline Utils::Type getTypeHelper(glw::GLuint index) const 3282 { 3283 return getType(index); 3284 } 3285 3286 protected: 3287 /* Methods to be implemented by child class */ 3288 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3289 3290 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3291 virtual glw::GLuint getTestCaseNumber(); 3292 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3293 virtual void testInit(); 3294 3295 private: 3296 enum AUXILIARIES 3297 { 3298 NONE = 0, 3299 PATCH, 3300 CENTROID, 3301 SAMPLE, 3302 3303 /* */ 3304 AUXILIARY_MAX 3305 }; 3306 3307 /* Private types */ 3308 struct testCase 3309 { 3310 glw::GLuint m_component_gohan; 3311 glw::GLuint m_component_goten; 3312 AUXILIARIES m_aux_gohan; 3313 AUXILIARIES m_aux_goten; 3314 bool m_is_input; 3315 Utils::Shader::STAGES m_stage; 3316 Utils::Type m_type_gohan; 3317 Utils::Type m_type_goten; 3318 }; 3319 3320 /* Private routines */ 3321 const glw::GLchar *getAuxiliaryQualifier(AUXILIARIES aux); 3322 3323 /* Private fields */ 3324 std::vector<testCase> m_test_cases; 3325 glw::GLuint m_type_gohan; 3326 glw::GLuint m_type_goten; 3327 }; 3328 3329 /** Implementation of test VertexAttribLocationAPI. Description follows: 3330 * 3331 * Test verifies that vertex attribute location API works as expected. 3332 * 3333 * This test implements Texture algorithm. Tessellation shaders are not 3334 * necessary and can be omitted. Test following code snippet in vertex shader: 3335 * 3336 * layout (location = GOKU_LOCATION) in vec4 goku; 3337 * in vec4 gohan; 3338 * in vec4 goten; 3339 * in vec4 chichi; 3340 * 3341 * if ( (EXPECTED_VALUE == goku) && 3342 * (EXPECTED_VALUE == gohan) && 3343 * (EXPECTED_VALUE == gotan) && 3344 * (EXPECTED_VALUE == chichi) ) 3345 * { 3346 * result = 1; 3347 * } 3348 * 3349 * After compilation, before program is linked, specify locations for goku, 3350 * and goten with glBindAttribLocation. Specify different location than the one 3351 * used in shader. 3352 * 3353 * Select all locations so as not to exceed any limits. 3354 * 3355 * Additionally inspect program to verify that: 3356 * - goku location is as specified in shader text, 3357 * - goten location is as specified with API. 3358 **/ 3359 class VertexAttribLocationAPITest : public TextureTestBase 3360 { 3361 public: 3362 VertexAttribLocationAPITest(deqp::Context &context); 3363 ~VertexAttribLocationAPITest()3364 ~VertexAttribLocationAPITest() 3365 { 3366 } 3367 3368 protected: 3369 /* Protected methods */ 3370 virtual void prepareAttribLocation(Utils::Program &program, Utils::ProgramInterface &program_interface); 3371 3372 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 3373 Utils::VaryingPassthrough &varying_passthrough); 3374 3375 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3376 3377 private: 3378 /* Private fields */ 3379 std::vector<glw::GLubyte> m_goku_data; 3380 std::vector<glw::GLubyte> m_gohan_data; 3381 std::vector<glw::GLubyte> m_goten_data; 3382 std::vector<glw::GLubyte> m_chichi_data; 3383 3384 /* Private constants */ 3385 static const glw::GLuint m_goten_location; 3386 }; 3387 /** Implementation of test FragmentDataLocationAPI. Description follows: 3388 * 3389 * Test verifies that fragment data location API works as expected. 3390 * 3391 * This test implements Texture algorithm. Tessellation shaders are not 3392 * necessary and can be omitted. "result" is not necessary and can be omitted. 3393 * Test following code snippet in fragment shader: 3394 * 3395 * layout (location = GOKU_LOCATION) out vec4 goku; 3396 * out vec4 gohan; 3397 * out vec4 goten; 3398 * out vec4 chichi; 3399 * 3400 * goku = EXPECTED_VALUE; 3401 * gohan = EXPECTED_VALUE; 3402 * goten = EXPECTED_VALUE; 3403 * chichi = EXPECTED_VALUE; 3404 * 3405 * After compilation, before program is linked, specify locations for goku, 3406 * and goten with glBindFragDataLocation. Specify different location than the 3407 * one used in shader. 3408 * 3409 * Select all locations so as not to exceed any limits. 3410 * 3411 * Additionally inspect program to verify that: 3412 * - goku location is as specified in shader text, 3413 * - goten location is as specified with API. 3414 **/ 3415 class FragmentDataLocationAPITest : public TextureTestBase 3416 { 3417 public: 3418 FragmentDataLocationAPITest(deqp::Context &context); 3419 ~FragmentDataLocationAPITest()3420 ~FragmentDataLocationAPITest() 3421 { 3422 } 3423 3424 protected: 3425 /* Protected methods */ 3426 virtual bool checkResults(glw::GLuint test_case_index, Utils::Texture &color_0); 3427 3428 virtual std::string getPassSnippet(glw::GLuint test_case_index, Utils::VaryingPassthrough &varying_passthrough, 3429 Utils::Shader::STAGES stage); 3430 3431 virtual void getProgramInterface(glw::GLuint test_case_index, Utils::ProgramInterface &program_interface, 3432 Utils::VaryingPassthrough &varying_passthrough); 3433 3434 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3435 3436 virtual void prepareFragmentDataLoc(Utils::Program &program, Utils::ProgramInterface &program_interface); 3437 3438 virtual void prepareFramebuffer(Utils::Framebuffer &framebuffer, Utils::Texture &color_0_texture); 3439 3440 private: 3441 /* Private fields */ 3442 Utils::Texture m_goku; 3443 Utils::Texture m_gohan; 3444 Utils::Texture m_goten; 3445 Utils::Texture m_chichi; 3446 3447 glw::GLint m_goku_location; 3448 glw::GLint m_gohan_location; 3449 glw::GLint m_chichi_location; 3450 3451 /* Private constants */ 3452 static const glw::GLuint m_goten_location; 3453 }; 3454 3455 /** Implementation of test XFBInput. Description follows: 3456 * 3457 * Test verifies that using xfb_buffer, xfb_stride or xfb_offset qualifiers on 3458 * input variables will cause failure of build process. 3459 * 3460 * Test all shader stages. 3461 **/ 3462 class XFBInputTest : public NegativeTestBase 3463 { 3464 public: 3465 enum QUALIFIERS 3466 { 3467 BUFFER = 0, 3468 STRIDE, 3469 OFFSET, 3470 3471 /* */ 3472 QUALIFIERS_MAX 3473 }; 3474 3475 /* Public methods */ 3476 XFBInputTest(deqp::Context &context, glw::GLuint qualifier, glw::GLuint stage); ~XFBInputTest()3477 virtual ~XFBInputTest() 3478 { 3479 } 3480 3481 protected: 3482 /* Methods to be implemented by child class */ 3483 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3484 3485 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3486 virtual glw::GLuint getTestCaseNumber(); 3487 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3488 virtual void testInit(); 3489 3490 private: 3491 /* Private types */ 3492 struct testCase 3493 { 3494 QUALIFIERS m_qualifier; 3495 Utils::Shader::STAGES m_stage; 3496 }; 3497 3498 const glw::GLchar *getQualifierName(QUALIFIERS qualifier); 3499 3500 /* Private fields */ 3501 std::vector<testCase> m_test_cases; 3502 glw::GLuint m_qualifier; 3503 glw::GLuint m_stage; 3504 }; 3505 3506 /** Implementation of test XFBAllStages. Description follows: 3507 * 3508 * Test verifies that only outputs from last stage processing primitives can be 3509 * captured with XFB. 3510 * 3511 * This test implements Buffer algorithm. Rasterization can be discarded. 3512 * 3513 * At each stage declare a single active output variable qualified with 3514 * xfb_buffer and xfb_offset = 0. Use separate buffers for each stage. 3515 * 3516 * Test pass if outputs from geometry shader are captured, while outputs from: 3517 * vertex and tessellation stages are ignored. 3518 **/ 3519 class XFBAllStagesTest : public BufferTestBase 3520 { 3521 public: 3522 XFBAllStagesTest(deqp::Context &context); 3523 ~XFBAllStagesTest()3524 ~XFBAllStagesTest() 3525 { 3526 } 3527 3528 protected: 3529 /* Protected methods */ 3530 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 3531 3532 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 3533 std::string &out_calculations); 3534 3535 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 3536 std::string &out_interface); 3537 3538 private: 3539 /* Constants */ 3540 static const glw::GLuint m_gs_index; 3541 }; 3542 3543 /** Implementation of test XFBStrideOfEmptyList. Description follows: 3544 * 3545 * Test verifies correct behavior when xfb_stride qualifier is specified 3546 * but no variables are qualified with xfb_offset. 3547 * 3548 * Test implements Buffer algorithm. Rasterization can be discarded. 3549 * 3550 * Test following code snippet: 3551 * 3552 * layout (xfb_buffer = 1, xfb_stride = 64) out; 3553 * 3554 * Moreover program should output something to xfb at index 0 3555 * 3556 * Test following cases: 3557 * 1 Provide buffers to XFB at index 0 and 1 3558 * 2 Provide buffer to XFB at index 1, index 0 should be missing 3559 * 3 Provide buffer to XFB at index 0, index 1 should be missing 3560 * 3561 * It is expected that: 3562 * - BeginTransformFeedback operation will report GL_INVALID_OPERATION in case 2 3563 * - XFB at index 1 will not be modified in cases 1 and 3. 3564 **/ 3565 3566 class XFBStrideOfEmptyListTest : public BufferTestBase 3567 { 3568 public: 3569 XFBStrideOfEmptyListTest(deqp::Context &context); 3570 ~XFBStrideOfEmptyListTest()3571 ~XFBStrideOfEmptyListTest() 3572 { 3573 } 3574 3575 protected: 3576 /* Protected methods */ 3577 using BufferTestBase::executeDrawCall; 3578 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 3579 3580 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 3581 3582 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 3583 std::string &out_calculations); 3584 3585 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 3586 std::string &out_interface); 3587 3588 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3589 virtual glw::GLuint getTestCaseNumber(); 3590 3591 private: 3592 enum CASES 3593 { 3594 VALID = 0, 3595 FIRST_MISSING, 3596 SECOND_MISSING, 3597 }; 3598 3599 /* Private constants */ 3600 static const glw::GLuint m_stride; 3601 }; 3602 3603 /** Implementation of test XFBStrideOfEmptyListAndAPI. Description follows: 3604 * 3605 * Test verifies that xfb_stride qualifier is not overridden by API. 3606 * 3607 * Test implements Buffer algorithm. Rasterization can be discarded. 3608 * 3609 * Test following code snippet: 3610 * 3611 * layout (xfb_buffer = 0, xfb_stride = 64) out; 3612 * 3613 * Moreover program should output something to xfb at index 1 3614 3615 * Use TransformFeedbackVaryings to declare a single vec4 output variable to be 3616 * captured. 3617 * 3618 * Test following cases: 3619 * 1 Provide buffers to XFB at index 0 and 1 3620 * 2 Provide buffer to XFB at index 1, index 0 should be missing 3621 * 3 Provide buffer to XFB at index 0, index 1 should be missing 3622 * 3623 * It is expected that: 3624 * - BeginTransformFeedback operation will report GL_INVALID_OPERATION in cases 3625 * 2 and 3, 3626 * - XFB at index 0 will not be modified in case 1. 3627 **/ 3628 class XFBStrideOfEmptyListAndAPITest : public BufferTestBase 3629 { 3630 public: 3631 XFBStrideOfEmptyListAndAPITest(deqp::Context &context); 3632 ~XFBStrideOfEmptyListAndAPITest()3633 ~XFBStrideOfEmptyListAndAPITest() 3634 { 3635 } 3636 3637 protected: 3638 /* Protected methods */ 3639 using BufferTestBase::executeDrawCall; 3640 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 3641 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 3642 3643 virtual void getCapturedVaryings(glw::GLuint test_case_index, Utils::Program::NameVector &captured_varyings, 3644 glw::GLint *xfb_components); 3645 3646 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 3647 std::string &out_calculations); 3648 3649 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 3650 std::string &out_interface); 3651 3652 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3653 virtual glw::GLuint getTestCaseNumber(); 3654 3655 private: 3656 enum CASES 3657 { 3658 VALID = 0, 3659 FIRST_MISSING, 3660 SECOND_MISSING, 3661 }; 3662 3663 /* Private constants */ 3664 static const glw::GLuint m_stride; 3665 }; 3666 3667 /** Implementation of test XFBTooSmallStride. Description follows: 3668 * 3669 * Test verifies that build process fails when xfb_stride qualifier sets not 3670 * enough space for all variables. 3671 * 3672 * Test following code snippets: 3673 * 3674 * layout (xfb_buffer = 0, xfb_stride = 40) out; 3675 * 3676 * layout (xfb_offset = 32) out vec4 goku; 3677 * 3678 * goku = EXPECTED_VALUE. 3679 * 3680 * , 3681 * 3682 * layout (xfb_buffer = 0, xfb_stride = 28) out; 3683 * 3684 * layout (xfb_offset = 16, xfb_stride = 28) out vec4 goku; 3685 * 3686 * goku = EXPECTED_VALUE. 3687 * 3688 * , 3689 * 3690 * layout (xfb_buffer = 0, xfb_stride = 32) out; 3691 * 3692 * layout (xfb_offset = 0) out Goku { 3693 * vec4 gohan; 3694 * vec4 goten; 3695 * vec4 chichi; 3696 * }; 3697 * 3698 * gohan = EXPECTED_VALUE; 3699 * goten = EXPECTED_VALUE; 3700 * chichi = EXPECTED_VALUE; 3701 * 3702 * , 3703 * 3704 * layout (xfb_buffer = 0, xfb_stride = 32) out; 3705 * 3706 * layout (xfb_offset = 16) out vec4 goku[4]; 3707 * 3708 * goku[0] = EXPECTED_VALUE. 3709 * goku[1] = EXPECTED_VALUE. 3710 * goku[2] = EXPECTED_VALUE. 3711 * goku[3] = EXPECTED_VALUE. 3712 * 3713 * It is expected that build process will fail. 3714 * 3715 * Test all shader stages. 3716 **/ 3717 class XFBTooSmallStrideTest : public NegativeTestBase 3718 { 3719 public: 3720 enum CASES 3721 { 3722 OFFSET = 0, 3723 STRIDE, 3724 BLOCK, 3725 ARRAY, 3726 3727 /* */ 3728 CASE_MAX 3729 }; 3730 3731 /* Public methods */ 3732 XFBTooSmallStrideTest(deqp::Context &context, glw::GLuint constant, glw::GLuint stage); 3733 ~XFBTooSmallStrideTest()3734 virtual ~XFBTooSmallStrideTest() 3735 { 3736 } 3737 3738 protected: 3739 /* Methods to be implemented by child class */ 3740 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3741 3742 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3743 virtual glw::GLuint getTestCaseNumber(); 3744 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3745 virtual void testInit(); 3746 std::string getCaseEnumName(glw::GLuint case_index); 3747 3748 private: 3749 /* Private types */ 3750 struct testCase 3751 { 3752 CASES m_case; 3753 Utils::Shader::STAGES m_stage; 3754 }; 3755 3756 /* Private fields */ 3757 std::vector<testCase> m_test_cases; 3758 glw::GLuint m_constant; 3759 glw::GLuint m_stage; 3760 }; 3761 3762 /** Implementation of test XFBVariableStride. Description follows: 3763 * 3764 * Test verifies that xfb_stride qualifier change stride of output variable. 3765 * 3766 * Test following code snippets: 3767 * 3768 * layout (xfb_stride = sizeof(type)) out; 3769 * 3770 * layout (xfb_offset = 0) out type goku; 3771 * 3772 * and 3773 * 3774 * layout (xfb_stride = sizeof(type)) out; 3775 * 3776 * layout (xfb_offset = 0) out type goku; 3777 * layout (xfb_offset = sizeof(type)) out type vegeta; 3778 * 3779 * It is expected that: 3780 * - first snippet will build successfully, 3781 * - second snippet will fail to build. 3782 * 3783 * Test all types. Test all shader stages. 3784 **/ 3785 class XFBVariableStrideTest : public NegativeTestBase 3786 { 3787 public: 3788 enum CASES 3789 { 3790 VALID = 0, 3791 INVALID, 3792 3793 /* */ 3794 CASE_MAX 3795 }; 3796 3797 /* Public methods */ 3798 XFBVariableStrideTest(deqp::Context &context, glw::GLuint type, glw::GLuint stage, glw::GLuint constant); ~XFBVariableStrideTest()3799 virtual ~XFBVariableStrideTest() 3800 { 3801 } 3802 3803 protected: 3804 /* Methods to be implemented by child class */ 3805 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3806 3807 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3808 virtual glw::GLuint getTestCaseNumber(); 3809 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3810 virtual bool isFailureExpected(glw::GLuint test_case_index); 3811 virtual void testInit(); 3812 std::string getCaseEnumName(glw::GLuint case_index); 3813 3814 private: 3815 /* Private types */ 3816 struct testCase 3817 { 3818 CASES m_case; 3819 Utils::Shader::STAGES m_stage; 3820 Utils::Type m_type; 3821 }; 3822 3823 /* Private fields */ 3824 std::vector<testCase> m_test_cases; 3825 glw::GLuint m_type; 3826 glw::GLuint m_stage; 3827 glw::GLuint m_constant; 3828 }; 3829 3830 /** Implementation of test XFBBlockStride. Description follows: 3831 * 3832 * Test verifies that xfb_stride qualifier change stride of output block. 3833 * 3834 * Test following code snippet: 3835 * 3836 * layout (xfb_offset = 0, xfb_stride = 128) out Goku { 3837 * vec4 gohan; 3838 * vec4 goten; 3839 * vec4 chichi; 3840 * }; 3841 * 3842 * Inspect program to check if Goku stride is 128 units. 3843 * 3844 * Test all shader stages. 3845 **/ 3846 class XFBBlockStrideTest : public TestBase 3847 { 3848 public: 3849 /* Public methods */ 3850 XFBBlockStrideTest(deqp::Context &context, glw::GLuint stage); 3851 ~XFBBlockStrideTest()3852 virtual ~XFBBlockStrideTest() 3853 { 3854 } 3855 3856 protected: 3857 /* Methods to be implemented by child class */ 3858 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3859 virtual glw::GLuint getTestCaseNumber(); 3860 virtual bool testCase(glw::GLuint test_case_index); 3861 virtual void testInit(); 3862 3863 private: 3864 /* Private methods */ 3865 std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3866 3867 bool inspectProgram(Utils::Program &program); 3868 3869 /* Private fields */ 3870 std::vector<Utils::Shader::STAGES> m_test_cases; 3871 glw::GLuint m_stage; 3872 }; 3873 3874 /** Implementation of test XFBBlockMemberStride. Description follows: 3875 * 3876 * Test verifies that xfb_stride qualifier change stride of output block 3877 * member. 3878 * 3879 * This test implements Buffer algorithm. Rasterization can be discarded. Test 3880 * following code snippet: 3881 * 3882 * layout (xfb_offset = 0) out Goku { 3883 * vec4 gohan; 3884 * layout (xfb_stride = 32) vec4 goten; 3885 * vec4 chichi; 3886 * }; 3887 * 3888 * gohan = EXPECTED_VALUE; 3889 * goten = EXPECTED_VALUE; 3890 * chichi = EXPECTED_VALUE; 3891 * 3892 * Test pass if: 3893 * - goten stride is reported as 32, 3894 * - chichi offset is reported as 48, 3895 * - values captured for all members match expected values, 3896 * - part of memory reserved for goten, that is not used, is not modified. 3897 **/ 3898 class XFBBlockMemberStrideTest : public BufferTestBase 3899 { 3900 public: 3901 XFBBlockMemberStrideTest(deqp::Context &context); ~XFBBlockMemberStrideTest()3902 ~XFBBlockMemberStrideTest() 3903 { 3904 } 3905 3906 protected: 3907 /* Protected methods */ 3908 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 3909 3910 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 3911 std::string &out_calculations); 3912 3913 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 3914 std::string &out_interface); 3915 3916 virtual bool inspectProgram(glw::GLuint test_case_index, Utils::Program &program, std::stringstream &out_stream); 3917 }; 3918 3919 /** Implementation of test XFBDuplicatedStride. Description follows: 3920 * 3921 * Test verifies that conflicting xfb_stride qualifiers cause build process 3922 * failure. 3923 * 3924 * Test following code snippets: 3925 * 3926 * layout (xfb_buffer = 0, xfb_stride = 64) out; 3927 * layout (xfb_buffer = 0, xfb_stride = 64) out; 3928 * 3929 * and 3930 * 3931 * layout (xfb_buffer = 0, xfb_stride = 64) out; 3932 * layout (xfb_buffer = 0, xfb_stride = 128) out; 3933 * 3934 * It is expected that: 3935 * - first snippet will build successfully, 3936 * - second snippet will fail to build. 3937 **/ 3938 class XFBDuplicatedStrideTest : public NegativeTestBase 3939 { 3940 public: 3941 enum CASES 3942 { 3943 VALID = 0, 3944 INVALID, 3945 3946 /* */ 3947 CASE_MAX 3948 }; 3949 3950 /* Public methods */ 3951 XFBDuplicatedStrideTest(deqp::Context &context, glw::GLuint constant, glw::GLuint stage); 3952 ~XFBDuplicatedStrideTest()3953 virtual ~XFBDuplicatedStrideTest() 3954 { 3955 } 3956 3957 protected: 3958 /* Methods to be implemented by child class */ 3959 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 3960 3961 virtual std::string getTestCaseName(glw::GLuint test_case_index); 3962 virtual glw::GLuint getTestCaseNumber(); 3963 virtual bool isComputeRelevant(glw::GLuint test_case_index); 3964 virtual bool isFailureExpected(glw::GLuint test_case_index); 3965 virtual void testInit(); 3966 std::string getCaseEnumName(glw::GLuint test_case_index); 3967 3968 private: 3969 /* Private types */ 3970 struct testCase 3971 { 3972 CASES m_case; 3973 Utils::Shader::STAGES m_stage; 3974 }; 3975 3976 /* Private fields */ 3977 std::vector<testCase> m_test_cases; 3978 glw::GLuint m_constant; 3979 glw::GLuint m_stage; 3980 }; 3981 3982 /** Implementation of test XFBGetProgramResourceAPI. Description follows: 3983 * 3984 * Test verifies that GetProgramResource* API work as expected for transform 3985 * feedback. 3986 * 3987 * Test results of following queries: 3988 * - OFFSET, 3989 * - TRANSFORM_FEEDBACK_BUFFER_INDEX, 3990 * - TRANSFORM_FEEDBACK_BUFFER_STRIDE, 3991 * - TYPE. 3992 * 3993 * Test following cases: 3994 * - captured varyings are declared with API, TransformFeedbackVaryings 3995 * with INTERLEAVED_ATTRIBS, 3996 * - captured varyings are declared with API, TransformFeedbackVaryings 3997 * with SEPARATE_ATTRIBS, 3998 * - captured varyings are declared with "xfb" qualifiers. 3999 * 4000 * Following layout should be used in cases of INTERLEAVED_ATTRIBS and "xfb" 4001 * qualifiers: 4002 * | var 0 | var 1 | var 2 | var 3 4003 * buffer 0 | used | used | empty | used 4004 * buffer 1 | empty | used | empty | empty 4005 * 4006 * In "xfb" qualifiers case, use following snippet: 4007 * 4008 * layout (xfb_buffer = 1, xfb_stride = 4 * sizeof(type)) out; 4009 * 4010 * Declaration in shader should use following order: 4011 * buffer_0_var_1 4012 * buffer_1_var_1 4013 * buffer_0_var_3 4014 * buffer_0_var_0 4015 * 4016 * To make sure that captured varyings are active, they should be assigned. 4017 * 4018 * Test all types. Test all shader stages. 4019 **/ 4020 class XFBGetProgramResourceAPITest : public TestBase 4021 { 4022 public: 4023 /* Public methods */ 4024 XFBGetProgramResourceAPITest(deqp::Context &context, glw::GLuint type); 4025 ~XFBGetProgramResourceAPITest()4026 virtual ~XFBGetProgramResourceAPITest() 4027 { 4028 } 4029 getTypeHelper(glw::GLuint index) const4030 inline Utils::Type getTypeHelper(glw::GLuint index) const 4031 { 4032 return getType(index); 4033 } 4034 4035 protected: 4036 /* Methods to be implemented by child class */ 4037 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4038 virtual glw::GLuint getTestCaseNumber(); 4039 virtual bool testCase(glw::GLuint test_case_index); 4040 virtual void testInit(); 4041 virtual void insertSkipComponents(int num_components, Utils::Program::NameVector &varyings); 4042 4043 private: 4044 /* Private enums */ 4045 enum CASES 4046 { 4047 INTERLEAVED, 4048 SEPARATED, 4049 XFB, 4050 }; 4051 4052 /* Private types */ 4053 struct test_Case 4054 { 4055 CASES m_case; 4056 Utils::Shader::STAGES m_stage; 4057 Utils::Type m_type; 4058 }; 4059 4060 /* Private methods */ 4061 std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4062 4063 bool inspectProgram(glw::GLuint test_case_index, Utils::Program &program); 4064 4065 /* Private fields */ 4066 std::vector<test_Case> m_test_cases; 4067 glw::GLuint m_type; 4068 }; 4069 4070 /** Implementation of test XFBOverrideQualifiersWithAPI. Description follows: 4071 * 4072 * Test verifies that API is ignored, when qualifiers are in use. 4073 * 4074 * This test follows Buffer algorithm. Rasterization can disabled. Test 4075 * following code snippet: 4076 * 4077 * layout (xfb_offset = 2 * sizeof(type)) out type vegeta; 4078 * out type trunks; 4079 * layout (xfb_offset = 0) out type goku; 4080 * out type gohan; 4081 * 4082 * vegeta = EXPECTED_VALUE; 4083 * trunks = EXPECTED_VALUE; 4084 * goku = EXPECTED_VALUE; 4085 * gohan = EXPECTED_VALUE; 4086 * 4087 * Use API, TransformFeedbackVaryings, to specify trunks and gohan as outputs 4088 * to be captured. 4089 * 4090 * Test pass if: 4091 * - correct values are captured for vegeta and goku, 4092 * - trunks and gohan are not captured, 4093 * - correct stride is reported. 4094 * 4095 * Test all types. Test all shader stages. 4096 **/ 4097 class XFBOverrideQualifiersWithAPITest : public BufferTestBase 4098 { 4099 public: 4100 XFBOverrideQualifiersWithAPITest(deqp::Context &context); 4101 ~XFBOverrideQualifiersWithAPITest()4102 ~XFBOverrideQualifiersWithAPITest() 4103 { 4104 } 4105 4106 protected: 4107 /* Protected methods */ 4108 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4109 4110 virtual void getCapturedVaryings(glw::GLuint test_case_index, Utils::Program::NameVector &captured_varyings, 4111 glw::GLint *xfb_components); 4112 4113 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4114 std::string &out_calculations); 4115 4116 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4117 std::string &out_interface); 4118 4119 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4120 virtual glw::GLuint getTestCaseNumber(); 4121 4122 virtual bool inspectProgram(glw::GLuint test_case_index, Utils::Program &program, std::stringstream &out_stream); 4123 }; 4124 4125 /** Implementation of test XFBVertexStreams. Description follows: 4126 * 4127 * Test verifies that "xfb" qualifiers work as expected with multiple output 4128 * streams. 4129 * 4130 * Test implements Buffer algorithm. Rasterization can be discarded. 4131 * 4132 * Test following code snippet: 4133 * 4134 * layout (xfb_buffer = 1, xfb_stride = 64) out; 4135 * layout (xfb_buffer = 2, xfb_stride = 64) out; 4136 * layout (xfb_buffer = 3, xfb_stride = 64) out; 4137 * 4138 * layout (stream = 0, xfb_buffer = 1, xfb_offset = 48) out vec4 goku; 4139 * layout (stream = 0, xfb_buffer = 1, xfb_offset = 32) out vec4 gohan; 4140 * layout (stream = 0, xfb_buffer = 1, xfb_offset = 16) out vec4 goten; 4141 * layout (stream = 1, xfb_buffer = 3, xfb_offset = 48) out vec4 picolo; 4142 * layout (stream = 1, xfb_buffer = 3, xfb_offset = 32) out vec4 vegeta; 4143 * layout (stream = 2, xfb_buffer = 2, xfb_offset = 32) out vec4 bulma; 4144 * 4145 * goku = EXPECTED_VALUE; 4146 * gohan = EXPECTED_VALUE; 4147 * goten = EXPECTED_VALUE; 4148 * picolo = EXPECTED_VALUE; 4149 * vegeta = EXPECTED_VALUE; 4150 * bulma = EXPECTED_VALUE; 4151 * 4152 * Test pass if all captured outputs have expected values. 4153 **/ 4154 class XFBVertexStreamsTest : public BufferTestBase 4155 { 4156 public: 4157 XFBVertexStreamsTest(deqp::Context &context); 4158 ~XFBVertexStreamsTest()4159 ~XFBVertexStreamsTest() 4160 { 4161 } 4162 4163 protected: 4164 /* Protected methods */ 4165 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4166 4167 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4168 std::string &out_calculations); 4169 4170 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4171 std::string &out_interface); 4172 }; 4173 4174 /** Implementation of test XFBMultipleVertexStreams. Description follows: 4175 * 4176 * Test verifies that outputs from single stream must be captured with single 4177 * xfb binding. 4178 * 4179 * Test following code snippet: 4180 * 4181 * layout (xfb_buffer = 1, xfb_stride = 64) out; 4182 * layout (xfb_buffer = 3, xfb_stride = 64) out; 4183 * 4184 * layout (stream = 0, xfb_buffer = 1, xfb_offset = 48) out vec4 goku; 4185 * layout (stream = 1, xfb_buffer = 1, xfb_offset = 32) out vec4 gohan; 4186 * layout (stream = 2, xfb_buffer = 1, xfb_offset = 16) out vec4 goten; 4187 * 4188 * It is expected that linking of program will fail. 4189 **/ 4190 class XFBMultipleVertexStreamsTest : public NegativeTestBase 4191 { 4192 public: 4193 /* Public methods */ 4194 XFBMultipleVertexStreamsTest(deqp::Context &context); 4195 ~XFBMultipleVertexStreamsTest()4196 virtual ~XFBMultipleVertexStreamsTest() 4197 { 4198 } 4199 4200 protected: 4201 /* Methods to be implemented by child class */ 4202 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4203 4204 virtual bool isComputeRelevant(glw::GLuint test_case_index); 4205 }; 4206 4207 /** Implementation of test XFBExceedBufferLimit. Description follows: 4208 * 4209 * Test verifies that MAX_TRANSFORM_FEEDBACK_BUFFERS limit is respected. 4210 * 4211 * Test following code snippets: 4212 * 4213 * layout (xfb_buffer = MAX_TRANSFORM_FEEDBACK_BUFFERS) out; 4214 * 4215 * , 4216 * 4217 * layout (xfb_buffer = MAX_TRANSFORM_FEEDBACK_BUFFERS) out vec4 output; 4218 * 4219 * and 4220 * 4221 * layout (xfb_buffer = MAX_TRANSFORM_FEEDBACK_BUFFERS) out Block { 4222 * vec4 member; 4223 * }; 4224 * 4225 * It is expected that build process will fail. 4226 * 4227 * Test all shader stages. 4228 **/ 4229 class XFBExceedBufferLimitTest : public NegativeTestBase 4230 { 4231 public: 4232 enum CASES 4233 { 4234 BLOCK = 0, 4235 GLOBAL, 4236 VECTOR, 4237 4238 /* */ 4239 CASE_MAX 4240 }; 4241 4242 /* Public methods */ 4243 XFBExceedBufferLimitTest(deqp::Context &context, glw::GLuint constant, glw::GLuint stage); ~XFBExceedBufferLimitTest()4244 virtual ~XFBExceedBufferLimitTest() 4245 { 4246 } 4247 4248 protected: 4249 /* Methods to be implemented by child class */ 4250 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4251 4252 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4253 virtual glw::GLuint getTestCaseNumber(); 4254 virtual bool isComputeRelevant(glw::GLuint test_case_index); 4255 virtual void testInit(); 4256 std::string getCaseEnumName(glw::GLuint test_case_index); 4257 4258 private: 4259 /* Private types */ 4260 struct testCase 4261 { 4262 CASES m_case; 4263 Utils::Shader::STAGES m_stage; 4264 }; 4265 4266 /* Private fields */ 4267 std::vector<testCase> m_test_cases; 4268 glw::GLuint m_constant; 4269 glw::GLuint m_stage; 4270 }; 4271 4272 /** Implementation of test XFBExceedOffsetLimit. Description follows: 4273 * 4274 * Test verifies that MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS limit is 4275 * respected. 4276 * 4277 * Test following code snippets: 4278 * 4279 * layout (xfb_buffer = 0, xfb_stride = MAX_SIZE + 16) out; 4280 * 4281 * , 4282 * 4283 * layout (xfb_buffer = 0, xfb_offset = MAX_SIZE + 16) out vec4 output; 4284 * 4285 * and 4286 * 4287 * layout (xfb_buffer = 0, xfb_offset = MAX_SIZE + 16) out Block 4288 * { 4289 * vec4 member; 4290 * }; 4291 * 4292 * where MAX_SIZE is the maximum supported size of transform feedback buffer, 4293 * which should be equal to: 4294 * 4295 * MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS * sizeof(float) 4296 * 4297 * It is expected that build process will fail. 4298 * 4299 * Test all shader stages. 4300 **/ 4301 class XFBExceedOffsetLimitTest : public NegativeTestBase 4302 { 4303 public: 4304 enum CASES 4305 { 4306 BLOCK = 0, 4307 GLOBAL, 4308 VECTOR, 4309 4310 /* */ 4311 CASE_MAX 4312 }; 4313 4314 /* Public methods */ 4315 XFBExceedOffsetLimitTest(deqp::Context &context, glw::GLuint constant, glw::GLuint stage); ~XFBExceedOffsetLimitTest()4316 virtual ~XFBExceedOffsetLimitTest() 4317 { 4318 } 4319 4320 protected: 4321 /* Methods to be implemented by child class */ 4322 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4323 4324 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4325 virtual glw::GLuint getTestCaseNumber(); 4326 virtual bool isComputeRelevant(glw::GLuint test_case_index); 4327 virtual void testInit(); 4328 std::string getCaseEnumName(glw::GLuint test_case_index); 4329 4330 private: 4331 /* Private types */ 4332 struct testCase 4333 { 4334 CASES m_case; 4335 Utils::Shader::STAGES m_stage; 4336 }; 4337 4338 /* Private fields */ 4339 std::vector<testCase> m_test_cases; 4340 glw::GLuint m_constant; 4341 glw::GLuint m_stage; 4342 }; 4343 4344 /** Implementation of test XFBGlobalBuffer. Description follows: 4345 * 4346 * Test verifies that global setting of xfb_buffer qualifier work as expected. 4347 * 4348 * This test implements Buffer algorithm. Rasterization can be discarded. Test 4349 * following code snippet: 4350 * 4351 * layout (xfb_buffer = 3) out; 4352 * 4353 * layout ( xfb_offset = 2 * sizeof(type)) out type chichi; 4354 * layout (xfb_buffer = 1, xfb_offset = 0) out type bulma; 4355 * layout (xfb_buffer = 1, xfb_offset = sizeof(type)) out Vegeta { 4356 * type trunks; 4357 * type bra; 4358 * }; 4359 * layout ( xfb_offset = 0) out Goku { 4360 * type gohan; 4361 * type goten; 4362 * }; 4363 * 4364 * chichi = EXPECTED_VALUE; 4365 * bulma = EXPECTED_VALUE; 4366 * trunks = EXPECTED_VALUE; 4367 * bra = EXPECTED_VALUE; 4368 * gohan = EXPECTED_VALUE; 4369 * goten = EXPECTED_VALUE; 4370 * 4371 * Test pass if all captured outputs have expected values. 4372 * 4373 * Test all shader stages. Test all types. 4374 **/ 4375 class XFBGlobalBufferTest : public BufferTestBase 4376 { 4377 public: 4378 XFBGlobalBufferTest(deqp::Context &context, glw::GLuint type); 4379 ~XFBGlobalBufferTest()4380 ~XFBGlobalBufferTest() 4381 { 4382 } 4383 getTypeHelper(glw::GLuint index) const4384 inline Utils::Type getTypeHelper(glw::GLuint index) const 4385 { 4386 return getType(index); 4387 } 4388 4389 protected: 4390 /* Protected methods */ 4391 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4392 4393 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4394 4395 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4396 virtual glw::GLuint getTestCaseNumber(); 4397 virtual void testInit(); 4398 4399 private: 4400 /* Private types */ 4401 struct _testCase 4402 { 4403 Utils::Shader::STAGES m_stage; 4404 Utils::Type m_type; 4405 }; 4406 4407 /* Private fields */ 4408 std::vector<_testCase> m_test_cases; 4409 glw::GLuint m_type; 4410 }; 4411 4412 /** Implementation of test XFBStride. Description follows: 4413 * 4414 * Test verifies that expected stride values are used. 4415 * 4416 * Test following code snippet: 4417 * 4418 * layout (xfb_offset = 0) out type output; 4419 * 4420 * output = EXPECTED_VALUE; 4421 * 4422 * Test all types. Test all shader stages. 4423 **/ 4424 class XFBStrideTest : public BufferTestBase 4425 { 4426 public: 4427 XFBStrideTest(deqp::Context &context, glw::GLuint type, glw::GLuint stage); ~XFBStrideTest()4428 ~XFBStrideTest() 4429 { 4430 } 4431 4432 protected: 4433 /* Protected methods */ 4434 using BufferTestBase::executeDrawCall; 4435 4436 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 4437 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4438 4439 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4440 std::string &out_calculations); 4441 4442 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4443 std::string &out_interface); 4444 4445 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4446 4447 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4448 virtual glw::GLuint getTestCaseNumber(); 4449 virtual void testInit(); 4450 4451 private: 4452 /* Private types */ 4453 struct testCase 4454 { 4455 Utils::Shader::STAGES m_stage; 4456 Utils::Type m_type; 4457 }; 4458 4459 /* Private fields */ 4460 std::vector<testCase> m_test_cases; 4461 glw::GLuint m_type; 4462 glw::GLuint m_stage; 4463 }; 4464 4465 /** Implementation of test XFBBlockMemberBuffer. Description follows: 4466 * 4467 * Test verifies that member of block have to use same buffer as block. 4468 * 4469 * Test following code snippet: 4470 * 4471 * layout (xfb_offset = 0) out Goku 4472 * { 4473 * vec4 gohan; 4474 * layout (xfb_buffer = 1) vec4 goten; 4475 * }; 4476 * 4477 * It is expected that compilation will fail. 4478 * 4479 * Test all shader stages. 4480 **/ 4481 class XFBBlockMemberBufferTest : public NegativeTestBase 4482 { 4483 public: 4484 /* Public methods */ 4485 XFBBlockMemberBufferTest(deqp::Context &context, glw::GLuint stage); 4486 ~XFBBlockMemberBufferTest()4487 virtual ~XFBBlockMemberBufferTest() 4488 { 4489 } 4490 4491 protected: 4492 /* Methods to be implemented by child class */ 4493 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4494 4495 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4496 virtual glw::GLuint getTestCaseNumber(); 4497 virtual bool isComputeRelevant(glw::GLuint test_case_index); 4498 virtual void testInit(); 4499 4500 private: 4501 /* Private types */ 4502 struct testCase 4503 { 4504 Utils::Shader::STAGES m_stage; 4505 }; 4506 4507 /* Private fields */ 4508 std::vector<testCase> m_test_cases; 4509 glw::GLuint m_stage; 4510 }; 4511 4512 /** Implementation of test XFBOutputOverlapping. Description follows: 4513 * 4514 * Test verifies that overlapped outputs are reported as errors by compiler. 4515 * 4516 * Test following code snippet: 4517 * 4518 * layout (xfb_offset = 0) out type gohan; 4519 * layout (xfb_offset = 0.5 * sizeof(type)) out type goten; 4520 * 4521 * gohan = EXPECTED_VALUE; 4522 * goten = EXPECTED_VALUE; 4523 * 4524 * It is expected that compilation will fail. 4525 * 4526 * Test all shader stages. Test all types. 4527 **/ 4528 class XFBOutputOverlappingTest : public NegativeTestBase 4529 { 4530 public: 4531 /* Public methods */ 4532 XFBOutputOverlappingTest(deqp::Context &context, glw::GLuint type, glw::GLuint stage); 4533 ~XFBOutputOverlappingTest()4534 virtual ~XFBOutputOverlappingTest() 4535 { 4536 } 4537 getTypeHelper(glw::GLuint index) const4538 inline Utils::Type getTypeHelper(glw::GLuint index) const 4539 { 4540 return getType(index); 4541 } 4542 4543 protected: 4544 /* Methods to be implemented by child class */ 4545 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4546 4547 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4548 virtual glw::GLuint getTestCaseNumber(); 4549 virtual bool isComputeRelevant(glw::GLuint test_case_index); 4550 virtual void testInit(); 4551 4552 private: 4553 /* Private types */ 4554 struct testCase 4555 { 4556 glw::GLuint m_offset; 4557 Utils::Shader::STAGES m_stage; 4558 Utils::Type m_type; 4559 }; 4560 4561 /* Private fields */ 4562 std::vector<testCase> m_test_cases; 4563 glw::GLuint m_type; 4564 glw::GLuint m_stage; 4565 }; 4566 4567 /** Implementation of test XFBInvalidOffsetAlignment. Description follows: 4568 * 4569 * Test verifies that invalidly aligned outputs cause a failure to build 4570 * process. 4571 * 4572 * Test following code snippet: 4573 * 4574 * layout (xfb_offset = OFFSET) out type goku; 4575 * 4576 * goku = EXPECTED_VALUE; 4577 * 4578 * Select OFFSET values so as to cause invalid alignment. Inspect program to 4579 * verify offset of goku. 4580 * 4581 * Test all shader stages. Test all types. Test all offsets in range: 4582 * (sizeof(type), 2 * sizeof(type)). 4583 **/ 4584 class XFBInvalidOffsetAlignmentTest : public NegativeTestBase 4585 { 4586 public: 4587 /* Public methods */ 4588 XFBInvalidOffsetAlignmentTest(deqp::Context &context, glw::GLuint type, glw::GLuint stage); 4589 ~XFBInvalidOffsetAlignmentTest()4590 virtual ~XFBInvalidOffsetAlignmentTest() 4591 { 4592 } 4593 4594 protected: 4595 /* Methods to be implemented by child class */ 4596 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4597 4598 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4599 virtual glw::GLuint getTestCaseNumber(); 4600 virtual bool isComputeRelevant(glw::GLuint test_case_index); 4601 virtual void testInit(); 4602 4603 private: 4604 /* Private types */ 4605 struct testCase 4606 { 4607 glw::GLuint m_offset; 4608 Utils::Shader::STAGES m_stage; 4609 Utils::Type m_type; 4610 }; 4611 4612 /* Private fields */ 4613 std::vector<testCase> m_test_cases; 4614 glw::GLuint m_type; 4615 glw::GLuint m_stage; 4616 }; 4617 4618 /** Implementation of test XFBCaptureInactiveOutputVariable. Description follows: 4619 * 4620 * Test verifies behavior of inactive outputs. 4621 * 4622 * This test implements Buffer algorithm. Rasterization can be disabled. Draw 4623 * two vertices instead of one. Test following code snippet: 4624 * 4625 * layout (xfb_offset = 16) out vec4 goku; 4626 * layout (xfb_offset = 32) out vec4 gohan; 4627 * layout (xfb_offset = 0) out vec4 goten; 4628 * 4629 * gohan = EXPECTED_VALUE; 4630 * goten = EXPECTED_VALUE; 4631 * 4632 * Test pass if: 4633 * - values captured for goten and gohan are as expected, 4634 * - goku value is undefined 4635 * - stride is 3 * sizeof(vec4) - 48 4636 * 4637 * Test all shader stages. 4638 **/ 4639 class XFBCaptureInactiveOutputVariableTest : public BufferTestBase 4640 { 4641 public: 4642 XFBCaptureInactiveOutputVariableTest(deqp::Context &context); ~XFBCaptureInactiveOutputVariableTest()4643 ~XFBCaptureInactiveOutputVariableTest() 4644 { 4645 } 4646 4647 protected: 4648 /* Protected methods */ 4649 using BufferTestBase::executeDrawCall; 4650 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 4651 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4652 4653 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4654 std::string &out_calculations); 4655 4656 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4657 std::string &out_interface); 4658 4659 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4660 4661 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4662 virtual glw::GLuint getTestCaseNumber(); 4663 4664 virtual bool inspectProgram(glw::GLuint test_case_index, Utils::Program &program, std::stringstream &out_stream); 4665 4666 virtual bool verifyBuffers(bufferCollection &buffers); 4667 4668 private: 4669 enum test_cases 4670 { 4671 TEST_VS = 0, 4672 TEST_TES, 4673 TEST_GS, 4674 4675 /* */ 4676 TEST_MAX 4677 }; 4678 }; 4679 4680 /** Implementation of test XFBCaptureInactiveOutputComponent. Description follows: 4681 * 4682 * Test verifies behavior of inactive component. 4683 * 4684 * This test implements Buffer algorithm. Rasterization can be disabled. Draw 4685 * two vertices instead of one. Test following code snippet: 4686 * 4687 * layout (xfb_offset = 32) out vec4 goku; 4688 * layout (xfb_offset = 0) out vec4 gohan; 4689 * layout (xfb_offset = 16) out vec4 goten; 4690 * layout (xfb_offset = 48) out vec4 chichi; 4691 * layout (xfb_offset = 112) out vec4 vegeta; 4692 * layout (xfb_offset = 96) out vec4 trunks; 4693 * layout (xfb_offset = 80) out vec4 bra; 4694 * layout (xfb_offset = 64) out vec4 bulma; 4695 * 4696 * goku.x = EXPECTED_VALUE; 4697 * goku.z = EXPECTED_VALUE; 4698 * gohan.y = EXPECTED_VALUE; 4699 * gohan.w = EXPECTED_VALUE; 4700 * goten.x = EXPECTED_VALUE; 4701 * goten.y = EXPECTED_VALUE; 4702 * chichi.z = EXPECTED_VALUE; 4703 * chichi.w = EXPECTED_VALUE; 4704 * vegeta.x = EXPECTED_VALUE; 4705 * trunks.y = EXPECTED_VALUE; 4706 * bra.z = EXPECTED_VALUE; 4707 * bulma.w = EXPECTED_VALUE; 4708 * 4709 * Test pass when captured values of all assigned components match expected 4710 * values, while not assigned ones are undefined. 4711 * 4712 * Test all shader stages. 4713 **/ 4714 class XFBCaptureInactiveOutputComponentTest : public BufferTestBase 4715 { 4716 public: 4717 XFBCaptureInactiveOutputComponentTest(deqp::Context &context); ~XFBCaptureInactiveOutputComponentTest()4718 ~XFBCaptureInactiveOutputComponentTest() 4719 { 4720 } 4721 4722 protected: 4723 /* Protected methods */ 4724 using BufferTestBase::executeDrawCall; 4725 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 4726 4727 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4728 4729 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4730 std::string &out_calculations); 4731 4732 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4733 std::string &out_interface); 4734 4735 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4736 4737 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4738 virtual glw::GLuint getTestCaseNumber(); 4739 virtual bool verifyBuffers(bufferCollection &buffers); 4740 4741 private: 4742 enum test_cases 4743 { 4744 TEST_VS = 0, 4745 TEST_TES, 4746 TEST_GS, 4747 4748 /* */ 4749 TEST_MAX 4750 }; 4751 }; 4752 4753 /** Implementation of test XFBCaptureInactiveOutputBlockMember. Description follows: 4754 * 4755 * Test verifies behaviour of inactive block member. 4756 * 4757 * This test implements Buffer algorithm. Rasterization can be disabled. Draw 4758 * two vertices instead of one. Test following code snippet: 4759 * 4760 * layout (xfb_offset = 16) out Goku { 4761 * vec4 gohan; 4762 * vec4 goten; 4763 * vec4 chichi; 4764 * }; 4765 * 4766 * gohan = EXPECTED_VALUE; 4767 * chichi = EXPECTED_VALUE; 4768 * 4769 * Test pass when captured values of gohan and chichi match expected values. 4770 * It is expected that goten will receive undefined value. 4771 * 4772 * Test all shader stages. 4773 **/ 4774 class XFBCaptureInactiveOutputBlockMemberTest : public BufferTestBase 4775 { 4776 public: 4777 XFBCaptureInactiveOutputBlockMemberTest(deqp::Context &context); 4778 ~XFBCaptureInactiveOutputBlockMemberTest()4779 ~XFBCaptureInactiveOutputBlockMemberTest() 4780 { 4781 } 4782 4783 protected: 4784 /* Protected methods */ 4785 using BufferTestBase::executeDrawCall; 4786 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 4787 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4788 4789 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4790 std::string &out_calculations); 4791 4792 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4793 std::string &out_interface); 4794 4795 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4796 4797 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4798 virtual glw::GLuint getTestCaseNumber(); 4799 virtual bool verifyBuffers(bufferCollection &buffers); 4800 4801 private: 4802 enum test_cases 4803 { 4804 TEST_VS = 0, 4805 TEST_TES, 4806 TEST_GS, 4807 4808 /* */ 4809 TEST_MAX 4810 }; 4811 }; 4812 4813 /** Implementation of test XFBCaptureStruct. Description follows: 4814 * 4815 * Test verifies that structures are captured as expected. 4816 * 4817 * This test implements Buffer algorithm. Rasterization can be disabled. Draw 4818 * two vertices instead of one. Test following code snippet: 4819 * 4820 * struct Goku { 4821 * vec4 gohan; 4822 * vec4 goten; 4823 * vec4 chichi; 4824 * }; 4825 * 4826 * layout (xfb_offset = 16) out Goku goku; 4827 * 4828 * goku.gohan = EXPECTED_VALUE; 4829 * goku.chichi = EXPECTED_VALUE; 4830 * 4831 * Test pass when captured values of gohan and chichi match expected values. 4832 * It is expected that goten will receive undefined value. 4833 * 4834 * Test all shader stages. 4835 **/ 4836 class XFBCaptureStructTest : public BufferTestBase 4837 { 4838 public: 4839 XFBCaptureStructTest(deqp::Context &context); 4840 ~XFBCaptureStructTest()4841 ~XFBCaptureStructTest() 4842 { 4843 } 4844 4845 protected: 4846 /* Protected methods */ 4847 using BufferTestBase::executeDrawCall; 4848 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 4849 4850 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4851 4852 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4853 std::string &out_calculations); 4854 4855 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4856 std::string &out_interface); 4857 4858 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4859 4860 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4861 virtual glw::GLuint getTestCaseNumber(); 4862 virtual bool verifyBuffers(bufferCollection &buffers); 4863 4864 private: 4865 enum test_cases 4866 { 4867 TEST_VS = 0, 4868 TEST_TES, 4869 TEST_GS, 4870 4871 /* */ 4872 TEST_MAX 4873 }; 4874 }; 4875 4876 /** Implementation of test XFBCaptureUnsizedArray. Description follows: 4877 * 4878 * Test verifies this is not allowed to qualify unsized array with "xfb". 4879 * 4880 * Test following code snippet: 4881 * 4882 * layout (xfb_offset = 0) out vec4 goku[]; 4883 * 4884 * goku[0] = EXPECTED_VALUE; 4885 * 4886 * It is expected that compilation will fail. 4887 * 4888 * Test all shader stages. 4889 **/ 4890 class XFBCaptureUnsizedArrayTest : public NegativeTestBase 4891 { 4892 public: 4893 /* Public methods */ 4894 XFBCaptureUnsizedArrayTest(deqp::Context &context, glw::GLuint stage); ~XFBCaptureUnsizedArrayTest()4895 virtual ~XFBCaptureUnsizedArrayTest() 4896 { 4897 } 4898 4899 protected: 4900 /* Methods to be implemented by child class */ 4901 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4902 4903 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4904 virtual glw::GLuint getTestCaseNumber(); 4905 virtual bool isComputeRelevant(glw::GLuint test_case_index); 4906 virtual void testInit(); 4907 4908 private: 4909 /* Private types */ 4910 struct testCase 4911 { 4912 Utils::Shader::STAGES m_stage; 4913 }; 4914 4915 /* Private fields */ 4916 std::vector<testCase> m_test_cases; 4917 glw::GLuint m_stage; 4918 }; 4919 4920 /** Implementation of test XFBExplicitLocationTest. Description follows: 4921 * 4922 * Test verifies that explicit location on matrices and arrays does not impact xfb output. 4923 * 4924 * Test following code snippet: 4925 * 4926 * layout (location = 0, xfb_offset = 0) out vec2 goku[3]; 4927 * 4928 * Is expected to have the same output as: 4929 * 4930 * layout (xfb_offset = 0) out vec2 goku[3]; 4931 * 4932 * While explicit location does impact varyings layout of matrices and arrays, see 4933 * Ref. GLSL 4.60, Section 4.4.2. "Output Layout Qualifiers" - it shall not impact 4934 * xfb output. 4935 * 4936 * Test all shader stages. 4937 **/ 4938 class XFBExplicitLocationTest : public BufferTestBase 4939 { 4940 public: 4941 XFBExplicitLocationTest(deqp::Context &context, glw::GLuint type, glw::GLuint stage); ~XFBExplicitLocationTest()4942 ~XFBExplicitLocationTest() 4943 { 4944 } 4945 4946 protected: 4947 /* Protected methods */ 4948 using BufferTestBase::executeDrawCall; 4949 4950 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 4951 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 4952 4953 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 4954 std::string &out_calculations); 4955 4956 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 4957 std::string &out_interface); 4958 4959 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 4960 4961 virtual std::string getTestCaseName(glw::GLuint test_case_index); 4962 virtual glw::GLuint getTestCaseNumber(); 4963 virtual void testInit(); 4964 4965 private: 4966 /* Private types */ 4967 struct testCase 4968 { 4969 Utils::Shader::STAGES m_stage; 4970 Utils::Type m_type; 4971 glw::GLuint m_array_size; 4972 }; 4973 4974 /* Private fields */ 4975 std::vector<testCase> m_test_cases; 4976 glw::GLuint m_type; 4977 glw::GLuint m_stage; 4978 }; 4979 4980 /** Implementation of test XFBExplicitLocationStructTest. Description follows: 4981 * 4982 * Test verifies that explicit location on struct does not impact xfb output. 4983 * 4984 * Test following code snippet: 4985 * struct TestStruct { 4986 * float a; 4987 * double b; 4988 * }; 4989 * 4990 * layout (location = 0, xfb_offset = 0) flat out TestStruct goku; 4991 * 4992 * Is expected to have the same output as: 4993 * 4994 * layout (xfb_offset = 0) flat out TestStruct goku; 4995 * 4996 * While explicit location does impact varyings layout of structs, see 4997 * Ref. GLSL 4.60, Section 4.4.2. "Output Layout Qualifiers" - it shall not impact 4998 * xfb output. 4999 * 5000 * Test all shader stages. 5001 **/ 5002 class XFBExplicitLocationStructTest : public BufferTestBase 5003 { 5004 public: 5005 XFBExplicitLocationStructTest(deqp::Context &context, glw::GLuint stage); ~XFBExplicitLocationStructTest()5006 ~XFBExplicitLocationStructTest() 5007 { 5008 } 5009 5010 protected: 5011 /* Protected methods */ 5012 using BufferTestBase::executeDrawCall; 5013 5014 virtual bool executeDrawCall(bool tesEnabled, glw::GLuint test_case_index); 5015 virtual void getBufferDescriptors(glw::GLuint test_case_index, bufferDescriptor::Vector &out_descriptors); 5016 5017 virtual void getShaderBody(glw::GLuint test_case_index, Utils::Shader::STAGES stage, std::string &out_assignments, 5018 std::string &out_calculations); 5019 5020 virtual void getShaderInterface(glw::GLuint test_case_index, Utils::Shader::STAGES stage, 5021 std::string &out_interface); 5022 5023 virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage); 5024 5025 virtual std::string getTestCaseName(glw::GLuint test_case_index); 5026 virtual glw::GLuint getTestCaseNumber(); 5027 virtual void testInit(); 5028 5029 private: 5030 /* Private types */ 5031 5032 struct testType 5033 { 5034 Utils::Type m_type; 5035 glw::GLuint m_array_size; 5036 }; 5037 5038 struct testCase 5039 { 5040 Utils::Shader::STAGES m_stage; 5041 std::vector<testType> m_types; 5042 bool m_nested_struct; 5043 }; 5044 5045 /* Private fields */ 5046 std::vector<testCase> m_test_cases; 5047 glw::GLuint m_stage; 5048 }; 5049 5050 } // namespace EnhancedLayouts 5051 5052 /** Group class for Shader Language 420Pack conformance tests */ 5053 class EnhancedLayoutsTests : public deqp::TestCaseGroup 5054 { 5055 public: 5056 /* Public methods */ 5057 EnhancedLayoutsTests(deqp::Context &context); 5058 ~EnhancedLayoutsTests(void)5059 virtual ~EnhancedLayoutsTests(void) 5060 { 5061 } 5062 5063 virtual void init(void); 5064 5065 void addGLSLContantImmutablityTest(); 5066 void addUniformBlockLayoutQualifierConflictTest(); 5067 void addSSBMemberInvalidOffsetAlignmentTest(); 5068 void addSSBMemberOverlappingOffsetsTest(); 5069 void addVaryingInvalidValueComponentTest(); 5070 void addVaryingExceedingComponentsTest(); 5071 void addVaryingComponentOfInvalidTypeTest(); 5072 void addOutputComponentAliasingTest(); 5073 void addXFBInputTest(); 5074 void addXFBStrideTest(); 5075 void addUniformBlockMemberInvalidOffsetAlignmentTest(); 5076 void addUniformBlockMemberOverlappingOffsetsTest(); 5077 void addUniformBlockMemberAlignNonPowerOf2Test(); 5078 void addSSBLayoutQualifierConflictTest(); 5079 void addSSBMemberAlignNonPowerOf2Test(); 5080 void addVaryingStructureMemberLocationTest(); 5081 void addVaryingBlockAutomaticMemberLocationsTest(); 5082 void addVaryingComponentWithoutLocationTest(); 5083 void addInputComponentAliasingTest(); 5084 void addVaryingLocationAliasingWithMixedTypesTest(); 5085 void addVaryingLocationAliasingWithMixedInterpolationTest(); 5086 void addVaryingLocationAliasingWithMixedAuxiliaryStorageTest(); 5087 void addXFBTooSmallStrideTest(); 5088 void addXFBDuplicatedStrideTest(); 5089 void addXFBGetProgramResourceAPITest(); 5090 void addXFBExceedBufferLimitTest(); 5091 void addXFBExceedOffsetLimitTest(); 5092 void addXFBBlockMemberBufferTest(); 5093 void addXFBOutputOverlappingTest(); 5094 void addXFBInvalidOffsetAlignmentTest(); 5095 void addXFBCaptureUnsizedArrayTest(); 5096 void addVaryingBlockMemberLocationsTest(); 5097 void addXFBVariableStrideTest(); 5098 void addXFBBlockStrideTest(); 5099 void addXFBGlobalBufferTest(); 5100 void addXFBExplicitLocationTest(); 5101 void addXFBExplicitLocationStructTest(); 5102 void addVaryingLocationLimitTest(); 5103 void addVaryingComponentsTest(); 5104 void addVaryingArrayComponentsTest(); 5105 5106 private: 5107 /* Private methods */ 5108 EnhancedLayoutsTests(const EnhancedLayoutsTests &other); 5109 EnhancedLayoutsTests &operator=(const EnhancedLayoutsTests &other); 5110 5111 template <class varyingClass> 5112 void addVaryingTest(); 5113 }; 5114 5115 } // namespace gl4cts 5116 5117 #endif // _GL4CENHANCEDLAYOUTSTESTS_HPP 5118